Skip to content

Commit 1c7591d

Browse files
Merge pull request #1684 from caberos/issue1683
add the file volume-options command
2 parents cdf590a + ab646c9 commit 1c7591d

File tree

6 files changed

+62
-14
lines changed

6 files changed

+62
-14
lines changed

SoftLayer/CLI/file/options.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""List all options for ordering a file storage."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI.command import SLCommand
8+
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import formatting
10+
11+
12+
PACKAGE_STORAGE = 759
13+
14+
15+
@click.command(cls=SLCommand)
16+
@environment.pass_env
17+
def cli(env):
18+
"""List all options for ordering a file storage"""
19+
20+
order_manager = SoftLayer.OrderingManager(env.client)
21+
items = order_manager.get_items(PACKAGE_STORAGE)
22+
datacenters = order_manager.get_regions(PACKAGE_STORAGE)
23+
24+
iops_table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
25+
snapshot_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
26+
storage_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Storage')
27+
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
28+
29+
for datacenter in datacenters:
30+
datacenter_table.add_row([datacenter['location']['locationId'],
31+
datacenter.get('description'),
32+
datacenter['keyname']])
33+
34+
for item in items:
35+
if item['itemCategory']['categoryCode'] == 'performance_storage_space':
36+
storage_table.add_row([item.get('id'), item.get('description'),
37+
item.get('keyName')])
38+
39+
if item['itemCategory']['categoryCode'] == 'storage_tier_level':
40+
iops_table.add_row([item.get('id'), item.get('description'),
41+
item.get('keyName')])
42+
43+
if item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
44+
snapshot_table.add_row([item.get('id'), item.get('description'),
45+
item.get('keyName')])
46+
47+
env.fout(datacenter_table)
48+
env.fout(iops_table)
49+
env.fout(storage_table)
50+
env.fout(snapshot_table)

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
('file:volume-limits', 'SoftLayer.CLI.file.limit:cli'),
176176
('file:volume-refresh', 'SoftLayer.CLI.file.refresh:cli'),
177177
('file:volume-convert', 'SoftLayer.CLI.file.convert:cli'),
178+
('file:volume-options', 'SoftLayer.CLI.file.options:cli'),
178179
('file:volume-set-note', 'SoftLayer.CLI.file.set_note:cli'),
179180

180181
('firewall', 'SoftLayer.CLI.firewall'),
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
getDataCenters = [
2-
{
3-
"id": 358694,
4-
"longName": "London 2",
5-
"name": "lon02"
6-
},
7-
{
8-
"id": 168642,
9-
"longName": "San Jose 1",
10-
"name": "sjc01"
11-
}]
121
getDatacenters = [{'id': 1854895, 'longName': 'dallas 13', 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]

docs/cli/file.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ File Commands
123123
:prog: file volume-set-note
124124
:show-nested:
125125

126+
.. click:: SoftLayer.CLI.file.options:cli
127+
:prog: file volume-options
128+
:show-nested:
129+
126130
.. click:: SoftLayer.CLI.file.replication.disaster_recovery_failover:cli
127131
:prog: file disaster-recovery-failover
128132
:show-nested:

tests/CLI/modules/file_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,3 +798,7 @@ def test_snapshot_get_notification_status(self, status):
798798
result = self.run_command(['file', 'snapshot-get-notification-status', '999'])
799799
self.assert_no_fail(result)
800800
self.assertIn(expect, result.output)
801+
802+
def test_volume_options(self):
803+
result = self.run_command(['file', 'volume-options'])
804+
self.assert_no_fail(result)

tests/managers/ordering_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ def test_get_item_capacity_core(self):
744744
"capacity": "1",
745745
"id": 10201,
746746
"keyName": "GUEST_CORE_1_DEDICATED",
747-
}]
747+
}]
748748

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

@@ -761,7 +761,7 @@ def test_get_item_capacity_storage(self):
761761
"capacity": "1",
762762
"id": 10201,
763763
"keyName": "READHEAVY_TIER",
764-
}]
764+
}]
765765

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

@@ -779,7 +779,7 @@ def test_get_item_capacity_intel(self):
779779
"capacity": "1",
780780
"id": 10201,
781781
"keyName": "GUEST_CORE_1_DEDICATED",
782-
}]
782+
}]
783783

784784
item_capacity = self.ordering.get_item_capacity(items, ['INTEL_XEON_2690_2_60', 'BANDWIDTH_20000_GB'])
785785

0 commit comments

Comments
 (0)