compute: Shuffle options for 'server create'

argparse doesn't sort options by name, meaning we can use the
opportunity to group closely related options together. Do that.

Change-Id: I6714c8db1a549bd4206d2282d2876a406af65aa2
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2020-12-10 14:13:47 +00:00
parent 7ed4f68c68
commit d6c9b7f198

View File

@ -621,6 +621,12 @@ class CreateServer(command.ShowOne):
metavar='<server-name>',
help=_('New server name'),
)
parser.add_argument(
'--flavor',
metavar='<flavor>',
required=True,
help=_('Create server with this flavor (name or ID)'),
)
disk_group = parser.add_mutually_exclusive_group(
required=True,
)
@ -629,12 +635,17 @@ class CreateServer(command.ShowOne):
metavar='<image>',
help=_('Create server boot disk from this image (name or ID)'),
)
# TODO(stephenfin): Is this actually useful? Looks like a straight port
# from 'nova boot --image-with'. Perhaps we should deprecate this.
disk_group.add_argument(
'--image-property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
dest='image_properties',
help=_("Image property to be matched"),
help=_(
"Create server using the image that matches the specified "
"property. Property must match exactly one property."
),
)
disk_group.add_argument(
'--volume',
@ -649,17 +660,101 @@ class CreateServer(command.ShowOne):
'volume.'
),
)
parser.add_argument(
'--boot-from-volume',
metavar='<volume-size>',
type=int,
help=_(
'When used in conjunction with the ``--image`` or '
'``--image-property`` option, this option automatically '
'creates a block device mapping with a boot index of 0 '
'and tells the compute service to create a volume of the '
'given size (in GB) from the specified image and use it '
'as the root disk of the server. The root volume will not '
'be deleted when the server is deleted. This option is '
'mutually exclusive with the ``--volume`` option.'
)
)
parser.add_argument(
'--block-device-mapping',
metavar='<dev-name=mapping>',
action=parseractions.KeyValueAction,
default={},
# NOTE(RuiChen): Add '\n' to the end of line to improve formatting;
# see cliff's _SmartHelpFormatter for more details.
help=_(
'Create a block device on the server.\n'
'Block device mapping in the format\n'
'<dev-name>=<id>:<type>:<size(GB)>:<delete-on-terminate>\n'
'<dev-name>: block device name, like: vdb, xvdc '
'(required)\n'
'<id>: Name or ID of the volume, volume snapshot or image '
'(required)\n'
'<type>: volume, snapshot or image; default: volume '
'(optional)\n'
'<size(GB)>: volume size if create from image or snapshot '
'(optional)\n'
'<delete-on-terminate>: true or false; default: false '
'(optional)\n'
),
)
parser.add_argument(
'--network',
metavar="<network>",
action='append',
dest='nic',
type=_prefix_checked_value('net-id='),
# NOTE(RuiChen): Add '\n' to the end of line to improve formatting;
# see cliff's _SmartHelpFormatter for more details.
help=_(
"Create a NIC on the server and connect it to network. "
"Specify option multiple times to create multiple NICs. "
"This is a wrapper for the '--nic net-id=<network>' "
"parameter that provides simple syntax for the standard "
"use case of connecting a new server to a given network. "
"For more advanced use cases, refer to the '--nic' "
"parameter."
),
)
parser.add_argument(
'--port',
metavar="<port>",
action='append',
dest='nic',
type=_prefix_checked_value('port-id='),
help=_(
"Create a NIC on the server and connect it to port. "
"Specify option multiple times to create multiple NICs. "
"This is a wrapper for the '--nic port-id=<port>' "
"parameter that provides simple syntax for the standard "
"use case of connecting a new server to a given port. For "
"more advanced use cases, refer to the '--nic' parameter."
),
)
parser.add_argument(
'--nic',
metavar="<net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,"
"port-id=port-uuid,auto,none>",
action='append',
help=_(
"Create a NIC on the server. "
"Specify option multiple times to create multiple NICs. "
"Either net-id or port-id must be provided, but not both. "
"net-id: attach NIC to network with this UUID, "
"port-id: attach NIC to port with this UUID, "
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
"none: (v2.37+) no network is attached, "
"auto: (v2.37+) the compute service will automatically "
"allocate a network. Specifying a --nic of auto or none "
"cannot be used with any other --nic value."
),
)
parser.add_argument(
'--password',
metavar='<password>',
help=_("Set the password to this server"),
)
parser.add_argument(
'--flavor',
metavar='<flavor>',
required=True,
help=_('Create server with this flavor (name or ID)'),
)
parser.add_argument(
'--security-group',
metavar='<security-group>',
@ -736,95 +831,6 @@ class CreateServer(command.ShowOne):
'(supported by --os-compute-api-version 2.74 or above)'
),
)
parser.add_argument(
'--boot-from-volume',
metavar='<volume-size>',
type=int,
help=_(
'When used in conjunction with the ``--image`` or '
'``--image-property`` option, this option automatically '
'creates a block device mapping with a boot index of 0 '
'and tells the compute service to create a volume of the '
'given size (in GB) from the specified image and use it '
'as the root disk of the server. The root volume will not '
'be deleted when the server is deleted. This option is '
'mutually exclusive with the ``--volume`` option.'
)
)
parser.add_argument(
'--block-device-mapping',
metavar='<dev-name=mapping>',
action=parseractions.KeyValueAction,
default={},
# NOTE(RuiChen): Add '\n' at the end of line to put each item in
# the separated line, avoid the help message looks
# messy, see _SmartHelpFormatter in cliff.
help=_(
'Create a block device on the server.\n'
'Block device mapping in the format\n'
'<dev-name>=<id>:<type>:<size(GB)>:<delete-on-terminate>\n'
'<dev-name>: block device name, like: vdb, xvdc '
'(required)\n'
'<id>: Name or ID of the volume, volume snapshot or image '
'(required)\n'
'<type>: volume, snapshot or image; default: volume '
'(optional)\n'
'<size(GB)>: volume size if create from image or snapshot '
'(optional)\n'
'<delete-on-terminate>: true or false; default: false '
'(optional)\n'
),
)
parser.add_argument(
'--nic',
metavar="<net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,"
"port-id=port-uuid,auto,none>",
action='append',
help=_(
"Create a NIC on the server. "
"Specify option multiple times to create multiple NICs. "
"Either net-id or port-id must be provided, but not both. "
"net-id: attach NIC to network with this UUID, "
"port-id: attach NIC to port with this UUID, "
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
"none: (v2.37+) no network is attached, "
"auto: (v2.37+) the compute service will automatically "
"allocate a network. Specifying a --nic of auto or none "
"cannot be used with any other --nic value."
),
)
parser.add_argument(
'--network',
metavar="<network>",
action='append',
dest='nic',
type=_prefix_checked_value('net-id='),
help=_(
"Create a NIC on the server and connect it to network. "
"Specify option multiple times to create multiple NICs. "
"This is a wrapper for the '--nic net-id=<network>' "
"parameter that provides simple syntax for the standard "
"use case of connecting a new server to a given network. "
"For more advanced use cases, refer to the '--nic' "
"parameter."
),
)
parser.add_argument(
'--port',
metavar="<port>",
action='append',
dest='nic',
type=_prefix_checked_value('port-id='),
help=_(
"Create a NIC on the server and connect it to port. "
"Specify option multiple times to create multiple NICs. "
"This is a wrapper for the '--nic port-id=<port>' "
"parameter that provides simple syntax for the standard "
"use case of connecting a new server to a given port. For "
"more advanced use cases, refer to the '--nic' parameter."
),
)
parser.add_argument(
'--hint',
metavar='<key=value>',