Repository: softlayer/softlayer-python
Pull request #1293 (2020-07-03 14:28:30)

add system operation referenceCode in create-option
https://github.com/softlayer/softlayer-python/issues/1292


Patch:
diff --git a/SoftLayer/CLI/hardware/create_options.py b/SoftLayer/CLI/hardware/create_options.py
index 8c005de5..4eba88c8 100644
--- a/SoftLayer/CLI/hardware/create_options.py
+++ b/SoftLayer/CLI/hardware/create_options.py
@@ -33,10 +33,10 @@ def cli(env):
     tables.append(preset_table)
 
     # Operating systems
-    os_table = formatting.Table(['operating_system', 'value'])
+    os_table = formatting.Table(['operating_system', 'value', 'operatingSystemReferenceCode '])
     os_table.sortby = 'value'
     for operating_system in options['operating_systems']:
-        os_table.add_row([operating_system['name'], operating_system['key']])
+        os_table.add_row([operating_system['name'], operating_system['key'], operating_system['referenceCode']])
     tables.append(os_table)
 
     # Port speed
diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py
index ec9981c4..b531910e 100644
--- a/SoftLayer/managers/hardware.py
+++ b/SoftLayer/managers/hardware.py
@@ -403,7 +403,8 @@ def get_create_options(self):
             if item['itemCategory']['categoryCode'] == 'os':
                 operating_systems.append({
                     'name': item['softwareDescription']['longDescription'],
-                    'key': item['keyName']
+                    'key': item['keyName'],
+                    'referenceCode': item['softwareDescription']['referenceCode']
                 })
 
         # Port speeds


Test patch:
diff --git a/tests/CLI/modules/server_tests.py b/tests/CLI/modules/server_tests.py
index a7fd4e90..605bd32b 100644
--- a/tests/CLI/modules/server_tests.py
+++ b/tests/CLI/modules/server_tests.py
@@ -362,7 +362,8 @@ def test_create_options(self):
              {'size': 'Dual Xeon Gold, 384GB Ram, 4x960GB SSD, RAID 10',
               'value': 'DGOLD_6140_384GB_4X960GB_SSD_SED_RAID_10'}],
             [{'operating_system': 'Ubuntu / 14.04-64',
-              'value': 'OS_UBUNTU_14_04_LTS_TRUSTY_TAHR_64_BIT'}],
+              'value': 'OS_UBUNTU_14_04_LTS_TRUSTY_TAHR_64_BIT',
+              'operatingSystemReferenceCode ': 'UBUNTU_14_64'}],
             [{'port_speed': '10 Mbps Public & Private Network Uplinks',
               'value': '10'}],
             [{'extras': '1 IPv6 Address', 'value': '1_IPV6_ADDRESS'}]]
@@ -694,19 +695,19 @@ def test_dns_sync_both(self, confirm_mock):
                                            'getResourceRecords')
         getResourceRecords.return_value = []
         createAargs = ({
-            'type': 'a',
-            'host': 'hardware-test1',
-            'domainId': 12345,  # from SoftLayer_Account::getDomains
-            'data': '172.16.1.100',
-            'ttl': 7200
-        },)
+                           'type': 'a',
+                           'host': 'hardware-test1',
+                           'domainId': 12345,  # from SoftLayer_Account::getDomains
+                           'data': '172.16.1.100',
+                           'ttl': 7200
+                       },)
         createPTRargs = ({
-            'type': 'ptr',
-            'host': '100',
-            'domainId': 123456,
-            'data': 'hardware-test1.test.sftlyr.ws',
-            'ttl': 7200
-        },)
+                             'type': 'ptr',
+                             'host': '100',
+                             'domainId': 123456,
+                             'data': 'hardware-test1.test.sftlyr.ws',
+                             'ttl': 7200
+                         },)
 
         result = self.run_command(['hw', 'dns-sync', '1000'])
 
@@ -749,12 +750,12 @@ def test_dns_sync_v6(self, confirm_mock):
             }
         }
         createV6args = ({
-            'type': 'aaaa',
-            'host': 'hardware-test1',
-            'domainId': 12345,  # from SoftLayer_Account::getDomains
-            'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004',
-            'ttl': 7200
-        },)
+                            'type': 'aaaa',
+                            'host': 'hardware-test1',
+                            'domainId': 12345,  # from SoftLayer_Account::getDomains
+                            'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004',
+                            'ttl': 7200
+                        },)
         server.return_value = test_server
         result = self.run_command(['hw', 'dns-sync', '--aaaa-record', '1000'])
         self.assert_no_fail(result)
diff --git a/tests/managers/hardware_tests.py b/tests/managers/hardware_tests.py
index 69e7ae52..f6a2445d 100644
--- a/tests/managers/hardware_tests.py
+++ b/tests/managers/hardware_tests.py
@@ -121,7 +121,8 @@ def test_get_create_options(self):
             'extras': [{'key': '1_IPV6_ADDRESS', 'name': '1 IPv6 Address'}],
             'locations': [{'key': 'wdc01', 'name': 'Washington 1'}],
             'operating_systems': [{'key': 'OS_UBUNTU_14_04_LTS_TRUSTY_TAHR_64_BIT',
-                                   'name': 'Ubuntu / 14.04-64'}],
+                                   'name': 'Ubuntu / 14.04-64',
+                                   'referenceCode': 'UBUNTU_14_64'}],
             'port_speeds': [{
                 'key': '10',
                 'name': '10 Mbps Public & Private Network Uplinks'
@@ -374,10 +375,10 @@ def test_edit(self):
         self.assert_called_with('SoftLayer_Hardware_Server',
                                 'editObject',
                                 args=({
-                                    'hostname': 'new-host',
-                                    'domain': 'new.sftlyr.ws',
-                                    'notes': 'random notes',
-                                },),
+                                          'hostname': 'new-host',
+                                          'domain': 'new.sftlyr.ws',
+                                          'notes': 'random notes',
+                                      },),
                                 identifier=100)
 
     def test_rescue(self):