diff options
| author | Anthony Young <sleepsonthefloor@gmail.com> | 2011-01-18 18:14:03 -0800 |
|---|---|---|
| committer | Anthony Young <sleepsonthefloor@gmail.com> | 2011-01-18 18:14:03 -0800 |
| commit | d5fd7b68d2ec4b4ee3cf6de6b7c10a00300a81a0 (patch) | |
| tree | e7a9bb2663df78f43a729c381cdd0508981cd02b /bin | |
| parent | 76a4d683d973c7f8120ae6b409d9fd9c09a3ab98 (diff) | |
| parent | 9d76fb7d6bb88c7b8e1e78d076168ac58a6d978a (diff) | |
merge vish's changes (which merged trunk and fixed a pep8 problem)
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/nova-manage | 100 |
1 files changed, 19 insertions, 81 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index 654a13820..a347e86ce 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]), @@ -84,9 +83,9 @@ 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 -from nova.api.ec2 import cloud +from nova.db import migration + logging.basicConfig() FLAGS = flags.FLAGS @@ -479,82 +478,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""" @@ -609,6 +532,21 @@ 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): + """Sync the database up to the most recent version.""" + return migration.db_sync(version) + + def version(self): + """Print the current database version.""" + print migration.db_version() + + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" @@ -648,6 +586,7 @@ class VolumeCommands(object): "volume_id": volume['id'], "mountpoint": volume['mountpoint']}}) + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -656,10 +595,9 @@ CATEGORIES = [ ('vpn', VpnCommands), ('floating', FloatingIpCommands), ('network', NetworkCommands), - ('instance', InstanceCommands), - ('host', HostCommands), ('service', ServiceCommands), ('log', LogCommands), + ('db', DbCommands), ('volume', VolumeCommands)] |
