Skip to content

Commit dab368e

Browse files
#1233 refactored the file/block managers to reduce duplicated code
1 parent be19a02 commit dab368e

File tree

7 files changed

+585
-922
lines changed

7 files changed

+585
-922
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
getDatacenters = [
2+
{
3+
"id": 1441195,
4+
"longName": "Dallas 10",
5+
"name": "dal10"
6+
},
7+
{
8+
"id": 449494,
9+
"longName": "Dallas 9",
10+
"name": "dal09"
11+
}
12+
]

SoftLayer/managers/block.py

Lines changed: 14 additions & 437 deletions
Large diffs are not rendered by default.

SoftLayer/managers/file.py

Lines changed: 10 additions & 371 deletions
Large diffs are not rendered by default.

SoftLayer/managers/storage.py

Lines changed: 415 additions & 0 deletions
Large diffs are not rendered by default.

SoftLayer/managers/storage_utils.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
}
2020

2121

22-
def populate_host_templates(host_templates,
23-
hardware_ids=None,
22+
def populate_host_templates(hardware_ids=None,
2423
virtual_guest_ids=None,
2524
ip_address_ids=None,
2625
subnet_ids=None):
27-
"""Populate the given host_templates array with the IDs provided
26+
"""Returns a populated array with the IDs provided
2827
29-
:param host_templates: The array to which host templates will be added
3028
:param hardware_ids: A List of SoftLayer_Hardware ids
3129
:param virtual_guest_ids: A List of SoftLayer_Virtual_Guest ids
3230
:param ip_address_ids: A List of SoftLayer_Network_Subnet_IpAddress ids
3331
:param subnet_ids: A List of SoftLayer_Network_Subnet ids
32+
:return: array of objects formatted for allowAccessFromHostList
3433
"""
34+
host_templates = []
3535
if hardware_ids is not None:
3636
for hardware_id in hardware_ids:
3737
host_templates.append({
@@ -59,6 +59,7 @@ def populate_host_templates(host_templates,
5959
'objectType': 'SoftLayer_Network_Subnet',
6060
'id': subnet_id
6161
})
62+
return host_templates
6263

6364

6465
def get_package(manager, category_code):
@@ -984,6 +985,13 @@ def prepare_modify_order_object(manager, volume, new_iops, new_tier, new_size):
984985

985986
return modify_order
986987

988+
def block_or_file(storage_type_keyname):
989+
"""returns either 'block' or 'file'
990+
991+
:param storage_type_keyname: the Network_Storage['storageType']['keyName']
992+
:returns: 'block' or 'file'
993+
"""
994+
return 'block' if 'BLOCK_STORAGE' in storage_type_keyname else 'file'
987995

988996
def _has_category(categories, category_code):
989997
return any(
@@ -1014,3 +1022,4 @@ def _find_price_id(prices, category, restriction_type=None, restriction_value=No
10141022
continue
10151023

10161024
return {'id': price['id']}
1025+

0 commit comments

Comments
 (0)