def update_parser_network(self, parser): parser.add_argument('--project', metavar='<project>', help=self.enhance_help_neutron( _("Owner's project (name or ID)"))) identity_common.add_project_domain_option_to_parser( parser, enhance_help=self.enhance_help_neutron) _tag.add_tag_option_to_parser_for_create( parser, _('security group'), enhance_help=self.enhance_help_neutron) return parser
def update_parser_network(self, parser): parser.add_argument( '--subnet', metavar='<subnet>', help=self.enhance_help_neutron( _("Subnet on which you want to create the floating IP " "(name or ID)"))) parser.add_argument('--port', metavar='<port>', help=self.enhance_help_neutron( _("Port to be associated with the floating IP " "(name or ID)"))) parser.add_argument('--floating-ip-address', metavar='<ip-address>', dest='floating_ip_address', help=self.enhance_help_neutron( _("Floating IP address"))) parser.add_argument( '--fixed-ip-address', metavar='<ip-address>', dest='fixed_ip_address', help=self.enhance_help_neutron( _("Fixed IP address mapped to the floating IP"))) parser.add_argument( '--qos-policy', metavar='<qos-policy>', help=self.enhance_help_neutron( _("Attach QoS policy to the floating IP (name or ID)"))) parser.add_argument('--description', metavar='<description>', help=self.enhance_help_neutron( _('Set floating IP description'))) parser.add_argument('--project', metavar='<project>', help=self.enhance_help_neutron( _("Owner's project (name or ID)"))) parser.add_argument('--dns-domain', metavar='<dns-domain>', dest='dns_domain', help=self.enhance_help_neutron( _("Set DNS domain for this floating IP"))) parser.add_argument('--dns-name', metavar='<dns-name>', dest='dns_name', help=self.enhance_help_neutron( _("Set DNS name for this floating IP"))) identity_common.add_project_domain_option_to_parser( parser, enhance_help=self.enhance_help_neutron) _tag.add_tag_option_to_parser_for_create( parser, _('floating IP'), enhance_help=self.enhance_help_neutron) return parser
def test_add_tag_option_to_parser_for_create(self): parser = argparse.ArgumentParser() tags.add_tag_option_to_parser_for_create(parser, 'test') # Test that --tag and --no-tag are mutually exclusive self.assertRaises(SystemExit, parser.parse_args, ['--tag', 'tag1', '--no-tag']) parsed_args = parser.parse_args(['--tag', 'tag1']) actual = getattr(parsed_args, 'tags', []) expected = ['tag1'] self.assertCountEqual(expected, actual) parsed_args = parser.parse_args(['--no-tag']) actual = getattr(parsed_args, 'no-tag', []) expected = [] self.assertCountEqual(expected, actual)
def get_parser(self, prog_name): parser = super(CreateRouter, self).get_parser(prog_name) parser.add_argument('name', metavar='<name>', help=_("New router name")) admin_group = parser.add_mutually_exclusive_group() admin_group.add_argument('--enable', action='store_true', default=True, help=_("Enable router (default)")) admin_group.add_argument('--disable', action='store_true', help=_("Disable router")) distribute_group = parser.add_mutually_exclusive_group() distribute_group.add_argument('--distributed', action='store_true', help=_("Create a distributed router")) distribute_group.add_argument('--centralized', action='store_true', help=_("Create a centralized router")) ha_group = parser.add_mutually_exclusive_group() ha_group.add_argument('--ha', action='store_true', help=_("Create a highly available router")) ha_group.add_argument('--no-ha', action='store_true', help=_("Create a legacy router")) parser.add_argument('--description', metavar='<description>', help=_("Set router description")) parser.add_argument('--project', metavar='<project>', help=_("Owner's project (name or ID)")) identity_common.add_project_domain_option_to_parser(parser) parser.add_argument( '--availability-zone-hint', metavar='<availability-zone>', action='append', dest='availability_zone_hints', help=_("Availability Zone in which to create this router " "(Router Availability Zone extension required, " "repeat option to set multiple availability zones)")) _tag.add_tag_option_to_parser_for_create(parser, _('router')) return parser
def get_parser(self, prog_name): parser = super(CreateSubnetPool, self).get_parser(prog_name) parser.add_argument('name', metavar='<name>', help=_("Name of the new subnet pool")) _add_prefix_options(parser, for_create=True) parser.add_argument('--project', metavar='<project>', help=_("Owner's project (name or ID)")) identity_common.add_project_domain_option_to_parser(parser) parser.add_argument( '--address-scope', metavar='<address-scope>', help=_("Set address scope associated with the subnet pool " "(name or ID), prefixes must be unique across address " "scopes")) _add_default_options(parser) shared_group = parser.add_mutually_exclusive_group() shared_group.add_argument( '--share', action='store_true', help=_("Set this subnet pool as shared"), ) shared_group.add_argument( '--no-share', action='store_true', help=_("Set this subnet pool as not shared"), ) parser.add_argument('--description', metavar='<description>', help=_("Set subnet pool description")) parser.add_argument( '--default-quota', type=int, metavar='<num-ip-addresses>', help=_("Set default per-project quota for this subnet pool " "as the number of IP addresses that can be allocated " "from the subnet pool")), _tag.add_tag_option_to_parser_for_create(parser, _('subnet pool')) return parser
def update_parser_network(self, parser): parser.add_argument('--project', metavar='<project>', help=self.enhance_help_neutron( _("Owner's project (name or ID)"))) stateful_group = parser.add_mutually_exclusive_group() stateful_group.add_argument( "--stateful", action='store_true', default=None, help=_("Security group is stateful (Default)")) stateful_group.add_argument("--stateless", action='store_true', default=None, help=_("Security group is stateless")) identity_common.add_project_domain_option_to_parser( parser, enhance_help=self.enhance_help_neutron) _tag.add_tag_option_to_parser_for_create( parser, _('security group'), enhance_help=self.enhance_help_neutron) return parser
def get_parser(self, prog_name): parser = super(CreatePort, self).get_parser(prog_name) parser.add_argument( '--network', metavar='<network>', required=True, help=_("Network this port belongs to (name or ID)")) _add_updatable_args(parser) fixed_ip = parser.add_mutually_exclusive_group() fixed_ip.add_argument( '--fixed-ip', metavar='subnet=<subnet>,ip-address=<ip-address>', action=parseractions.MultiKeyValueAction, optional_keys=['subnet', 'ip-address'], help=_("Desired IP and/or subnet for this port (name or ID): " "subnet=<subnet>,ip-address=<ip-address> " "(repeat option to set multiple fixed IP addresses)")) fixed_ip.add_argument('--no-fixed-ip', action='store_true', help=_("No IP or subnet for this port.")) parser.add_argument( '--binding-profile', metavar='<binding-profile>', action=JSONKeyValueAction, help=_("Custom data to be passed as binding:profile. Data may " "be passed as <key>=<value> or JSON. " "(repeat option to set multiple binding:profile data)")) admin_group = parser.add_mutually_exclusive_group() admin_group.add_argument('--enable', action='store_true', default=True, help=_("Enable port (default)")) admin_group.add_argument('--disable', action='store_true', help=_("Disable port")) uplink_status_group = parser.add_mutually_exclusive_group() uplink_status_group.add_argument( '--enable-uplink-status-propagation', action='store_true', help=_("Enable uplink status propagate")) uplink_status_group.add_argument( '--disable-uplink-status-propagation', action='store_true', help=_("Disable uplink status propagate (default)")) parser.add_argument('--project', metavar='<project>', help=_("Owner's project (name or ID)")) identity_common.add_project_domain_option_to_parser(parser) parser.add_argument('name', metavar='<name>', help=_("Name of this port")) parser.add_argument( '--extra-dhcp-option', metavar='name=<name>[,value=<value>,ip-version={4,6}]', default=[], action=parseractions.MultiKeyValueCommaAction, dest='extra_dhcp_options', required_keys=['name'], optional_keys=['value', "ip-version"], help=_('Extra DHCP options to be assigned to this port: ' 'name=<name>[,value=<value>,ip-version={4,6}] ' '(repeat option to set multiple extra DHCP options)')) secgroups = parser.add_mutually_exclusive_group() secgroups.add_argument( '--security-group', metavar='<security-group>', action='append', dest='security_group', help=_("Security group to associate with this port (name or ID) " "(repeat option to set multiple security groups)")) secgroups.add_argument( '--no-security-group', dest='no_security_group', action='store_true', help=_("Associate no security groups with this port")) parser.add_argument( '--qos-policy', metavar='<qos-policy>', help=_("Attach QoS policy to this port (name or ID)")) port_security = parser.add_mutually_exclusive_group() port_security.add_argument( '--enable-port-security', action='store_true', help=_("Enable port security for this port (Default)")) port_security.add_argument( '--disable-port-security', action='store_true', help=_("Disable port security for this port")) parser.add_argument( '--allowed-address', metavar='ip-address=<ip-address>[,mac-address=<mac-address>]', action=parseractions.MultiKeyValueAction, dest='allowed_address_pairs', required_keys=['ip-address'], optional_keys=['mac-address'], help=_("Add allowed-address pair associated with this port: " "ip-address=<ip-address>[,mac-address=<mac-address>] " "(repeat option to set multiple allowed-address pairs)")) _tag.add_tag_option_to_parser_for_create(parser, _('port')) return parser
def update_parser_network(self, parser): admin_group = parser.add_mutually_exclusive_group() admin_group.add_argument('--enable', action='store_true', default=True, help=self.enhance_help_neutron( _("Enable network (default)"))) admin_group.add_argument('--disable', action='store_true', help=self.enhance_help_neutron( _("Disable network"))) parser.add_argument('--project', metavar='<project>', help=self.enhance_help_neutron( _("Owner's project (name or ID)"))) parser.add_argument('--description', metavar='<description>', help=self.enhance_help_neutron( _("Set network description"))) parser.add_argument('--mtu', metavar='<mtu>', help=self.enhance_help_neutron( _("Set network mtu"))) identity_common.add_project_domain_option_to_parser(parser) parser.add_argument( '--availability-zone-hint', action='append', dest='availability_zone_hints', metavar='<availability-zone>', help=self.enhance_help_neutron( _("Availability Zone in which to create this network " "(Network Availability Zone extension required, " "repeat option to set multiple availability zones)"))) port_security_group = parser.add_mutually_exclusive_group() port_security_group.add_argument( '--enable-port-security', action='store_true', help=self.enhance_help_neutron( _("Enable port security by default for ports created on " "this network (default)"))) port_security_group.add_argument( '--disable-port-security', action='store_true', help=self.enhance_help_neutron( _("Disable port security by default for ports created on " "this network"))) external_router_grp = parser.add_mutually_exclusive_group() external_router_grp.add_argument( '--external', action='store_true', help=self.enhance_help_neutron( _("Set this network as an external network " "(external-net extension required)"))) external_router_grp.add_argument( '--internal', action='store_true', help=self.enhance_help_neutron( _("Set this network as an internal network (default)"))) default_router_grp = parser.add_mutually_exclusive_group() default_router_grp.add_argument( '--default', action='store_true', help=self.enhance_help_neutron( _("Specify if this network should be used as the default " "external network"))) default_router_grp.add_argument( '--no-default', action='store_true', help=self.enhance_help_neutron( _("Do not use the network as the default external network " "(default)"))) parser.add_argument( '--qos-policy', metavar='<qos-policy>', help=self.enhance_help_neutron( _("QoS policy to attach to this network (name or ID)"))) vlan_transparent_grp = parser.add_mutually_exclusive_group() vlan_transparent_grp.add_argument( '--transparent-vlan', action='store_true', help=self.enhance_help_neutron( _("Make the network VLAN transparent"))) vlan_transparent_grp.add_argument( '--no-transparent-vlan', action='store_true', help=self.enhance_help_neutron( _("Do not make the network VLAN transparent"))) _add_additional_network_options(parser) _tag.add_tag_option_to_parser_for_create( parser, _('network'), enhance_help=self.enhance_help_neutron) return parser
def get_parser(self, prog_name): parser = super(CreateSubnet, self).get_parser(prog_name) parser.add_argument('name', metavar='<name>', help=_("New subnet name")) parser.add_argument('--project', metavar='<project>', help=_("Owner's project (name or ID)")) identity_common.add_project_domain_option_to_parser(parser) subnet_pool_group = parser.add_mutually_exclusive_group() subnet_pool_group.add_argument( '--subnet-pool', metavar='<subnet-pool>', help=_("Subnet pool from which this subnet will obtain a CIDR " "(Name or ID)")) subnet_pool_group.add_argument( '--use-prefix-delegation', help=_("Use 'prefix-delegation' if IP is IPv6 format " "and IP would be delegated externally")) subnet_pool_group.add_argument( '--use-default-subnet-pool', action='store_true', help=_("Use default subnet pool for --ip-version")) parser.add_argument( '--prefix-length', metavar='<prefix-length>', help=_("Prefix length for subnet allocation from subnet pool")) parser.add_argument('--subnet-range', metavar='<subnet-range>', help=_( "Subnet range in CIDR notation " "(required if --subnet-pool is not specified, " "optional otherwise)")) dhcp_enable_group = parser.add_mutually_exclusive_group() dhcp_enable_group.add_argument('--dhcp', action='store_true', help=_("Enable DHCP (default)")) dhcp_enable_group.add_argument('--no-dhcp', action='store_true', help=_("Disable DHCP")) dns_publish_fixed_ip_group = parser.add_mutually_exclusive_group() dns_publish_fixed_ip_group.add_argument( '--dns-publish-fixed-ip', action='store_true', help=_("Enable publishing fixed IPs in DNS")) dns_publish_fixed_ip_group.add_argument( '--no-dns-publish-fixed-ip', action='store_true', help=_("Disable publishing fixed IPs in DNS (default)")) parser.add_argument( '--gateway', metavar='<gateway>', default='auto', help=_("Specify a gateway for the subnet. The three options are: " "<ip-address>: Specific IP address to use as the gateway, " "'auto': Gateway address should automatically be chosen " "from within the subnet itself, 'none': This subnet will " "not use a gateway, e.g.: --gateway 192.168.9.1, " "--gateway auto, --gateway none (default is 'auto').")) parser.add_argument( '--ip-version', type=int, default=4, choices=[4, 6], help=_("IP version (default is 4). Note that when subnet pool is " "specified, IP version is determined from the subnet pool " "and this option is ignored.")) parser.add_argument( '--ipv6-ra-mode', choices=['dhcpv6-stateful', 'dhcpv6-stateless', 'slaac'], help=_("IPv6 RA (Router Advertisement) mode, " "valid modes: [dhcpv6-stateful, dhcpv6-stateless, slaac]")) parser.add_argument( '--ipv6-address-mode', choices=['dhcpv6-stateful', 'dhcpv6-stateless', 'slaac'], help=_("IPv6 address mode, " "valid modes: [dhcpv6-stateful, dhcpv6-stateless, slaac]")) parser.add_argument( '--network-segment', metavar='<network-segment>', help=_("Network segment to associate with this subnet " "(name or ID)")) parser.add_argument( '--network', required=True, metavar='<network>', help=_("Network this subnet belongs to (name or ID)")) parser.add_argument('--description', metavar='<description>', help=_("Set subnet description")) _get_common_parse_arguments(parser) _tag.add_tag_option_to_parser_for_create(parser, _('subnet')) return parser
def get_parser(self, prog_name): parser = super(CreateRouter, self).get_parser(prog_name) parser.add_argument('name', metavar='<name>', help=_("New router name")) admin_group = parser.add_mutually_exclusive_group() admin_group.add_argument('--enable', action='store_true', default=True, help=_("Enable router (default)")) admin_group.add_argument('--disable', action='store_true', help=_("Disable router")) distribute_group = parser.add_mutually_exclusive_group() distribute_group.add_argument('--distributed', action='store_true', help=_("Create a distributed router")) distribute_group.add_argument('--centralized', action='store_true', help=_("Create a centralized router")) ha_group = parser.add_mutually_exclusive_group() ha_group.add_argument('--ha', action='store_true', help=_("Create a highly available router")) ha_group.add_argument('--no-ha', action='store_true', help=_("Create a legacy router")) parser.add_argument('--description', metavar='<description>', help=_("Set router description")) parser.add_argument('--project', metavar='<project>', help=_("Owner's project (name or ID)")) identity_common.add_project_domain_option_to_parser(parser) parser.add_argument( '--availability-zone-hint', metavar='<availability-zone>', action='append', dest='availability_zone_hints', help=_("Availability Zone in which to create this router " "(Router Availability Zone extension required, " "repeat option to set multiple availability zones)")) _tag.add_tag_option_to_parser_for_create(parser, _('router')) parser.add_argument( '--external-gateway', metavar="<network>", help=_("External Network used as router's gateway (name or ID)")) parser.add_argument( '--fixed-ip', metavar='subnet=<subnet>,ip-address=<ip-address>', action=parseractions.MultiKeyValueAction, optional_keys=['subnet', 'ip-address'], help=_("Desired IP and/or subnet (name or ID) " "on external gateway: " "subnet=<subnet>,ip-address=<ip-address> " "(repeat option to set multiple fixed IP addresses)")) snat_group = parser.add_mutually_exclusive_group() snat_group.add_argument( '--enable-snat', action='store_true', help=_("Enable Source NAT on external gateway")) snat_group.add_argument( '--disable-snat', action='store_true', help=_("Disable Source NAT on external gateway")) return parser