Due to how novaclient works, it tends to do a 'get' first on whatever ID

you pass on command line.  Then it does the real command, re-using the
ID found in the 'get' call, instead of the initial ID that you specified
(which may have been a UUID).

This makes it use the UUID from the initial 'get' call if it finds it,
so that commands work across zones.  'nova delete UUID', for instance,
wouldn't recurse zones as novaclient was doing a delete on the integer
ID, even though you specified a UUID.

This change has a side effect of trying to find 'uuid' in Image and
Flavors as well, but it'll fall back to using the integer ID.
This commit is contained in:
Chris Behrens 2011-06-23 21:49:10 -07:00
parent 9e86dd0634
commit 6b25dd66df
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,13 @@ def getid(obj):
Abstracts the common pattern of allowing both an object or an object's ID
(UUID) as a parameter when dealing with relationships.
"""
# Try to return the object's UUID first, if we have a UUID.
try:
if obj.uuid:
return obj.uuid
except AttributeError:
pass
try:
return obj.id
except AttributeError: