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
31 changes: 31 additions & 0 deletions SoftLayer/CLI/block/limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""List number of block storage volumes limit per datacenter."""
# :license: MIT, see LICENSE for more details.

import click
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting

DEFAULT_COLUMNS = [
'Datacenter',
'MaximumAvailableCount',
'ProvisionedCount'
]


@click.command()
@click.option('--sortby', help='Column to sort by', default='Datacenter')
@environment.pass_env
def cli(env, sortby):
"""List number of block storage volumes limit per datacenter."""
block_manager = SoftLayer.BlockStorageManager(env.client)
block_volumes = block_manager.list_block_volume_limit()

table = formatting.KeyValueTable(DEFAULT_COLUMNS)
table.sortby = sortby
for volume in block_volumes:
datacenter_name = volume['datacenterName']
maximum_available_count = volume['maximumAvailableCount']
provisioned_count = volume['provisionedCount']
table.add_row([datacenter_name, maximum_available_count, provisioned_count])
env.fout(table)
31 changes: 31 additions & 0 deletions SoftLayer/CLI/file/limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""List number of file storage volumes limit per datacenter."""
# :license: MIT, see LICENSE for more details.

import click
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting

DEFAULT_COLUMNS = [
'Datacenter',
'MaximumAvailableCount',
'ProvisionedCount'
]


@click.command()
@click.option('--sortby', help='Column to sort by', default='Datacenter')
@environment.pass_env
def cli(env, sortby):
"""List number of block storage volumes limit per datacenter."""
file_manager = SoftLayer.FileStorageManager(env.client)
file_volumes = file_manager.list_file_volume_limit()

table = formatting.KeyValueTable(DEFAULT_COLUMNS)
table.sortby = sortby
for volume in file_volumes:
datacenter_name = volume['datacenterName']
maximum_available_count = volume['maximumAvailableCount']
provisioned_count = volume['provisionedCount']
table.add_row([datacenter_name, maximum_available_count, provisioned_count])
env.fout(table)
2 changes: 2 additions & 0 deletions SoftLayer/CLI/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
('block:volume-modify', 'SoftLayer.CLI.block.modify:cli'),
('block:volume-order', 'SoftLayer.CLI.block.order:cli'),
('block:volume-set-lun-id', 'SoftLayer.CLI.block.lun:cli'),
('block:volume-limits', 'SoftLayer.CLI.block.limit:cli'),

('event-log', 'SoftLayer.CLI.event_log'),
('event-log:get', 'SoftLayer.CLI.event_log.get:cli'),
Expand Down Expand Up @@ -132,6 +133,7 @@
('file:volume-list', 'SoftLayer.CLI.file.list:cli'),
('file:volume-modify', 'SoftLayer.CLI.file.modify:cli'),
('file:volume-order', 'SoftLayer.CLI.file.order:cli'),
('file:volume-limits', 'SoftLayer.CLI.file.limit:cli'),

('firewall', 'SoftLayer.CLI.firewall'),
('firewall:add', 'SoftLayer.CLI.firewall.add:cli'),
Expand Down
6 changes: 6 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Network_Storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,9 @@

enableSnapshots = True
disableSnapshots = True

getVolumeCountLimits = {
'datacenterName': 'global',
'maximumAvailableCount': 300,
'provisionedCount': 100
}
7 changes: 7 additions & 0 deletions SoftLayer/managers/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def __init__(self, client):
self.configuration = {}
self.client = client

def list_block_volume_limit(self):
"""Returns a list of block volume count limit.

:return: Returns a list of block volume count limit.
"""
return self.client.call('Network_Storage', 'getVolumeCountLimits')

def list_block_volumes(self, datacenter=None, username=None,
storage_type=None, **kwargs):
"""Returns a list of block volumes.
Expand Down
7 changes: 7 additions & 0 deletions SoftLayer/managers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def __init__(self, client):
self.configuration = {}
self.client = client

def list_file_volume_limit(self):
"""Returns a list of file volume count limit.

:return: Returns a list of file volume count limit.
"""
return self.client.call('Network_Storage', 'getVolumeCountLimits')

def list_file_volumes(self, datacenter=None, username=None,
storage_type=None, **kwargs):
"""Returns a list of file volumes.
Expand Down
12 changes: 12 additions & 0 deletions tests/CLI/modules/block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,15 @@ def test_modify_order(self, order_mock):
def test_set_password(self):
result = self.run_command(['block', 'access-password', '1234', '--password=AAAAA'])
self.assert_no_fail(result)

