本文整理汇总了Python中neutronclient.common.utils.str2dict_type函数的典型用法代码示例。如果您正苦于以下问题:Python str2dict_type函数的具体用法?Python str2dict_type怎么用?Python str2dict_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str2dict_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_updatable_arguments
def add_updatable_arguments(parser):
parser.add_argument(
'--name',
help=_('Name of this subnet.'))
parser.add_argument(
'--description',
help=_('Description of this subnet.'))
gateway_sg = parser.add_mutually_exclusive_group()
gateway_sg.add_argument(
'--gateway', metavar='GATEWAY_IP',
help=_('Gateway IP of this subnet.'))
gateway_sg.add_argument(
'--no-gateway',
action='store_true',
help=_('Do not configure a gateway for this subnet.'))
parser.add_argument(
'--allocation-pool', metavar='start=IP_ADDR,end=IP_ADDR',
action='append', dest='allocation_pools',
type=utils.str2dict_type(required_keys=['start', 'end']),
help=_('Allocation pool IP addresses for this subnet '
'(This option can be repeated).'))
parser.add_argument(
'--allocation_pool',
action='append', dest='allocation_pools',
type=utils.str2dict_type(required_keys=['start', 'end']),
help=argparse.SUPPRESS)
parser.add_argument(
'--host-route', metavar='destination=CIDR,nexthop=IP_ADDR',
action='append', dest='host_routes',
type=utils.str2dict_type(required_keys=['destination', 'nexthop']),
help=_('Additional route (This option can be repeated).'))
parser.add_argument(
'--dns-nameserver', metavar='DNS_NAMESERVER',
action='append', dest='dns_nameservers',
help=_('DNS name server for this subnet '
'(This option can be repeated).'))
parser.add_argument(
'--disable-dhcp',
action='store_true',
help=_('Disable DHCP for this subnet.'))
parser.add_argument(
'--enable-dhcp',
action='store_true',
help=_('Enable DHCP for this subnet.'))
# NOTE(ihrachys): yes, that's awful, but should be left as-is for
# backwards compatibility for versions <=2.3.4 that passed the
# boolean values through to the server without any argument
# validation.
parser.add_argument(
'--enable-dhcp=True',
action='store_true',
dest='enable_dhcp',
help=argparse.SUPPRESS)
parser.add_argument(
'--enable-dhcp=False',
action='store_true',
dest='disable_dhcp',
help=argparse.SUPPRESS)
示例2: add_arguments_snmp_netconf
def add_arguments_snmp_netconf(self, parser):
group_snmp_netconf = parser.add_mutually_exclusive_group()
group_snmp_netconf.add_argument(
"--snmpv1",
metavar=meta_snmpv1_v2,
action="append",
type=utils.str2dict_type(optional_keys=["write_community"]),
dest="snmpv1",
help=_("SNMPV1 access " "credentials for" " physical" " switch."),
)
group_snmp_netconf.add_argument(
"--snmpv2c",
metavar=meta_snmpv1_v2,
action="append",
dest="snmpv2c",
type=utils.str2dict_type(optional_keys=["write_community"]),
help=_("SNMPV2c access credentials" " for physical switch."),
)
group_snmp_netconf.add_argument(
"--snmpv3",
metavar=meta_snmpv3,
action="append",
dest="snmpv3",
type=utils.str2dict_type(
optional_keys=["security_name", "auth_protocol", "priv_protocol", "auth_key", "priv_key"]
),
help=_("SNMPV3 access credentials for" " physical switch."),
)
group_snmp_netconf.add_argument(
"--netconf-ssh",
metavar=meta_netconf_ssh,
action="append",
dest="netconf_ssh",
type=utils.str2dict_type(optional_keys=["user_name", "password", "key_path"]),
help=_(
"NETCONF-SSH access credentials"
" for physical switch."
" Absolute path has to be pro"
"vided for key_path."
),
)
group_snmp_netconf.add_argument(
"--netconf-soap",
metavar=meta_netconf_soap,
action="append",
dest="netconf_soap",
type=utils.str2dict_type(optional_keys=["user_name", "password"]),
help=_("NETCONF-SOAP access" " credentials for physical" " switch."),
)
示例3: add_arguments_snmp_netconf
def add_arguments_snmp_netconf(self, parser):
group_snmp_netconf = parser.add_mutually_exclusive_group()
group_snmp_netconf.add_argument('--snmpv1',
metavar=meta_snmpv1_v2,
action='append',
type=utils.str2dict_type(
optional_keys=['write_community']),
dest='snmpv1', help=_('SNMPV1 access '
'credentials for'
' physical'
' switch.')
)
group_snmp_netconf.add_argument('--snmpv2c',
metavar=meta_snmpv1_v2,
action='append', dest='snmpv2c',
type=utils.str2dict_type(
optional_keys=['write_community']),
help=_('SNMPV2c access credentials'
' for physical switch.'))
group_snmp_netconf.add_argument('--snmpv3', metavar=meta_snmpv3,
action='append', dest='snmpv3',
type=utils.str2dict_type(
optional_keys=[
'security_name',
'auth_protocol',
'priv_protocol', 'auth_key',
'priv_key']),
help=_('SNMPV3 access credentials for'
' physical switch.'))
group_snmp_netconf.add_argument('--netconf-ssh',
metavar=meta_netconf_ssh,
action='append', dest='netconf_ssh',
type=utils.str2dict_type(
optional_keys=['user_name',
'password',
'key_path']),
help=_('NETCONF-SSH access credentials'
' for physical switch.'
' Absolute path has to be pro'
'vided for key_path.'))
group_snmp_netconf.add_argument('--netconf-soap',
metavar=meta_netconf_soap,
action='append', dest='netconf_soap',
type=utils.str2dict_type(
optional_keys=['user_name',
'password']),
help=_('NETCONF-SOAP access'
' credentials for physical'
' switch.'))
示例4: get_parser
def get_parser(self, prog_name):
parser = super(SetGatewayRouter, self).get_parser(prog_name)
parser.add_argument(
'router', metavar='ROUTER',
help=_('ID or name of the router.'))
parser.add_argument(
'external_network', metavar='EXTERNAL-NETWORK',
help=_('ID or name of the external network for the gateway.'))
parser.add_argument(
'--enable-snat', action='store_true',
help=_('Enable source NAT on the router gateway.'))
parser.add_argument(
'--disable-snat', action='store_true',
help=_('Disable source NAT on the router gateway.'))
parser.add_argument(
'--fixed-ip', metavar='subnet_id=SUBNET,ip_address=IP_ADDR',
action='append',
type=utils.str2dict_type(optional_keys=['subnet_id',
'ip_address']),
help=_('Desired IP and/or subnet on external network: '
'subnet_id=<name_or_id>,ip_address=<ip>. '
'You can specify both of subnet_id and ip_address or '
'specify one of them as well. '
'You can repeat this option.'))
return parser
示例5: get_parser
def get_parser(self, prog_name):
parser = super(CreatePortPairGroup, self).get_parser(prog_name)
parser.add_argument(
'name',
metavar='NAME',
help=_('Name of the Port Pair Group.'))
parser.add_argument(
'--description',
help=_('Description for the Port Pair Group.'))
parser.add_argument(
'--port-pair',
metavar='PORT-PAIR',
dest='port_pairs',
default=[],
action='append',
help=_('ID or name of the Port Pair.'
'This option can be repeated.'))
parser.add_argument(
'--port-pair-group-parameters',
metavar='[lb_fields=LB_FIELDS]',
type=nc_utils.str2dict_type(optional_keys=['lb_fields']),
help=_('Dictionary of Port pair group parameters. '
'Currently, only \'&\' separated string of the lb_fields '
'are supported.'))
return parser
示例6: add_known_arguments
def add_known_arguments(self, parser):
parser.add_argument(
'--description',
help=_('Description of the IPsec policy.'))
parser.add_argument(
'--transform-protocol',
default='esp', choices=['esp', 'ah', 'ah-esp'],
help=_('Transform protocol in lowercase, default:esp'))
parser.add_argument(
'--auth-algorithm',
default='sha1', choices=['sha1', 'sha256'],
help=_('Authentication algorithm in lowercase, default:sha1'))
parser.add_argument(
'--encryption-algorithm',
default='aes-128',
help=_('Encryption algorithm in lowercase, default:aes-128'))
parser.add_argument(
'--encapsulation-mode',
default='tunnel', choices=['tunnel', 'transport'],
help=_('Encapsulation mode in lowercase, default:tunnel'))
parser.add_argument(
'--pfs',
default='group5', choices=['group2', 'group5', 'group14'],
help=_('Perfect Forward Secrecy in lowercase, default:group5'))
parser.add_argument(
'--lifetime',
metavar="units=UNITS,value=VALUE",
type=utils.str2dict_type(optional_keys=['units', 'value']),
help=vpn_utils.lifetime_help("IPsec"))
parser.add_argument(
'name', metavar='NAME',
help=_('Name of the IPsec policy.'))
示例7: add_known_arguments
def add_known_arguments(self, parser):
parser.add_argument(
'--name',
help=_('Name of this router.'))
utils.add_boolean_argument(
parser, '--admin-state-up', dest='admin_state',
help=_('Specify the administrative state of the router'
' (True meaning "Up")'))
utils.add_boolean_argument(
parser, '--admin_state_up', dest='admin_state',
help=argparse.SUPPRESS)
utils.add_boolean_argument(
parser, '--distributed', dest='distributed',
help=_('True means this router should operate in'
' distributed mode.'))
routes_group = parser.add_mutually_exclusive_group()
routes_group.add_argument(
'--route', metavar='destination=CIDR,nexthop=IP_ADDR',
action='append', dest='routes',
type=utils.str2dict_type(required_keys=['destination', 'nexthop']),
help=_('Route to associate with the router.'
' You can repeat this option.'))
routes_group.add_argument(
'--no-routes',
action='store_true',
help=_('Remove routes associated with the router.'))
示例8: add_known_arguments
def add_known_arguments(self, parser):
parser.add_argument(
'--description',
help=_('Description of the IKE policy'))
parser.add_argument(
'--auth-algorithm',
default='sha1', choices=['sha1', 'sha256'],
help=_('Authentication algorithm in lowercase. '
'Default:sha1'))
parser.add_argument(
'--encryption-algorithm',
default='aes-128',
help=_('Encryption algorithm in lowercase, default:aes-128'))
parser.add_argument(
'--phase1-negotiation-mode',
default='main', choices=['main'],
help=_('IKE Phase1 negotiation mode in lowercase, default:main'))
parser.add_argument(
'--ike-version',
default='v1', choices=['v1', 'v2'],
help=_('IKE version in lowercase, default:v1'))
parser.add_argument(
'--pfs',
default='group5', choices=['group2', 'group5', 'group14'],
help=_('Perfect Forward Secrecy in lowercase, default:group5'))
parser.add_argument(
'--lifetime',
metavar="units=UNITS,value=VALUE",
type=utils.str2dict_type(optional_keys=['units', 'value']),
help=vpn_utils.lifetime_help("IKE"))
parser.add_argument(
'name', metavar='NAME',
help=_('Name of the IKE policy.'))
示例9: _add_updatable_args
def _add_updatable_args(parser):
parser.add_argument(
'--name',
help=_('Name of this port.'))
parser.add_argument(
'--description',
help=_('Description of this port.'))
parser.add_argument(
'--fixed-ip', metavar='subnet_id=SUBNET,ip_address=IP_ADDR',
action='append',
type=utils.str2dict_type(optional_keys=['subnet_id', 'ip_address']),
help=_('Desired IP and/or subnet for this port: '
'subnet_id=<name_or_id>,ip_address=<ip>. '
'You can repeat this option.'))
parser.add_argument(
'--fixed_ip',
action='append',
help=argparse.SUPPRESS)
parser.add_argument(
'--device-id',
help=_('Device ID of this port.'))
parser.add_argument(
'--device_id',
help=argparse.SUPPRESS)
parser.add_argument(
'--device-owner',
help=_('Device owner of this port.'))
parser.add_argument(
'--device_owner',
help=argparse.SUPPRESS)
示例10: add_known_arguments
def add_known_arguments(self, parser):
parser.add_argument(
'name',
metavar='NAME',
help=_('Name of the Port Pair.'))
parser.add_argument(
'--description',
help=_('Description for the Port Pair.'))
parser.add_argument(
'--ingress',
required=True,
help=_('ID or name of the ingress neutron port.'))
parser.add_argument(
'--egress',
required=True,
help=_('ID or name of the egress neutron port.'))
parser.add_argument(
'--service-function-parameters',
metavar='[correlation=CORRELATION_TYPE, weight=WEIGHT]',
type=utils.str2dict_type(optional_keys=['correlation',
'weight']),
help=_('Dictionary of Service function parameters. '
'Currently, only correlation=None and weight '
'is supported. Weight is an integer that influences '
'the selection of a port pair within a port pair group '
'for a flow. The higher the weight, the more flows will '
'hash to the port pair. The default weight is 1.'))
示例11: add_known_arguments
def add_known_arguments(self, parser):
_add_common_args(parser)
parser.add_argument(
'--admin-state-down',
dest='admin_state', action='store_false',
help=_('Set admin state up to false.'))
parser.add_argument(
'--listener',
help=_('Listener whose default-pool should be set to this pool. '
'At least one of --listener or --loadbalancer must be '
'specified.'))
parser.add_argument(
'--loadbalancer',
help=_('Loadbalancer with which this pool should be associated. '
'At least one of --listener or --loadbalancer must be '
'specified.'))
parser.add_argument(
'--protocol',
type=utils.convert_to_uppercase,
required=True,
choices=['HTTP', 'HTTPS', 'TCP'],
help=_('Protocol for balancing.'))
parser.add_argument(
'--session-persistence',
metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
type=utils.str2dict_type(required_keys=['type'],
optional_keys=['cookie_name']),
help=_('The type of session persistence to use and associated '
'cookie name.'))
示例12: _get_common_parser
def _get_common_parser(parser):
parser.add_argument(
'--description',
metavar='<description>',
help=_('Description of the IPsec policy'))
parser.add_argument(
'--auth-algorithm',
choices=['sha1', 'sha256', 'sha384', 'sha512'],
type=_convert_to_lowercase,
help=_('Authentication algorithm for IPsec policy'))
parser.add_argument(
'--encapsulation-mode',
choices=['tunnel', 'transport'],
type=_convert_to_lowercase,
help=_('Encapsulation mode for IPsec policy'))
parser.add_argument(
'--encryption-algorithm',
choices=['3des', 'aes-128', 'aes-192', 'aes-256'],
type=_convert_to_lowercase,
help=_('Encryption algorithm for IPsec policy'))
parser.add_argument(
'--lifetime',
metavar="units=UNITS,value=VALUE",
type=nc_utils.str2dict_type(optional_keys=['units', 'value']),
help=vpn_utils.lifetime_help("IPsec"))
parser.add_argument(
'--pfs',
choices=['group2', 'group5', 'group14'],
type=_convert_to_lowercase,
help=_('Perfect Forward Secrecy for IPsec policy'))
parser.add_argument(
'--transform-protocol',
type=_convert_to_lowercase,
choices=['esp', 'ah', 'ah-esp'],
help=_('Transform protocol for IPsec policy'))
示例13: add_known_arguments
def add_known_arguments(self, parser):
parser.add_argument(
'name',
metavar='NAME',
help=_('Name of the Port Chain.'))
parser.add_argument(
'--description',
help=_('Description for the Port Chain.'))
parser.add_argument(
'--port-pair-group',
metavar='PORT-PAIR-GROUP',
dest='port_pair_groups',
default=[], required=True,
action='append',
help=_('ID or name of the Port Pair Group. '
'This option can be repeated.'))
parser.add_argument(
'--flow-classifier',
default=[],
metavar='FLOW-CLASSIFIER',
dest='flow_classifiers',
action='append',
help=_('ID or name of the Flow Classifier.'
'This option can be repeated.'))
parser.add_argument(
'--chain-parameters',
metavar='[correlation=CORRELATION_TYPE, symmetric=BOOLEAN_TYPE]',
type=utils.str2dict_type(optional_keys=['correlation',
'symmetric']),
help=_('Dictionary of chain parameters. Supports '
'correlation=mpls and symmetric=true|false.'))
示例14: _get_common_parser
def _get_common_parser(parser, is_create=True):
parser.add_argument(
'--description',
metavar='<description>',
help=_('Description for the connection'))
parser.add_argument(
'--dpd',
metavar="action=ACTION,interval=INTERVAL,timeout=TIMEOUT",
type=nc_utils.str2dict_type(
optional_keys=['action', 'interval', 'timeout']),
help=vpn_utils.dpd_help("IPsec connection"))
parser.add_argument(
'--mtu',
help=_('MTU size for the connection'))
parser.add_argument(
'--initiator',
choices=['bi-directional', 'response-only'],
type=_convert_to_lowercase,
help=_('Initiator state'))
peer_group = parser.add_mutually_exclusive_group()
peer_group.add_argument(
'--peer-cidr',
dest='peer_cidrs',
help=_('Remote subnet(s) in CIDR format. '
'Cannot be specified when using endpoint groups. Only '
'applicable, if subnet provided for VPN service.')
)
peer_group.add_argument(
'--local-endpoint-group',
help=_('Local endpoint group (name or ID) with subnet(s) '
'for IPsec connection')
)
parser.add_argument(
'--peer-endpoint-group',
help=_('Peer endpoint group (name or ID) with CIDR(s) for '
'IPSec connection'))
admin_group = parser.add_mutually_exclusive_group()
admin_group.add_argument(
'--enable',
action='store_true',
help=_("Enable IPSec site connection")
)
admin_group.add_argument(
'--disable',
action='store_true',
help=_("Disable IPSec site connection")
)
parser.add_argument(
'--local-id',
help=_('An ID to be used instead of the external IP '
'address for a virtual router'))
return parser
示例15: add_known_arguments
def add_known_arguments(self, parser):
parser.add_argument(
'--name',
help=_('Name of this router.'))
parser.add_argument(
'--description',
help=_('Description of router.'))
utils.add_boolean_argument(
parser, '--admin-state-up', dest='admin_state',
help=_('Specify the administrative state of the router'
' (True meaning "Up")'))
utils.add_boolean_argument(
parser, '--admin_state_up', dest='admin_state',
help=argparse.SUPPRESS)
utils.add_boolean_argument(
parser, '--distributed', dest='distributed',
help=_('True means this router should operate in'
' distributed mode.'))
routes_group = parser.add_mutually_exclusive_group()
routes_group.add_argument(
'--route', metavar='destination=CIDR,nexthop=IP_ADDR',
action='append', dest='routes',
type=utils.str2dict_type(required_keys=['destination', 'nexthop']),
help=_('Route to associate with the router.'
' You can repeat this option.'))
routes_group.add_argument(
'--no-routes',
action='store_true',
help=_('Remove routes associated with the router.'))
portfwds_group = parser.add_mutually_exclusive_group()
portfwds_group.add_argument(
'--portforwarding', metavar='inside_addr=IP_ADDR,protocol=PROTOCOL,outside_port=PORT,inside_port=PORT',
action='append', dest='portforwardings',
type=utils.str2dict_type(required_keys=['inside_addr', 'protocol', 'outside_port', 'inside_port']),
help=_('Port-forwardings to associate with the router.'))
portfwds_group.add_argument(
'--no-portforwardings',
action='store_true',
help=_('Remove portforwardings associated with the router.'))