summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-02-05 11:30:55 +0000
committerDaniel P. Berrange <berrange@redhat.com>2015-02-19 11:44:00 +0000
commitca9ef2df93268971109ae537c81de11969b4a3fe (patch)
treedd117c0e2744f11d44e39f6ad2ac39a0aac402c3
parent90f843cdc47b494cd568507820d45868765697b1 (diff)
downloadnova-ca9ef2df93268971109ae537c81de11969b4a3fe.tar.gz
fake: fix public API signatures to match virt driver
The fake driver had a number of places where it did not correctly follow the API signature of the virt driver. Fix them, and add a test to validate it. Change-Id: I7b0b3855a0dd291a71ccfc9e5afb0235ed7536f0
-rw-r--r--nova/tests/unit/compute/test_compute.py2
-rw-r--r--nova/tests/unit/virt/test_fake.py26
-rw-r--r--nova/virt/fake.py33
3 files changed, 44 insertions, 17 deletions
diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py
index 020fe81d49..968e843f78 100644
--- a/nova/tests/unit/compute/test_compute.py
+++ b/nova/tests/unit/compute/test_compute.py
@@ -5839,7 +5839,7 @@ class ComputeTestCase(BaseTestCase):
self.assertEqual(len(instances), 1)
instance_name = instances[0]['name']
- self.compute.driver.test_remove_vm(instance_name)
+ self.compute.driver._test_remove_vm(instance_name)
# Force the compute manager to do its periodic poll
ctxt = context.get_admin_context()
diff --git a/nova/tests/unit/virt/test_fake.py b/nova/tests/unit/virt/test_fake.py
new file mode 100644
index 0000000000..0f34f3752e
--- /dev/null
+++ b/nova/tests/unit/virt/test_fake.py
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2015 Red Hat, Inc.
+#
+# 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 nova import test
+from nova.virt import driver
+from nova.virt import fake
+
+
+class FakeDriverTest(test.NoDBTestCase):
+
+ def test_public_api_signatures(self):
+ baseinst = driver.ComputeDriver(None)
+ inst = fake.FakeDriver(fake.FakeVirtAPI(), True)
+ self.assertPublicAPISignatures(baseinst, inst)
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 1a9bd9ecf5..c4e3b13381 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -150,7 +150,7 @@ class FakeDriver(driver.ComputeDriver):
fake_instance = FakeInstance(name, state, instance['uuid'])
self.instances[name] = fake_instance
- def snapshot(self, context, instance, name, update_task_state):
+ def snapshot(self, context, instance, image_id, update_task_state):
if instance['name'] not in self.instances:
raise exception.InstanceNotRunning(instance_id=instance['uuid'])
update_task_state(task_state=task_states.IMAGE_UPLOADING)
@@ -199,10 +199,11 @@ class FakeDriver(driver.ComputeDriver):
block_device_info=None):
pass
- def power_off(self, instance, shutdown_timeout=0, shutdown_attempts=0):
+ def power_off(self, instance, timeout=0, retry_interval=0):
pass
- def power_on(self, context, instance, network_info, block_device_info):
+ def power_on(self, context, instance, network_info,
+ block_device_info=None):
pass
def soft_delete(self, instance):
@@ -284,7 +285,7 @@ class FakeDriver(driver.ComputeDriver):
num_cpu=2,
cpu_time_ns=0)
- def get_diagnostics(self, instance_name):
+ def get_diagnostics(self, instance):
return {'cpu0_time': 17300000000,
'memory': 524288,
'vda_errors': -1,
@@ -302,7 +303,7 @@ class FakeDriver(driver.ComputeDriver):
'vnet1_tx_packets': 662,
}
- def get_instance_diagnostics(self, instance_name):
+ def get_instance_diagnostics(self, instance):
diags = diagnostics.Diagnostics(state='running', driver='fake',
hypervisor_os='fake-os', uptime=46664, config_drive=True)
diags.add_cpu(time=17300000000)
@@ -341,7 +342,7 @@ class FakeDriver(driver.ComputeDriver):
stats['frequency'] = 800
return stats
- def block_stats(self, instance_name, disk_id):
+ def block_stats(self, instance, disk_id):
return [0L, 0L, 0L, 0L, None]
def get_console_output(self, context, instance):
@@ -401,30 +402,30 @@ class FakeDriver(driver.ComputeDriver):
host_status['cpu_info'] = '?'
return host_status
- def ensure_filtering_rules_for_instance(self, instance_ref, network_info):
+ def ensure_filtering_rules_for_instance(self, instance, network_info):
return
def get_instance_disk_info(self, instance, block_device_info=None):
return
- def live_migration(self, context, instance_ref, dest,
+ def live_migration(self, context, instance, dest,
post_method, recover_method, block_migration=False,
migrate_data=None):
- post_method(context, instance_ref, dest, block_migration,
+ post_method(context, instance, dest, block_migration,
migrate_data)
return
- def check_can_live_migrate_destination_cleanup(self, ctxt,
+ def check_can_live_migrate_destination_cleanup(self, context,
dest_check_data):
return
- def check_can_live_migrate_destination(self, ctxt, instance_ref,
+ def check_can_live_migrate_destination(self, context, instance,
src_compute_info, dst_compute_info,
block_migration=False,
disk_over_commit=False):
return {}
- def check_can_live_migrate_source(self, ctxt, instance_ref,
+ def check_can_live_migrate_source(self, context, instance,
dest_check_data, block_device_info=None):
return
@@ -436,14 +437,14 @@ class FakeDriver(driver.ComputeDriver):
def confirm_migration(self, migration, instance, network_info):
return
- def pre_live_migration(self, context, instance_ref, block_device_info,
- network_info, disk, migrate_data=None):
+ def pre_live_migration(self, context, instance, block_device_info,
+ network_info, disk_info, migrate_data=None):
return
- def unfilter_instance(self, instance_ref, network_info):
+ def unfilter_instance(self, instance, network_info):
return
- def test_remove_vm(self, instance_name):
+ def _test_remove_vm(self, instance_name):
"""Removes the named VM, as if it crashed. For testing."""
self.instances.pop(instance_name)