Skip to content

Commit 18bcb87

Browse files
caberoscaberos
authored andcommitted
add the block volume-options command
1 parent 393e70c commit 18bcb87

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

SoftLayer/CLI/block/options.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""List all options for ordering a block 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+
volume_size = ['20', '40', '80', '100', '250', '500', '1000', '2000-3000', '4000-7000', '8000-9000', '10000-12000']
12+
13+
14+
@click.command(cls=SLCommand)
15+
@environment.pass_env
16+
def cli(env):
17+
"""List all options for ordering a block storage"""
18+
19+
network_manager = SoftLayer.NetworkManager(env.client)
20+
datacenters = network_manager.get_datacenter()
21+
22+
table = formatting.Table(['Name', 'Value'], title='Volume table')
23+
24+
table.add_row(['Storage Type', 'performance,endurance'])
25+
table.add_row(['Size (GB)', str(volume_size)])
26+
table.add_row(['OS Type', 'HYPER_V,LINUX,VMWARE,WINDOWS_2008,WINDOWS_GPT,WINDOWS,XEN'])
27+
iops_table = formatting.Table(['Size (GB)', '20', '40', '80', '100', '250', '500', '1000', '2000-3000',
28+
'4000-7000', '8000-9000', '10000-12000'], title='IOPS table')
29+
snapshot_table = formatting.Table(['Storage Size (GB)', 'Available Snapshot Size (GB)'], title="Snapshot table")
30+
31+
datacenter_str = ','.join([str(dc['longName']) for dc in datacenters])
32+
iops_table.add_row(['Size (GB)', *volume_size])
33+
iops_table.add_row(['Min IOPS', '100', '100', '100', '100', '100', '100', '100', '200', '300', '500', '1000'])
34+
iops_table.add_row(['Max IOPS', '1000', '2000', '4000', '6000', '6000', '6000 or 10000', '6000 or 20000',
35+
'6000 or 40000', '6000 or 48000', '6000 or 48000', '6000 or 48000'])
36+
# table.add_row(['iops', iops_table])
37+
table.add_row(['Tier', '0.25,2,4,10'])
38+
table.add_row(['location', datacenter_str])
39+
40+
snapshot_table.add_row(['20', '0,5,10,20'])
41+
snapshot_table.add_row(['40', '0,5,10,20,40'])
42+
snapshot_table.add_row(['80', '0,5,10,20,40,60,80'])
43+
snapshot_table.add_row(['100', '0,5,10,20,40,60,80,100'])
44+
snapshot_table.add_row(['250', '0,5,10,20,40,60,80,100,150,200,250'])
45+
snapshot_table.add_row(['500', '0,5,10,20,40,60,80,100,150,200,250,300,350,400,450,500'])
46+
snapshot_table.add_row(['1000', '0,5,10,20,40,60,80,100,150,200,250,300,350,400,450,500,600,700,1000'])
47+
snapshot_table.add_row(['2000-3000', '0,5,10,20,40,60,80,100,150,200,250,300,350,400,450,500,600,700,1000,2000'])
48+
snapshot_table.add_row(
49+
['4000-7000', '0,5,10,20,40,60,80,100,150,200,250,300,350,400,450,500,600,700,1000,2000,4000'])
50+
snapshot_table.add_row(
51+
['8000-9000', '0,5,10,20,40,60,80,100,150,200,250,300,350,400,450,500,600,700,1000,2000,4000'])
52+
snapshot_table.add_row(
53+
['10000-12000', '0,5,10,20,40,60,80,100,150,200,250,300,350,400,450,500,600,700,1000,2000,4000'])
54+
55+
# table.add_row(['Snapshot Size (GB)', snapshot_table])
56+
table.add_row(['Note:',
57+
'IOPs limit above 6000 available in select data centers, refer to:'
58+
'http://knowledgelayer.softlayer.com/articles/new-ibm-block-and-file-storage-location-and-features'])
59+
env.fout(table)
60+
env.fout(iops_table)
61+
env.fout(snapshot_table)

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
('block:volume-limits', 'SoftLayer.CLI.block.limit:cli'),
126126
('block:volume-refresh', 'SoftLayer.CLI.block.refresh:cli'),
127127
('block:volume-convert', 'SoftLayer.CLI.block.convert:cli'),
128+
('block:volume-options', 'SoftLayer.CLI.block.options:cli'),
128129
('block:volume-set-note', 'SoftLayer.CLI.block.set_note:cli'),
129130
('block:object-list', 'SoftLayer.CLI.block.object_list:cli'),
130131

SoftLayer/fixtures/SoftLayer_Location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"longName": "San Jose 1",
1010
"name": "sjc01"
1111
}]
12-
getDatacenters = [{'id': 1854895, 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]
12+
getDatacenters = [{'id': 1854895, 'longName': 'dallas 13', 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]

docs/cli/block.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Block Commands
8383
:prog: block volume-count
8484
:show-nested:
8585

86+
.. click:: SoftLayer.CLI.block.options:cli
87+
:prog: block volume-options
88+
:show-nested:
89+
8690
.. click:: SoftLayer.CLI.block.detail:cli
8791
:prog: block volume-detail
8892
:show-nested:

tests/CLI/modules/block_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,11 @@ def test_dep_dupe_convert(self):
792792

793793
self.assert_no_fail(result)
794794

795+
def test_volume_options(self):
796+
result = self.run_command(['block', 'volume-options'])
797+
798+
self.assert_no_fail(result)
799+
795800
@mock.patch('SoftLayer.BlockStorageManager.volume_set_note')
796801
def test_volume_set_note(self, set_note):
797802
set_note.return_value = True

0 commit comments

Comments
 (0)