summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLance Bragstad <ldbragst@us.ibm.com>2013-03-08 19:51:12 +0000
committerLance Bragstad <ldbragst@us.ibm.com>2013-03-14 03:42:53 +0000
commit45d4ec4aefa1a4c5b4327c07c635a5e47e807178 (patch)
tree874a98aa465afeedf68a457f3ee92e86c3389d9b
parent2830ef14eca5695e796e8e3104528bbc8766bafa (diff)
downloadnova-45d4ec4aefa1a4c5b4327c07c635a5e47e807178.tar.gz
nova-45d4ec4aefa1a4c5b4327c07c635a5e47e807178.tar.xz
nova-45d4ec4aefa1a4c5b4327c07c635a5e47e807178.zip
Resize/Migrate refactoring fixes and test cases
This patch will fix the construction of an scp command to be joined on spaces. Also adds a parameter in driver.finish_migration to _create_lpar_instance(), some refactoring that needed to be done in order to launch the instance on the destination host. This patch fixes Bug #1153599. This patch also address the tests cases for resize/migrate functionality for PowerVM. Bug #1133058 is for tracking these test cases Change-Id: I86c1b697fe5c7d6e4a6c689f75fd5cf737cef5d4
-rw-r--r--nova/tests/test_powervm.py87
-rw-r--r--nova/virt/powervm/blockdev.py2
-rwxr-xr-xnova/virt/powervm/driver.py2
3 files changed, 89 insertions, 2 deletions
diff --git a/nova/tests/test_powervm.py b/nova/tests/test_powervm.py
index a951ba44c..c6a385bdd 100644
--- a/nova/tests/test_powervm.py
+++ b/nova/tests/test_powervm.py
@@ -18,6 +18,8 @@
Test suite for PowerVMDriver.
"""
+import contextlib
+
from nova import context
from nova import db
from nova import test
@@ -106,6 +108,9 @@ class FakeIVMOperator(object):
class FakeBlockAdapter(powervm_blockdev.PowerVMLocalVolumeAdapter):
def __init__(self):
+ self.connection_data = common.Connection(host='fake_compute_1',
+ username='fake_user',
+ password='fake_pass')
pass
def _create_logical_volume(self, size):
@@ -306,3 +311,85 @@ class PowerVMDriverTestCase(test.TestCase):
def test_finish_revert_migration_after_crash_before_backup(self):
self._test_finish_revert_migration_after_crash(False, False)
+
+ def test_migrate_volume_use_instance_name(self):
+ inst_name = 'instance-00000000'
+ lv_name = 'logical-vol-name'
+ src_host = 'compute_host_1'
+ dest = 'compute_host_1'
+ image_path = 'some/image/path'
+ fake_noop = lambda *args, **kwargs: None
+
+ self.stubs.Set(self.powervm_connection._powervm._disk_adapter,
+ '_copy_device_to_file', fake_noop)
+
+ self.stubs.Set(self.powervm_connection._powervm._disk_adapter,
+ 'run_vios_command_as_root', fake_noop)
+ blockdev_op = self.powervm_connection._powervm._disk_adapter
+ file_path = blockdev_op.migrate_volume(lv_name, src_host, dest,
+ image_path, inst_name)
+ expected_path = 'some/image/path/instance-00000000_rsz.gz'
+ self.assertEqual(file_path, expected_path)
+
+ def test_migrate_volume_use_lv_name(self):
+ lv_name = 'logical-vol-name'
+ src_host = 'compute_host_1'
+ dest = 'compute_host_1'
+ image_path = 'some/image/path'
+ fake_noop = lambda *args, **kwargs: None
+
+ self.stubs.Set(self.powervm_connection._powervm._disk_adapter,
+ '_copy_device_to_file', fake_noop)
+
+ self.stubs.Set(self.powervm_connection._powervm._disk_adapter,
+ 'run_vios_command_as_root', fake_noop)
+ blockdev_op = self.powervm_connection._powervm._disk_adapter
+ file_path = blockdev_op.migrate_volume(lv_name, src_host, dest,
+ image_path)
+ expected_path = 'some/image/path/logical-vol-name_rsz.gz'
+ self.assertEqual(file_path, expected_path)
+
+ def test_migrate_build_scp_command(self):
+ lv_name = 'logical-vol-name'
+ src_host = 'compute_host_1'
+ dest = 'compute_host_2'
+ image_path = 'some/image/path'
+ fake_noop = lambda *args, **kwargs: None
+
+ @contextlib.contextmanager
+ def fake_vios_to_vios_auth(*args, **kwargs):
+ key_name = 'some_key'
+ yield key_name
+ self.stubs.Set(common, 'vios_to_vios_auth',
+ fake_vios_to_vios_auth)
+
+ self.stubs.Set(self.powervm_connection._powervm._disk_adapter,
+ 'run_vios_command_as_root', fake_noop)
+
+ def fake_run_vios_command(*args, **kwargs):
+ cmd = args[0]
+ exp_cmd = ' '.join(['scp -o "StrictHostKeyChecking no" -i',
+ 'some_key',
+ 'some/image/path/logical-vol-name_rsz.gz',
+ 'fake_user@compute_host_2:some/image/path'])
+ self.assertEqual(exp_cmd, cmd)
+
+ self.stubs.Set(self.powervm_connection._powervm._disk_adapter,
+ 'run_vios_command',
+ fake_run_vios_command)
+
+ blockdev_op = self.powervm_connection._powervm._disk_adapter
+ file_path = blockdev_op.migrate_volume(lv_name, src_host, dest,
+ image_path)
+
+ def test_get_resize_name(self):
+ inst_name = 'instance-00000001'
+ expected_name = 'rsz_instance-00000001'
+ result = self.powervm_connection._get_resize_name(inst_name)
+ self.assertEqual(expected_name, result)
+
+ def test_get_long_resize_name(self):
+ inst_name = 'some_really_long_instance_name_00000001'
+ expected_name = 'rsz__really_long_instance_name_00000001'
+ result = self.powervm_connection._get_resize_name(inst_name)
+ self.assertEqual(expected_name, result)
diff --git a/nova/virt/powervm/blockdev.py b/nova/virt/powervm/blockdev.py
index c8d58d939..247746faa 100644
--- a/nova/virt/powervm/blockdev.py
+++ b/nova/virt/powervm/blockdev.py
@@ -273,7 +273,7 @@ class PowerVMLocalVolumeAdapter(PowerVMDiskAdapter):
with common.vios_to_vios_auth(self.connection_data.host,
dest,
self.connection_data) as key_name:
- cmd = ''.join(['scp -o "StrictHostKeyChecking no"',
+ cmd = ' '.join(['scp -o "StrictHostKeyChecking no"',
('-i %s' % key_name),
file_path,
'%s@%s:%s' % (self.connection_data.username,
diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py
index d06948f17..c193111c8 100755
--- a/nova/virt/powervm/driver.py
+++ b/nova/virt/powervm/driver.py
@@ -278,7 +278,7 @@ class PowerVMDriver(driver.ComputeDriver):
defines the image from which this instance
was created
"""
- lpar_obj = self._powervm._create_lpar_instance(instance)
+ lpar_obj = self._powervm._create_lpar_instance(instance, network_info)
instance_type = instance_types.extract_instance_type(instance)
new_lv_size = instance_type['root_gb']