From d31e9cb2c33e751d4dbbd4720714c2d952fe3861 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 12 Jan 2011 16:57:04 -0800 Subject: [PATCH 1/5] add support for database migration --- bin/nova-manage | 20 +++++++++++++++++++- run_tests.py | 9 ++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 3e290567..c441fa7f 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): diff --git a/run_tests.py b/run_tests.py index 5b8617f6..fbca3cbe 100644 --- a/run_tests.py +++ b/run_tests.py @@ -17,7 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - +import gettext import os import unittest import sys @@ -26,6 +26,10 @@ from nose import config from nose import result from nose import core +gettext.install('nova', unicode=1) + +from nova.db import migration + class NovaTestResult(result.TextTestResult): def __init__(self, *args, **kw): @@ -61,6 +65,9 @@ if __name__ == '__main__': c = config.Config(stream=sys.stdout, env=os.environ, verbosity=3) + + migration.db_sync() + runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity, From 2fefd8c794a543c7a1a64761925c8a106f9ee452 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 18 Jan 2011 11:01:16 -0800 Subject: [PATCH 2/5] revert live_migration branch --- .mailmap | 2 -- Authors | 2 -- bin/nova-manage | 82 +------------------------------------------------ 3 files changed, 1 insertion(+), 85 deletions(-) diff --git a/.mailmap b/.mailmap index d13219ab..2af2d7cd 100644 --- a/.mailmap +++ b/.mailmap @@ -16,8 +16,6 @@ - - Masumoto diff --git a/Authors b/Authors index 82e07a6b..bcb2cd0f 100644 --- a/Authors +++ b/Authors @@ -26,7 +26,6 @@ Josh Durgin Josh Kearney Joshua McKenty Justin Santa Barbara -Kei Masumoto Ken Pepple Koji Iida Lorin Hochstein @@ -35,7 +34,6 @@ Michael Gundlach Monsyne Dragon Monty Taylor MORITA Kazutaka -Muneyuki Noguchi Nachi Ueno Paul Voccio Rick Clark diff --git a/bin/nova-manage b/bin/nova-manage index 1ad3120b..b5842b59 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)] From cffbd0a3ba86a4e86491a8b25b14c4fe64fda05e Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 18 Jan 2011 11:34:29 -0800 Subject: [PATCH 3/5] authors needed for test --- .mailmap | 2 ++ Authors | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.mailmap b/.mailmap index 2af2d7cd..d13219ab 100644 --- a/.mailmap +++ b/.mailmap @@ -16,6 +16,8 @@ + + Masumoto diff --git a/Authors b/Authors index bcb2cd0f..82e07a6b 100644 --- a/Authors +++ b/Authors @@ -26,6 +26,7 @@ Josh Durgin Josh Kearney Joshua McKenty Justin Santa Barbara +Kei Masumoto Ken Pepple Koji Iida Lorin Hochstein @@ -34,6 +35,7 @@ Michael Gundlach Monsyne Dragon Monty Taylor MORITA Kazutaka +Muneyuki Noguchi Nachi Ueno Paul Voccio Rick Clark From 7050c2abf71ee1243eea68efbcf41fd2e1b74937 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 19 Jan 2011 00:39:24 +0100 Subject: [PATCH 4/5] Enable the use_ipv6 flag in unit tests by default. --- nova/tests/fake_flags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/tests/fake_flags.py b/nova/tests/fake_flags.py index 7376a11d..1097488e 100644 --- a/nova/tests/fake_flags.py +++ b/nova/tests/fake_flags.py @@ -40,3 +40,4 @@ FLAGS.blades_per_shelf = 4 FLAGS.iscsi_num_targets = 8 FLAGS.verbose = True FLAGS.sql_connection = 'sqlite:///nova.sqlite' +FLAGS.use_ipv6 = True From 36c5b8fcb4aec4b719090edd7d8f24b2ec016f09 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 18 Jan 2011 17:32:54 -0800 Subject: [PATCH 5/5] move db sync into nosetests package-level fixtures so that the existing nosetests attempt in hudson will pass --- run_tests.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/run_tests.py b/run_tests.py index fbca3cbe..7b5e2192 100644 --- a/run_tests.py +++ b/run_tests.py @@ -26,10 +26,6 @@ from nose import config from nose import result from nose import core -gettext.install('nova', unicode=1) - -from nova.db import migration - class NovaTestResult(result.TextTestResult): def __init__(self, *args, **kw): @@ -65,9 +61,6 @@ if __name__ == '__main__': c = config.Config(stream=sys.stdout, env=os.environ, verbosity=3) - - migration.db_sync() - runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity,