Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Example and sub feature for slcli file volume-order, volume-refresh, volume-set-note command
  • Loading branch information
J Jayasilan authored and J Jayasilan committed Jul 27, 2023
1 parent 029e87d commit 4b37958
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
19 changes: 17 additions & 2 deletions SoftLayer/CLI/file/order.py
Expand Up @@ -5,6 +5,7 @@
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.CLI import formatting


CONTEXT_SETTINGS = {'token_normalize_func': lambda x: x.upper()}
Expand All @@ -26,7 +27,7 @@
@click.option('--tier',
help='Endurance Storage Tier (IOP per GB) [required for storage-type endurance]',
type=click.Choice(['0.25', '2', '4', '10']))
@click.option('--location',
@click.option('-l', '--location',
help='Datacenter short name (e.g.: dal09)',
required=True)
@click.option('--snapshot-size',
Expand All @@ -46,17 +47,31 @@
type=click.Choice(['hourly', 'monthly']),
default='monthly',
help="Optional parameter for Billing rate (default to monthly)")
@click.option('--force', default=False, is_flag=True, help="Force order file storage volume without confirmation")
@environment.pass_env
def cli(env, storage_type, size, iops, tier,
location, snapshot_size, service_offering, billing):
location, snapshot_size, service_offering, billing, force):
"""Order a file storage volume.
Example::
slcli file volume-order --storage-type performance --size 1000 --iops 4000 -d dal09
This command orders a performance volume with size is 1000GB, IOPS is 4000, located at dal09.
slcli file volume-order --storage-type endurance --size 500 --tier 4 -d dal09 --snapshot-size 500
This command orders an endurance volume with size is 500GB, tier level is 4 IOPS per GB,\
located at dal09 with an additional snapshot space size of 500GB
Valid size and iops options can be found here:
https://cloud.ibm.com/docs/FileStorage/index.html#provisioning-considerations
"""
file_manager = SoftLayer.FileStorageManager(env.client)
storage_type = storage_type.lower()

if not force:
if not (env.skip_confirmations or
formatting.confirm("This action will incur charges on your account. Continue?")):
raise exceptions.CLIAbort('Aborted')

hourly_billing_flag = False
if billing.lower() == "hourly":
hourly_billing_flag = True
Expand Down
9 changes: 8 additions & 1 deletion SoftLayer/CLI/file/refresh.py
Expand Up @@ -13,7 +13,14 @@
help="Cancel current refresh process and initiates the new refresh.")
@environment.pass_env
def cli(env, volume_id, snapshot_id, force_refresh):
"""Refresh a duplicate volume with a snapshot from its parent."""
"""Refresh a duplicate volume with a snapshot from its parent.
Example::
slcli file volume-refresh volume_id snapshot_id
Refresh a duplicate volume_id with a snapshot from its parent snapshot_id.
Refresh a duplicate volume with a snapshot from its parent.
"""
file_manager = SoftLayer.FileStorageManager(env.client)
resp = file_manager.refresh_dupe(volume_id, snapshot_id, force_refresh)

Expand Down
7 changes: 6 additions & 1 deletion SoftLayer/CLI/file/set_note.py
Expand Up @@ -15,7 +15,12 @@
help='Public notes related to a Storage volume')
@environment.pass_env
def cli(env, volume_id, note):
"""Set note for an existing file storage volume."""
"""Set note for an existing file storage volume.
Example::
slcli file volume-set-note 12345678 --note 'this is my note'
"""

file_manager = SoftLayer.FileStorageManager(env.client)
file_volume_id = helpers.resolve_id(file_manager.resolve_ids, volume_id, 'File Storage')

Expand Down

0 comments on commit 4b37958

Please sign in to comment.