test_pool = self.cli_data.fake_lv_id[0]
test_partition_id = self.cli_data.fake_partition_id[2]
test_ref_volume_id = test_ref_volume['source-id'].replace('-', '')
+ test_model_update = {
+ 'provider_location': 'system_id^%s@partition_id^%s' % (
+ int(self.cli_data.fake_system_id[0], 16),
+ test_partition_id),
+ }
mock_commands = {
'ShowPartition': self.cli_data.get_test_show_partition_detail(
'cinder-unmanaged-%s' % test_ref_volume_id[:-17], test_pool),
'SetPartition': SUCCEED,
+ 'ShowDevice': self.cli_data.get_test_show_device(),
}
self._driver_setup(mock_commands)
- self.driver.manage_existing(test_volume, test_ref_volume)
+ model_update = self.driver.manage_existing(
+ test_volume, test_ref_volume)
expect_cli_cmd = [
mock.call('SetPartition', test_partition_id,
]
self._assert_cli_has_calls(expect_cli_cmd)
self.assertEqual(1, log_info.call_count)
+ self.assertDictMatch(model_update, test_model_update)
def test_manage_existing_rename_fail(self):
test_volume,
test_ref_volume)
+ def test_manage_existing_with_part_not_found(self):
+
+ test_volume = self.cli_data.test_volume
+ test_ref_volume = self.cli_data.test_ref_volume
+
+ mock_commands = {
+ 'ShowPartition':
+ self.cli_data.get_test_show_partition_detail(),
+ 'SetPartition': SUCCEED,
+ }
+ self._driver_setup(mock_commands)
+
+ self.assertRaises(
+ exception.ManageExistingInvalidReference,
+ self.driver.manage_existing,
+ test_volume,
+ test_ref_volume)
+
@mock.patch.object(common_cli.LOG, 'info')
def test_manage_existing_with_import(self, log_info):
test_ref_volume = self.cli_data.test_ref_volume_with_import
test_pool = self.cli_data.fake_lv_id[0]
test_partition_id = self.cli_data.fake_partition_id[2]
+ test_model_update = {
+ 'provider_location': 'system_id^%s@partition_id^%s' % (
+ int(self.cli_data.fake_system_id[0], 16),
+ test_partition_id),
+ }
mock_commands = {
'ShowPartition': self.cli_data.get_test_show_partition_detail(
test_ref_volume['source-name'], test_pool),
'SetPartition': SUCCEED,
+ 'ShowDevice': self.cli_data.get_test_show_device(),
}
self._driver_setup(mock_commands)
- self.driver.manage_existing(test_volume, test_ref_volume)
+ model_update = self.driver.manage_existing(
+ test_volume, test_ref_volume)
expect_cli_cmd = [
mock.call('SetPartition', test_partition_id,
]
self._assert_cli_has_calls(expect_cli_cmd)
self.assertEqual(1, log_info.call_count)
+ self.assertDictMatch(model_update, test_model_update)
@mock.patch.object(common_cli.LOG, 'info')
def test_unmanage(self, log_info):
volume_name = self._get_existing_volume_ref_name(ref)
part_entry = self._get_latter_volume_dict(volume_name)
+ if part_entry is None:
+ msg = _('Specified logical volume does not exist.')
+ LOG.error(msg)
+ raise exception.ManageExistingInvalidReference(
+ existing_ref=ref, reason=msg)
+
rc, map_info = self._execute('ShowMap', 'part=%s' % part_entry['ID'])
if len(map_info) != 0:
part_entry = self._get_latter_volume_dict(volume_name)
+ if part_entry is None:
+ msg = _('Specified logical volume does not exist.')
+ LOG.error(msg)
+ raise exception.ManageExistingInvalidReference(
+ existing_ref=ref, reason=msg)
+
self._execute('SetPartition', part_entry['ID'], 'name=%s' % volume_id)
+ model_dict = {
+ 'system_id': self._get_system_id(self.ip),
+ 'partition_id': part_entry['ID'],
+ }
+ model_update = {
+ "provider_location": self._concat_provider_location(model_dict),
+ }
+
LOG.info(_LI('Rename Volume %(volume_id)s completed.'), {
'volume_id': volume['id']})
+ return model_update
+
def _get_existing_volume_ref_name(self, ref):
volume_name = None
if 'source-name' in ref:
rc, part_list = self._execute('ShowPartition', '-l')
latest_timestamps = 0
- ref_dict = {}
+ ref_dict = None
for entry in part_list:
if entry['Name'] == volume_name: