File tree Expand file tree Collapse file tree
src/testing/integration/Compute/v2_1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,9 +78,32 @@ public void Dispose()
7878 public ServerCreateDefinition BuildServer ( )
7979 {
8080 string name = TestData . GenerateName ( ) ;
81- const string flavor = "1" ; // m1.tiny
82- Identifier image = new Identifier ( "74382d40-c0c0-49b0-bacd-42eb3fbaf271" ) ; // cirros
83- return new ServerCreateDefinition ( name , image , flavor ) ;
81+ var flavor = GetDefaultFlavor ( ) ;
82+ var image = GetDefaultImage ( ) ;
83+ Task . WaitAll ( flavor , image ) ;
84+ return new ServerCreateDefinition ( name , image . Result , flavor . Result ) ;
85+ }
86+
87+ private Identifier _defaultFlavor ;
88+ private async Task < Identifier > GetDefaultFlavor ( )
89+ {
90+ if ( _defaultFlavor == null )
91+ {
92+ var flavors = await _compute . ListFlavorsAsync ( ) ;
93+ _defaultFlavor = flavors . First ( x => x . Name == "m1.tiny" ) . Id ;
94+ }
95+ return _defaultFlavor ;
96+ }
97+
98+ private Identifier _defaultImage ;
99+ private async Task < Identifier > GetDefaultImage ( )
100+ {
101+ if ( _defaultImage == null )
102+ {
103+ var images = await _compute . ListImagesAsync ( new ImageListOptions { Name = "cirros" } ) ;
104+ _defaultImage = images . First ( ) . Id ;
105+ }
106+ return _defaultImage ;
84107 }
85108
86109 public async Task < Server > CreateServer ( )
You can’t perform that action at this time.
0 commit comments