From b984af2d11a2ce4df8a38f818c278e2a2b28acdd Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 24 Feb 2011 17:46:07 +0000 Subject: [PATCH 1/2] Requiring kernel and ramdisk args in glance-upload --- bin/glance-upload | 40 ++++++++++++++++++++++++++-------------- tests/unit/test_misc.py | 8 +++++++- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/bin/glance-upload b/bin/glance-upload index a41b8df95f..fa033e6114 100755 --- a/bin/glance-upload +++ b/bin/glance-upload @@ -19,19 +19,29 @@ """ Upload an image into Glance -Usage: +Usage +===== -Raw: + Machine - Kernel outside of the image + ------------------------------------- - glance-upload + glance-upload --type=kernel + glance-upload --type=ramdisk + glance-upload --type=machine --kernel=KERNEL_ID --ramdisk=RAMDISK_ID \ + -Kernel-outside: + Raw - Kernel inside, raw image data + ----------------------------------- - glance-upload --type=kernel - glance-upload --type=ramdisk - glance-upload --type=machine --kernel=KERNEL_ID --ramdisk=RAMDISK_ID \ - + glance-upload --type=raw --kernel=nokernel --ramdisk=noramdisk \ + + + VHD - Kernel inside, data encoded with VHD format + ------------------------------------------------- + + glance-upload --type=vhd --kernel=nokernel --ramdisk=noramdisk \ + """ # FIXME(sirp): This can be merged into glance-admin when that becomes @@ -72,12 +82,14 @@ def main(): args = parse_args() meta = {'name': args.name, 'type': args.type, 'is_public': True} - if args.type == 'machine': - if args.kernel and args.ramdisk: - meta['properties'] = {'kernel_id': args.kernel, - 'ramdisk_id': args.ramdisk} - else: - die("kernel and ramdisk required for machine image") + # FIXME(sirp): remove kernel_id requirement when nova removes + # `null_kernel` concept + if args.kernel and args.ramdisk: + meta['properties'] = {'kernel_id': args.kernel, + 'ramdisk_id': args.ramdisk} + else: + die("kernel and ramdisk required (use 'nokernel' and 'noramdisk' " + "to omit)") client = Client(args.host, args.port) with open(args.filename) as f: diff --git a/tests/unit/test_misc.py b/tests/unit/test_misc.py index 372aa70b1f..1bbb9a40f2 100644 --- a/tests/unit/test_misc.py +++ b/tests/unit/test_misc.py @@ -153,8 +153,14 @@ sql_idle_timeout = 3600 "Could not find 'Image type is required' " "in output: %s" % out) + # FIXME(sirp): Nova currently requires a `null_kernel` to be + # specified using the string 'nokernel'. This is slated to be + # removed shortly (within days of 2011-02-24). Once this is done, + # we can remove the required --kernel and --ramdisk options here. cmd = "./bin/glance-upload --port=%(api_port)d "\ - "--type=invalid %(conf_file_name)s 'my image'" % locals() + "--kernel=nokernel --ramdisk=noramdisk "\ + "--type=invalid %(conf_file_name)s "\ + "'my image'" % locals() # Normally, we would simply self.assertRaises() here, but # we also want to check that the Invalid image type is in From 78d7580b2c8c64d5c89c74746ea61aab8e82ef41 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 24 Feb 2011 23:06:10 +0000 Subject: [PATCH 2/2] Removing requirement to pass kernel and ramdisk --- bin/glance-upload | 16 +++++++--------- tests/unit/test_misc.py | 5 ----- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/bin/glance-upload b/bin/glance-upload index fa033e6114..0dbe6bc57b 100755 --- a/bin/glance-upload +++ b/bin/glance-upload @@ -80,16 +80,14 @@ def parse_args(): def main(): args = parse_args() - meta = {'name': args.name, 'type': args.type, 'is_public': True} + meta = {'name': args.name, 'type': args.type, 'is_public': True, + 'properties': {}} - # FIXME(sirp): remove kernel_id requirement when nova removes - # `null_kernel` concept - if args.kernel and args.ramdisk: - meta['properties'] = {'kernel_id': args.kernel, - 'ramdisk_id': args.ramdisk} - else: - die("kernel and ramdisk required (use 'nokernel' and 'noramdisk' " - "to omit)") + if args.kernel: + meta['properties']['kernel_id'] = args.kernel + + if args.ramdisk: + meta['properties']['ramdisk_id'] = args.ramdisk client = Client(args.host, args.port) with open(args.filename) as f: diff --git a/tests/unit/test_misc.py b/tests/unit/test_misc.py index 1bbb9a40f2..ee3d2d6748 100644 --- a/tests/unit/test_misc.py +++ b/tests/unit/test_misc.py @@ -153,12 +153,7 @@ sql_idle_timeout = 3600 "Could not find 'Image type is required' " "in output: %s" % out) - # FIXME(sirp): Nova currently requires a `null_kernel` to be - # specified using the string 'nokernel'. This is slated to be - # removed shortly (within days of 2011-02-24). Once this is done, - # we can remove the required --kernel and --ramdisk options here. cmd = "./bin/glance-upload --port=%(api_port)d "\ - "--kernel=nokernel --ramdisk=noramdisk "\ "--type=invalid %(conf_file_name)s "\ "'my image'" % locals()