Skip to content

Commit 1819853

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 1819853

3 files changed

Lines changed: 110 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: 103 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -170,50 +170,73 @@ 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 '
189+
'times')
190+
parser.add_argument(
191+
'--scenario',
192+
dest="scenario",
193+
metavar="SCENARIO",
194+
choices=[
195+
TRANSFER_SCENARIO_REPLICA,
196+
TRANSFER_SCENARIO_LIVE_MIGRATION],
197+
default=TRANSFER_SCENARIO_REPLICA,
198+
help='The type of scenario to use when creating '
199+
'the Transfer. "replica" will create a '
200+
'monthly-billed Replica which can be '
201+
'executed and deployed as many times as '
202+
'desired, while "live_migration" will '
203+
'create a Transfer which can be synced '
204+
'as many times as needed but only '
205+
'deployed once.')
206+
parser.add_argument(
207+
'--notes',
208+
dest='notes',
209+
help='Notes about the transfer')
210+
parser.add_argument(
211+
'--user-script-global',
212+
action='append',
213+
required=False,
214+
dest="global_scripts",
215+
type=cli_utils.comma_separated_kv_to_dict,
216+
help='A script that will run for a particular '
217+
'os_type. This option can be used multiple '
218+
'times. Use: linux=/path/to/script.sh or '
219+
'windows=/path/to/script.ps1.'
220+
'Can optionally include a script phase: '
221+
'windows=/path/to/script.ps1,phase=osmorphing_pre_os_mount. '
222+
'Supported phases: osmorphing_post_os_mount (default), '
223+
'osmorphing_pre_os_mount.')
224+
parser.add_argument(
225+
'--user-script-instance', action='append',
226+
required=False,
227+
dest="instance_scripts",
228+
type=cli_utils.comma_separated_kv_to_dict,
229+
help='A script that will run for a particular '
230+
'instance specified by the --instance option. '
231+
'This option can be used multiple times. '
232+
'Use: "instance_name"=/path/to/script.sh.'
233+
' This option overwrites any OS specific script '
234+
'specified in --user-script-global for this '
235+
'instance. Can optionally include a script phase: '
236+
'instance_name=/path/to/script.ps1,'
237+
'phase=osmorphing_pre_os_mount. '
238+
'Supported phases: osmorphing_post_os_mount (default), '
239+
'osmorphing_pre_os_mount.')
217240

218241
cli_utils.add_args_for_json_option_to_parser(
219242
parser, 'destination-environment')
@@ -351,27 +374,42 @@ class UpdateTransfer(show.ShowOne):
351374
def get_parser(self, prog_name):
352375
parser = super(UpdateTransfer, self).get_parser(prog_name)
353376
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')
377+
parser.add_argument(
378+
'--notes',
379+
dest='notes',
380+
help='Notes about the transfer.')
381+
parser.add_argument(
382+
'--user-script-global',
383+
action='append',
384+
required=False,
385+
dest="global_scripts",
386+
type=cli_utils.comma_separated_kv_to_dict,
387+
help='A script that will run for a particular '
388+
'os_type. This option can be used multiple '
389+
'times. Use: linux=/path/to/script.sh or '
390+
'windows=/path/to/script.ps1. '
391+
'Omit the path to unregister the script, e.g. "linux=".'
392+
'Can optionally include a script phase: '
393+
'windows=/path/to/script.ps1,phase=osmorphing_pre_os_mount. '
394+
'Supported phases: osmorphing_post_os_mount (default), '
395+
'osmorphing_pre_os_mount.')
396+
parser.add_argument(
397+
'--user-script-instance', action='append',
398+
required=False,
399+
dest="instance_scripts",
400+
type=cli_utils.comma_separated_kv_to_dict,
401+
help='A script that will run for a particular '
402+
'instance specified by the --instance option. '
403+
'This option can be used multiple times. '
404+
'Use: "instance_name"=/path/to/script.sh.'
405+
' This option overwrites any OS specific script '
406+
'specified in --user-script-global for this instance.'
407+
'Omit the path to unregister the script, e.g. "linux=".'
408+
'Can optionally include a script phase: '
409+
'instance_name=/path/to/script.ps1,'
410+
'phase=osmorphing_pre_os_mount. '
411+
'Supported phases: osmorphing_post_os_mount (default), '
412+
'osmorphing_pre_os_mount.')
375413

376414
cli_utils.add_args_for_json_option_to_parser(
377415
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)