summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2011-03-04 05:58:49 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2011-03-04 05:58:49 +0000
commit517a571f8905c32efd45f7b3410fb263ad705545 (patch)
treee3405024071b46d532eda668e2bae1fa2e0f18ff /nova/api
parente2c95e198f1982bc50bc95bc61ef3211b17937a2 (diff)
downloadnova-517a571f8905c32efd45f7b3410fb263ad705545.tar.gz
nova-517a571f8905c32efd45f7b3410fb263ad705545.tar.xz
nova-517a571f8905c32efd45f7b3410fb263ad705545.zip
add the ec2utils file i forgot
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/ec2utils.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py
new file mode 100644
index 000000000..0ea22c0e6
--- /dev/null
+++ b/nova/api/ec2/ec2utils.py
@@ -0,0 +1,27 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+def ec2_id_to_id(ec2_id):
+ """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-%08x'):
+ """Convert an instance ID (int) to an ec2 ID (i-[base 16 number])"""
+ return template % instance_id