Skip to content

Commit 3d5e025

Browse files
Merge pull request #1208 from samsony17/feature/VolumeLimit
Functionality for VolumeLimit per DataCenter
2 parents 59126e7 + 03c74b1 commit 3d5e025

File tree

12 files changed

+125
-11
lines changed

12 files changed

+125
-11
lines changed

SoftLayer/CLI/block/limit.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""List number of block storage volumes limit per datacenter."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
9+
DEFAULT_COLUMNS = [
10+
'Datacenter',
11+
'MaximumAvailableCount',
12+
'ProvisionedCount'
13+
]
14+
15+
16+
@click.command()
17+
@click.option('--sortby', help='Column to sort by', default='Datacenter')
18+
@environment.pass_env
19+
def cli(env, sortby):
20+
"""List number of block storage volumes limit per datacenter."""
21+
block_manager = SoftLayer.BlockStorageManager(env.client)
22+
block_volumes = block_manager.list_block_volume_limit()
23+
24+
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
25+
table.sortby = sortby
26+
for volume in block_volumes:
27+
datacenter_name = volume['datacenterName']
28+
maximum_available_count = volume['maximumAvailableCount']
29+
provisioned_count = volume['provisionedCount']
30+
table.add_row([datacenter_name, maximum_available_count, provisioned_count])
31+
env.fout(table)

SoftLayer/CLI/file/limit.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""List number of file storage volumes limit per datacenter."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
9+
DEFAULT_COLUMNS = [
10+
'Datacenter',
11+
'MaximumAvailableCount',
12+
'ProvisionedCount'
13+
]
14+
15+
16+
@click.command()
17+
@click.option('--sortby', help='Column to sort by', default='Datacenter')
18+
@environment.pass_env
19+
def cli(env, sortby):
20+
"""List number of block storage volumes limit per datacenter."""
21+
file_manager = SoftLayer.FileStorageManager(env.client)
22+
file_volumes = file_manager.list_file_volume_limit()
23+
24+
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
25+
table.sortby = sortby
26+
for volume in file_volumes:
27+
datacenter_name = volume['datacenterName']
28+
maximum_available_count = volume['maximumAvailableCount']
29+
provisioned_count = volume['provisionedCount']
30+
table.add_row([datacenter_name, maximum_available_count, provisioned_count])
31+
env.fout(table)

SoftLayer/CLI/routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
('block:volume-modify', 'SoftLayer.CLI.block.modify:cli'),
103103
('block:volume-order', 'SoftLayer.CLI.block.order:cli'),
104104
('block:volume-set-lun-id', 'SoftLayer.CLI.block.lun:cli'),
105+
('block:volume-limits', 'SoftLayer.CLI.block.limit:cli'),
105106

106107
('event-log', 'SoftLayer.CLI.event_log'),
107108
('event-log:get', 'SoftLayer.CLI.event_log.get:cli'),
@@ -132,6 +133,7 @@
132133
('file:volume-list', 'SoftLayer.CLI.file.list:cli'),
133134
('file:volume-modify', 'SoftLayer.CLI.file.modify:cli'),
134135
('file:volume-order', 'SoftLayer.CLI.file.order:cli'),
136+
('file:volume-limits', 'SoftLayer.CLI.file.limit:cli'),
135137

136138
('firewall', 'SoftLayer.CLI.firewall'),
137139
('firewall:add', 'SoftLayer.CLI.firewall.add:cli'),

SoftLayer/fixtures/SoftLayer_Network_Storage.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,9 @@
226226

227227
enableSnapshots = True
228228
disableSnapshots = True
229+
230+
getVolumeCountLimits = {
231+
'datacenterName': 'global',
232+
'maximumAvailableCount': 300,
233+
'provisionedCount': 100
234+
}

SoftLayer/managers/block.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ def __init__(self, client):
2424
self.configuration = {}
2525
self.client = client
2626

