Skip to content

Commit 4da502b

Browse files
Merge pull request #969 from allmightyspiff/issues959
#959 added warning message when ordering legacy storage offerings
2 parents e9b174c + b153838 commit 4da502b

File tree

5 files changed

+45
-70
lines changed

5 files changed

+45
-70
lines changed

SoftLayer/CLI/block/order.py

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
required=True)
1818
@click.option('--size',
1919
type=int,
20-
help='Size of block storage volume in GB. Permitted Sizes:\n'
21-
'20, 40, 80, 100, 250, 500, 1000, 2000, 4000, 8000, 12000',
20+
help='Size of block storage volume in GB.',
2221
required=True)
2322
@click.option('--iops',
2423
type=int,
25-
help='Performance Storage IOPs,'
26-
' between 100 and 6000 in multiples of 100'
27-
' [required for storage-type performance]')
24+
help="""Performance Storage IOPs. Options vary based on storage size.
25+
[required for storage-type performance]""")
2826
@click.option('--tier',
29-
help='Endurance Storage Tier (IOP per GB)'
30-
' [required for storage-type endurance]',
27+
help='Endurance Storage Tier (IOP per GB) [required for storage-type endurance]',
3128
type=click.Choice(['0.25', '2', '4', '10']))
3229
@click.option('--os-type',
3330
help='Operating System',
@@ -49,8 +46,8 @@
4946
'space along with endurance block storage; specifies '
5047
'the size (in GB) of snapshot space to order')
5148
@click.option('--service-offering',
52-
help='The service offering package to use for placing '
53-
'the order [optional, default is \'storage_as_a_service\']',
49+
help="""The service offering package to use for placing the order.
50+
[optional, default is \'storage_as_a_service\']. enterprise and performance are depreciated""",
5451
default='storage_as_a_service',
5552
type=click.Choice([
5653
'storage_as_a_service',
@@ -63,34 +60,33 @@
6360
@environment.pass_env
6461
def cli(env, storage_type, size, iops, tier, os_type,
6562
location, snapshot_size, service_offering, billing):
66-
"""Order a block storage volume."""
63+
"""Order a block storage volume.
64+
65+
Valid size and iops options can be found here:
66+
https://console.bluemix.net/docs/infrastructure/BlockStorage/index.html#provisioning
67+
"""
6768
block_manager = SoftLayer.BlockStorageManager(env.client)
6869
storage_type = storage_type.lower()
6970

7071
hourly_billing_flag = False
7172
if billing.lower() == "hourly":
7273
hourly_billing_flag = True
7374

74-
if hourly_billing_flag and service_offering != 'storage_as_a_service':
75-
raise exceptions.CLIAbort(
76-
'Hourly billing is only available for the storage_as_a_service '
77-
'service offering'
78-
)
75+
if service_offering != 'storage_as_a_service':
76+
click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
77+
if hourly_billing_flag:
78+
raise exceptions.CLIAbort(
79+
'Hourly billing is only available for the storage_as_a_service service offering'
80+
)
7981

8082
if storage_type == 'performance':
8183
if iops is None:
82-
raise exceptions.CLIAbort(
83-
'Option --iops required with Performance')
84-
85-
if iops % 100 != 0:
86-
raise exceptions.CLIAbort(
87-
'Option --iops must be a multiple of 100'
88-
)
84+
raise exceptions.CLIAbort('Option --iops required with Performance')
8985

9086
if service_offering == 'performance' and snapshot_size is not None:
9187
raise exceptions.CLIAbort(
92-
'--snapshot-size is not available for performance volumes '
93-
'ordered with the \'performance\' service offering option'
88+
'--snapshot-size is not available for performance service offerings. '
89+
'Use --service-offering storage_as_a_service'
9490
)
9591

9692
try:
@@ -110,8 +106,7 @@ def cli(env, storage_type, size, iops, tier, os_type,
110106
if storage_type == 'endurance':
111107
if tier is None:
112108
raise exceptions.CLIAbort(
113-
'Option --tier required with Endurance in IOPS/GB '
114-
'[0.25,2,4,10]'
109+
'Option --tier required with Endurance in IOPS/GB [0.25,2,4,10]'
115110
)
116111

117112
try:
@@ -134,5 +129,4 @@ def cli(env, storage_type, size, iops, tier, os_type,
134129
for item in order['placedOrder']['items']:
135130
click.echo(" > %s" % item['description'])
136131
else:
137-
click.echo("Order could not be placed! Please verify your options " +
138-
"and try again.")
132+
click.echo("Order could not be placed! Please verify your options and try again.")

SoftLayer/CLI/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def get_command(self, ctx, name):
7575
use: 'slcli setup'""",
7676
cls=CommandLoader,
7777
context_settings={'help_option_names': ['-h', '--help'],
78-
'auto_envvar_prefix': 'SLCLI'})
78+
'auto_envvar_prefix': 'SLCLI',
79+
'max_content_width': 999})
7980
@click.option('--format',
8081
default=DEFAULT_FORMAT,
8182
show_default=True,

SoftLayer/CLI/file/order.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
required=True)
2222
@click.option('--iops',
2323
type=int,
24-
help='Performance Storage IOPs,'
25-
' between 100 and 6000 in multiples of 100'
26-
' [required for storage-type performance]')
24+
help="""Performance Storage IOPs. Options vary based on storage size.
25+
[required for storage-type performance]""")
2726
@click.option('--tier',
28-
help='Endurance Storage Tier (IOP per GB)'
29-
' [required for storage-type endurance]',
27+
help='Endurance Storage Tier (IOP per GB) [required for storage-type endurance]',
3028
type=click.Choice(['0.25', '2', '4', '10']))
3129
@click.option('--location',
3230
help='Datacenter short name (e.g.: dal09)',
@@ -37,8 +35,8 @@
3735
'space along with endurance file storage; specifies '
3836
'the size (in GB) of snapshot space to order')
3937
@click.option('--service-offering',
40-
help='The service offering package to use for placing '
41-
'the order [optional, default is \'storage_as_a_service\']',
38+
help="""The service offering package to use for placing the order.
39+
[optional, default is \'storage_as_a_service\']. enterprise and performance are depreciated""",
4240
default='storage_as_a_service',
4341
type=click.Choice([
4442
'storage_as_a_service',
@@ -51,34 +49,33 @@
5149
@environment.pass_env
5250
def cli(env, storage_type, size, iops, tier,
5351
location, snapshot_size, service_offering, billing):
54-
"""Order a file storage volume."""
52+
"""Order a file storage volume.
53+
54+
Valid size and iops options can be found here:
55+
https://console.bluemix.net/docs/infrastructure/FileStorage/index.html#provisioning
56+
"""
5557
file_manager = SoftLayer.FileStorageManager(env.client)
5658
storage_type = storage_type.lower()
5759

5860
hourly_billing_flag = False
5961
if billing.lower() == "hourly":
6062
hourly_billing_flag = True
6163

62-
if hourly_billing_flag and service_offering != 'storage_as_a_service':
63-
raise exceptions.CLIAbort(
64-
'Hourly billing is only available for the storage_as_a_service '
65-
'service offering'
66-
)
64+
if service_offering != 'storage_as_a_service':
65+
click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
66+
if hourly_billing_flag:
67+
raise exceptions.CLIAbort(
68+
'Hourly billing is only available for the storage_as_a_service service offering'
69+
)
6770

6871
if storage_type == 'performance':
6972
if iops is None:
70-
raise exceptions.CLIAbort(
71-
'Option --iops required with Performance')
72-
73-
if iops % 100 != 0:
74-
raise exceptions.CLIAbort(
75-
'Option --iops must be a multiple of 100'
76-
)
73+
raise exceptions.CLIAbort('Option --iops required with Performance')
7774

7875
if service_offering == 'performance' and snapshot_size is not None:
7976
raise exceptions.CLIAbort(
80-
'--snapshot-size is not available for performance volumes '
81-
'ordered with the \'performance\' service offering option'
77+
'--snapshot-size is not available for performance service offerings. '
78+
'Use --service-offering storage_as_a_service'
8279
)
8380

8481
try:
@@ -97,8 +94,7 @@ def cli(env, storage_type, size, iops, tier,
9794
if storage_type == 'endurance':
9895
if tier is None:
9996
raise exceptions.CLIAbort(
100-
'Option --tier required with Endurance in IOPS/GB '
101-
'[0.25,2,4,10]'
97+
'Option --tier required with Endurance in IOPS/GB [0.25,2,4,10]'
10298
)
10399

104100
try:
@@ -120,5 +116,4 @@ def cli(env, storage_type, size, iops, tier,
120116
for item in order['placedOrder']['items']:
121117
click.echo(" > %s" % item['description'])
122118
else:
123-
click.echo("Order could not be placed! Please verify your options " +
124-
"and try again.")
119+
click.echo("Order could not be placed! Please verify your options and try again.")

tests/CLI/modules/block_tests.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ def test_volume_order_performance_iops_not_given(self):
141141

142142
self.assertEqual(2, result.exit_code)
143143

144-
def test_volume_order_performance_iops_not_multiple_of_100(self):
145-
result = self.run_command(['block', 'volume-order',
146-
'--storage-type=performance', '--size=20',
147-
'--iops=122', '--os-type=linux',
148-
'--location=dal05'])
149-
150-
self.assertEqual(2, result.exit_code)
151-
152144
def test_volume_order_performance_snapshot_error(self):
153145
result = self.run_command(['block', 'volume-order',
154146
'--storage-type=performance', '--size=20',

tests/CLI/modules/file_tests.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,6 @@ def test_volume_order_performance_iops_not_given(self):
144144

145145
self.assertEqual(2, result.exit_code)
146146

147-
def test_volume_order_performance_iops_not_multiple_of_100(self):
148-
result = self.run_command(['file', 'volume-order',
149-
'--storage-type=performance', '--size=20',
150-
'--iops=122', '--location=dal05'])
151-
152-
self.assertEqual(2, result.exit_code)
153-
154147
def test_volume_order_performance_snapshot_error(self):
155148
result = self.run_command(['file', 'volume-order',
156149
'--storage-type=performance', '--size=20',

0 commit comments

Comments
 (0)