Skip to content

Commit 3632cca

Browse files
committed
Improved the docopt docs with example, etc.
1 parent 3afada2 commit 3632cca

2 files changed

Lines changed: 68 additions & 48 deletions

File tree

SoftLayer/CLI/modules/iscsi.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
"""
22
usage: sl iscsi [<command>] [<args>...] [options]
33
4-
Manage iSCSI targets
4+
Manage, order, delete iSCSI targets
55
66
The available commands are:
7-
cancel Cancel iSCSI target
8-
create Create iSCSI target
9-
detail Output details about iSCSI
10-
list List iSCSI targets
7+
cancel Cancel an existing iSCSI target
8+
create Order and create an iSCSI target
9+
detail Output details about an iSCSI
10+
list List iSCSI targets on the account
1111
12-
For several commands, <identifier> will be asked for. This can be the id
13-
for iSCSI.
12+
For several commands, <identifier> will be asked for. This will be the id
13+
for iSCSI target.
1414
"""
1515
from SoftLayer.CLI import (CLIRunnable, Table, no_going_back, FormattedItem)
1616
from SoftLayer.CLI.helpers import (
1717
CLIAbort, ArgumentError, NestedDict, blank, resolve_id, KeyValueTable)
1818
from SoftLayer import ISCSIManager
1919

2020

21-
class ListISCSI(CLIRunnable):
21+
class ListISCSIs(CLIRunnable):
2222

2323
"""
24-
usage: sl iscsi list [options]
24+
usage: sl iscsi list [options]
2525
26-
List iSCSI accounts
26+
List iSCSI targets
2727
"""
2828
action = 'list'
2929

@@ -60,14 +60,19 @@ def execute(self, args):
6060
class CreateISCSI(CLIRunnable):
6161

6262
"""
63-
usage: sl iscsi create [options]
63+
usage: sl iscsi create [options]
6464
65-
Order/create an iSCSI storage.
65+
Orders and creates an iSCSI target.
6666
67-
Required:
68-
-s, --size=SIZE Size of the iSCSI volume to create
69-
-d, --datacenter=DC Datacenter shortname (sng01, dal05, ...)
70-
"""
67+
Examples:
68+
sl iscsi create --size=1 --datacenter=dal05
69+
sl iscsi create --size 1 -d dal05
70+
sl iscsi create -s 1 -d dal05
71+
72+
Required:
73+
-s, --size=SIZE Size of the iSCSI volume to create
74+
-d, --datacenter=DC Datacenter shortname (sng01, dal05, ...)
75+
"""
7176
action = 'create'
7277
options = ['confirm']
7378
required_params = ['--size', '--datacenter']
@@ -83,9 +88,9 @@ def _parse_create_args(self, args):
8388
ISCSIManager.create_iscsi.
8489
:param dict args: CLI arguments
8590
"""
86-
size = int(args['--size'])
87-
location = str(args['--datacenter'])
88-
return size, location
91+
size = args['--size']
92+
location = args['--datacenter']
93+
return int(size), str(location)
8994

9095
def _validate_create_args(self, args):
9196
""" Raises an ArgumentError if the given arguments are not valid """
@@ -100,13 +105,17 @@ class CancelISCSI(CLIRunnable):
100105
"""
101106
usage: sl iscsi cancel <identifier> [options]
102107
103-
Cancel iSCSI Storage
108+
Cancel existing iSCSI
104109
105-
options :
106-
--immediate Cancels the iSCSI immediately (instead of on the billing
107-
anniversary)
108-
--reason=REASON An optional cancellation reason.
110+
Examples:
111+
sl iscsi cancel 12345
112+
sl iscsi cancel 12345 --immediate
113+
sl iscsi cancel 12345 --immediate --reason='no longer needed'
109114
115+
options :
116+
--immediate Cancels the iSCSI immediately (instead of on the billing
117+
anniversary)
118+
--reason=REASON An optional reason for cancellation.
110119
"""
111120
action = 'cancel'
112121
options = ['confirm']
@@ -132,12 +141,14 @@ class ISCSIDetails(CLIRunnable):
132141
"""
133142
usage: sl iscsi detail [--password] <identifier> [options]
134143
135-
Get details for a iSCSI
136-
137-
Options:
138-
--password Show password
144+
Get details for an iSCSI
139145
146+
Examples:
147+
sl iscsi detail 12345
148+
sl iscsi detail 12345 --password
140149
150+
Options:
151+
--password Show credentials to access the iSCSI target
141152
"""
142153
action = 'detail'
143154

