From 6fc00d34651858308c5b08fdabe8a0b9ce663e26 Mon Sep 17 00:00:00 2001 From: Kravchenko Pavel Date: Tue, 8 Jan 2013 22:54:14 +0200 Subject: Adds to manager init_host validation for instances location While the compute was down the instances running on it could be evacuated to another host. The method checks that instance host identical to current host. Otherwise destroying it. part of blueprint rebuild-for-ha DocImpact Change-Id: Ic90df2b2887ee203e6d8261084e3f97773c5d81c Co-authored-by: Oshrit Feder --- nova/virt/driver.py | 7 +++++++ nova/virt/fake.py | 3 +++ nova/virt/libvirt/driver.py | 4 ++++ 3 files changed, 14 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/driver.py b/nova/virt/driver.py index f4fcaa33e..da4a9475c 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -167,6 +167,13 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() + def list_instance_uuids(self): + """ + Return the UUIDS of all the instances known to the virtualization + layer, as a list. + """ + raise NotImplementedError() + def spawn(self, context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None): """ diff --git a/nova/virt/fake.py b/nova/virt/fake.py index afbf3df66..837ab635b 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -399,6 +399,9 @@ class FakeDriver(driver.ComputeDriver): def instance_on_disk(self, instance): return False + def list_instance_uuids(self): + return [] + class FakeVirtAPI(virtapi.VirtAPI): def instance_update(self, context, instance_uuid, updates): diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 9cbe7896a..556e6c9b2 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -456,6 +456,10 @@ class LibvirtDriver(driver.ComputeDriver): return names + def list_instance_uuids(self): + return [self._conn.lookupByName(name).UUIDString() + for name in self.list_instances()] + def plug_vifs(self, instance, network_info): """Plug VIFs into networks.""" for (network, mapping) in network_info: -- cgit