diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2011-06-20 21:53:01 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2011-06-20 21:53:01 +0000 |
| commit | db7796b0a42faafff450eedbd7c09609f008c6c7 (patch) | |
| tree | 053237cb7db70cd853c2a75e63af59e5c6ad250a /nova/utils.py | |
| parent | 46e016348ff4303310af328fa1af8fab513632c9 (diff) | |
| parent | d835283ee86f31debc8c639b875c808b18e8dff8 (diff) | |
| download | nova-db7796b0a42faafff450eedbd7c09609f008c6c7.tar.gz nova-db7796b0a42faafff450eedbd7c09609f008c6c7.tar.xz nova-db7796b0a42faafff450eedbd7c09609f008c6c7.zip | |
Merge with parent
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 15 |
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) |
