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
50 changes: 22 additions & 28 deletions SoftLayer/CLI/block/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
required=True)
@click.option('--size',
type=int,
help='Size of block storage volume in GB. Permitted Sizes:\n'
'20, 40, 80, 100, 250, 500, 1000, 2000, 4000, 8000, 12000',
help='Size of block storage volume in GB.',
required=True)
@click.option('--iops',
type=int,
help='Performance Storage IOPs,'
' between 100 and 6000 in multiples of 100'
' [required for storage-type performance]')
help="""Performance Storage IOPs. Options vary based on storage size.
[required for storage-type performance]""")
@click.option('--tier',
help='Endurance Storage Tier (IOP per GB)'
' [required for storage-type endurance]',
help='Endurance Storage Tier (IOP per GB) [required for storage-type endurance]',
type=click.Choice(['0.25', '2', '4', '10']))
@click.option('--os-type',
help='Operating System',
Expand All @@ -49,8 +46,8 @@
'space along with endurance block storage; specifies '
'the size (in GB) of snapshot space to order')
@click.option('--service-offering',
help='The service offering package to use for placing '
'the order [optional, default is \'storage_as_a_service\']',
help="""The service offering package to use for placing the order.
[optional, default is \'storage_as_a_service\']. enterprise and performance are depreciated""",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, but I noticed it is only here in the block volume order command. Would it be possible to add it to SoftLayer/CLI/file/order.py as well?

default='storage_as_a_service',
type=click.Choice([
'storage_as_a_service',
Expand All @@ -63,34 +60,33 @@
@environment.pass_env
def cli(env, storage_type, size, iops, tier, os_type,
location, snapshot_size, service_offering, billing):
"""Order a block storage volume."""
"""Order a block storage volume.

Valid size and iops options can be found here:
https://console.bluemix.net/docs/infrastructure/BlockStorage/index.html#provisioning
"""
block_manager = SoftLayer.BlockStorageManager(env.client)
storage_type = storage_type.lower()

hourly_billing_flag = False
if billing.lower() == "hourly":
hourly_billing_flag = True

if hourly_billing_flag and service_offering != 'storage_as_a_service':
raise exceptions.CLIAbort(
'Hourly billing is only available for the storage_as_a_service '
'service offering'
)
if service_offering != 'storage_as_a_service':
click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
if hourly_billing_flag:
raise exceptions.CLIAbort(
'Hourly billing is only available for the storage_as_a_service service offering'
)

if storage_type == 'performance':
if iops is None:
raise exceptions.CLIAbort(
'Option --iops required with Performance')

if iops % 100 != 0:
raise exceptions.CLIAbort(
'Option --iops must be a multiple of 100'
)
raise exceptions.CLIAbort('Option --iops required with Performance')

if service_offering == 'performance' and snapshot_size is not None:
raise exceptions.CLIAbort(
'--snapshot-size is not available for performance volumes '
'ordered with the \'performance\' service offering option'
'--snapshot-size is not available for performance service offerings. '
'Use --service-offering storage_as_a_service'
)

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

try:
Expand All @@ -134,5 +129,4 @@ def cli(env, storage_type, size, iops, tier, os_type,
for item in order['placedOrder']['items']:
click.echo(" > %s" % item['description'])
else:
click.echo("Order could not be placed! Please verify your options " +
"and try again.")
click.echo("Order could not be placed! Please verify your options and try again.")
3 changes: 2 additions & 1 deletion SoftLayer/CLI/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def get_command(self, ctx, name):
use: 'slcli setup'""",
cls=CommandLoader,
context_settings={'help_option_names': ['-h', '--help'],
'auto_envvar_prefix': 'SLCLI'})
'auto_envvar_prefix': 'SLCLI',
'max_content_width': 999})
@click.option('--format',
default=DEFAULT_FORMAT,
show_default=True,
Expand Down
47 changes: 21 additions & 26 deletions SoftLayer/CLI/file/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
required=True)
@click.option('--iops',
type=int,
help='Performance Storage IOPs,'
' between 100 and 6000 in multiples of 100'
' [required for storage-type performance]')
help="""Performance Storage IOPs. Options vary based on storage size.
[required for storage-type performance]""")
@click.option('--tier',
help='Endurance Storage Tier (IOP per GB)'
' [required for storage-type endurance]',
help='Endurance Storage Tier (IOP per GB) [required for storage-type endurance]',
type=click.Choice(['0.25', '2', '4', '10']))
@click.option('--location',
help='Datacenter short name (e.g.: dal09)',
Expand All @@ -37,8 +35,8 @@
'space along with endurance file storage; specifies '
'the size (in GB) of snapshot space to order')
@click.option('--service-offering',
help='The service offering package to use for placing '
'the order [optional, default is \'storage_as_a_service\']',
help="""The service offering package to use for placing the order.
[optional, default is \'storage_as_a_service\']. enterprise and performance are depreciated""",
default='storage_as_a_service',
type=click.Choice([
'storage_as_a_service',
Expand All @@ -51,34 +49,33 @@
@environment.pass_env
def cli(env, storage_type, size, iops, tier,
location, snapshot_size, service_offering, billing):
"""Order a file storage volume."""
"""Order a file storage volume.

Valid size and iops options can be found here:
https://console.bluemix.net/docs/infrastructure/FileStorage/index.html#provisioning
"""
file_manager = SoftLayer.FileStorageManager(env.client)
storage_type = storage_type.lower()

hourly_billing_flag = False
if billing.lower() == "hourly":
hourly_billing_flag = True

if hourly_billing_flag and service_offering != 'storage_as_a_service':
raise exceptions.CLIAbort(
'Hourly billing is only available for the storage_as_a_service '
'service offering'
)
if service_offering != 'storage_as_a_service':
click.secho('{} is a legacy storage offering'.format(service_offering), fg='red')
if hourly_billing_flag:
raise exceptions.CLIAbort(
'Hourly billing is only available for the storage_as_a_service service offering'
)

if storage_type == 'performance':
if iops is None:
raise exceptions.CLIAbort(
'Option --iops required with Performance')

if iops % 100 != 0:
raise exceptions.CLIAbort(
'Option --iops must be a multiple of 100'
)
raise exceptions.CLIAbort('Option --iops required with Performance')

if service_offering == 'performance' and snapshot_size is not None:
raise exceptions.CLIAbort(
'--snapshot-size is not available for performance volumes '
'ordered with the \'performance\' service offering option'
'--snapshot-size is not available for performance service offerings. '
'Use --service-offering storage_as_a_service'
)

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

try:
Expand All @@ -120,5 +116,4 @@ def cli(env, storage_type, size, iops, tier,
for item in order['placedOrder']['items']:
click.echo(" > %s" % item['description'])
else:
click.echo("Order could not be placed! Please verify your options " +
"and try again.")
click.echo("Order could not be placed! Please verify your options and try again.")
8 changes: 0 additions & 8 deletions tests/CLI/modules/block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ def test_volume_order_performance_iops_not_given(self):

self.assertEqual(2, result.exit_code)

def test_volume_order_performance_iops_not_multiple_of_100(self):
result = self.run_command(['block', 'volume-order',
'--storage-type=performance', '--size=20',
'--iops=122', '--os-type=linux',
'--location=dal05'])

self.assertEqual(2, result.exit_code)

def test_volume_order_performance_snapshot_error(self):
result = self.run_command(['block', 'volume-order',
'--storage-type=performance', '--size=20',
Expand Down
7 changes: 0 additions & 7 deletions tests/CLI/modules/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,6 @@ def test_volume_order_performance_iops_not_given(self):

self.assertEqual(2, result.exit_code)

def test_volume_order_performance_iops_not_multiple_of_100(self):
result = self.run_command(['file', 'volume-order',
'--storage-type=performance', '--size=20',
'--iops=122', '--location=dal05'])

self.assertEqual(2, result.exit_code)

def test_volume_order_performance_snapshot_error(self):
result = self.run_command(['file', 'volume-order',
'--storage-type=performance', '--size=20',
Expand Down