summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCerberus <matt.dietz@rackspace.com>2011-02-08 10:47:23 -0600
committerCerberus <matt.dietz@rackspace.com>2011-02-08 10:47:23 -0600
commit3f2cd17011e17991ebf1a77605686ce3dc48d92e (patch)
tree06ce2ffe89cb4910a8e933ca584cdf5e9dd2fc54
parent203c94c89caabc1d4ece4c462819a90c05cde163 (diff)
downloadnova-3f2cd17011e17991ebf1a77605686ce3dc48d92e.tar.gz
nova-3f2cd17011e17991ebf1a77605686ce3dc48d92e.tar.xz
nova-3f2cd17011e17991ebf1a77605686ce3dc48d92e.zip
Changes and bug fixes
-rw-r--r--nova/compute/manager.py8
-rw-r--r--nova/db/sqlalchemy/api.py6
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/003_cactus.py46
-rw-r--r--nova/db/sqlalchemy/migration.py2
-rw-r--r--nova/virt/xenapi/vmops.py2
5 files changed, 54 insertions, 10 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 485efc047..4189c49a4 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -387,7 +387,7 @@ class ComputeManager(manager.Manager):
pass
@exception.wrap_exception
- @echecks_instance_lock
+ @checks_instance_lock
def revert_resize(self, context, instance_id):
"""Destroys the new instance on the destination machine,
reverts the model changes, and powers on the old
@@ -406,7 +406,7 @@ class ComputeManager(manager.Manager):
{ 'instance_id': instance_id,
'source_host': instance_ref['host'],
'dest_host': socket.gethostbyname(socket.gethostname()),
- 'status': 'pre-migrating' }
+ 'status': 'pre-migrating' })
LOG.audit(_('instance %s: migrating to '), instance_id, context=context)
service = self.db.service_get_by_host_and_topic(context,
instance_ref['host'], FLAGS.compute_topic)
@@ -414,7 +414,7 @@ class ComputeManager(manager.Manager):
service['id'])
rpc.cast(context, topic,
{ 'method': 'resize_instance',
- 'migration_id': migration_ref['id'], }
+ 'migration_id': migration_ref['id'], })
@exception.wrap_exception
@checks_instance_lock
@@ -437,7 +437,7 @@ class ComputeManager(manager.Manager):
service['id'])
rpc.cast(context, topic,
{ 'method': 'finish_resize',
- 'migration_id': migration_ref['id'], }
+ 'migration_id': migration_ref['id'], })
@exception.wrap_exception
@checks_instance_lock
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index e94f9f4d2..ece1cd373 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -1942,8 +1942,7 @@ def migration_update(context, migration_id, values):
def migration_get(context, migration_id):
session = get_session()
result = session.query(models.Migration.\
- filter_by(migration_id=migration_id)).
- first()
+ filter_by(migration_id=migration_id)).first()
if not result:
raise exception.NotFound(_("No migration found with id %s")
% migration_id)
@@ -1954,8 +1953,7 @@ def migration_get(context, migration_id):
def migration_get_by_instance(context, instance_id):
session = get_session()
result = session.query(models.Migration.\
- filter_by(instance_id=instance_id)).
- first()
+ filter_by(instance_id=instance_id)).first()
if not result:
raise exception.NotFound(_("No migration found with instance id %s")
% migration_id)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/003_cactus.py b/nova/db/sqlalchemy/migrate_repo/versions/003_cactus.py
new file mode 100644
index 000000000..bbe5cbcb0
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/003_cactus.py
@@ -0,0 +1,46 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 OpenStack LLC.
+# 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.from sqlalchemy import *
+
+from migrate import *
+
+from nova import log as logging
+
+
+meta = MetaData()
+
+#
+# New Tables
+#
+
+migrations = Table('migrations', meta,
+ Column('source_host', String(255))
+ Column('dest_host', String(255))
+ Column('instance_id', Integer, ForeignKey('instances.id'), nullable=True)
+ Column('status', String(255))
+ )
+
+def upgrade(migrate_engine):
+ # Upgrade operations go here. Don't create your own engine;
+ # bind migrate_engine to your metadata
+ meta.bind = migrate_engine
+ for table in (migrations):
+ try:
+ table.create()
+ except Exception:
+ logging.info(repr(table))
+ logging.exception('Exception while creating table')
+ raise
diff --git a/nova/db/sqlalchemy/migration.py b/nova/db/sqlalchemy/migration.py
index 2a13c5466..644e3e45e 100644
--- a/nova/db/sqlalchemy/migration.py
+++ b/nova/db/sqlalchemy/migration.py
@@ -50,7 +50,7 @@ def db_version():
'key_pairs', 'networks', 'projects', 'quotas',
'security_group_instance_association',
'security_group_rules', 'security_groups',
- 'services',
+ 'services', 'migrations',
'users', 'user_project_association',
'user_project_role_association',
'user_role_association',
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 4b835c707..6a7621502 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -226,7 +226,7 @@ class VMOps(object):
:param instance: the instance that owns the VHD in question
:param dest: the destination host machine
"""
-
+ vm_ref = VMHelper.lookup(self._session, instance.name)
def resize(self, instance, flavor):
"""Resize a running instance by changing it's RAM and disk size """