From 2925ca3ac3010b9a65276ad2cfc8118679827da3 Mon Sep 17 00:00:00 2001 From: masumotok Date: Tue, 7 Dec 2010 19:25:43 +0900 Subject: rev439ベースにライブマイグレーションの機能をマージ このバージョンはEBSなし、CPUフラグのチェックなし MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/nova-manage | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index eb7c6b87b..d41ae8600 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -76,6 +76,13 @@ from nova import quota from nova import utils from nova.auth import manager from nova.cloudpipe import pipelib +#added by masumotok +from nova import rpc +# added by masumotok +from nova.api.ec2 import cloud +# added by masumotok +from nova.compute import power_state + FLAGS = flags.FLAGS @@ -424,6 +431,116 @@ class NetworkCommands(object): int(network_size), int(vlan_start), int(vpn_start)) +# this class is added by masumotok +class InstanceCommands(object): + """Class for mangaging VM instances.""" + + def live_migration(self, ec2_id, dest): + """live_migration""" + + logging.basicConfig() + ctxt = context.get_admin_context() + + if 'nova.network.manager.VlanManager' != FLAGS.network_manager : + msg = 'Only nova.network.manager.VlanManager is supported now. Sorry!' + raise Exception(msg) + + # 1. whether destination host exists + host_ref = db.host_get_by_name(ctxt, dest) + + # 2. whether instance exists and running + # try-catch clause is necessary because only internal_id is shown + # when NotFound exception occurs. it isnot understandable to admins. + try : + internal_id = cloud.ec2_id_to_internal_id(ec2_id) + instance_ref = db.instance_get_by_internal_id(ctxt, internal_id) + except exception.NotFound : + print 'Not found instance_id(%s (internal_id:%s))' % ( ec2_id, internal_id) + raise + + if power_state.RUNNING != instance_ref['state'] or \ + 'running' != instance_ref['state_description']: + print 'Instance(%s) is not running' % ec2_id + sys.exit(1) + + # 3. the host where instance is running and dst host is not same + if dest == instance_ref['host'] : + print '%s is where %s is running now. choose different host.' \ + % (dest, ec2_id) + sys.exit(2) + + # 4. live migration + rpc.cast(ctxt, + FLAGS.scheduler_topic, + { "method": "live_migration", + "args": {"ec2_id": ec2_id, + "dest":dest}}) + + print 'Finished all procedure. check instance are migrated successfully' + print 'chech status by using euca-describe-instances.' + + +# this class is created by masumotok +class HostCommands(object): + """Class for mangaging host(physical nodes).""" + + + def list(self): + """describe host list.""" + + # to supress msg: No handlers could be found for logger "amqplib" + logging.basicConfig() + + host_refs = db.host_get_all(context.get_admin_context()) + for host_ref in host_refs: + print host_ref['name'] + + def show(self, host): + """describe cpu/memory/hdd info for host.""" + + # to supress msg: No handlers could be found for logger "amqplib" + logging.basicConfig() + + result = rpc.call(context.get_admin_context(), + FLAGS.scheduler_topic, + {"method": "show_host_resource", + "args": {"host": host}}) + + # checing result msg format is necessary, that will have done + # when this feture is included in API. + if dict != type(result): + print 'Unexpected error occurs' + elif not result['ret'] : + print '%s' % result['msg'] + else : + cpu = result['phy_resource']['cpu'] + mem = result['phy_resource']['memory_mb'] + hdd = result['phy_resource']['hdd_gb'] + + print 'HOST\t\tPROJECT\t\tcpu\tmem(mb)\tdisk(gb)' + print '%s\t\t\t%s\t%s\t%s' % ( host,cpu, mem, hdd) + for p_id, val in result['usage'].items() : + print '%s\t%s\t\t%s\t%s\t%s' % ( host, + p_id, + val['cpu'], + val['memory_mb'], + val['hdd_gb']) + + def has_keys(self, dic, keys): + not_found = [ key for key in keys if not dict.has_key(key) ] + return ( (0 == len(not_found)), not_found ) + + + +# modified by masumotok +#CATEGORIES = [ +# ('user', UserCommands), +# ('project', ProjectCommands), +# ('role', RoleCommands), +# ('shell', ShellCommands), +# ('vpn', VpnCommands), +# ('floating', FloatingIpCommands), +# ('network', NetworkCommands)] CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -431,8 +548,9 @@ CATEGORIES = [ ('shell', ShellCommands), ('vpn', VpnCommands), ('floating', FloatingIpCommands), - ('network', NetworkCommands)] - + ('network', NetworkCommands), + ('instance', InstanceCommands), + ('host',HostCommands)] def lazy_match(name, key_value_tuples): """Finds all objects that have a key that case insensitively contains -- cgit From 4809c1bf82130f969614a8f0458636a462b81a88 Mon Sep 17 00:00:00 2001 From: masumotok Date: Thu, 16 Dec 2010 18:20:04 +0900 Subject: Hostテーブルのカラム名を修正 FlatManager, FlatDHCPManagerに対応 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/nova-manage | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index d41ae8600..d1cda72b7 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -441,10 +441,6 @@ class InstanceCommands(object): logging.basicConfig() ctxt = context.get_admin_context() - if 'nova.network.manager.VlanManager' != FLAGS.network_manager : - msg = 'Only nova.network.manager.VlanManager is supported now. Sorry!' - raise Exception(msg) - # 1. whether destination host exists host_ref = db.host_get_by_name(ctxt, dest) @@ -513,18 +509,18 @@ class HostCommands(object): elif not result['ret'] : print '%s' % result['msg'] else : - cpu = result['phy_resource']['cpu'] + cpu = result['phy_resource']['vcpus'] mem = result['phy_resource']['memory_mb'] - hdd = result['phy_resource']['hdd_gb'] + hdd = result['phy_resource']['local_gb'] print 'HOST\t\tPROJECT\t\tcpu\tmem(mb)\tdisk(gb)' print '%s\t\t\t%s\t%s\t%s' % ( host,cpu, mem, hdd) for p_id, val in result['usage'].items() : print '%s\t%s\t\t%s\t%s\t%s' % ( host, p_id, - val['cpu'], + val['vcpus'], val['memory_mb'], - val['hdd_gb']) + val['local_gb']) def has_keys(self, dic, keys): not_found = [ key for key in keys if not dict.has_key(key) ] -- cgit From f983884dd262f46907f80a04121d957347881240 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 Dec 2010 15:09:05 +0900 Subject: nova.compute.managerがこれまでの修正でデグレしていたので修正 CPUID, その他のチェックルーチンをnova.scheduler.manager.live_migrationに追加 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/nova-manage | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index d1cda72b7..d6aa29679 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -456,24 +456,25 @@ class InstanceCommands(object): if power_state.RUNNING != instance_ref['state'] or \ 'running' != instance_ref['state_description']: - print 'Instance(%s) is not running' % ec2_id - sys.exit(1) + raise exception.Invalid('Instance(%s) is not running' % ec2_id) # 3. the host where instance is running and dst host is not same if dest == instance_ref['host'] : - print '%s is where %s is running now. choose different host.' \ - % (dest, ec2_id) - sys.exit(2) + msg = '%s is where %s is running now. choose other host.' % (dest, ec2_id) + raise exception.Invalid(msg) # 4. live migration - rpc.cast(ctxt, - FLAGS.scheduler_topic, - { "method": "live_migration", - "args": {"ec2_id": ec2_id, - "dest":dest}}) + ret = rpc.call(ctxt, + FLAGS.scheduler_topic, + { "method": "live_migration", + "args": {"ec2_id": ec2_id, + "dest":dest}}) + + if None != ret : + raise ret print 'Finished all procedure. check instance are migrated successfully' - print 'chech status by using euca-describe-instances.' + print 'check status by using euca-describe-instances.' # this class is created by masumotok -- cgit From 5afd9848ad09414c00062ceebdad45bca0604888 Mon Sep 17 00:00:00 2001 From: Muneyuki Noguchi Date: Tue, 11 Jan 2011 18:01:23 +0900 Subject: Add support for EBS volumes to the live migration feature. Currently, only AoE is supported. --- bin/nova-manage | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7c87d21ff..fa044859d 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -83,8 +83,6 @@ from nova import rpc from nova.cloudpipe import pipelib from nova.api.ec2 import cloud - - FLAGS = flags.FLAGS flags.DECLARE('fixed_range', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager') @@ -462,6 +460,10 @@ class InstanceCommands(object): def live_migration(self, ec2_id, dest): """live_migration""" + if FLAGS.volume_driver != 'nova.volume.driver.AOEDriver': + raise exception.Error('Only AOEDriver is supported for now. ' + 'Sorry.') + logging.basicConfig() ctxt = context.get_admin_context() @@ -491,7 +493,6 @@ class InstanceCommands(object): class HostCommands(object): """Class for mangaging host(physical nodes).""" - def list(self): """describe host list.""" @@ -502,7 +503,6 @@ class HostCommands(object): for host_ref in host_refs: print host_ref['name'] - def show(self, host): """describe cpu/memory/hdd info for host.""" @@ -546,6 +546,7 @@ CATEGORIES = [ ('instance', InstanceCommands), ('host', HostCommands)] + def lazy_match(name, key_value_tuples): """Finds all objects that have a key that case insensitively contains [name] key_value_tuples is a list of tuples of the form (key, value) -- cgit From 4f5c0c64ec9d397048dfd7b8d5c007ec0fa39ec5 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 12 Jan 2011 16:57:04 -0800 Subject: add support for database migration --- bin/nova-manage | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 3e290567c..c441fa7f2 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -82,6 +82,7 @@ from nova import quota from nova import utils from nova.auth import manager from nova.cloudpipe import pipelib +from nova.db import migration logging.basicConfig() @@ -515,6 +516,22 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) +class DbCommands(object): + """Class for managing the database.""" + + def __init__(self): + pass + + def sync(self, version=None): + """adds role to user + if project is specified, adds project specific role + arguments: user, role [project]""" + return migration.db_sync(version) + + def version(self): + print migration.db_version() + + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -524,7 +541,8 @@ CATEGORIES = [ ('floating', FloatingIpCommands), ('network', NetworkCommands), ('service', ServiceCommands), - ('log', LogCommands)] + ('log', LogCommands), + ('db', DbCommands)] def lazy_match(name, key_value_tuples): -- cgit From c57ccba743c54786e28317194000bcf22dc5b69e Mon Sep 17 00:00:00 2001 From: Kei Masumoto Date: Fri, 14 Jan 2011 08:26:25 +0900 Subject: checking based on pep8 --- bin/nova-manage | 1 - 1 file changed, 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index fb6b06694..b8a181343 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -468,7 +468,6 @@ class InstanceCommands(object): def live_migration(self, ec2_id, dest): """live_migration""" - if FLAGS.connection_type != 'libvirt': raise exception.Error('Only KVM is supported for now. ' 'Sorry.') -- cgit From 525544e689334346305ecc11552105fc1b32a5dd Mon Sep 17 00:00:00 2001 From: Kei Masumoto Date: Sun, 16 Jan 2011 14:54:35 +0900 Subject: merged to rev 561 and fixed based on reviewer's comment --- bin/nova-manage | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index b8a181343..6bd6aef64 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -62,6 +62,7 @@ import time import IPy + # 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]), @@ -468,17 +469,19 @@ class InstanceCommands(object): def live_migration(self, ec2_id, dest): """live_migration""" + ctxt = context.get_admin_context() + instance_id = cloud.ec2_id_to_id(ec2_id) + if FLAGS.connection_type != 'libvirt': - raise exception.Error('Only KVM is supported for now. ' - 'Sorry.') + msg = _('Only KVM is supported for now. Sorry!') + raise exception.Error(msg) if FLAGS.volume_driver != 'nova.volume.driver.AOEDriver': - raise exception.Error('Only AOEDriver is supported for now. ' - 'Sorry.') - - logging.basicConfig() - ctxt = context.get_admin_context() - instance_id = cloud.ec2_id_to_id(ec2_id) + instance_ref = db.instance_get(instance_id) + if len(instance_ref['volumes']) != 0: + msg = _(("""Volumes attached by ISCSIDriver""" + """ are not supported. Sorry!""")) + raise exception.Error(msg) rpc.call(ctxt, FLAGS.scheduler_topic, @@ -501,16 +504,15 @@ class HostCommands(object): # To supress msg: No handlers could be found for logger "amqplib" logging.basicConfig() - host_refs = db.host_get_all(context.get_admin_context()) - for host_ref in host_refs: - print host_ref['name'] + service_refs = db.service_get_all(context.get_admin_context()) + hosts = [ h['host'] for h in service_refs] + hosts = list(set(hosts)) + for host in hosts: + print host def show(self, host): """describe cpu/memory/hdd info for host.""" - # To supress msg: No handlers could be found for logger "amqplib" - logging.basicConfig() - result = rpc.call(context.get_admin_context(), FLAGS.scheduler_topic, {"method": "show_host_resource", -- cgit From c9610db6c4d573568bd4b6dc390df99349b0a4ea Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 08:48:50 -0500 Subject: ComputeAPI -> compute.API in bin/nova-direct-api. Fixes LP#704422 --- bin/nova-direct-api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-direct-api b/bin/nova-direct-api index e7dd14fb2..173b39bdb 100755 --- a/bin/nova-direct-api +++ b/bin/nova-direct-api @@ -49,7 +49,7 @@ if __name__ == '__main__': utils.default_flagfile() FLAGS(sys.argv) - direct.register_service('compute', compute_api.ComputeAPI()) + direct.register_service('compute', compute_api.API()) direct.register_service('reflect', direct.Reflection()) router = direct.Router() with_json = direct.JsonParamsMiddleware(router) -- cgit From 785c5df3d17bb158ef2c1a66ce59ee8e6d4236b1 Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 10:24:20 -0500 Subject: Removes circular import issues from bin/stack and replaces utils.loads with json.loads. Fixes Bug#704424 --- bin/stack | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/stack b/bin/stack index 7a6ce5960..25caca06f 100755 --- a/bin/stack +++ b/bin/stack @@ -22,6 +22,7 @@ import eventlet eventlet.monkey_patch() +import json import os import pprint import sys @@ -38,7 +39,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) import gflags -from nova import utils FLAGS = gflags.FLAGS @@ -106,8 +106,12 @@ def do_request(controller, method, params=None): 'X-OpenStack-Project': FLAGS.project} req = urllib2.Request(url, data, headers) - resp = urllib2.urlopen(req) - return utils.loads(resp.read()) + try: + resp = urllib2.urlopen(req) + except urllib2.HTTPError, e: + print e.read() + sys.exit(1) + return json.loads(resp.read()) if __name__ == '__main__': -- cgit From d91229f7a3b60095677e1bb76a548668c59ee9e2 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 18 Jan 2011 11:01:16 -0800 Subject: revert live_migration branch --- bin/nova-manage | 82 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 81 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 1ad3120b8..b5842b595 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -62,7 +62,6 @@ import time import IPy - # 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]), @@ -82,9 +81,8 @@ from nova import log as logging from nova import quota from nova import utils from nova.auth import manager -from nova import rpc from nova.cloudpipe import pipelib -from nova.api.ec2 import cloud + logging.basicConfig() FLAGS = flags.FLAGS @@ -467,82 +465,6 @@ class NetworkCommands(object): int(vpn_start), fixed_range_v6) -class InstanceCommands(object): - """Class for mangaging VM instances.""" - - def live_migration(self, ec2_id, dest): - """live_migration""" - - ctxt = context.get_admin_context() - instance_id = cloud.ec2_id_to_id(ec2_id) - - if FLAGS.connection_type != 'libvirt': - msg = _('Only KVM is supported for now. Sorry!') - raise exception.Error(msg) - - if FLAGS.volume_driver != 'nova.volume.driver.AOEDriver': - instance_ref = db.instance_get(ctxt, instance_id) - if len(instance_ref['volumes']) != 0: - msg = _(("""Volumes attached by ISCSIDriver""" - """ are not supported. Sorry!""")) - raise exception.Error(msg) - - rpc.call(ctxt, - FLAGS.scheduler_topic, - {"method": "live_migration", - "args": {"instance_id": instance_id, - "dest": dest, - "topic": FLAGS.compute_topic}}) - - msg = 'Migration of %s initiated. ' % ec2_id - msg += 'Check its progress using euca-describe-instances.' - print msg - - -class HostCommands(object): - """Class for mangaging host(physical nodes).""" - - def list(self): - """describe host list.""" - - # To supress msg: No handlers could be found for logger "amqplib" - logging.basicConfig() - - service_refs = db.service_get_all(context.get_admin_context()) - hosts = [h['host'] for h in service_refs] - hosts = list(set(hosts)) - for host in hosts: - print host - - def show(self, host): - """describe cpu/memory/hdd info for host.""" - - result = rpc.call(context.get_admin_context(), - FLAGS.scheduler_topic, - {"method": "show_host_resource", - "args": {"host": host}}) - - # Checking result msg format is necessary, that will have done - # when this feture is included in API. - if type(result) != dict: - print 'Unexpected error occurs' - elif not result['ret']: - print '%s' % result['msg'] - else: - cpu = result['phy_resource']['vcpus'] - mem = result['phy_resource']['memory_mb'] - hdd = result['phy_resource']['local_gb'] - - print 'HOST\t\tPROJECT\t\tcpu\tmem(mb)\tdisk(gb)' - print '%s\t\t\t%s\t%s\t%s' % (host, cpu, mem, hdd) - for p_id, val in result['usage'].items(): - print '%s\t%s\t\t%s\t%s\t%s' % (host, - p_id, - val['vcpus'], - val['memory_mb'], - val['local_gb']) - - class ServiceCommands(object): """Enable and disable running services""" @@ -605,8 +527,6 @@ CATEGORIES = [ ('vpn', VpnCommands), ('floating', FloatingIpCommands), ('network', NetworkCommands), - ('instance', InstanceCommands), - ('host', HostCommands), ('service', ServiceCommands), ('log', LogCommands)] -- cgit From 25f9c308714a41c93450ae4c5b14e90615d75425 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 13:46:06 -0800 Subject: fixes related to #701749. Also, added nova-manage commands to recover from certain states: # Delete a volume that is in an error state nova-manage cleanup delete_volume vol-id # reattach a volume. this is typically required after a host reboot nova-manage cleanup reattach_volume vol-id --- bin/nova-manage | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 1ad3120b8..f8523f18b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -80,7 +80,9 @@ from nova import exception from nova import flags from nova import log as logging from nova import quota +from nova import rpc from nova import utils +from nova.api.ec2.cloud import ec2_id_to_id from nova.auth import manager from nova import rpc from nova.cloudpipe import pipelib @@ -597,6 +599,45 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) +class CleanupCommands(object): + """Methods for dealing with a cloud in an odd state""" + + def delete_volume(self, volume_id): + """Delete a volume, bypassing the check that it + must be available. + args: volume_id_id""" + ctxt = context.get_admin_context() + volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + host = volume['host'] + if volume['status'] == 'in-use': + print "Volume is in-use." + print "Detach volume from instance and then try again." + return + + rpc.cast(ctxt, + db.queue_get_for(ctxt, FLAGS.volume_topic, host), + {"method": "delete_volume", + "args": {"volume_id": volume['id']}}) + + def reattach_volume(self, volume_id): + """Re-attach a volume that has previously been attached + to an instance. Typically called after a compute host + has been rebooted. + args: volume_id_id""" + ctxt = context.get_admin_context() + volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + if not volume['instance_id']: + print "volume is not attached to an instance" + return + instance = db.instance_get(ctxt, volume['instance_id']) + host = instance['host'] + rpc.cast(ctxt, + db.queue_get_for(ctxt, FLAGS.compute_topic, host), + {"method": "attach_volume", + "args": {"instance_id": instance['id'], + "volume_id": volume['id'], + "mountpoint": volume['mountpoint']}}) + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -608,7 +649,8 @@ CATEGORIES = [ ('instance', InstanceCommands), ('host', HostCommands), ('service', ServiceCommands), - ('log', LogCommands)] + ('log', LogCommands), + ('cleanup', CleanupCommands)] def lazy_match(name, key_value_tuples): -- cgit From a0af78323131b05a76eb7959df38f6a18e2b39ed Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 14:17:54 -0800 Subject: s/cleanup/volume. volume commands will need their own ns in the long run --- bin/nova-manage | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index f8523f18b..3e4f28fe5 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -599,10 +599,10 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) -class CleanupCommands(object): +class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" - def delete_volume(self, volume_id): + def delete(self, volume_id): """Delete a volume, bypassing the check that it must be available. args: volume_id_id""" @@ -619,7 +619,7 @@ class CleanupCommands(object): {"method": "delete_volume", "args": {"volume_id": volume['id']}}) - def reattach_volume(self, volume_id): + def reattach(self, volume_id): """Re-attach a volume that has previously been attached to an instance. Typically called after a compute host has been rebooted. @@ -650,7 +650,7 @@ CATEGORIES = [ ('host', HostCommands), ('service', ServiceCommands), ('log', LogCommands), - ('cleanup', CleanupCommands)] + ('volume', VolumeCommands)] def lazy_match(name, key_value_tuples): -- cgit From 76a4d683d973c7f8120ae6b409d9fd9c09a3ab98 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 16:12:52 -0800 Subject: per vish's feedback, allow admin to specify volume id in any of the acceptable manners (vol-, volume-, and int) Also, have manager only attempt to export volumes that are in-use or available --- bin/nova-manage | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 3e4f28fe5..654a13820 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -98,6 +98,16 @@ flags.DECLARE('vpn_start', 'nova.network.manager') flags.DECLARE('fixed_range_v6', 'nova.network.manager') +def param2id(object_id): + """Helper function to convert various id types to internal id. + args: [object_id], e.g. 'vol-0000000a' or 'volume-0000000a' or '10' + """ + if '-' in object_id: + return ec2_id_to_id(object_id) + else: + return int(object_id) + + class VpnCommands(object): """Class for managing VPNs.""" @@ -607,7 +617,7 @@ class VolumeCommands(object): must be available. args: volume_id_id""" ctxt = context.get_admin_context() - volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + volume = db.volume_get(ctxt, param2id(volume_id)) host = volume['host'] if volume['status'] == 'in-use': print "Volume is in-use." @@ -625,7 +635,7 @@ class VolumeCommands(object): has been rebooted. args: volume_id_id""" ctxt = context.get_admin_context() - volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + volume = db.volume_get(ctxt, param2id(volume_id)) if not volume['instance_id']: print "volume is not attached to an instance" return -- cgit