summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorRick Harris <rick.harris@rackspace.com>2011-06-20 16:17:35 +0000
committerTarmac <>2011-06-20 16:17:35 +0000
commita62e0f3e10cae4938ca2fec047268064cab3bff2 (patch)
tree33ed9c6245fa6bc7f154707e86e2e516781d4b09 /nova/utils.py
parentc2a8d0f1e2e9a25465100128bae4f60b532d16f5 (diff)
parent56042d3a60bb76108b21261c3a4dbd8f67d6549c (diff)
This patch adds support for working with instances by UUID in addition to integer IDs.
The Zone Scheduler routing mechanics were changed slightly so that when an UUID is passed in, it checks to see whether the item is available locally. If it isn't it re-routes to a child zone. If it is available locally, it substitutes the UUID with the integer ID and calls the wrapped function. This is the 'trick' allows us to not change any of the virt-layer code-- everything still uses integer IDs locally.
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 691134ada..e2ac16f31 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -35,6 +35,7 @@ import struct
import sys
import time
import types
+import uuid
from xml.sax import saxutils
from eventlet import event
@@ -726,3 +727,17 @@ def parse_server_string(server_str):
except:
LOG.debug(_('Invalid server_string: %s' % server_str))
return ('', '')
+
+
+def gen_uuid():
+ return uuid.uuid4()
+
+
+def is_uuid_like(val):
+ """For our purposes, a UUID is a string in canoical form:
+
+ aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
+ """
+ if not isinstance(val, basestring):
+ return False
+ return (len(val) == 36) and (val.count('-') == 4)