From 68dbbbba34af234f2770b40c03e4e4bfa5ad78d8 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 10 Dec 2010 21:09:37 +0000 Subject: Includes kernel and ramdisk on register. Additinally removes a couple lines of cruft --- nova/objectstore/image.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/nova/objectstore/image.py b/nova/objectstore/image.py index 7292dbab8..ed0f75cd2 100644 --- a/nova/objectstore/image.py +++ b/nova/objectstore/image.py @@ -21,15 +21,12 @@ Take uploaded bucket contents and register them as disk images (AMIs). Requires decryption using keys in the manifest. """ -# TODO(jesse): Got these from Euca2ools, will need to revisit them - import binascii import glob import json import os import shutil import tarfile -import tempfile from xml.etree import ElementTree from nova import exception @@ -185,33 +182,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: + architecture = manifest.find("machine_configuration/kernel_id").text + info['architecture'] = architecture + except: + pass try: kernel_id = manifest.find("machine_configuration/kernel_id").text if kernel_id == 'true': - image_type = 'kernel' + info['imageType'] = 'kernel' + else: + info['kernelId'] = kernel_id except: - kernel_id = None - + pass try: ramdisk_id = manifest.find("machine_configuration/ramdisk_id").text if ramdisk_id == 'true': - image_type = 'ramdisk' + info['imageType'] = 'ramdisk' + else: + info['ramdiskId'] = ramdisk_id except: - ramdisk_id = None - - info = { - 'imageId': image_id, - 'imageLocation': image_location, - 'imageOwnerId': context.project_id, - 'isPublic': False, # FIXME: grab public from manifest - 'architecture': 'x86_64', # FIXME: grab architecture from manifest - 'imageType': image_type} - - if kernel_id: - info['kernelId'] = kernel_id - - if ramdisk_id: - info['ramdiskId'] = ramdisk_id + pass def write_state(state): info['imageState'] = state -- cgit