@mock.patch('SoftLayer.BlockStorageManager.list_block_volume_limit')
def test_volume_limit(self, list_mock):
list_mock.return_value = [
{
"datacenterName": "global",
"maximumAvailableCount": 300,
"provisionedCount": 100
}]

result = self.run_command(['block', 'volume-limits'])
self.assert_no_fail(result)
11 changes: 11 additions & 0 deletions tests/CLI/modules/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,14 @@ def test_modify_order(self, order_mock):
self.assert_no_fail(result)
self.assertEqual('Order #24602 placed successfully!\n > Storage as a Service\n > 1000 GBs\n > 4 IOPS per GB\n',
result.output)

@mock.patch('SoftLayer.FileStorageManager.list_file_volume_limit')
def test_volume_limit(self, list_mock):
list_mock.return_value = [
{
'datacenterName': 'global',
'maximumAvailableCount': 300,
'provisionedCount': 100
}]
result = self.run_command(['file', 'volume-limits'])
self.assert_no_fail(result)
4 changes: 4 additions & 0 deletions tests/managers/block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,3 +936,7 @@ def test_setCredentialPassword(self):
result = self.block.set_credential_password(access_id=102, password='AAAaaa')
self.assertEqual(True, result)
self.assert_called_with('SoftLayer_Network_Storage_Allowed_Host', 'setCredentialPassword')

def test_list_block_volume_limit(self):
result = self.block.list_block_volume_limit()
self.assertEqual(fixtures.SoftLayer_Network_Storage.getVolumeCountLimits, result)
16 changes: 8 additions & 8 deletions tests/managers/cdn_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ def test_add_origin(self):
cache_query="include all")

args = ({
'uniqueId': "12345",
'origin': '10.10.10.1',
'path': '/example/videos',
'uniqueId': "12345",
'origin': '10.10.10.1',
'path': '/example/videos',
'originType': 'HOST_SERVER',
'header': 'test.example.com',
'httpPort': 80,
'protocol': 'HTTP',
'performanceConfiguration': 'General web delivery',
'cacheKeyQueryRule': "include all"
},)
},)
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping_Path',
'createOriginPath',
args=args)
Expand All @@ -69,9 +69,9 @@ def test_add_origin_with_bucket_and_file_extension(self):
protocol='http', optimize_for="web", cache_query="include all")

args = ({
'uniqueId': "12345",
'origin': '10.10.10.1',
'path': '/example/videos',
'uniqueId': "12345",
'origin': '10.10.10.1',
'path': '/example/videos',
'originType': 'OBJECT_STORAGE',
'header': 'test.example.com',
'httpPort': 80,
Expand All @@ -80,7 +80,7 @@ def test_add_origin_with_bucket_and_file_extension(self):
'fileExtension': 'jpg',
'performanceConfiguration': 'General web delivery',
'cacheKeyQueryRule': "include all"
},)
},)
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping_Path',
'createOriginPath',
args=args)
Expand Down
5 changes: 4 additions & 1 deletion tests/managers/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ def test_order_file_duplicate_performance_no_duplicate_snapshot(self):
def test_order_file_duplicate_performance(self):
mock = self.set_mock('SoftLayer_Product_Package', 'getAllObjects')
mock.return_value = [fixtures.SoftLayer_Product_Package.SAAS_PACKAGE]

mock_volume = copy.deepcopy(fixtures.SoftLayer_Network_Storage.STAAS_TEST_VOLUME)
mock_volume['storageType']['keyName'] = 'PERFORMANCE_FILE_STORAGE'
mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')
Expand Down Expand Up @@ -829,3 +828,7 @@ def test_order_file_modified_endurance(self):
'volume': {'id': 102},
'volumeSize': 1000},)
)

def test_list_file_volume_limit(self):
result = self.file.list_file_volume_limit()
self.assertEqual(fixtures.SoftLayer_Network_Storage.getVolumeCountLimits, result)
4 changes: 2 additions & 2 deletions tests/managers/ordering_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def test_get_item_capacity_core(self):
"capacity": "1",
"id": 10201,
"keyName": "GUEST_CORE_1_DEDICATED",
}]
}]

item_capacity = self.ordering.get_item_capacity(items, ['GUEST_CORE_1_DEDICATED', 'OS_RHEL_7_X_LAMP_64_BIT'])

Expand All @@ -739,7 +739,7 @@ def test_get_item_capacity_storage(self):
"capacity": "1",
"id": 10201,
"keyName": "READHEAVY_TIER",
}]
}]

item_capacity = self.ordering.get_item_capacity(items, ['READHEAVY_TIER', 'STORAGE_SPACE_FOR_2_IOPS_PER_GB'])

Expand Down