Repository: softlayer/softlayer-python
Pull request #2004 (2023-06-27 15:15:14)

block volume-list errors for this issue #1732
Hi @allmightyspiff,

Fixes: #1732 

Please review this pull request.

Title:
block volume-list errors for this issue #1732

Description:
Now, result.output was displayed in the table from block volume detail.

Please find the screen shot for reference.

Screen Shot:
<img width="1062" alt="Screenshot 2023-06-27 at 8 06 34 PM" src="https://github.com/softlayer/softlayer-python/assets/125332006/b61a9c2b-9e61-4434-9f51-54f5545848e9">


Thanks,
Ramkishor Chaladi.


Patch:
diff --git a/SoftLayer/fixtures/SoftLayer_Network_Storage.py b/SoftLayer/fixtures/SoftLayer_Network_Storage.py
index b6097c71..2d9cdc49 100644
--- a/SoftLayer/fixtures/SoftLayer_Network_Storage.py
+++ b/SoftLayer/fixtures/SoftLayer_Network_Storage.py
@@ -263,3 +263,75 @@
     'deDuplicateConversionPercentage': 50,
     'volumeUsername': 'testUser'
 }
+
+BLOCK_LIST_ISSUES_1732 = {
+    'capacityGb': 16000,
+    'id': 167214314,
+    'notes': 'test',
+    'username': 'SL02SEL307608-60',
+    'activeTransactionCount': 0,
+    'replicationPartnerCount': 1,
+    'lunId': '1',
+    'parentVolume': {
+        'accountId': 307608,
+        'capacityGb': 16000,
+        'createDate': '2020-09-02T14:55:32-06:00',
+        'guestId': None,
+        'hardwareId': None,
+        'hostId': None,
+        'id': 167214302,
+        'nasType': 'NAS_CONTAINER',
+        'serviceProviderId': 1,
+        'storageTypeId': '3',
+        'upgradableFlag': True,
+        'username': 'SL02SEVC307608_60',
+        'serviceResourceBackendIpAddress': 'fsf-mex0101b-fz.service.softlayer.com',
+        'serviceResourceName': 'Storage Type 02 Aggregate stxf-mex0101b',
+        'snapshotSizeBytes': '831488'
+    },
+    'provisionedIops': '4096',
+    'replicationPartners': [{
+        'id': 167236648,
+        'username': 'SL02SEL307608_60_REP_1',
+        'replicationSchedule': {
+            'active': 1,
+            'createDate': '2020-09-02T17:10:04-06:00',
+            'id': 542062,
+            'modifyDate': None,
+            'name': 'SL02SEVC307608_60_WEEKLY',
+            'partnershipId': None,
+            'typeId': 34,
+            'volumeId': 167214302,
+            'type': {
+                'keyname': 'REPLICATION_WEEKLY'
+            }
+        },
+        'serviceResource': {
+            'backendIpAddress': 'fsf-sao0102c-fz.service.softlayer.com',
+            'id': 30650,
+            'name': 'Storage Type 02 Aggregate stxf-sao0102c',
+            'datacenter': {
+                'name': 'sao01'
+            },
+            'type': {
+                'type': 'NETAPP_STOR_AGGR'
+            }
+        },
+        'serviceResourceBackendIpAddress': '10.200.14.72'
+    }],
+    'replicationStatus': 'FAILBACK_COMPLETED',
+    'serviceResource': {
+        'backendIpAddress': 'fsf-mex0101b-fz.service.softlayer.com',
+        'id': 9291,
+        'name': 'Storage Type 02 Aggregate stxf-mex0101b',
+        'datacenter': {
+            'name': 'mex01'
+        }
+    },
+    'serviceResourceBackendIpAddress': '10.2.190.99',
+    'snapshotCapacityGb': '1000',
+    'storageTierLevel': 'LOW_INTENSITY_TIER',
+    'storageType': {
+        'keyName': 'ENDURANCE_BLOCK_STORAGE'
+    }
+    }


Test patch:
diff --git a/tests/CLI/modules/block_tests.py b/tests/CLI/modules/block_tests.py
index 894acd94..ac34b537 100644
--- a/tests/CLI/modules/block_tests.py
+++ b/tests/CLI/modules/block_tests.py
@@ -5,6 +5,7 @@
     :license: MIT, see LICENSE for more details.
 """
 from SoftLayer.CLI import exceptions
+from SoftLayer.fixtures import SoftLayer_Network_Storage
 from SoftLayer import SoftLayerAPIError
 from SoftLayer import testing
 
@@ -96,6 +97,16 @@ def test_volume_detail(self):
             ]
         }, json.loads(result.output))
 
+    def test_block_detail_issue1732(self):
+        lun_mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')
+        lun_mock.return_value = SoftLayer_Network_Storage.BLOCK_LIST_ISSUES_1732
+        result = self.run_command(['--format=table',  'block', 'volume-detail', '1234'])
+        self.assert_no_fail(result)
+        self.assertIn('│                 Username │ SL02SEL307608-60                          │', result.output)
+        self.assertIn('│            Capacity (GB) │ 16000GB                                   │', result.output)
+        self.assertIn('│       Replication Status │ FAILBACK_COMPLETED                        │', result.output)
+        self.assertIn('│                    Notes │ test                                      │', result.output)
+
     def test_volume_detail_name_identifier(self):
         result = self.run_command(['block', 'volume-detail', 'SL-12345'])
         expected_filter = {