From 84cea12bceb44a457c649afc8ba5c5cc0c83e5d9 Mon Sep 17 00:00:00 2001 From: David Pickle Date: Tue, 6 Jun 2017 14:16:33 -0500 Subject: [PATCH] Update file & block volume-detail commands to show duplicate volume info --- SoftLayer/CLI/block/detail.py | 9 ++++++ SoftLayer/CLI/file/detail.py | 9 ++++++ .../fixtures/SoftLayer_Network_Storage.py | 3 ++ SoftLayer/managers/block.py | 3 ++ SoftLayer/managers/file.py | 3 ++ tests/CLI/modules/block_tests.py | 9 +++++- tests/CLI/modules/file_tests.py | 8 ++++- tests/managers/block_tests.py | 27 ++++++++++++++++- tests/managers/file_tests.py | 29 ++++++++++++++++++- 9 files changed, 96 insertions(+), 4 deletions(-) diff --git a/SoftLayer/CLI/block/detail.py b/SoftLayer/CLI/block/detail.py index d1461df2e..b8ba8bed5 100644 --- a/SoftLayer/CLI/block/detail.py +++ b/SoftLayer/CLI/block/detail.py @@ -99,4 +99,13 @@ def cli(env, volume_id): replicant_list.append(replicant_table) table.add_row(['Replicant Volumes', replicant_list]) + if block_volume.get('originalVolumeSize'): + duplicate_info = formatting.Table(['Original Volume Name', + block_volume['originalVolumeName']]) + duplicate_info.add_row(['Original Volume Size', + block_volume['originalVolumeSize']]) + duplicate_info.add_row(['Original Snapshot Name', + block_volume['originalSnapshotName']]) + table.add_row(['Duplicate Volume Properties', duplicate_info]) + env.fout(table) diff --git a/SoftLayer/CLI/file/detail.py b/SoftLayer/CLI/file/detail.py index 8f7024aab..1fae6774d 100644 --- a/SoftLayer/CLI/file/detail.py +++ b/SoftLayer/CLI/file/detail.py @@ -114,4 +114,13 @@ def cli(env, volume_id): replicant_list.append(replicant_table) table.add_row(['Replicant Volumes', replicant_list]) + if file_volume.get('originalVolumeSize'): + duplicate_info = formatting.Table(['Original Volume Name', + file_volume['originalVolumeName']]) + duplicate_info.add_row(['Original Volume Size', + file_volume['originalVolumeSize']]) + duplicate_info.add_row(['Original Snapshot Name', + file_volume['originalSnapshotName']]) + table.add_row(['Duplicate Volume Properties', duplicate_info]) + env.fout(table) diff --git a/SoftLayer/fixtures/SoftLayer_Network_Storage.py b/SoftLayer/fixtures/SoftLayer_Network_Storage.py index ea5b91e6c..e596cc9d9 100644 --- a/SoftLayer/fixtures/SoftLayer_Network_Storage.py +++ b/SoftLayer/fixtures/SoftLayer_Network_Storage.py @@ -25,6 +25,9 @@ 'snapshotCapacityGb': '10', 'parentVolume': {'snapshotSizeBytes': 1024}, 'osType': {'keyName': 'LINUX'}, + 'originalSnapshotName': 'test-origin-snapshot-name', + 'originalVolumeName': 'test-origin-volume-name', + 'originalVolumeSize': '20', 'schedules': [{ 'id': 978, 'type': {'keyname': 'SNAPSHOT_WEEKLY'}, diff --git a/SoftLayer/managers/block.py b/SoftLayer/managers/block.py index 89660d13e..9ab09d477 100644 --- a/SoftLayer/managers/block.py +++ b/SoftLayer/managers/block.py @@ -89,6 +89,9 @@ def get_block_volume_details(self, volume_id, **kwargs): 'storageTierLevel', 'iops', 'lunId', + 'originalVolumeName', + 'originalSnapshotName', + 'originalVolumeSize', 'activeTransactionCount', 'activeTransactions.transactionStatus[friendlyName]', 'replicationPartnerCount', diff --git a/SoftLayer/managers/file.py b/SoftLayer/managers/file.py index 22c73b45b..e100ddbb6 100644 --- a/SoftLayer/managers/file.py +++ b/SoftLayer/managers/file.py @@ -86,6 +86,9 @@ def get_file_volume_details(self, volume_id, **kwargs): 'storageTierLevel', 'iops', 'lunId', + 'originalVolumeName', + 'originalSnapshotName', + 'originalVolumeSize', 'activeTransactionCount', 'activeTransactions.transactionStatus[friendlyName]', 'replicationPartnerCount', diff --git a/tests/CLI/modules/block_tests.py b/tests/CLI/modules/block_tests.py index 58c46a0e9..b9634b121 100644 --- a/tests/CLI/modules/block_tests.py +++ b/tests/CLI/modules/block_tests.py @@ -67,6 +67,7 @@ def test_volume_cancel(self): def test_volume_detail(self): result = self.run_command(['block', 'volume-detail', '1234']) + self.assert_no_fail(result) self.assertEqual({ 'Username': 'username', @@ -94,7 +95,13 @@ def test_volume_detail(self): {'Replicant ID': 'Target IP', '1785': '10.3.177.84'}, {'Replicant ID': 'Data Center', '1785': 'dal01'}, {'Replicant ID': 'Schedule', '1785': 'REPLICATION_DAILY'}, - ]] + ]], + 'Duplicate Volume Properties': [ + {'Original Volume Name': 'Original Volume Size', + 'test-origin-volume-name': '20'}, + {'Original Volume Name': 'Original Snapshot Name', + 'test-origin-volume-name': 'test-origin-snapshot-name'} + ] }, json.loads(result.output)) def test_volume_list(self): diff --git a/tests/CLI/modules/file_tests.py b/tests/CLI/modules/file_tests.py index c3b3b7a40..74b25101e 100644 --- a/tests/CLI/modules/file_tests.py +++ b/tests/CLI/modules/file_tests.py @@ -145,7 +145,13 @@ def test_volume_detail(self): {'Replicant ID': 'Target IP', '1785': '10.3.177.84'}, {'Replicant ID': 'Data Center', '1785': 'dal01'}, {'Replicant ID': 'Schedule', '1785': 'REPLICATION_DAILY'}, - ]] + ]], + 'Duplicate Volume Properties': [ + {'Original Volume Name': 'Original Volume Size', + 'test-origin-volume-name': '20'}, + {'Original Volume Name': 'Original Snapshot Name', + 'test-origin-volume-name': 'test-origin-snapshot-name'} + ] }, json.loads(result.output)) def test_volume_order_performance_iops_not_given(self): diff --git a/tests/managers/block_tests.py b/tests/managers/block_tests.py index e336fbbbf..cb26244bb 100644 --- a/tests/managers/block_tests.py +++ b/tests/managers/block_tests.py @@ -30,10 +30,35 @@ def test_get_block_volume_details(self): self.assertEqual(fixtures.SoftLayer_Network_Storage.getObject, result) + expected_mask = 'id,'\ + 'username,'\ + 'password,'\ + 'capacityGb,'\ + 'snapshotCapacityGb,'\ + 'parentVolume.snapshotSizeBytes,'\ + 'storageType.keyName,'\ + 'serviceResource.datacenter[name],'\ + 'serviceResourceBackendIpAddress,'\ + 'storageTierLevel,'\ + 'iops,'\ + 'lunId,'\ + 'originalVolumeName,'\ + 'originalSnapshotName,'\ + 'originalVolumeSize,'\ + 'activeTransactionCount,'\ + 'activeTransactions.transactionStatus[friendlyName],'\ + 'replicationPartnerCount,'\ + 'replicationStatus,'\ + 'replicationPartners[id,username,'\ + 'serviceResourceBackendIpAddress,'\ + 'serviceResource[datacenter[name]],'\ + 'replicationSchedule[type[keyname]]]' + self.assert_called_with( 'SoftLayer_Network_Storage', 'getObject', - identifier=100 + identifier=100, + mask='mask[%s]' % expected_mask ) def test_list_block_volumes(self): diff --git a/tests/managers/file_tests.py b/tests/managers/file_tests.py index 3b761e0c1..63d893655 100644 --- a/tests/managers/file_tests.py +++ b/tests/managers/file_tests.py @@ -105,10 +105,37 @@ def test_get_file_volume_details(self): self.assertEqual(fixtures.SoftLayer_Network_Storage.getObject, result) + expected_mask = 'id,'\ + 'username,'\ + 'password,'\ + 'capacityGb,'\ + 'bytesUsed,'\ + 'snapshotCapacityGb,'\ + 'parentVolume.snapshotSizeBytes,'\ + 'storageType.keyName,'\ + 'serviceResource.datacenter[name],'\ + 'serviceResourceBackendIpAddress,'\ + 'fileNetworkMountAddress,'\ + 'storageTierLevel,'\ + 'iops,'\ + 'lunId,'\ + 'originalVolumeName,'\ + 'originalSnapshotName,'\ + 'originalVolumeSize,'\ + 'activeTransactionCount,'\ + 'activeTransactions.transactionStatus[friendlyName],'\ + 'replicationPartnerCount,'\ + 'replicationStatus,'\ + 'replicationPartners[id,username,'\ + 'serviceResourceBackendIpAddress,'\ + 'serviceResource[datacenter[name]],'\ + 'replicationSchedule[type[keyname]]]' + self.assert_called_with( 'SoftLayer_Network_Storage', 'getObject', - identifier=100) + identifier=100, + mask='mask[%s]' % expected_mask) def test_get_file_volume_snapshot_list(self): result = self.file.get_file_volume_snapshot_list(100)