27+
def list_block_volume_limit(self):
28+
"""Returns a list of block volume count limit.
29+
30+
:return: Returns a list of block volume count limit.
31+
"""
32+
return self.client.call('Network_Storage', 'getVolumeCountLimits')
33+
2734
def list_block_volumes(self, datacenter=None, username=None,
2835
storage_type=None, **kwargs):
2936
"""Returns a list of block volumes.

SoftLayer/managers/file.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ def __init__(self, client):
1919
self.configuration = {}
2020
self.client = client
2121

22+
def list_file_volume_limit(self):
23+
"""Returns a list of file volume count limit.
24+
25+
:return: Returns a list of file volume count limit.
26+
"""
27+
return self.client.call('Network_Storage', 'getVolumeCountLimits')
28+
2229
def list_file_volumes(self, datacenter=None, username=None,
2330
storage_type=None, **kwargs):
2431
"""Returns a list of file volumes.

tests/CLI/modules/block_tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,15 @@ def test_modify_order(self, order_mock):
665665
def test_set_password(self):
666666
result = self.run_command(['block', 'access-password', '1234', '--password=AAAAA'])
667667
self.assert_no_fail(result)
668+
669+
@mock.patch('SoftLayer.BlockStorageManager.list_block_volume_limit')
670+
def test_volume_limit(self, list_mock):
671+
list_mock.return_value = [
672+
{
673+
"datacenterName": "global",
674+
"maximumAvailableCount": 300,
675+
"provisionedCount": 100
676+
}]
677+
678+
result = self.run_command(['block', 'volume-limits'])
679+
self.assert_no_fail(result)

tests/CLI/modules/file_tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,14 @@ def test_modify_order(self, order_mock):
665665
self.assert_no_fail(result)
666666
self.assertEqual('Order #24602 placed successfully!\n > Storage as a Service\n > 1000 GBs\n > 4 IOPS per GB\n',
667667
result.output)
668+
669+
@mock.patch('SoftLayer.FileStorageManager.list_file_volume_limit')
670+
def test_volume_limit(self, list_mock):
671+
list_mock.return_value = [
672+
{
673+
'datacenterName': 'global',
674+
'maximumAvailableCount': 300,
675+
'provisionedCount': 100
676+
}]
677+
result = self.run_command(['file', 'volume-limits'])
678+
self.assert_no_fail(result)

tests/managers/block_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,3 +936,7 @@ def test_setCredentialPassword(self):
936936
result = self.block.set_credential_password(access_id=102, password='AAAaaa')
937937
self.assertEqual(True, result)
938938
self.assert_called_with('SoftLayer_Network_Storage_Allowed_Host', 'setCredentialPassword')
939+
940+
def test_list_block_volume_limit(self):
941+
result = self.block.list_block_volume_limit()
942+
self.assertEqual(fixtures.SoftLayer_Network_Storage.getVolumeCountLimits, result)

tests/managers/cdn_tests.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ def test_add_origin(self):
4949
cache_query="include all")
5050

5151
args = ({
52-
'uniqueId': "12345",
53-
'origin': '10.10.10.1',
54-
'path': '/example/videos',
52+
'uniqueId': "12345",
53+
'origin': '10.10.10.1',
54+
'path': '/example/videos',
5555
'originType': 'HOST_SERVER',
5656
'header': 'test.example.com',
5757
'httpPort': 80,
5858
'protocol': 'HTTP',
5959
'performanceConfiguration': 'General web delivery',
6060
'cacheKeyQueryRule': "include all"
61-
},)
61+
},)
6262
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping_Path',
6363
'createOriginPath',
6464
args=args)
@@ -69,9 +69,9 @@ def test_add_origin_with_bucket_and_file_extension(self):
6969
protocol='http', optimize_for="web", cache_query="include all")
7070

7171
args = ({
72-
'uniqueId': "12345",
73-
'origin': '10.10.10.1',
74-
'path': '/example/videos',
72+
'uniqueId': "12345",
73+
'origin': '10.10.10.1',
74+
'path': '/example/videos',
7575
'originType': 'OBJECT_STORAGE',
7676
'header': 'test.example.com',
7777
'httpPort': 80,
@@ -80,7 +80,7 @@ def test_add_origin_with_bucket_and_file_extension(self):
8080
'fileExtension': 'jpg',
8181
'performanceConfiguration': 'General web delivery',
8282
'cacheKeyQueryRule': "include all"
83-
},)
83+
},)
8484
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping_Path',
8585
'createOriginPath',
8686
args=args)

0 commit comments

Comments
 (0)