diff options
| author | Andy Smith <code@term.ie> | 2011-01-12 15:03:08 -0800 |
|---|---|---|
| committer | Andy Smith <code@term.ie> | 2011-01-12 15:03:08 -0800 |
| commit | 5fbc74784918abb509aba88400e6ed9a1d01deb9 (patch) | |
| tree | c94566c8bc59732b5b4bc5da0fd9de94553dada6 /nova/api | |
| parent | 1fa45c2ce52612455d88d1fdabec38d4bcc01ca7 (diff) | |
| download | nova-5fbc74784918abb509aba88400e6ed9a1d01deb9.tar.gz nova-5fbc74784918abb509aba88400e6ed9a1d01deb9.tar.xz nova-5fbc74784918abb509aba88400e6ed9a1d01deb9.zip | |
standardize on hex for ids, allow configurable instance names
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 7df2feb98..c68a1f4bc 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -73,17 +73,13 @@ def _gen_key(context, user_id, key_name): def ec2_id_to_id(ec2_id): - """Convert an ec2 ID (i-[base 36 number]) to an instance id (int)""" - return int(ec2_id[2:], 36) + """Convert an ec2 ID (i-[base 16 number]) to an instance id (int)""" + return int(ec2_id.split('-')[-1], 16) -def id_to_ec2_id(instance_id, template='i-%s'): - """Convert an instance ID (int) to an ec2 ID (i-[base 36 number])""" - digits = [] - while instance_id != 0: - instance_id, remainder = divmod(instance_id, 36) - digits.append('0123456789abcdefghijklmnopqrstuvwxyz'[remainder]) - return template % (''.join(reversed(digits)).zfill(8)) +def id_to_ec2_id(instance_id, template='i-%08x'): + """Convert an instance ID (int) to an ec2 ID (i-[base 16 number])""" + return template % instance_id class CloudController(object): |
