Fix reporting of image classes for undercloud

The current populate_image_vars script fails when run on the undercloud
because the undercloud instance does not have a subclass (e.g. compute)
in its name. Modify the script to accept this, while still preserving
its ability to deal with build numbers in the name.

Change-Id: I4a19c7c00594e8d6224649ad6b1374e4f91a4910
This commit is contained in:
Stephanie Miller 2014-12-09 13:15:26 -08:00 committed by stephane
parent 74ea04fad8
commit 4c04e6dbd7
1 changed files with 9 additions and 2 deletions

View File

@ -60,15 +60,22 @@ def image_list():
def name_to_class(name):
(stack, bits) = name.split('-', 1)
bits = bits.split('-')
bits = name.split('-', 1)
stack = bits.pop(0)
new_bits = []
buildnum = None
# this try-catch block is "intuitively obvious". we use it to find
# the build number by testing for whether we can str->int on that
# part of the name. this keeps "control-mgmt" from being split up in
# the method output.
for bit in bits:
try:
buildnum = int(bit)
except ValueError:
new_bits.append(bit)
if len(new_bits) == 0:
# use stack name if all else fails
return (stack, buildnum)
if new_bits == ['compute']:
return ('nova-compute', buildnum)
if new_bits == ['control']: