diff options
-rwxr-xr-x | bin/nova-manage | 2 | ||||
-rw-r--r-- | nova/compute/manager.py | 14 | ||||
-rw-r--r-- | nova/network/api.py | 3 | ||||
-rw-r--r-- | nova/tests/test_cloud.py | 29 | ||||
-rw-r--r-- | nova/tests/test_compute.py | 51 | ||||
-rwxr-xr-x[-rw-r--r--] | plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | plugins/xenserver/xenapi/etc/xapi.d/plugins/migration | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost | 0 |
10 files changed, 94 insertions, 5 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index b892d958a..2446309e8 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -518,7 +518,7 @@ class FixedIpCommands(object): instance = fixed_ip['instance'] hostname = instance['hostname'] host = instance['host'] - mac_address = fixed_ip['mac_address']['address'] + mac_address = fixed_ip['virtual_interface']['address'] print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % ( fixed_ip['network']['cidr'], fixed_ip['address'], diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 47becdcc6..eb3996d29 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -720,7 +720,8 @@ class ComputeManager(manager.SchedulerDependentManager): self.db.instance_update(context, instance_id, dict(memory_mb=instance_type['memory_mb'], vcpus=instance_type['vcpus'], - local_gb=instance_type['local_gb'])) + local_gb=instance_type['local_gb'], + instance_type_id=instance_type['id'])) self.driver.revert_resize(instance_ref) self.db.migration_update(context, migration_id, @@ -741,18 +742,20 @@ class ComputeManager(manager.SchedulerDependentManager): """ context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) + if instance_ref['host'] == FLAGS.host: raise exception.Error(_( 'Migration error: destination same as source!')) - instance_type = self.db.instance_type_get_by_flavor_id(context, - flavor_id) + old_instance_type = self.db.instance_type_get_by_id(context, + instance_ref['instance_type_id']) + migration_ref = self.db.migration_create(context, {'instance_id': instance_id, 'source_compute': instance_ref['host'], 'dest_compute': FLAGS.host, 'dest_host': self.driver.get_host_ip_addr(), - 'old_flavor_id': instance_type['flavorid'], + 'old_flavor_id': old_instance_type['flavorid'], 'new_flavor_id': flavor_id, 'status': 'pre-migrating'}) @@ -766,6 +769,9 @@ class ComputeManager(manager.SchedulerDependentManager): 'migration_id': migration_ref['id'], 'instance_id': instance_id, }, }) + + instance_type = self.db.instance_type_get_by_flavor_id(context, + flavor_id) usage_info = utils.usage_from_instance(instance_ref, new_instance_type=instance_type['name'], new_instance_type_id=instance_type['id']) diff --git a/nova/network/api.py b/nova/network/api.py index 70b1099f0..f03081be4 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -61,6 +61,9 @@ class API(base.Base): affect_auto_assigned=False): """Removes floating ip with address from a project.""" floating_ip = self.db.floating_ip_get_by_address(context, address) + if floating_ip['fixed_ip']: + raise exception.ApiError(_('Floating ip is in use. ' + 'Disassociate it before releasing.')) if not affect_auto_assigned and floating_ip.get('auto_assigned'): return # NOTE(vish): We don't know which network host should get the ip diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index a0d50b287..8cdc73a66 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -15,6 +15,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import mox from base64 import b64decode from M2Crypto import BIO @@ -29,6 +30,7 @@ from nova import db from nova import exception from nova import flags from nova import log as logging +from nova import network from nova import rpc from nova import test from nova import utils @@ -132,6 +134,33 @@ class CloudTestCase(test.TestCase): allocate, self.context) + def test_release_address(self): + address = "10.10.10.10" + allocate = self.cloud.allocate_address + db.floating_ip_create(self.context, + {'address': address, + 'host': self.network.host}) + result = self.cloud.release_address(self.context, address) + self.assertEqual(result['releaseResponse'], ['Address released.']) + + def test_release_address_still_associated(self): + address = "10.10.10.10" + fixed_ip = {'instance': {'id': 1}} + floating_ip = {'id': 0, + 'address': address, + 'fixed_ip_id': 0, + 'fixed_ip': fixed_ip, + 'project_id': None, + 'auto_assigned': False} + network_api = network.api.API() + self.mox.StubOutWithMock(network_api.db, 'floating_ip_get_by_address') + network_api.db.floating_ip_get_by_address(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(floating_ip) + self.mox.ReplayAll() + release = self.cloud.release_address + # ApiError: Floating ip is in use. Disassociate it before releasing. + self.assertRaises(exception.ApiError, release, self.context, address) + @test.skip_test("Skipping this pending future merge") def test_associate_disassociate_address(self): """Verifies associate runs cleanly without raising an exception""" diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 2900c594e..dc3f0596d 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -519,6 +519,57 @@ class ComputeTestCase(test.TestCase): self.compute.terminate_instance(context, instance_id) + def test_finish_revert_resize(self): + """Ensure that the flavor is reverted to the original on revert""" + context = self.context.elevated() + instance_id = self._create_instance() + + def fake(*args, **kwargs): + pass + + self.stubs.Set(self.compute.driver, 'finish_resize', fake) + self.stubs.Set(self.compute.driver, 'revert_resize', fake) + self.stubs.Set(self.compute.network_api, 'get_instance_nw_info', fake) + + self.compute.run_instance(self.context, instance_id) + + # Confirm the instance size before the resize starts + inst_ref = db.instance_get(context, instance_id) + instance_type_ref = db.instance_type_get_by_id(context, + inst_ref['instance_type_id']) + self.assertEqual(instance_type_ref['flavorid'], 1) + + db.instance_update(self.context, instance_id, {'host': 'foo'}) + + self.compute.prep_resize(context, instance_id, 3) + + migration_ref = db.migration_get_by_instance_and_status(context, + instance_id, 'pre-migrating') + + self.compute.resize_instance(context, instance_id, + migration_ref['id']) + self.compute.finish_resize(context, instance_id, + int(migration_ref['id']), {}) + + # Prove that the instance size is now the new size + inst_ref = db.instance_get(context, instance_id) + instance_type_ref = db.instance_type_get_by_id(context, + inst_ref['instance_type_id']) + self.assertEqual(instance_type_ref['flavorid'], 3) + + # Finally, revert and confirm the old flavor has been applied + self.compute.revert_resize(context, instance_id, + migration_ref['id']) + self.compute.finish_revert_resize(context, instance_id, + migration_ref['id']) + + inst_ref = db.instance_get(context, instance_id) + instance_type_ref = db.instance_type_get_by_id(context, + inst_ref['instance_type_id']) + self.assertEqual(instance_type_ref['flavorid'], 1) + + self.compute.terminate_instance(context, instance_id) + def test_get_by_flavor_id(self): type = instance_types.get_instance_type_by_flavor_id(1) self.assertEqual(type['name'], 'm1.tiny') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index fbe080b22..fbe080b22 100644..100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration index ac1c50ad9..ac1c50ad9 100644..100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore index d0313b4ed..d0313b4ed 100644..100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py index f51f5fce4..f51f5fce4 100755..100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost index 292bbce12..292bbce12 100644..100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost |