Browse code

Check if flavors exist before creating them.

* lib/tempest: When creating the m1.tiny and m1.nano flavors ensure that
they don't exist first. This is important for Grenade where code may be
run multiple times and should expect that some things preexist.

Change-Id: I1772d4334f39d612f8a187eb5311a1b2caee3953

Clark Boylan authored on 2013/11/21 10:51:50
Showing 1 changed files
... ...
@@ -73,6 +73,7 @@ function configure_tempest() {
73 73
     local password
74 74
     local line
75 75
     local flavors
76
+    local available_flavors
76 77
     local flavors_ref
77 78
     local flavor_lines
78 79
     local public_network_id
... ...
@@ -142,10 +143,15 @@ function configure_tempest() {
142 142
     # If the ``DEFAULT_INSTANCE_TYPE`` not declared, use the new behavior
143 143
     # Tempest creates instane types for himself
144 144
     if  [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then
145
-        nova flavor-create m1.nano 42 64 0 1
145
+        available_flavors=$(nova flavor-list)
146
+        if [[ ! ( $available_flavors =~ 'm1.nano' ) ]]; then
147
+            nova flavor-create m1.nano 42 64 0 1
148
+        fi
146 149
         flavor_ref=42
147 150
         boto_instance_type=m1.nano
148
-        nova flavor-create m1.micro 84 128 0 1
151
+        if [[ ! ( $available_flavors =~ 'm1.micro' ) ]]; then
152
+            nova flavor-create m1.micro 84 128 0 1
153
+        fi
149 154
         flavor_ref_alt=84
150 155
     else
151 156
         # Check Nova for existing flavors and, if set, look for the