From e46c0a620619758e22f7f73e7668ffe5c95d722b Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Tue, 25 Oct 2011 22:02:10 -0400 Subject: [PATCH] Removing glance-upload The glance-upload tool targets a very specific use-case that is easily handled by simply using the standard glance client. It's not worth keeping around. This addresses bug 767344. Change-Id: Ie7cf42ba517b744a2a440deb15336c0ee372b2e7 --- README | 4 +- bin/glance-upload | 135 --------------------------- glance/tests/functional/test_misc.py | 3 - glance/tests/unit/test_api.py | 5 +- setup.py | 3 +- 5 files changed, 5 insertions(+), 145 deletions(-) delete mode 100755 bin/glance-upload diff --git a/README b/README index b50f715522..61db9ab679 100644 --- a/README +++ b/README @@ -35,10 +35,10 @@ do that is by using the `glance-control` utility which runs both the glance-control all start -Once both services are running, you can now use the `glance-upload` tool to +Once both services are running, you can now use the `glance` tool to register new images in Glance. - glance-upload --type=machine --kernel=1 --ramdisk=2 myimage.img "MyImage" + glance add name="My Image" < /path/to/my/image With an image registered, you can now configure your IAAS provider to use diff --git a/bin/glance-upload b/bin/glance-upload deleted file mode 100755 index 66d183bb99..0000000000 --- a/bin/glance-upload +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2011 OpenStack LLC. -# 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. - -""" -Upload an image into Glance - -Usage -===== - - Machine - Kernel outside of the image - ------------------------------------- - - glance-upload --type=kernel - glance-upload --type=ramdisk - glance-upload --type=machine --kernel=KERNEL_ID --ramdisk=RAMDISK_ID \ - - - Raw - Kernel inside, raw image data - ----------------------------------- - - 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 -# available -import argparse -import gettext -import pprint -import os -import sys - -# If ../glance/__init__.py exists, add ../ to Python search path, so that -# it will override what happens to be installed in /usr/(local/)lib/python... -possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), - os.pardir, - os.pardir)) -if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')): - sys.path.insert(0, possible_topdir) - -gettext.install('glance', unicode=1) - -from glance.client import Client -from glance.registry.db.api import DISK_FORMATS, CONTAINER_FORMATS - - -def die(msg): - print >> sys.stderr, msg - sys.exit(1) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Upload an image into Glance') - parser.add_argument('filename', help='file to upload into Glance') - parser.add_argument('name', help='name of image') - parser.add_argument('--host', metavar='HOST', default='127.0.0.1', - help='Location of Glance Server (default: %(default)s)') - parser.add_argument('--port', metavar='PORT', type=int, default=9292, - help='Port of Glance Server (default: %(default)s)') - parser.add_argument('--type', metavar='TYPE', default='raw', - help='Type of Image [kernel, ramdisk, machine, raw] ' - '(default: %(default)s)') - parser.add_argument('--disk-format', metavar='DISK_FORMAT', default=None, - choices=DISK_FORMATS, - help='Disk format of Image [%s] ' - '(default: %%(default)s)' % ','.join(DISK_FORMATS)) - parser.add_argument('--container-format', metavar='CONTAINER_FORMAT', - default=None, choices=CONTAINER_FORMATS, - help='Disk format of Image [%s] ' - '(default: %%(default)s)' % ','.join(CONTAINER_FORMATS)) - parser.add_argument('--kernel', metavar='KERNEL', - help='ID of kernel associated with this machine image') - parser.add_argument('--ramdisk', metavar='RAMDISK', - help='ID of ramdisk associated with this machine ' - 'image') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - meta = {'name': args.name, - 'is_public': True, - 'properties': {}} - - if args.kernel: - meta['properties']['kernel_id'] = args.kernel - - if args.ramdisk: - meta['properties']['ramdisk_id'] = args.ramdisk - - if args.type: - meta['properties']['type'] = args.type - - if args.disk_format: - meta['disk_format'] = args.disk_format - - if args.container_format: - meta['container_format'] = args.container_format - - client = Client(args.host, args.port) - with open(args.filename) as f: - try: - new_meta = client.add_image(meta, f) - except Exception, e: - print "Failed to add new image. Got error: %s" % e - return 1 - - print 'Stored image. Got identifier: %s' % pprint.pformat(new_meta) - - -if __name__ == "__main__": - main() diff --git a/glance/tests/functional/test_misc.py b/glance/tests/functional/test_misc.py index 165efc8b3a..de40e0e63d 100644 --- a/glance/tests/functional/test_misc.py +++ b/glance/tests/functional/test_misc.py @@ -90,9 +90,6 @@ class TestMiscellaneous(functional.FunctionalTest): We then use curl to try adding an image that does not meet validation requirements on the registry server and test that the error returned from the API server to curl is appropriate - - We also fire the glance-upload tool against the API server - and verify that glance-upload doesn't eat the exception either... """ self.cleanup() self.start_servers() diff --git a/glance/tests/unit/test_api.py b/glance/tests/unit/test_api.py index 2e05b9e603..d2975d8730 100644 --- a/glance/tests/unit/test_api.py +++ b/glance/tests/unit/test_api.py @@ -2378,9 +2378,8 @@ class TestGlanceAPI(unittest.TestCase): that had had its save process killed manually results in failure because the location attribute is None. """ - # Add an image the way that glance-upload adds an image... - # by reserving a place in the database for an image without - # really any attributes or information on the image and then + # Add an image by reserving a place in the database for an image + # without really any attributes or information on the image and then # later doing an update with the image body and other attributes. # We will stop the process after the reservation stage, then # try to delete the image. diff --git a/setup.py b/setup.py index 87f7c1d57f..0edbe32fad 100644 --- a/setup.py +++ b/setup.py @@ -125,6 +125,5 @@ setup( 'bin/glance-control', 'bin/glance-manage', 'bin/glance-registry', - 'bin/glance-scrubber', - 'bin/glance-upload'], + 'bin/glance-scrubber'], py_modules=[])