Risk of Regression: This patch don’t modify existing functionlities, but I have added some.

1. nova.db.service.sqlalchemy.model.Serivce (adding a column to database)
    2. nova.service ( nova-compute needes to insert information defined by 1 above)

So, db migration is necessary for existing user, but just adding columns.
This commit is contained in:
Kei Masumoto
2011-01-18 16:39:26 +00:00
committed by Tarmac
3 changed files with 85 additions and 1 deletions

View File

@@ -16,6 +16,8 @@
<jmckenty@gmail.com> <jmckenty@joshua-mckentys-macbook-pro.local> <jmckenty@gmail.com> <jmckenty@joshua-mckentys-macbook-pro.local>
<jmckenty@gmail.com> <joshua.mckenty@nasa.gov> <jmckenty@gmail.com> <joshua.mckenty@nasa.gov>
<justin@fathomdb.com> <justinsb@justinsb-desktop> <justin@fathomdb.com> <justinsb@justinsb-desktop>
<masumotok@nttdata.co.jp> <root@openstack2-api>
<masumotok@nttdata.co.jp> Masumoto<masumotok@nttdata.co.jp>
<mordred@inaugust.com> <mordred@hudson> <mordred@inaugust.com> <mordred@hudson>
<paul@openstack.org> <pvoccio@castor.local> <paul@openstack.org> <pvoccio@castor.local>
<paul@openstack.org> <paul.voccio@rackspace.com> <paul@openstack.org> <paul.voccio@rackspace.com>

View File

@@ -26,6 +26,7 @@ Josh Durgin <joshd@hq.newdream.net>
Josh Kearney <josh.kearney@rackspace.com> Josh Kearney <josh.kearney@rackspace.com>
Joshua McKenty <jmckenty@gmail.com> Joshua McKenty <jmckenty@gmail.com>
Justin Santa Barbara <justin@fathomdb.com> Justin Santa Barbara <justin@fathomdb.com>
Kei Masumoto <masumotok@nttdata.co.jp>
Ken Pepple <ken.pepple@gmail.com> Ken Pepple <ken.pepple@gmail.com>
Koji Iida <iida.koji@lab.ntt.co.jp> Koji Iida <iida.koji@lab.ntt.co.jp>
Lorin Hochstein <lorin@isi.edu> Lorin Hochstein <lorin@isi.edu>
@@ -34,6 +35,7 @@ Michael Gundlach <michael.gundlach@rackspace.com>
Monsyne Dragon <mdragon@rackspace.com> Monsyne Dragon <mdragon@rackspace.com>
Monty Taylor <mordred@inaugust.com> Monty Taylor <mordred@inaugust.com>
MORITA Kazutaka <morita.kazutaka@gmail.com> MORITA Kazutaka <morita.kazutaka@gmail.com>
Muneyuki Noguchi <noguchimn@nttdata.co.jp>
Nachi Ueno <ueno.nachi@lab.ntt.co.jp> <openstack@lab.ntt.co.jp> <nati.ueno@gmail.com> <nova@u4> Nachi Ueno <ueno.nachi@lab.ntt.co.jp> <openstack@lab.ntt.co.jp> <nati.ueno@gmail.com> <nova@u4>
Paul Voccio <paul@openstack.org> Paul Voccio <paul@openstack.org>
Rick Clark <rick@openstack.org> Rick Clark <rick@openstack.org>

View File

@@ -62,6 +62,7 @@ import time
import IPy import IPy
# If ../nova/__init__.py exists, add ../ to Python search path, so that # 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... # 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]), possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
@@ -81,8 +82,9 @@ from nova import log as logging
from nova import quota from nova import quota
from nova import utils from nova import utils
from nova.auth import manager from nova.auth import manager
from nova import rpc
from nova.cloudpipe import pipelib from nova.cloudpipe import pipelib
from nova.api.ec2 import cloud
logging.basicConfig() logging.basicConfig()
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
@@ -465,6 +467,82 @@ class NetworkCommands(object):
int(vpn_start), fixed_range_v6) 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): class ServiceCommands(object):
"""Enable and disable running services""" """Enable and disable running services"""
@@ -527,6 +605,8 @@ CATEGORIES = [
('vpn', VpnCommands), ('vpn', VpnCommands),
('floating', FloatingIpCommands), ('floating', FloatingIpCommands),
('network', NetworkCommands), ('network', NetworkCommands),
('instance', InstanceCommands),
('host', HostCommands),
('service', ServiceCommands), ('service', ServiceCommands),
('log', LogCommands)] ('log', LogCommands)]