From 40a9488b4b96fa809bd18f4a06018186a488507a Mon Sep 17 00:00:00 2001 From: Ilya Alekseyev Date: Thu, 14 Jul 2011 22:34:49 +0400 Subject: added commands --- bin/nova-manage | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7dfe91698..5a934b613 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -518,6 +518,27 @@ class FixedIpCommands(object): fixed_ip['address'], mac_address, hostname, host) + def reserve(self, address): + """Mark fixed ip as reserved + arguments: address""" + self._set_reserved(address, True) + + def waste(self, address): + """Mark fixed ip as free to use + arguments: address""" + self._set_reserved(address, False) + + def _set_reserved(self, address, reserved): + ctxt = context.get_admin_context() + + try: + fixed_ip = db.fixed_ip_get_by_address(ctxt, address) + db.fixed_ip_update(ctxt, fixed_ip['address'], + {'reserved': reserved}) + except exception.NotFound as ex: + print "error: %s" % ex + sys.exit(2) + class FloatingIpCommands(object): """Class for managing floating ip.""" -- cgit From 6fb2fe901bc4f4479e6a2bb087870927be7318a2 Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 26 Jul 2011 10:03:16 -0700 Subject: added warning when size of subnet(s) being created are larger than FLAG.network_size in attempt to alleviate confusion. For example, currently when 'nova-manage network create foo 192.168.0.0/16', the result is that it creates a 192.168.0.0/24 instead without any indication to why. --- bin/nova-manage | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index b63bd326f..da9538e39 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -56,6 +56,7 @@ import gettext import glob import json +import math import netaddr import os import sys @@ -669,6 +670,14 @@ class NetworkCommands(object): num_networks = FLAGS.num_networks if not network_size: network_size = FLAGS.network_size + fixnet = netaddr.IPNetwork(fixed_range) + each_subnet_size = fixnet.size / int(num_networks) + if each_subnet_size > network_size: + subnet = 32 - int(math.log(network_size, 2)) + oversize_msg = _('Subnet(s) too large, defaulting to /%s.' + ' To override, specify network_size flag.' + % subnet) + print oversize_msg if not multi_host: multi_host = FLAGS.multi_host else: -- cgit From e239dc589982a0d90eb8a50967af05a10d5e4d5b Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 26 Jul 2011 13:12:34 -0700 Subject: fixed per peer review --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index da9538e39..ca60d28d6 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -676,7 +676,7 @@ class NetworkCommands(object): subnet = 32 - int(math.log(network_size, 2)) oversize_msg = _('Subnet(s) too large, defaulting to /%s.' ' To override, specify network_size flag.' - % subnet) + ) % subnet print oversize_msg if not multi_host: multi_host = FLAGS.multi_host -- cgit From bfb5a5e1204bf868b5db8d8d038b63d0899665ce Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 3 Aug 2011 00:11:52 -0700 Subject: updated to work w/ changes after merged trunk fixing var renaming. the logic which forces default to FLAGS.network_size if requested cidr was larger, was also applying to requested cidrs smaller than FLAGS.network_size. Requested cidrs smaller than FLAGS.network_size should be ignored and not overriden. --- bin/nova-manage | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 78cc96818..f53021581 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -695,15 +695,18 @@ class NetworkCommands(object): if not num_networks: num_networks = FLAGS.num_networks if not network_size: - network_size = FLAGS.network_size - fixnet = netaddr.IPNetwork(fixed_range) + #network_size = FLAGS.network_size + fixnet = netaddr.IPNetwork(fixed_range_v4) each_subnet_size = fixnet.size / int(num_networks) - if each_subnet_size > network_size: + if each_subnet_size > FLAGS.network_size: + network_size = FLAGS.network_size subnet = 32 - int(math.log(network_size, 2)) oversize_msg = _('Subnet(s) too large, defaulting to /%s.' ' To override, specify network_size flag.' ) % subnet print oversize_msg + else: + network_size = fixnet.size if not multi_host: multi_host = FLAGS.multi_host else: -- cgit From f942a7f22acb6a6719a3de778ba55ca25ea0ee68 Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 3 Aug 2011 00:16:52 -0700 Subject: forgot to remove comment --- bin/nova-manage | 1 - 1 file changed, 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index f53021581..f272351c2 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -695,7 +695,6 @@ class NetworkCommands(object): if not num_networks: num_networks = FLAGS.num_networks if not network_size: - #network_size = FLAGS.network_size fixnet = netaddr.IPNetwork(fixed_range_v4) each_subnet_size = fixnet.size / int(num_networks) if each_subnet_size > FLAGS.network_size: -- cgit From e34a4c2feb7b2abef806ed720e1533e2e0fb94ef Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 3 Aug 2011 14:05:58 -0400 Subject: remove bit-rotted code. fixes #820062 --- bin/nova-import-canonical-imagestore | 110 ----------------------------------- 1 file changed, 110 deletions(-) delete mode 100755 bin/nova-import-canonical-imagestore (limited to 'bin') diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore deleted file mode 100755 index 404ae37f4..000000000 --- a/bin/nova-import-canonical-imagestore +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# 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. - -""" - Download images from Canonical Image Store -""" - -import gettext -import json -import os -import tempfile -import shutil -import subprocess -import sys -import urllib2 - -# If ../nova/__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, 'nova', '__init__.py')): - sys.path.insert(0, possible_topdir) - -gettext.install('nova', unicode=1) - -from nova import flags -from nova import log as logging -from nova import utils -from nova.objectstore import image - -FLAGS = flags.FLAGS - -API_URL = 'https://imagestore.canonical.com/api/dashboard' - - -def get_images(): - """Get a list of the images from the imagestore URL.""" - images = json.load(urllib2.urlopen(API_URL))['images'] - images = [img for img in images if img['title'].find('amd64') > -1] - return images - - -def download(img): - """Download an image to the local filesystem.""" - # FIXME(ja): add checksum/signature checks - tempdir = tempfile.mkdtemp(prefix='cis-') - - kernel_id = None - ramdisk_id = None - - for f in img['files']: - if f['kind'] == 'kernel': - dest = os.path.join(tempdir, 'kernel') - subprocess.call(['curl', '--fail', f['url'], '-o', dest]) - kernel_id = image.Image.add(dest, - description='kernel/' + img['title'], kernel=True) - - for f in img['files']: - if f['kind'] == 'ramdisk': - dest = os.path.join(tempdir, 'ramdisk') - subprocess.call(['curl', '--fail', f['url'], '-o', dest]) - ramdisk_id = image.Image.add(dest, - description='ramdisk/' + img['title'], ramdisk=True) - - for f in img['files']: - if f['kind'] == 'image': - dest = os.path.join(tempdir, 'image') - subprocess.call(['curl', '--fail', f['url'], '-o', dest]) - ramdisk_id = image.Image.add(dest, - description=img['title'], kernel=kernel_id, ramdisk=ramdisk_id) - - shutil.rmtree(tempdir) - - -def main(): - """Main entry point.""" - utils.default_flagfile() - argv = FLAGS(sys.argv) - logging.setup() - images = get_images() - - if len(argv) == 2: - for img in images: - if argv[1] == 'all' or argv[1] == img['title']: - download(img) - else: - print 'usage: %s (title|all)' - print 'available images:' - for img in images: - print img['title'] - -if __name__ == '__main__': - main() -- cgit From ca79470843ff351623d07378ab553b2548cb8dc0 Mon Sep 17 00:00:00 2001 From: Mandell Degerness Date: Thu, 4 Aug 2011 10:43:16 -0700 Subject: Fix to nova-ajax-console-proxy to use the new syntax. create_consumer and create_connection abstractions were added recently. --- bin/nova-ajax-console-proxy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy index 21cf68007..2329581a2 100755 --- a/bin/nova-ajax-console-proxy +++ b/bin/nova-ajax-console-proxy @@ -114,11 +114,11 @@ class AjaxConsoleProxy(object): AjaxConsoleProxy.tokens[kwargs['token']] = \ {'args': kwargs, 'last_activity': time.time()} - conn = rpc.Connection.instance(new=True) - consumer = rpc.TopicAdapterConsumer( - connection=conn, - proxy=TopicProxy, - topic=FLAGS.ajax_console_proxy_topic) + conn = rpc.create_connection(new=True) + consumer = rpc.create_consumer( + conn, + FLAGS.ajax_console_proxy_topic, + TopicProxy) def delete_expired_tokens(): now = time.time() -- cgit From a77f10ee052fdafeb9d52407695719397c52e68d Mon Sep 17 00:00:00 2001 From: Ilya Alekseyev Date: Fri, 5 Aug 2011 19:45:17 +0400 Subject: methods renamed --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index ba08f136b..6f71bc403 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -601,7 +601,7 @@ class FixedIpCommands(object): @args('--address', dest="address", metavar='', help='IP address') - def waste(self, address): + def unreserve(self, address): """Mark fixed ip as free to use arguments: address""" self._set_reserved(address, False) -- cgit From 8a87a3ecc0bc9fe524f42950ec0d50124bb5b2b6 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 5 Aug 2011 15:25:12 -0700 Subject: Pass a real context object into image service calls --- bin/nova-manage | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index f272351c2..7b4923021 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1235,11 +1235,12 @@ class ImageCommands(object): is_public, architecture) def _lookup(self, old_image_id): + elevated = context.get_admin_context() try: internal_id = ec2utils.ec2_id_to_id(old_image_id) - image = self.image_service.show(context, internal_id) + image = self.image_service.show(elevated, internal_id) except (exception.InvalidEc2Id, exception.ImageNotFound): - image = self.image_service.show_by_name(context, old_image_id) + image = self.image_service.show_by_name(elevated, old_image_id) return image['id'] def _old_to_new(self, old): -- cgit From 450a9ff6d7082c2c12ad933be0743c010103ffa9 Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Mon, 8 Aug 2011 14:43:52 -0700 Subject: added --purge optparse for flavor delete --- bin/nova-manage | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 40f22c19c..e010bbe4b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1120,10 +1120,12 @@ class InstanceTypeCommands(object): @args('--name', dest='name', metavar='', help='Name of instance type/flavor') - def delete(self, name, purge=None): + @args('--purge', action="store_true", dest='purge', default=False, + help='purge record from database') + def delete(self, name, purge): """Marks instance types / flavors as deleted""" try: - if purge == "--purge": + if purge == True: instance_types.purge(name) verb = "purged" else: -- cgit From 9a52a79f45bb526f5ff15d8bb136bb947a114824 Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Mon, 8 Aug 2011 15:33:17 -0700 Subject: fixed conditional because jk0 is very picky :) --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index e010bbe4b..a8a872c28 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1125,7 +1125,7 @@ class InstanceTypeCommands(object): def delete(self, name, purge): """Marks instance types / flavors as deleted""" try: - if purge == True: + if purge: instance_types.purge(name) verb = "purged" else: -- cgit From f80ac0c7404882fa0f3e640d1330ab37e6da797a Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Tue, 9 Aug 2011 15:44:43 +0100 Subject: Fix remaining two pep8 violations --- bin/nova-manage | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 40f22c19c..550454686 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -726,8 +726,7 @@ class NetworkCommands(object): network_size = FLAGS.network_size subnet = 32 - int(math.log(network_size, 2)) oversize_msg = _('Subnet(s) too large, defaulting to /%s.' - ' To override, specify network_size flag.' - ) % subnet + ' To override, specify network_size flag.') % subnet print oversize_msg else: network_size = fixnet.size -- cgit