Skip to content
4 changes: 3 additions & 1 deletion SoftLayer/CLI/block/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers
from SoftLayer import utils


Expand All @@ -14,7 +15,8 @@
def cli(env, volume_id):
"""Display details for a specified volume."""
block_manager = SoftLayer.BlockStorageManager(env.client)
block_volume = block_manager.get_block_volume_details(volume_id)
block_volume_id = helpers.resolve_id(block_manager.resolve_ids, volume_id, 'Block Volume')
block_volume = block_manager.get_block_volume_details(block_volume_id)
block_volume = utils.NestedDict(block_volume)

table = formatting.KeyValueTable(['Name', 'Value'])
Expand Down
4 changes: 3 additions & 1 deletion SoftLayer/CLI/file/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers
from SoftLayer import utils


Expand All @@ -14,7 +15,8 @@
def cli(env, volume_id):
"""Display details for a specified volume."""
file_manager = SoftLayer.FileStorageManager(env.client)
file_volume = file_manager.get_file_volume_details(volume_id)
file_volume_id = helpers.resolve_id(file_manager.resolve_ids, volume_id, 'File Storage')
file_volume = file_manager.get_file_volume_details(file_volume_id)
file_volume = utils.NestedDict(file_volume)

table = formatting.KeyValueTable(['Name', 'Value'])
Expand Down
12 changes: 12 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Location_Datacenter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
getDatacenters = [
{
"id": 1441195,
"longName": "Dallas 10",
"name": "dal10"
},
{
"id": 449494,
"longName": "Dallas 9",
"name": "dal09"
}
]
465 changes: 20 additions & 445 deletions SoftLayer/managers/block.py

Large diffs are not rendered by default.

395 changes: 16 additions & 379 deletions SoftLayer/managers/file.py

Large diffs are not rendered by default.

416 changes: 416 additions & 0 deletions SoftLayer/managers/storage.py

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions SoftLayer/managers/storage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
}


def populate_host_templates(host_templates,
hardware_ids=None,
def populate_host_templates(hardware_ids=None,
virtual_guest_ids=None,
ip_address_ids=None,
subnet_ids=None):
"""Populate the given host_templates array with the IDs provided
"""Returns a populated array with the IDs provided

:param host_templates: The array to which host templates will be added
:param hardware_ids: A List of SoftLayer_Hardware ids
:param virtual_guest_ids: A List of SoftLayer_Virtual_Guest ids
:param ip_address_ids: A List of SoftLayer_Network_Subnet_IpAddress ids
:param subnet_ids: A List of SoftLayer_Network_Subnet ids
:return: array of objects formatted for allowAccessFromHostList
"""
host_templates = []
if hardware_ids is not None:
for hardware_id in hardware_ids:
host_templates.append({
Expand Down Expand Up @@ -59,6 +59,7 @@ def populate_host_templates(host_templates,
'objectType': 'SoftLayer_Network_Subnet',
'id': subnet_id
})
return host_templates


def get_package(manager, category_code):
Expand Down Expand Up @@ -991,6 +992,15 @@ def prepare_modify_order_object(manager, volume, new_iops, new_tier, new_size):
return modify_order


def block_or_file(storage_type_keyname):
"""returns either 'block' or 'file'

:param storage_type_keyname: the Network_Storage['storageType']['keyName']
:returns: 'block' or 'file'
"""
return 'block' if 'BLOCK_STORAGE' in storage_type_keyname else 'file'


def _has_category(categories, category_code):
return any(
True
Expand Down
21 changes: 21 additions & 0 deletions tests/CLI/modules/block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_volume_detail(self):

self.assert_no_fail(result)
isinstance(json.loads(result.output)['IOPs'], float)
self.assert_called_with('SoftLayer_Network_Storage', 'getObject', identifier=1234)
self.assertEqual({
'Username': 'username',
'LUN Id': '2',
Expand Down Expand Up @@ -98,6 +99,26 @@ def test_volume_detail(self):
]
}, json.loads(result.output))

def test_volume_detail_name_identifier(self):
result = self.run_command(['block', 'volume-detail', 'SL-12345'])
expected_filter = {
'iscsiNetworkStorage': {
'serviceResource': {
'type': {
'type': {'operation': '!~ ISCSI'}
}
},
'storageType': {
'keyName': {'operation': '*= BLOCK_STORAGE'}
},
'username': {'operation': '_= SL-12345'}
}
}

self.assert_called_with('SoftLayer_Account', 'getIscsiNetworkStorage', filter=expected_filter)
self.assert_called_with('SoftLayer_Network_Storage', 'getObject', identifier=100)
self.assert_no_fail(result)

def test_volume_list(self):
result = self.run_command(['block', 'volume-list'])

Expand Down
18 changes: 18 additions & 0 deletions tests/CLI/modules/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ def test_volume_detail(self):
]
}, json.loads(result.output))

def test_volume_detail_name_identifier(self):
result = self.run_command(['file', 'volume-detail', 'SL-12345'])
expected_filter = {
'nasNetworkStorage': {
'serviceResource': {
'type': {
'type': {'operation': '!~ NAS'}
}
},
'storageType': {
'keyName': {'operation': '*= FILE_STORAGE'}
},
'username': {'operation': '_= SL-12345'}}}

self.assert_called_with('SoftLayer_Account', 'getNasNetworkStorage', filter=expected_filter)
self.assert_called_with('SoftLayer_Network_Storage', 'getObject', identifier=1)
self.assert_no_fail(result)

def test_volume_order_performance_iops_not_given(self):
result = self.run_command(['file', 'volume-order',
'--storage-type=performance', '--size=20',
Expand Down
Loading