Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SoftLayer/CLI/block/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def cli(env, volume_id):
if block_volume.get('storageTierLevel'):
table.add_row([
'Endurance Tier',
block_volume['storageTierLevel']['description'],
block_volume['storageTierLevel'],
])

table.add_row([
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/CLI/file/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def cli(env, volume_id):
if file_volume.get('storageTierLevel'):
table.add_row([
'Endurance Tier',
file_volume['storageTierLevel']['description'],
file_volume['storageTierLevel'],
])

table.add_row([
Expand Down
1 change: 0 additions & 1 deletion SoftLayer/fixtures/SoftLayer_Metric_Tracking_Object.py

This file was deleted.

2 changes: 1 addition & 1 deletion SoftLayer/fixtures/SoftLayer_Network_Storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'password': '',
'serviceProviderId': 1,
'iops': 1000,
'storageTierLevel': {'description': '2 IOPS per GB'},
'storageTierLevel': 'READHEAVY_TIER',
'snapshotCapacityGb': '10',
'parentVolume': {'snapshotSizeBytes': 1024},
'osType': {'keyName': 'LINUX'},
Expand Down
68 changes: 0 additions & 68 deletions SoftLayer/fixtures/SoftLayer_Network_Storage_Iscsi.py

This file was deleted.

1 change: 0 additions & 1 deletion SoftLayer/fixtures/SoftLayer_User_Customer.py

This file was deleted.

31 changes: 14 additions & 17 deletions SoftLayer/managers/storage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,21 @@ def find_endurance_tier_iops_per_gb(volume):
:param volume: The volume for which the tier level is desired
:return: Returns a float value indicating the IOPS per GB for the volume
"""
tier_description_split = volume['storageTierLevel']['description'].split()

if tier_description_split != []:
iops_per_gb = tier_description_split[0]

if iops_per_gb == '0.25':
return 0.25

if iops_per_gb == '2':
return 2.0

if iops_per_gb == '4':
return 4.0

if iops_per_gb == '10':
return 10.0
tier = volume['storageTierLevel']
iops_per_gb = 0.25

if tier == "LOW_INTENSITY_TIER":
iops_per_gb = 0.25
elif tier == "READHEAVY_TIER":
iops_per_gb = 2
elif tier == "WRITEHEAVY_TIER":
iops_per_gb = 4
elif tier == "10_IOPS_PER_GB":
iops_per_gb = 10
else:
raise ValueError("Could not find tier IOPS per GB for this volume")

raise ValueError("Could not find tier IOPS per GB for this volume")
return iops_per_gb


def find_performance_price(package, price_category):
Expand Down
2 changes: 1 addition & 1 deletion tests/CLI/modules/block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_volume_detail(self):
self.assertEqual({
'Username': 'username',
'LUN Id': '2',
'Endurance Tier': '2 IOPS per GB',
'Endurance Tier': 'READHEAVY_TIER',
'IOPs': 1000,
'Snapshot Capacity (GB)': '10',
'Snapshot Used (Bytes)': 1024,
Expand Down
2 changes: 1 addition & 1 deletion tests/CLI/modules/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_volume_detail(self):
self.assertEqual({
'Username': 'username',
'Used Space': '0B',
'Endurance Tier': '2 IOPS per GB',
'Endurance Tier': 'READHEAVY_TIER',
'IOPs': 1000,
'Mount Address': '127.0.0.1:/TEST',
'Snapshot Capacity (GB)': '10',
Expand Down
64 changes: 64 additions & 0 deletions tests/managers/block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def test_list_block_volumes(self):

self.assert_called_with('SoftLayer_Account', 'getIscsiNetworkStorage')

result = self.block.list_block_volumes(datacenter="dal09", storage_type="Endurance", username="username")
self.assert_called_with('SoftLayer_Account', 'getIscsiNetworkStorage')

def test_get_block_volume_access_list(self):
result = self.block.get_block_volume_access_list(100)

Expand Down Expand Up @@ -133,6 +136,47 @@ def test_cancel_snapshot_immediately(self):
identifier=123,
)

def test_cancel_snapshot_exception_1(self):
mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')
mock.return_value = {
'capacityGb': 20,
'snapshotCapacityGb': '10',
'schedules': [{
'id': 7770,
'type': {'keyname': 'SNAPSHOT_WEEKLY'}
}],
'billingItem': {
'categoryCode': 'storage_service_enterprise',
'cancellationDate': '2016-09-04T22:00:00-07:00'
}
}
self.assertRaises(
exceptions.SoftLayerError,
self.block.cancel_snapshot_space,
12345,
immediate=True
)

def test_cancel_snapshot_exception_2(self):
mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')
mock.return_value = {
'capacityGb': 20,
'snapshotCapacityGb': '10',
'schedules': [{
'id': 7770,
'type': {'keyname': 'SNAPSHOT_WEEKLY'}
}],
'billingItem': {
'activeChildren': []
}
}
self.assertRaises(
exceptions.SoftLayerError,
self.block.cancel_snapshot_space,
12345,
immediate=True
)

def test_replicant_failover(self):
result = self.block.failover_to_replicant(1234, 5678, immediate=True)

Expand Down Expand Up @@ -595,6 +639,26 @@ def test_order_snapshot_space(self):
'setupFee': '1'}],
},
)
result = self.block.order_snapshot_space(100, 5, None, True)

self.assertEqual(
result,
{
'orderId': 1234,
'orderDate': '2013-08-01 15:23:45',
'prices': [{
'hourlyRecurringFee': '2',
'id': 1,
'item': {'description': 'this is a thing', 'id': 1},
'laborFee': '2',
'oneTimeFee': '2',
'oneTimeFeeTax': '.1',
'quantity': 1,
'recurringFee': '2',
'recurringFeeTax': '.1',
'setupFee': '1'}],
},
)

def test_order_snapshot_space_invalid_category(self):
mock = self.set_mock('SoftLayer_Product_Package', 'getAllObjects')
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[tox]
envlist = py27,py33,py34,py35,py36,pypy,analysis,coverage

[flake8]
max-line-length=120

[testenv]
deps = -r{toxinidir}/tools/test-requirements.txt
commands = py.test {posargs:tests}
Expand Down Expand Up @@ -34,7 +37,7 @@ commands =
--max-branches=20 \
--max-statements=60 \
--min-public-methods=0 \
--min-similarity-lines=30
--min-similarity-lines=30

# invalid-name - Fixtures don't follow proper naming conventions
# missing-docstring - Fixtures don't have docstrings
Expand Down