diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-12-14 00:20:27 +0000 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-12-14 00:20:27 +0000 |
| commit | 72b18d065669a01d8d083aa3edcc726be9be6547 (patch) | |
| tree | b5e3c1ffe057431dd138ab9fb5c1d99f7a820869 | |
| parent | f09b008388b9ed8dbd1d3f74cb1e9f2a458a3000 (diff) | |
| download | nova-72b18d065669a01d8d083aa3edcc726be9be6547.tar.gz nova-72b18d065669a01d8d083aa3edcc726be9be6547.tar.xz nova-72b18d065669a01d8d083aa3edcc726be9be6547.zip | |
simplified version using original logic
| -rw-r--r-- | nova/objectstore/image.py | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/nova/objectstore/image.py b/nova/objectstore/image.py index c4d752124..34a90b0a2 100644 --- a/nova/objectstore/image.py +++ b/nova/objectstore/image.py @@ -21,6 +21,7 @@ Take uploaded bucket contents and register them as disk images (AMIs). Requires decryption using keys in the manifest. """ + import binascii import glob import json @@ -182,38 +183,38 @@ class Image(object): manifest = ElementTree.fromstring(bucket_object[manifest_path].read()) image_type = 'machine' - info = { - 'imageId': image_id, - 'imageLocation': image_location, - 'imageOwnerId': context.project_id, - 'isPublic': False, # FIXME: grab public from manifest - 'architecture': 'x86_64', - 'imageType': 'machine' - } - - manifest = ElementTree.fromstring(bucket_object[manifest_path].read()) - - try: - arch = manifest.find("machine_configuration/kernel_id").text - info['architecture'] = arch - except: - pass try: kernel_id = manifest.find("machine_configuration/kernel_id").text if kernel_id == 'true': - info['imageType'] = 'kernel' - else: - info['kernelId'] = kernel_id + image_type = 'kernel' except: - pass + kernel_id = None + try: ramdisk_id = manifest.find("machine_configuration/ramdisk_id").text if ramdisk_id == 'true': - info['imageType'] = 'ramdisk' - else: - info['ramdiskId'] = ramdisk_id + image_type = 'ramdisk' except: - pass + ramdisk_id = None + + try: + arch = manifest.find("machine_configuration/architecture").text + except: + arch = 'x86_64' + + info = { + 'imageId': image_id, + 'imageLocation': image_location, + 'imageOwnerId': context.project_id, + 'isPublic': False, # FIXME: grab public from manifest + 'architecture': arch, + 'imageType': image_type} + + if kernel_id: + info['kernelId'] = kernel_id + + if ramdisk_id: + info['ramdiskId'] = ramdisk_id def write_state(state): info['imageState'] = state |
