Skip to content

Commit 82cf920

Browse files
Update user script help strings
* specify the supported phases and which one is the default * mention the fact that when updating transfers, the script path can be omitted in order to unregister it
1 parent b557fad commit 82cf920

3 files changed

Lines changed: 109 additions & 69 deletions

File tree

coriolisclient/cli/deployments.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def get_parser(self, prog_name):
192192
'Use: linux=/path/to/script.sh or '
193193
'windows=/path/to/script.ps1. '
194194
'Can optionally include a script phase: '
195-
'windows=/path/to/script.ps1,phase=osmorphing_pre_os_mount.')
195+
'windows=/path/to/script.ps1,phase=osmorphing_pre_os_mount. '
196+
'Supported phases: osmorphing_post_os_mount (default), '
197+
'osmorphing_pre_os_mount.')
196198
parser.add_argument(
197199
'--user-script-instance',
198200
action='append',
@@ -207,7 +209,9 @@ def get_parser(self, prog_name):
207209
'specified in --user-script-global for this '
208210
'instance. Can optionally include a script phase: '
209211
'instance_name=/path/to/script.ps1,'
210-
'phase=osmorphing_pre_os_mount.')
212+
'phase=osmorphing_pre_os_mount. '
213+
'Supported phases: osmorphing_post_os_mount (default), '
214+
'osmorphing_pre_os_mount.')
211215
cli_utils.add_minion_pool_args_to_parser(
212216
parser, include_origin_pool_arg=False,
213217
include_destination_pool_arg=False,

coriolisclient/cli/transfers.py

Lines changed: 102 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -170,50 +170,72 @@ class CreateTransfer(show.ShowOne):
170170
"""Create a new transfer"""
171171
def get_parser(self, prog_name):
172172
parser = super(CreateTransfer, self).get_parser(prog_name)
173-
parser.add_argument('--origin-endpoint', required=True,
174-
help='The origin endpoint id')
175-
parser.add_argument('--destination-endpoint', required=True,
176-
help='The destination endpoint id')
177-
parser.add_argument('--instance', action='append', required=True,
178-
dest="instances", metavar="INSTANCE_IDENTIFIER",
179-
help='The identifier of a source instance to be '
180-
'transferred. Can be specified multiple '
181-
'times')
182-
parser.add_argument('--scenario',
183-
dest="scenario", metavar="SCENARIO",
184-
choices=[
185-
TRANSFER_SCENARIO_REPLICA,
186-
TRANSFER_SCENARIO_LIVE_MIGRATION],
187-
default=TRANSFER_SCENARIO_REPLICA,
188-
help='The type of scenario to use when creating '
189-
'the Transfer. "replica" will create a '
190-
'monthly-billed Replica which can be '
191-
'executed and deployed as many times as '
192-
'desired, while "live_migration" will '
193-
'create a Transfer which can be synced '
194-
'as many times as needed but only '
195-
'deployed once.')
196-
parser.add_argument('--notes', dest='notes',
197-
help='Notes about the transfer')
198-
parser.add_argument('--user-script-global', action='append',
199-
required=False,
200-
dest="global_scripts",
201-
type=cli_utils.comma_separated_kv_to_dict,
202-
help='A script that will run for a particular '
203-
'os_type. This option can be used multiple '
204-
'times. Use: linux=/path/to/script.sh or '
205-
'windows=/path/to/script.ps1')
206-
parser.add_argument('--user-script-instance', action='append',
207-
required=False,
208-
dest="instance_scripts",
209-
type=cli_utils.comma_separated_kv_to_dict,
210-
help='A script that will run for a particular '
211-
'instance specified by the --instance option. '
212-
'This option can be used multiple times. '
213-
'Use: "instance_name"=/path/to/script.sh.'
214-
' This option overwrites any OS specific script '
215-
'specified in --user-script-global for this '
216-
'instance')
173+
parser.add_argument(
174+
'--origin-endpoint',
175+
required=True,
176+
help='The origin endpoint id')
177+
parser.add_argument(
178+
'--destination-endpoint',
179+
required=True,
180+
help='The destination endpoint id')
181+
parser.add_argument(
182+
'--instance',
183+
action='append',
184+
required=True,
185+
dest="instances",
186+
metavar="INSTANCE_IDENTIFIER",
187+
help='The identifier of a source instance to be '
188+
'transferred. Can be specified multiple times')
189+
parser.add_argument(
190+
'--scenario',
191+
dest="scenario",
192+
metavar="SCENARIO",
193+
choices=[
194+
TRANSFER_SCENARIO_REPLICA,
195+
TRANSFER_SCENARIO_LIVE_MIGRATION],
196+
default=TRANSFER_SCENARIO_REPLICA,
197+
help='The type of scenario to use when creating '
198+
'the Transfer. "replica" will create a '
199+
'monthly-billed Replica which can be '
200+
'executed and deployed as many times as '
201+
'desired, while "live_migration" will '
202+
'create a Transfer which can be synced '
203+
'as many times as needed but only '
204+
'deployed once.')
205+
parser.add_argument(
206+
'--notes',
207+
dest='notes',
208+
help='Notes about the transfer')
209+
parser.add_argument(
210+
'--user-script-global',
211+
action='append',
212+
required=False,
213+
dest="global_scripts",
214+
type=cli_utils.comma_separated_kv_to_dict,
215+
help='A script that will run for a particular '
216+
'os_type. This option can be used multiple '
217+
'times. Use: linux=/path/to/script.sh or '
218+
'windows=/path/to/script.ps1.'
219+
'Can optionally include a script phase: '
220+
'windows=/path/to/script.ps1,phase=osmorphing_pre_os_mount. '
221+
'Supported phases: osmorphing_post_os_mount (default), '
222+
'osmorphing_pre_os_mount.')
223+
parser.add_argument(
224+
'--user-script-instance', action='append',
225+
required=False,
226+
dest="instance_scripts",
227+
type=cli_utils.comma_separated_kv_to_dict,
228+
help='A script that will run for a particular '
229+
'instance specified by the --instance option. '
230+
'This option can be used multiple times. '
231+
'Use: "instance_name"=/path/to/script.sh.'
232+
' This option overwrites any OS specific script '
233+
'specified in --user-script-global for this '
234+
'instance. Can optionally include a script phase: '
235+
'instance_name=/path/to/script.ps1,'
236+
'phase=osmorphing_pre_os_mount. '
237+
'Supported phases: osmorphing_post_os_mount (default), '
238+
'osmorphing_pre_os_mount.')
217239

218240
cli_utils.add_args_for_json_option_to_parser(
219241
parser, 'destination-environment')
@@ -351,27 +373,42 @@ class UpdateTransfer(show.ShowOne):
351373
def get_parser(self, prog_name):
352374
parser = super(UpdateTransfer, self).get_parser(prog_name)
353375
parser.add_argument('id', help='The transfer\'s id')
354-
parser.add_argument('--notes', dest='notes',
355-
help='Notes about the transfer.')
356-
parser.add_argument('--user-script-global', action='append',
357-
required=False,
358-
dest="global_scripts",
359-
type=cli_utils.comma_separated_kv_to_dict,
360-
help='A script that will run for a particular '
361-
'os_type. This option can be used multiple '
362-
'times. Use: linux=/path/to/script.sh or '
363-
'windows=/path/to/script.ps1')
364-
parser.add_argument('--user-script-instance', action='append',
365-
required=False,
366-
dest="instance_scripts",
367-
type=cli_utils.comma_separated_kv_to_dict,
368-
help='A script that will run for a particular '
369-
'instance specified by the --instance option. '
370-
'This option can be used multiple times. '
371-
'Use: "instance_name"=/path/to/script.sh.'
372-
' This option overwrites any OS specific script '
373-
'specified in --user-script-global for this '
374-
'instance')
376+
parser.add_argument(
377+
'--notes',
378+
dest='notes',
379+
help='Notes about the transfer.')
380+
parser.add_argument(
381+
'--user-script-global',
382+
action='append',
383+
required=False,
384+
dest="global_scripts",
385+
type=cli_utils.comma_separated_kv_to_dict,
386+
help='A script that will run for a particular '
387+
'os_type. This option can be used multiple '
388+
'times. Use: linux=/path/to/script.sh or '
389+
'windows=/path/to/script.ps1. '
390+
'Omit the path to unregister the script, e.g. "linux=".'
391+
'Can optionally include a script phase: '
392+
'windows=/path/to/script.ps1,phase=osmorphing_pre_os_mount. '
393+
'Supported phases: osmorphing_post_os_mount (default), '
394+
'osmorphing_pre_os_mount.')
395+
parser.add_argument(
396+
'--user-script-instance', action='append',
397+
required=False,
398+
dest="instance_scripts",
399+
type=cli_utils.comma_separated_kv_to_dict,
400+
help='A script that will run for a particular '
401+
'instance specified by the --instance option. '
402+
'This option can be used multiple times. '
403+
'Use: "instance_name"=/path/to/script.sh.'
404+
' This option overwrites any OS specific script '
405+
'specified in --user-script-global for this instance.'
406+
'Omit the path to unregister the script, e.g. "linux=".'
407+
'Can optionally include a script phase: '
408+
'instance_name=/path/to/script.ps1,'
409+
'phase=osmorphing_pre_os_mount. '
410+
'Supported phases: osmorphing_post_os_mount (default), '
411+
'osmorphing_pre_os_mount.')
375412

376413
cli_utils.add_args_for_json_option_to_parser(
377414
parser, 'destination-environment')

coriolisclient/cli/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ def compose_user_scripts(
246246
"OS type not specified. "
247247
"Available options are: %s" % ", ".join(constants.OS_LIST))
248248
if len(params.keys()) > 1:
249-
raise ValueError(
250-
"Too many parameters. Expecting just the OS type.")
249+
raise ValueError("Too many parameters.")
251250
os_type = list(params.keys())[0]
252251
script_path = params[os_type]
253252
if os_type not in constants.OS_LIST:

0 commit comments

Comments
 (0)