Skip to content

Commit b9f61f7

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "compute: Shuffle options for 'server create'"
2 parents d4f8aa1 + d6c9b7f commit b9f61f7

1 file changed

Lines changed: 102 additions & 96 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 102 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,12 @@ def get_parser(self, prog_name):
621621
metavar='<server-name>',
622622
help=_('New server name'),
623623
)
624+
parser.add_argument(
625+
'--flavor',
626+
metavar='<flavor>',
627+
required=True,
628+
help=_('Create server with this flavor (name or ID)'),
629+
)
624630
disk_group = parser.add_mutually_exclusive_group(
625631
required=True,
626632
)
@@ -629,12 +635,17 @@ def get_parser(self, prog_name):
629635
metavar='<image>',
630636
help=_('Create server boot disk from this image (name or ID)'),
631637
)
638+
# TODO(stephenfin): Is this actually useful? Looks like a straight port
639+
# from 'nova boot --image-with'. Perhaps we should deprecate this.
632640
disk_group.add_argument(
633641
'--image-property',
634642
metavar='<key=value>',
635643
action=parseractions.KeyValueAction,
636644
dest='image_properties',
637-
help=_("Image property to be matched"),
645+
help=_(
646+
"Create server using the image that matches the specified "
647+
"property. Property must match exactly one property."
648+
),
638649
)
639650
disk_group.add_argument(
640651
'--volume',
@@ -649,17 +660,101 @@ def get_parser(self, prog_name):
649660
'volume.'
650661
),
651662
)
663+
parser.add_argument(
664+
'--boot-from-volume',
665+
metavar='<volume-size>',
666+
type=int,
667+
help=_(
668+
'When used in conjunction with the ``--image`` or '
669+
'``--image-property`` option, this option automatically '
670+
'creates a block device mapping with a boot index of 0 '
671+
'and tells the compute service to create a volume of the '
672+
'given size (in GB) from the specified image and use it '
673+
'as the root disk of the server. The root volume will not '
674+
'be deleted when the server is deleted. This option is '
675+
'mutually exclusive with the ``--volume`` option.'
676+
)
677+
)
678+
parser.add_argument(
679+
'--block-device-mapping',
680+
metavar='<dev-name=mapping>',
681+
action=parseractions.KeyValueAction,
682+
default={},
683+
# NOTE(RuiChen): Add '\n' to the end of line to improve formatting;
684+
# see cliff's _SmartHelpFormatter for more details.
685+
help=_(
686+
'Create a block device on the server.\n'
687+
'Block device mapping in the format\n'
688+
'<dev-name>=<id>:<type>:<size(GB)>:<delete-on-terminate>\n'
689+
'<dev-name>: block device name, like: vdb, xvdc '
690+
'(required)\n'
691+
'<id>: Name or ID of the volume, volume snapshot or image '
692+
'(required)\n'
693+
'<type>: volume, snapshot or image; default: volume '
694+
'(optional)\n'
695+
'<size(GB)>: volume size if create from image or snapshot '
696+
'(optional)\n'
697+
'<delete-on-terminate>: true or false; default: false '
698+
'(optional)\n'
699+
),
700+
)
701+
parser.add_argument(
702+
'--network',
703+
metavar="<network>",
704+
action='append',
705+
dest='nic',
706+
type=_prefix_checked_value('net-id='),
707+
# NOTE(RuiChen): Add '\n' to the end of line to improve formatting;
708+
# see cliff's _SmartHelpFormatter for more details.
709+
help=_(
710+
"Create a NIC on the server and connect it to network. "
711+
"Specify option multiple times to create multiple NICs. "
712+
"This is a wrapper for the '--nic net-id=<network>' "
713+
"parameter that provides simple syntax for the standard "
714+
"use case of connecting a new server to a given network. "
715+
"For more advanced use cases, refer to the '--nic' "
716+
"parameter."
717+
),
718+
)
719+
parser.add_argument(
720+
'--port',
721+
metavar="<port>",
722+
action='append',
723+
dest='nic',
724+
type=_prefix_checked_value('port-id='),
725+
help=_(
726+
"Create a NIC on the server and connect it to port. "
727+
"Specify option multiple times to create multiple NICs. "
728+
"This is a wrapper for the '--nic port-id=<port>' "
729+
"parameter that provides simple syntax for the standard "
730+
"use case of connecting a new server to a given port. For "
731+
"more advanced use cases, refer to the '--nic' parameter."
732+
),
733+
)
734+
parser.add_argument(
735+
'--nic',
736+
metavar="<net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,"
737+
"port-id=port-uuid,auto,none>",
738+
action='append',
739+
help=_(
740+
"Create a NIC on the server. "
741+
"Specify option multiple times to create multiple NICs. "
742+
"Either net-id or port-id must be provided, but not both. "
743+
"net-id: attach NIC to network with this UUID, "
744+
"port-id: attach NIC to port with this UUID, "
745+
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
746+
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
747+
"none: (v2.37+) no network is attached, "
748+
"auto: (v2.37+) the compute service will automatically "
749+
"allocate a network. Specifying a --nic of auto or none "
750+
"cannot be used with any other --nic value."
751+
),
752+
)
652753
parser.add_argument(
653754
'--password',
654755
metavar='<password>',
655756
help=_("Set the password to this server"),
656757
)
657-
parser.add_argument(
658-
'--flavor',
659-
metavar='<flavor>',
660-
required=True,
661-
help=_('Create server with this flavor (name or ID)'),
662-
)
663758
parser.add_argument(
664759
'--security-group',
665760
metavar='<security-group>',
@@ -736,95 +831,6 @@ def get_parser(self, prog_name):
736831
'(supported by --os-compute-api-version 2.74 or above)'
737832
),
738833
)
739-
parser.add_argument(
740-
'--boot-from-volume',
741-
metavar='<volume-size>',
742-
type=int,
743-
help=_(
744-
'When used in conjunction with the ``--image`` or '
745-
'``--image-property`` option, this option automatically '
746-
'creates a block device mapping with a boot index of 0 '
747-
'and tells the compute service to create a volume of the '
748-
'given size (in GB) from the specified image and use it '
749-
'as the root disk of the server. The root volume will not '
750-
'be deleted when the server is deleted. This option is '
751-
'mutually exclusive with the ``--volume`` option.'
752-
)
753-
)
754-
parser.add_argument(
755-
'--block-device-mapping',
756-
metavar='<dev-name=mapping>',
757-
action=parseractions.KeyValueAction,
758-
default={},
759-
# NOTE(RuiChen): Add '\n' at the end of line to put each item in
760-
# the separated line, avoid the help message looks
761-
# messy, see _SmartHelpFormatter in cliff.
762-
help=_(
763-
'Create a block device on the server.\n'
764-
'Block device mapping in the format\n'
765-
'<dev-name>=<id>:<type>:<size(GB)>:<delete-on-terminate>\n'
766-
'<dev-name>: block device name, like: vdb, xvdc '
767-
'(required)\n'
768-
'<id>: Name or ID of the volume, volume snapshot or image '
769-
'(required)\n'
770-
'<type>: volume, snapshot or image; default: volume '
771-
'(optional)\n'
772-
'<size(GB)>: volume size if create from image or snapshot '
773-
'(optional)\n'
774-
'<delete-on-terminate>: true or false; default: false '
775-
'(optional)\n'
776-
),
777-
)
778-
parser.add_argument(
779-
'--nic',
780-
metavar="<net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,"
781-
"port-id=port-uuid,auto,none>",
782-
action='append',
783-
help=_(
784-
"Create a NIC on the server. "
785-
"Specify option multiple times to create multiple NICs. "
786-
"Either net-id or port-id must be provided, but not both. "
787-
"net-id: attach NIC to network with this UUID, "
788-
"port-id: attach NIC to port with this UUID, "
789-
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
790-
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
791-
"none: (v2.37+) no network is attached, "
792-
"auto: (v2.37+) the compute service will automatically "
793-
"allocate a network. Specifying a --nic of auto or none "
794-
"cannot be used with any other --nic value."
795-
),
796-
)
797-
parser.add_argument(
798-
'--network',
799-
metavar="<network>",
800-
action='append',
801-
dest='nic',
802-
type=_prefix_checked_value('net-id='),
803-
help=_(
804-
"Create a NIC on the server and connect it to network. "
805-
"Specify option multiple times to create multiple NICs. "
806-
"This is a wrapper for the '--nic net-id=<network>' "
807-
"parameter that provides simple syntax for the standard "
808-
"use case of connecting a new server to a given network. "
809-
"For more advanced use cases, refer to the '--nic' "
810-
"parameter."
811-
),
812-
)
813-
parser.add_argument(
814-
'--port',
815-
metavar="<port>",
816-
action='append',
817-
dest='nic',
818-
type=_prefix_checked_value('port-id='),
819-
help=_(
820-
"Create a NIC on the server and connect it to port. "
821-
"Specify option multiple times to create multiple NICs. "
822-
"This is a wrapper for the '--nic port-id=<port>' "
823-
"parameter that provides simple syntax for the standard "
824-
"use case of connecting a new server to a given port. For "
825-
"more advanced use cases, refer to the '--nic' parameter."
826-
),
827-
)
828834
parser.add_argument(
829835
'--hint',
830836
metavar='<key=value>',

0 commit comments

Comments
 (0)