diff options
| author | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-10-05 18:58:37 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-10-05 18:58:37 +0000 |
| commit | f0db8b74ec894631fe29c2a33748b797758ecf50 (patch) | |
| tree | 373bc6d8a070df0afe952d014fceb78c46092efc /nova/utils.py | |
| parent | 5820cc7a5c4c649c326a9da0e306298f081743ce (diff) | |
| parent | 8a2d7efa542e168fda81f703fa8e8c19467bf800 (diff) | |
Replace model.Instance.ec2_id with an integer internal_id so that both APIs can represent the ID to external users.
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nova/utils.py b/nova/utils.py index d18dd9843..b1699bda8 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -126,7 +126,15 @@ def runthis(prompt, cmd, check_exit_code = True): def generate_uid(topic, size=8): - return '%s-%s' % (topic, ''.join([random.choice('01234567890abcdefghijklmnopqrstuvwxyz') for x in xrange(size)])) + if topic == "i": + # Instances have integer internal ids. + #TODO(gundlach): We should make this more than 32 bits, but we need to + #figure out how to make the DB happy with 64 bit integers. + return random.randint(0, 2**32-1) + else: + characters = '01234567890abcdefghijklmnopqrstuvwxyz' + choices = [random.choice(characters) for x in xrange(size)] + return '%s-%s' % (topic, ''.join(choices)) def generate_mac(): |
