Skip to content

Commit 882132b

Browse files
Merge pull request #2055 from softlayer/jayasilan-issue2031
Example and sub feature for slcli file volume-order, volume-refresh, volume-set-note command #2031
2 parents 8562473 + 4b37958 commit 882132b

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

SoftLayer/CLI/file/order.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import SoftLayer
66
from SoftLayer.CLI import environment
77
from SoftLayer.CLI import exceptions
8+
from SoftLayer.CLI import formatting
89

910

1011
CONTEXT_SETTINGS = {'token_normalize_func': lambda x: x.upper()}
@@ -26,7 +27,7 @@
2627
@click.option('--tier',
2728
help='Endurance Storage Tier (IOP per GB) [required for storage-type endurance]',
2829
type=click.Choice(['0.25', '2', '4', '10']))
29-
@click.option('--location',
30+
@click.option('-l', '--location',
3031
help='Datacenter short name (e.g.: dal09)',
3132
required=True)
3233
@click.option('--snapshot-size',
@@ -46,17 +47,31 @@
4647
type=click.Choice(['hourly', 'monthly']),
4748
default='monthly',
4849
help="Optional parameter for Billing rate (default to monthly)")
50+
@click.option('--force', default=False, is_flag=True, help="Force order file storage volume without confirmation")
4951
@environment.pass_env
5052
def cli(env, storage_type, size, iops, tier,
51-
location, snapshot_size, service_offering, billing):
53+
location, snapshot_size, service_offering, billing, force):
5254
"""Order a file storage volume.
5355
56+
Example::
57+
slcli file volume-order --storage-type performance --size 1000 --iops 4000 -d dal09
58+
This command orders a performance volume with size is 1000GB, IOPS is 4000, located at dal09.
59+
60+
slcli file volume-order --storage-type endurance --size 500 --tier 4 -d dal09 --snapshot-size 500
61+
This command orders an endurance volume with size is 500GB, tier level is 4 IOPS per GB,\
62+
located at dal09 with an additional snapshot space size of 500GB
63+
5464
Valid size and iops options can be found here:
5565
https://cloud.ibm.com/docs/FileStorage/index.html#provisioning-considerations
5666
"""
5767
file_manager = SoftLayer.FileStorageManager(env.client)
5868
storage_type = storage_type.lower()
5969

70+
if not force:
71+
if not (env.skip_confirmations or
72+
formatting.confirm("This action will incur charges on your account. Continue?")):
73+
raise exceptions.CLIAbort('Aborted')
74+
6075
hourly_billing_flag = False
6176
if billing.lower() == "hourly":
6277
hourly_billing_flag = True

SoftLayer/CLI/file/refresh.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
help="Cancel current refresh process and initiates the new refresh.")
1414
@environment.pass_env
1515
def cli(env, volume_id, snapshot_id, force_refresh):
16-
"""Refresh a duplicate volume with a snapshot from its parent."""
16+
"""Refresh a duplicate volume with a snapshot from its parent.
17+
18+
Example::
19+
slcli file volume-refresh volume_id snapshot_id
20+
21+
Refresh a duplicate volume_id with a snapshot from its parent snapshot_id.
22+
Refresh a duplicate volume with a snapshot from its parent.
23+
"""
1724
file_manager = SoftLayer.FileStorageManager(env.client)
1825
resp = file_manager.refresh_dupe(volume_id, snapshot_id, force_refresh)
1926

SoftLayer/CLI/file/set_note.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
help='Public notes related to a Storage volume')
1616
@environment.pass_env
1717
def cli(env, volume_id, note):
18-
"""Set note for an existing file storage volume."""
18+
"""Set note for an existing file storage volume.
19+
20+
Example::
21+
slcli file volume-set-note 12345678 --note 'this is my note'
22+
"""
23+
1924
file_manager = SoftLayer.FileStorageManager(env.client)
2025
file_volume_id = helpers.resolve_id(file_manager.resolve_ids, volume_id, 'File Storage')
2126

0 commit comments

Comments
 (0)