Repository: softlayer/softlayer-python
Pull request #912 (2017-12-20 20:56:39)

Small fixes
- updated iops on block and file detail view to use provisionedIops
- updated managers.hardware.place_order to accept a presetID as a valid size


Patch:
diff --git a/SoftLayer/CLI/block/detail.py b/SoftLayer/CLI/block/detail.py
index ecfd5c4d..87c53a8d 100644
--- a/SoftLayer/CLI/block/detail.py
+++ b/SoftLayer/CLI/block/detail.py
@@ -28,8 +28,8 @@ def cli(env, volume_id):
     table.add_row(['Capacity (GB)', "%iGB" % block_volume['capacityGb']])
     table.add_row(['LUN Id', "%s" % block_volume['lunId']])
 
-    if block_volume.get('iops'):
-        table.add_row(['IOPs', block_volume['iops']])
+    if block_volume.get('provisionedIops'):
+        table.add_row(['IOPs', int(block_volume['provisionedIops'])])
 
     if block_volume.get('storageTierLevel'):
         table.add_row([
diff --git a/SoftLayer/CLI/file/detail.py b/SoftLayer/CLI/file/detail.py
index cb712dc9..e34c1d41 100644
--- a/SoftLayer/CLI/file/detail.py
+++ b/SoftLayer/CLI/file/detail.py
@@ -38,8 +38,8 @@ def cli(env, volume_id):
     else:
         table.add_row(['Used Space', "%dGB" % (used_space / (1 << 30))])
 
-    if file_volume.get('iops'):
-        table.add_row(['IOPs', file_volume['iops']])
+    if file_volume.get('provisionedIops'):
+        table.add_row(['IOPs', int(file_volume['provisionedIops'])])
 
     if file_volume.get('storageTierLevel'):
         table.add_row([
diff --git a/SoftLayer/managers/block.py b/SoftLayer/managers/block.py
index 2b68ba13..6d8f0e1b 100644
--- a/SoftLayer/managers/block.py
+++ b/SoftLayer/managers/block.py
@@ -90,7 +90,7 @@ def get_block_volume_details(self, volume_id, **kwargs):
                 'serviceResource.datacenter[name]',
                 'serviceResourceBackendIpAddress',
                 'storageTierLevel',
-                'iops',
+                'provisionedIops',
                 'lunId',
                 'originalVolumeName',
                 'originalSnapshotName',
@@ -105,8 +105,7 @@ def get_block_volume_details(self, volume_id, **kwargs):
                 'replicationSchedule[type[keyname]]]',
             ]
             kwargs['mask'] = ','.join(items)
-        return self.client.call('Network_Storage', 'getObject',
-                                id=volume_id, **kwargs)
+        return self.client.call('Network_Storage', 'getObject', id=volume_id, **kwargs)
 
     def get_block_volume_access_list(self, volume_id, **kwargs):
         """Returns a list of authorized hosts for a specified volume.
diff --git a/SoftLayer/managers/file.py b/SoftLayer/managers/file.py
index 7c271b2e..e1135ebe 100644
--- a/SoftLayer/managers/file.py
+++ b/SoftLayer/managers/file.py
@@ -87,7 +87,7 @@ def get_file_volume_details(self, volume_id, **kwargs):
                 'serviceResourceBackendIpAddress',
                 'fileNetworkMountAddress',
                 'storageTierLevel',
-                'iops',
+                'provisionedIops',
                 'lunId',
                 'originalVolumeName',
                 'originalSnapshotName',
diff --git a/SoftLayer/managers/hardware.py b/SoftLayer/managers/hardware.py
index f6fcf68f..97ef6cd6 100644
--- a/SoftLayer/managers/hardware.py
+++ b/SoftLayer/managers/hardware.py
@@ -298,7 +298,7 @@ def place_order(self, **kwargs):
 
         See get_create_options() for valid arguments.
 
-        :param string size: server size name
+        :param string size: server size name or presetId
         :param string hostname: server hostname
         :param string domain: server domain name
         :param string location: location (datacenter) name
@@ -748,15 +748,13 @@ def _get_location(package, location):
         if region['location']['location']['name'] == location:
             return region
 
-    raise SoftLayer.SoftLayerError("Could not find valid location for: '%s'"
-                                   % location)
+    raise SoftLayer.SoftLayerError("Could not find valid location for: '%s'" % location)
 
 
 def _get_preset_id(package, size):
     """Get the preset id given the keyName of the preset."""
     for preset in package['activePresets']:
-        if preset['keyName'] == size:
+        if preset['keyName'] == size or preset['id'] == size:
             return preset['id']
 
-    raise SoftLayer.SoftLayerError("Could not find valid size for: '%s'"
-                                   % size)
+    raise SoftLayer.SoftLayerError("Could not find valid size for: '%s'" % size)


Test patch:
diff --git a/tests/managers/block_tests.py b/tests/managers/block_tests.py
index 203c021b..6f2e5eb6 100644
--- a/tests/managers/block_tests.py
+++ b/tests/managers/block_tests.py
@@ -56,7 +56,7 @@ def test_get_block_volume_details(self):
                         'serviceResource.datacenter[name],'\
                         'serviceResourceBackendIpAddress,'\
                         'storageTierLevel,'\
-                        'iops,'\
+                        'provisionedIops,'\
                         'lunId,'\
                         'originalVolumeName,'\
                         'originalSnapshotName,'\
diff --git a/tests/managers/file_tests.py b/tests/managers/file_tests.py
index 389682cd..1cbcb47c 100644
--- a/tests/managers/file_tests.py
+++ b/tests/managers/file_tests.py
@@ -130,7 +130,7 @@ def test_get_file_volume_details(self):
                         'serviceResourceBackendIpAddress,'\
                         'fileNetworkMountAddress,'\
                         'storageTierLevel,'\
-                        'iops,'\
+                        'provisionedIops,'\
                         'lunId,'\
                         'originalVolumeName,'\
                         'originalSnapshotName,'\