SoftLayer/CLI/modules/snapshot.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
"""
22
usage: sl snapshot [<command>] [<args>...] [options]
33
4-
Manage iSCSI snapshots
4+
Manage, order, delete iSCSI snapshots
55
66
The available commands are:
7-
create Create snapshot of iSCSI
8-
create_space Orders space for snapshots
9-
delete Delete iSCSI snapshot
7+
cancel Cancel an iSCSI snapshot
8+
create Create a snapshot of given iSCSI volume
9+
create-space Orders space for storing snapshots
1010
list List snpshots of given iSCSI
11-
restore_volume Restores volume from existing snapshot
11+
restore-volume Restores volume from existing snapshot
1212
13+
For several commands <identifier> will be asked for.This can be the id
14+
of iSCSI volume or iSCSI snapshot.
1315
"""
1416
from SoftLayer.CLI import (CLIRunnable, Table)
1517
from SoftLayer.CLI.helpers import (
@@ -18,15 +20,19 @@
1820
from SoftLayer import ISCSIManager
1921

2022

21-
class ISCSICreateSnapshot(CLIRunnable):
23+
class CreateSnapshot(CLIRunnable):
2224

2325
"""
2426
usage: sl snapshot create <identifier> [options]
2527
26-
create an iSCSI snapshot.
28+
Create a snapshot of the iSCSI volume.
29+
30+
Examples:
31+
sl snapshot create 123456 --note='Backup'
32+
sl snapshot create 123456
2733
2834
Options:
29-
--notes=NOTE An optional note
35+
--notes=NOTE An optional snapshot's note
3036
3137
"""
3238
action = 'create'
@@ -41,18 +47,21 @@ def execute(self, args):
4147
iscsi_mgr.create_snapshot(iscsi_id, notes)
4248

4349

44-
class CreateIscsiSpace(CLIRunnable):
50+
class CreateSnapshotSpace(CLIRunnable):
4551

4652
"""
47-
usage: sl snapshot create_space <identifier> [options]
53+
usage: sl snapshot create-space <identifier> [options]
54+
55+
Orders snapshot space for given iSCSI.
4856
49-
Orders iSCSI snapshot space.
57+
Examples:
58+
sl snapshot create-space 123456 --capacity=20
5059
5160
Required :
52-
--capacity=Capacity Snapshot Capacity
61+
--capacity=CAPACITY Size of snapshot space to create
5362
"""
5463

55-
action = 'create_space'
64+
action = 'create-space'
5665
required_params = ['--capacity']
5766

5867
def execute(self, args):
@@ -69,15 +78,15 @@ def execute(self, args):
6978
iscsi_mgr.create_snapshot_space(iscsi_id, capacity)
7079

7180

72-
class ISCSIDeleteSnapshot(CLIRunnable):
81+
class CancelSnapshot(CLIRunnable):
7382

7483
"""
75-
usage: sl snapshot delete <identifier> [options]
84+
usage: sl snapshot cancel <identifier> [options]
7685
77-
Delete iSCSI snapshot.
86+
Cancel/Delete iSCSI snapshot.
7887
7988
"""
80-
action = 'delete'
89+
action = 'cancel'
8190

8291
def execute(self, args):
8392
iscsi_mgr = ISCSIManager(self.client)
@@ -91,12 +100,12 @@ def execute(self, args):
91100
class RestoreVolumeFromSnapshot(CLIRunnable):
92101

93102
"""
94-
usage: sl snapshot restore_volume <volume_identifier> <snapshot_identifier>
103+
usage: sl snapshot restore-volume <volume_identifier> <snapshot_identifier>
95104
96105
restores volume from existing snapshot.
97106
98107
"""
99-
action = 'restore_volume'
108+
action = 'restore-volume'
100109

101110
def execute(self, args):
102111
iscsi_mgr = ISCSIManager(self.client)
@@ -109,7 +118,7 @@ def execute(self, args):
109118
iscsi_mgr.restore_from_snapshot(volume_id, snapshot_id)
110119

111120

112-
class ListISCSISnapshots(CLIRunnable):
121+
class ListSnapshots(CLIRunnable):
113122

114123
"""
115124
usage: sl snapshot list <identifier>

0 commit comments

Comments
 (0)