Пример #1
0
def to_bytes(text, default=0):
    """Converts a string into an integer of bytes.

    Looks at the last characters of the text to determine
    what conversion is needed to turn the input text into a byte number.
    Supports "B, K(B), M(B), G(B), and T(B)". (case insensitive)

    :param text: String input for bytes size conversion.
    :param default: Default return value when text is blank.

    """
    match = BYTE_REGEX.search(text)
    if match:
        magnitude = int(match.group(1))
        mult_key_org = match.group(2)
        if not mult_key_org:
            return magnitude
    elif text:
        msg = _('Invalid string format: %s') % text
        raise TypeError(msg)
    else:
        return default
    mult_key = mult_key_org.lower().replace('b', '', 1)
    multiplier = BYTE_MULTIPLIERS.get(mult_key)
    if multiplier is None:
        msg = _('Unknown byte multiplier: %s') % mult_key_org
        raise TypeError(msg)
    return magnitude * multiplier
Пример #2
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of security group'))
     parser.add_argument(
         '--description',
         help=_('Description of security group'))
Пример #3
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         "loadbalancer_id", metavar="LOADBALANCER", help=_("ID of the load balancer the listener belong to.")
     )
     parser.add_argument(
         "protocol",
         metavar="PROTOCOL",
         choices=["TCP", "HTTP", "HTTPS", "TERMINATED_HTTPS"],
         help=_("Protocol for the listener."),
     )
     parser.add_argument("protocol_port", metavar="PROTOCOL_PORT", help=_("Protocol port for the listener."))
     parser.add_argument(
         "--connection-limit", metavar="CONNETION_LIMIT", help=_("The connection limit for the listener.")
     )
     parser.add_argument("--default-pool-id", metavar="POOL", help=_("The default pool ID to use."))
     parser.add_argument(
         "--default-tls-container-id",
         metavar="DEFAULT_TLS_CONTAINER_ID",
         help=_("The default tls container ID to use."),
     )
     parser.add_argument(
         "--sni_container_ids", metavar="SNI_TLS_CONTAINER_IDs", help=_("The sni tls container IDs to use.")
     )
     parser.add_argument(
         "--admin-state-down", dest="admin_state", action="store_false", help=_("Set admin state up to false.")
     )
     parser.add_argument("--keep-alive", dest="keep_alive", action="store_true", help=_("Set keep alive flag."))
     parser.add_argument("--name", required=False, help=_("Name of the listener."))
     parser.add_argument("--description", help=_("Description of the listener."))
Пример #4
0
def validate_lifetime_dict(lifetime_dict):

    for key, value in lifetime_dict.items():
        if key not in lifetime_keys:
            message = _(
                "Lifetime Dictionary KeyError: "
                "Reason-Invalid unit key : "
                "'%(key)s' not in %(supported_key)s ") % {
                    'key': key, 'supported_key': lifetime_keys}
            raise KeyError(message)
        if key == 'units' and value not in lifetime_units:
            message = _(
                "Lifetime Dictionary ValueError: "
                "Reason-Invalid units : "
                "'%(key_value)s' not in %(supported_units)s ") % {
                    'key_value': key, 'supported_units': lifetime_units}
            raise ValueError(message)
        if key == 'value':
            if int(value) < 60:
                message = _(
                    "Lifetime Dictionary ValueError: "
                    "Reason-Invalid value should be at least 60:"
                    "'%(key_value)s' = %(value)i ") % {
                        'key_value': key, 'value': int(value)}
                raise ValueError(str(message))
            else:
                lifetime_dict['value'] = int(value)
    return
Пример #5
0
 def get_parser(self, prog_name):
     parser = super(UpdatePolicyProfileV2, self).get_parser(prog_name)
     parser.add_argument("--add-tenant",
                         help=_("Add tenant to the policy profile"))
     parser.add_argument("--remove-tenant",
                         help=_("Remove tenant from the policy profile"))
     return parser
Пример #6
0
def validate_dpd_dict(dpd_dict):
    for key, value in dpd_dict.items():
        if key not in dpd_supported_keys:
            message = _(
                "DPD Dictionary KeyError: "
                "Reason-Invalid DPD key : "
                "'%(key)s' not in %(supported_key)s ") % {
                    'key': key, 'supported_key': dpd_supported_keys}
            raise KeyError(message)
        if key == 'action' and value not in dpd_supported_actions:
            message = _(
                "DPD Dictionary ValueError: "
                "Reason-Invalid DPD action : "
                "'%(key_value)s' not in %(supported_action)s ") % {
                    'key_value': value,
                    'supported_action': dpd_supported_actions}
            raise ValueError(message)
        if key in ('interval', 'timeout'):
            if int(value) <= 0:
                message = _(
                    "DPD Dictionary ValueError: "
                    "Reason-Invalid positive integer value: "
                    "'%(key)s' = %(value)i ") % {
                        'key': key, 'value': int(value)}
                raise ValueError(message)
            else:
                dpd_dict[key] = int(value)
    return
 def add_known_arguments(self, parser):
     parser.add_argument(
         '--name',
         help=_('Name of security group.'))
     parser.add_argument(
         '--description',
         help=_('Description of security group.'))
Пример #8
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of metering label to create'))
     parser.add_argument(
         '--description',
         help=_('Description of metering label to create'))
 def get_parser(self, prog_name):
     parser = super(DisassociateHealthMonitor, self).get_parser(prog_name)
     parser.add_argument("health_monitor_id", metavar="HEALTH_MONITOR_ID", help=_("Health monitor to associate."))
     parser.add_argument(
         "pool_id", metavar="POOL", help=_("ID of the pool to be associated with the health monitor.")
     )
     return parser
Пример #10
0
 def run_subcommand(self, argv):
     subcommand = self.command_manager.find_command(argv)
     cmd_factory, cmd_name, sub_argv = subcommand
     cmd = cmd_factory(self, self.options)
     err = None
     result = 1
     try:
         self.prepare_to_run_command(cmd)
         full_name = cmd_name if self.interactive_mode else " ".join([self.NAME, cmd_name])
         cmd_parser = cmd.get_parser(full_name)
         return run_command(cmd, cmd_parser, sub_argv)
     except Exception as err:
         if self.options.verbose_level == self.DEBUG_LEVEL:
             self.log.exception(unicode(err))
         else:
             self.log.error(unicode(err))
         try:
             self.clean_up(cmd, result, err)
         except Exception as err2:
             if self.options.verbose_level == self.DEBUG_LEVEL:
                 self.log.exception(unicode(err2))
             else:
                 self.log.error(_("Could not clean up: %s"), unicode(err2))
         if self.options.verbose_level == self.DEBUG_LEVEL:
             raise
     else:
         try:
             self.clean_up(cmd, result, None)
         except Exception as err3:
             if self.options.verbose_level == self.DEBUG_LEVEL:
                 self.log.exception(unicode(err3))
             else:
                 self.log.error(_("Could not clean up: %s"), unicode(err3))
     return result
Пример #11
0
def updatable_args2body(parsed_args, body):
    if parsed_args.gateway and parsed_args.no_gateway:
        raise exceptions.CommandError(_("--gateway option and "
                                      "--no-gateway option can "
                                      "not be used same time"))
    if parsed_args.disable_dhcp and parsed_args.enable_dhcp:
        raise exceptions.CommandError(_("--enable-dhcp and --disable-dhcp can "
                                      "not be used in the same command."))

    if parsed_args.no_gateway:
        body['subnet'].update({'gateway_ip': None})
    if parsed_args.gateway:
        body['subnet'].update({'gateway_ip': parsed_args.gateway})
    if parsed_args.name:
        body['subnet'].update({'name': parsed_args.name})
    if parsed_args.disable_dhcp:
        body['subnet'].update({'enable_dhcp': False})
    if parsed_args.enable_dhcp:
        body['subnet'].update({'enable_dhcp': True})
    if parsed_args.allocation_pools:
        body['subnet']['allocation_pools'] = parsed_args.allocation_pools
    if parsed_args.host_routes:
        body['subnet']['host_routes'] = parsed_args.host_routes
    if parsed_args.dns_nameservers:
        body['subnet']['dns_nameservers'] = parsed_args.dns_nameservers
Пример #12
0
 def run(self, parsed_args):
     self.log.debug('run(%s)', parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _extra_values = parse_args_to_dict(self.values_specs)
     _merge_args(self, parsed_args, _extra_values,
                 self.values_specs)
     body = self.args2body(parsed_args)
     if self.resource in body:
         body[self.resource].update(_extra_values)
     else:
         body[self.resource] = _extra_values
     if not body[self.resource]:
         raise exceptions.CommandError(
             _("Must specify new values to update %s") %
             self.cmd_resource)
     if self.allow_names:
         _id = find_resourceid_by_name_or_id(
             neutron_client, self.resource, parsed_args.id,
             cmd_resource=self.cmd_resource)
     else:
         _id = find_resourceid_by_id(
             neutron_client, self.resource, parsed_args.id,
             self.cmd_resource, self.parent_id)
     obj_updater = getattr(neutron_client,
                           "update_%s" % self.cmd_resource)
     if self.parent_id:
         obj_updater(_id, self.parent_id, body)
     else:
         obj_updater(_id, body)
     print((_('Updated %(resource)s: %(id)s') %
            {'id': parsed_args.id, 'resource': self.resource}),
           file=self.app.stdout)
     return
Пример #13
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'l7policy_id', metavar='L7POLICY',
         help=_('ID of the l7policy that this l7rule belongs to.'))
     parser.add_argument(
         '--key',
         required=False,
         help=_('Key of the l7rule.'))
Пример #14
0
 def add_known_arguments(self, parser):
     parser.add_argument("--remove-tenant",
                         action='append', dest='remove_tenants',
                         help=_("Remove tenant from the network profile. "
                                "You can repeat this option."))
     parser.add_argument("--add-tenant",
                         action='append', dest='add_tenants',
                         help=_("Add tenant to the network profile. "
                                "You can repeat this option."))
 def get_parser(self, prog_name):
     parser = super(RemoveNetworkFromDhcpAgent, self).get_parser(prog_name)
     parser.add_argument(
         'dhcp_agent',
         help=_('ID of the DHCP agent.'))
     parser.add_argument(
         'network',
         help=_('Network to remove.'))
     return parser
 def get_parser(self, prog_name):
     parser = super(AddNetworkToDhcpAgent, self).get_parser(prog_name)
     parser.add_argument(
         'dhcp_agent',
         help=_('ID of the DHCP agent.'))
     parser.add_argument(
         'network',
         help=_('Network to add.'))
     return parser
 def get_parser(self, prog_name):
     parser = super(RemoveRouterFromL3Agent, self).get_parser(prog_name)
     parser.add_argument(
         'l3_agent',
         help=_('ID of the L3 agent.'))
     parser.add_argument(
         'router',
         help=_('Router to remove.'))
     return parser
Пример #18
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of network gateway to create'))
     parser.add_argument(
         '--device', metavar='id=ID,interface_name=NAME_OR_ID',
         action='append',
         help=_('Device info for this gateway, '
         'can be repeated for multiple devices for HA gateways'))
Пример #19
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         "--admin-state-down", dest="admin_state", action="store_false", help=_("Set admin state up to false.")
     )
     parser.add_argument("--admin_state_down", dest="admin_state", action="store_false", help=argparse.SUPPRESS)
     parser.add_argument(
         "--shared", action="store_true", help=_("Set the network as shared."), default=argparse.SUPPRESS
     )
     parser.add_argument("name", metavar="NAME", help=_("Name of network to create."))
 def get_parser(self, prog_name):
     parser = super(AddRouterToL3Agent, self).get_parser(prog_name)
     parser.add_argument(
         'l3_agent',
         help=_('ID of the L3 agent.'))
     parser.add_argument(
         'router',
         help=_('Router to add.'))
     return parser
Пример #21
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         '--tunnel_id',
         required=True,
         help=_('Tunnel id'))
     parser.add_argument(
         '--network_cidr',
         required=True,
         help=_('network_cidr'))
 def get_parser(self, prog_name):
     parser = super(DisassociateHealthMonitor, self).get_parser(prog_name)
     parser.add_argument(
         'health_monitor_id', metavar='HEALTH_MONITOR_ID',
         help=_('Health monitor to associate.'))
     parser.add_argument(
         'pool_id', metavar='POOL',
         help=_('ID of the pool to be associated with the health monitor.'))
     return parser
Пример #23
0
def check_non_negative_int(value):
    try:
        value = int(value)
    except ValueError:
        raise argparse.ArgumentTypeError(_("invalid int value: %r") % value)
    if value < 0:
        raise argparse.ArgumentTypeError(_("input value %d is negative") %
                                         value)
    return value
Пример #24
0
 def add_known_arguments(self, parser):
     parser.add_argument("firewall_policy_id", metavar="POLICY", help=_("Firewall policy name or ID."))
     parser.add_argument("--name", help=_("Name for the firewall."))
     parser.add_argument("--description", help=_("Description for the firewall rule."))
     parser.add_argument(
         "--shared", action="store_true", help=_("Set shared to True (default is False)."), default=argparse.SUPPRESS
     )
     parser.add_argument(
         "--admin-state-down", dest="admin_state", action="store_false", help=_("Set admin state up to false.")
     )
Пример #25
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'name',
         help=_('Name of this vpn user'))
     parser.add_argument(
         'password',
         help=_('Password of the vpn user'))
     parser.add_argument(
         '--description',
         help=_('Descrition of the vpn user'))
Пример #26
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         "--admin-state-down", dest="admin_state", action="store_false", help=_("Set admin state up to false.")
     )
     parser.add_argument("--name", help=_("Set a name for the VPN service."))
     parser.add_argument("--description", help=_("Set a description for the VPN service."))
     parser.add_argument("router", metavar="ROUTER", help=_("Router unique identifier for the VPN service."))
     parser.add_argument(
         "subnet", metavar="SUBNET", help=_("Subnet unique identifier for the VPN service deployment.")
     )
Пример #27
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         '--name', metavar='NAME',
         help=_('Name of ovs network.'))
     parser.add_argument(
         '--vm_host', metavar='VM_HOST',
         help=_("vm's host for this vm link."))
     parser.add_argument(
         'ovs_network_id', metavar='OVS_NETWORK_ID',
         help=_("ovs network's id of the ovs link."))
Пример #28
0
 def get_parser(self, prog_name):
     parser = super(DeleteCommand, self).get_parser(prog_name)
     if self.allow_names:
         help_str = _('ID or name of %s to delete.')
     else:
         help_str = _('ID of %s to delete.')
     parser.add_argument(
         'id', metavar=self.resource.upper(),
         help=help_str % self.resource)
     return parser
Пример #29
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         '--name',
         help=_('Name of ovs link.'))
     parser.add_argument(
         '--left_ovs_id', metavar='OVS_NETWORK_ID',
         help=_("Left ovs network's id of the ovs link."))
     parser.add_argument(
         '--right_ovs_id', metavar='OVS_NETWORK_ID',
         help=_("Right ovs network's id of the ovs link."))
Пример #30
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'pool_id', metavar='POOL',
         help=_('Pool ID or name this vip belongs to.'))
     parser.add_argument(
         '--address',
         help=_('IP address of the vip.'))
     parser.add_argument(
         '--admin-state-down',
         dest='admin_state', action='store_false',
         help=_('Set admin state up to false.'))
     parser.add_argument(
         '--connection-limit',
         help=_('The maximum number of connections per second allowed for '
                'the vip. Positive integer or -1 for unlimited (default).'))
     parser.add_argument(
         '--description',
         help=_('Description of the vip.'))
     parser.add_argument(
         '--name',
         required=True,
         help=_('Name of the vip.'))
     parser.add_argument(
         '--protocol-port',
         required=True,
         help=_('TCP port on which to listen for client traffic that is '
                'associated with the vip address.'))
     parser.add_argument(
         '--protocol',
         required=True, choices=['TCP', 'HTTP', 'HTTPS'],
         help=_('Protocol for balancing.'))
     parser.add_argument(
         '--subnet-id', metavar='SUBNET',
         required=True,
         help=_('The subnet on which to allocate the vip address.'))
Пример #31
0
 def get_data(self, parsed_args):
     self.log.debug('get_data(%s)' % parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _extra_values = parse_args_to_dict(self.values_specs)
     _merge_args(self, parsed_args, _extra_values,
                 self.values_specs)
     body = self.args2body(parsed_args)
     body[self.resource].update(_extra_values)
     obj_creator = getattr(neutron_client,
                           "create_%s" % self.resource)
     data = obj_creator(body)
     self.format_output_data(data)
     # {u'network': {u'id': u'e9424a76-6db4-4c93-97b6-ec311cd51f19'}}
     info = self.resource in data and data[self.resource] or None
     if info:
         print(_('Created a new %s:') % self.resource,
               file=self.app.stdout)
     else:
         info = {'': ''}
     return zip(*sorted(info.iteritems()))
    def args2body(self, parsed_args):
        _vpnservice_id = neutronv20.find_resourceid_by_name_or_id(
            self.get_client(), 'vpnservice', parsed_args.vpnservice_id)
        _ikepolicy_id = neutronv20.find_resourceid_by_name_or_id(
            self.get_client(), 'ikepolicy', parsed_args.ikepolicy_id)
        _ipsecpolicy_id = neutronv20.find_resourceid_by_name_or_id(
            self.get_client(), 'ipsecpolicy', parsed_args.ipsecpolicy_id)
        if int(parsed_args.mtu) < 68:
            message = _("Invalid MTU value: MTU must be "
                        "greater than or equal to 68")
            raise exceptions.CommandError(message)
        body = {
            'ipsec_site_connection': {
                'vpnservice_id': _vpnservice_id,
                'ikepolicy_id': _ikepolicy_id,
                'ipsecpolicy_id': _ipsecpolicy_id,
                'peer_address': parsed_args.peer_address,
                'peer_id': parsed_args.peer_id,
                'mtu': parsed_args.mtu,
                'initiator': parsed_args.initiator,
                'psk': parsed_args.psk,
                'admin_state_up': parsed_args.admin_state_down,
            },
        }
        if parsed_args.name:
            body['ipsec_site_connection'].update({'name': parsed_args.name})
        if parsed_args.description:
            body['ipsec_site_connection'].update(
                {'description': parsed_args.description})
        if parsed_args.tenant_id:
            body['ipsec_site_connection'].update(
                {'tenant_id': parsed_args.tenant_id})
        if parsed_args.dpd:
            vpn_utils.validate_dpd_dict(parsed_args.dpd)
            body['ipsec_site_connection'].update({'dpd': parsed_args.dpd})
        if parsed_args.peer_cidrs:
            body['ipsec_site_connection'][
                'peer_cidrs'] = parsed_args.peer_cidrs

        return body
Пример #33
0
def add_updatable_arguments(parser):
    parser.add_argument(
        '--name',
        help=_('Name of this subnet.'))
    parser.add_argument(
        '--gateway', metavar='GATEWAY_IP',
        help=_('Gateway IP of this subnet.'))
    parser.add_argument(
        '--no-gateway',
        action='store_true',
        help=_('No distribution of gateway.'))
    parser.add_argument(
        '--allocation-pool', metavar='start=IP_ADDR,end=IP_ADDR',
        action='append', dest='allocation_pools', type=utils.str2dict,
        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,
        help=argparse.SUPPRESS)
    parser.add_argument(
        '--host-route', metavar='destination=CIDR,nexthop=IP_ADDR',
        action='append', dest='host_routes', type=utils.str2dict,
        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.'))
Пример #34
0
    def args2body(self, parsed_args):
        if parsed_args.ip_version == 4 and parsed_args.cidr.endswith('/32'):
            self.log.warning(
                _("An IPv4 subnet with a /32 CIDR will have "
                  "only one usable IP address so the device "
                  "attached to it will not have any IP "
                  "connectivity."))
        _network_id = neutronV20.find_resourceid_by_name_or_id(
            self.get_client(), 'network', parsed_args.network_id)
        body = {
            'subnet': {
                'cidr': parsed_args.cidr,
                'network_id': _network_id,
                'ip_version': parsed_args.ip_version,
            },
        }

        updatable_args2body(parsed_args, body)
        if parsed_args.tenant_id:
            body['subnet'].update({'tenant_id': parsed_args.tenant_id})

        return body
Пример #35
0
def find_resourceid_by_id(client, resource, resource_id, cmd_resource=None,
                          parent_id=None):
    if not cmd_resource:
        cmd_resource = resource
    cmd_resource_plural = _get_resource_plural(cmd_resource, client)
    resource_plural = _get_resource_plural(resource, client)
    obj_lister = getattr(client, "list_%s" % cmd_resource_plural)
    # perform search by id only if we are passing a valid UUID
    match = re.match(UUID_PATTERN, resource_id)
    collection = resource_plural
    if match:
        if parent_id:
            data = obj_lister(parent_id, id=resource_id, fields='id')
        else:
            data = obj_lister(id=resource_id, fields='id')
        if data and data[collection]:
            return data[collection][0]['id']
    not_found_message = (_("Unable to find %(resource)s with id "
                           "'%(id)s'") %
                         {'resource': resource, 'id': resource_id})
    # 404 is used to simulate server side behavior
    raise exceptions.NeutronClientException(
        message=not_found_message, status_code=404)
Пример #36
0
 def get_data(self, parsed_args):
     self.log.debug('get_data(%s)' % parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _extra_values = parse_args_to_dict(self.values_specs)
     _merge_args(self, parsed_args, _extra_values,
                 self.values_specs)
     body = self.args2body(parsed_args)
     body[self.resource].update(_extra_values)
     obj_creator = getattr(neutron_client,
                           "create_%s" % self.cmd_resource)
     if self.parent_id:
         data = obj_creator(self.parent_id, body)
     else:
         data = obj_creator(body)
     self.format_output_data(data)
     info = self.resource in data and data[self.resource] or None
     if info:
         print(_('Created a new %s:') % self.resource,
               file=self.app.stdout)
     else:
         info = {'': ''}
     return zip(*sorted(six.iteritems(info)))
Пример #37
0
 def run(self, parsed_args):
     self.log.debug('run(%s)' % parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _extra_values = parse_args_to_dict(self.values_specs)
     _merge_args(self, parsed_args, _extra_values, self.values_specs)
     body = self.args2body(parsed_args)
     if self.resource in body:
         body[self.resource].update(_extra_values)
     else:
         body[self.resource] = _extra_values
     if not body[self.resource]:
         raise exceptions.CommandError(
             "Must specify new values to update %s" % self.resource)
     _id = find_resourceid_by_name_or_id(neutron_client, self.resource,
                                         parsed_args.id)
     obj_updator = getattr(neutron_client, "update_%s" % self.resource)
     obj_updator(_id, body)
     print >> self.app.stdout, (_('Updated %(resource)s: %(id)s') % {
         'id': parsed_args.id,
         'resource': self.resource
     })
     return
Пример #38
0
    def args2body_extradhcpopt(self, parsed_args, port):
        ops = []
        if parsed_args.extra_dhcp_opts:
            # the extra_dhcp_opt params (opt_name & opt_value)
            # must come in pairs, if there is a parm error
            # both must be thrown out.
            opt_ele = {}
            edo_err_msg = _("Invalid --extra-dhcp-opt option, can only be: "
                            "opt_name=<dhcp_option_name>,opt_value=<value>, "
                            "(This option can be repeated.")
            for opt in parsed_args.extra_dhcp_opts:
                if opt.split('=')[0] in ['opt_value', 'opt_name']:
                    opt_ele.update(utils.str2dict(opt))
                    if (('opt_name' in opt_ele) and ('opt_value' in opt_ele)):
                        ops.append(opt_ele)
                        opt_ele = {}
                    else:
                        raise exceptions.CommandError(edo_err_msg)
                else:
                    raise exceptions.CommandError(edo_err_msg)

        if ops:
            port.update({'extra_dhcp_opts': ops})
Пример #39
0
 def add_known_arguments(self, parser):
     parser.add_argument('vip_network_id',
                         metavar='VIP_NETWORK_ID',
                         help=_('ID of the load balancer network.'))
     parser.add_argument('securitygroup_id',
                         metavar='SECURITYGROUP_ID',
                         help=_('Security group of the load balancer.'))
     parser.add_argument('--vip_subnet_id',
                         required=False,
                         help=_('ID of the load balancer subnet.'))
     parser.add_argument('--vip_address',
                         required=False,
                         help=_('VIP address of the load balancer.'))
     parser.add_argument('--name',
                         required=False,
                         help=_('Name of the load balancer.'))
     parser.add_argument('--description',
                         help=_('Description of the load balancer.'))
Пример #40
0
 def add_known_arguments(self, parser):
     parser.add_argument('name', help=_('Name for Network Profile'))
     parser.add_argument('segment_type',
                         choices=SEGMENT_TYPE_CHOICES,
                         help='Segment type')
     # TODO(Abhishek): Check on sub-type choices depending on segment_type
     parser.add_argument(
         '--sub_type',
         help=_('Sub-type for the segment. Available sub-'
                'types for overlay segments: native, enhanced; '
                'For trunk segments: vlan, overlay.'))
     parser.add_argument('--segment_range', help=_('Range for the Segment'))
     parser.add_argument('--physical_network',
                         help=_('Name for the Physical Network'))
     parser.add_argument('--multicast_ip_range',
                         help=_('Multicast IPv4 Range'))
     parser.add_argument("--add-tenant",
                         help=_("Add tenant to the network profile"))
Пример #41
0
 def add_known_arguments(self, parser):
     parser.add_argument('--connection-limit',
                         metavar='CONNETION_LIMIT',
                         help=_('The connection limit for the listener.'))
     parser.add_argument('--default-tls-container-id',
                         metavar='DEFAULT_TLS_CONTAINER_ID',
                         help=_('The default tls container ID to use.'))
     parser.add_argument('--sni_container_ids',
                         metavar='SNI_TLS_CONTAINER_IDs',
                         help=_('The sni tls container IDs to use.'))
     parser.add_argument('--default-pool-id',
                         metavar='POOL',
                         help=_('The default pool ID to use.'))
     parser.add_argument('--admin-state-down',
                         dest='admin_state',
                         action='store_false',
                         help=_('Set admin state up to false.'))
     parser.add_argument('--name',
                         required=False,
                         help=_('Name of the listener.'))
     parser.add_argument('--description',
                         help=_('Description of the listener.'))
Пример #42
0
 def _discover_auth_versions(self, session, auth_url):
     # discover the API versions the server is supporting base on the
     # given URL
     try:
         ks_discover = discover.Discover(session=session, auth_url=auth_url)
         return (ks_discover.url_for('2.0'), ks_discover.url_for('3.0'))
     except ks_exc.ClientException:
         # Identity service may not support discover API version.
         # Lets try to figure out the API version from the original URL.
         url_parts = urlparse.urlparse(auth_url)
         (scheme, netloc, path, params, query, fragment) = url_parts
         path = path.lower()
         if path.startswith('/v3'):
             return (None, auth_url)
         elif path.startswith('/v2'):
             return (auth_url, None)
         else:
             # not enough information to determine the auth version
             msg = _('Unable to determine the Keystone version '
                     'to authenticate with using the given '
                     'auth_url. Identity service may not support API '
                     'version discovery. Please provide a versioned '
                     'auth_url instead.')
             raise exc.CommandError(msg)
Пример #43
0
    def run(self, parsed_args):
        self.log.debug('run(%s)' % parsed_args)
        neutron_client = self.get_client()
        neutron_client.format = parsed_args.request_format

        if '=' in parsed_args.interface:
            resource, value = parsed_args.interface.split('=', 1)
            if resource not in ['subnet', 'port']:
                exceptions.CommandError(_('You must specify either subnet or '
                                        'port for INTERFACE parameter.'))
        else:
            resource = 'subnet'
            value = parsed_args.interface

        _router_id = neutronV20.find_resourceid_by_name_or_id(
            neutron_client, self.resource, parsed_args.router_id)

        _interface_id = neutronV20.find_resourceid_by_name_or_id(
            neutron_client, resource, value)
        body = {'%s_id' % resource: _interface_id}

        portinfo = self.call_api(neutron_client, _router_id, body)
        print >>self.app.stdout, self.success_message(parsed_args.router_id,
                                                      portinfo)
Пример #44
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'name',
         help=_('Name of this openvpn'))
     parser.add_argument(
         'peer_cidr',
         help=_('CIDR of the openvpn client'))
     parser.add_argument(
         'port',
         help=_('port of the openvpn'))
     parser.add_argument(
         'protocol',
         help=_('protocol of the openvpn, UDP or TCP'))
     parser.add_argument(
         'router_id',
         help=_('router of the openvpn'))
     parser.add_argument(
         '--description',
         help=_('Descrition of the openvpn'))
Пример #45
0
 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'],
         help=_('Authentication algorithm in lowercase. '
                'default:sha1'))
     parser.add_argument(
         '--encryption-algorithm',
         default='aes-128', choices=['3des',
                                     'aes-128',
                                     'aes-192',
                                     'aes-256'],
         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,
         help=vpn_utils.lifetime_help("IKE"))
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of the IKE Policy'))
Пример #46
0
    def add_known_arguments(self, parser):
        parser.add_argument(
            '--name',
            help=_('Name of this port.'))
        parser.add_argument(
            '--admin-state-down',
            dest='admin_state', action='store_false',
            help=_('Set admin state up to false.'))
        parser.add_argument(
            '--admin_state_down',
            dest='admin_state', action='store_false',
            help=argparse.SUPPRESS)
        parser.add_argument(
            '--mac-address',
            help=_('MAC address of this port.'))
        parser.add_argument(
            '--mac_address',
            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(
            '--fixed-ip', metavar='subnet_id=SUBNET,ip_address=IP_ADDR',
            action='append',
            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)

        self.add_arguments_secgroup(parser)
        self.add_arguments_extradhcpopt(parser)

        parser.add_argument(
            'network_id', metavar='NETWORK',
            help=_('Network ID or name this port belongs to.'))
Пример #47
0
 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of queue'))
     parser.add_argument(
         '--min',
         help=_('min-rate')),
     parser.add_argument(
         '--max',
         help=_('max-rate')),
     parser.add_argument(
         '--qos-marking',
         help=_('QOS marking untrusted/trusted')),
     parser.add_argument(
         '--default',
         default=False,
         help=_('If true all ports created with be the size of this queue'
                ' if queue is not specified')),
     parser.add_argument(
         '--dscp',
         help=_('Differentiated Services Code Point')),
 def add_known_arguments(self, parser):
     parser.add_argument('name',
                         help=_('Name for network profile.'))
     parser.add_argument('segment_type',
                         choices=SEGMENT_TYPE_CHOICES,
                         help='Segment type.')
     # TODO(Abhishek): Check on sub-type choices depending on segment_type
     parser.add_argument('--sub_type',
                         help=_('Sub-type for the segment. Available sub-'
                         'types for overlay segments: native, enhanced; '
                         'For trunk segments: vlan, overlay.'))
     parser.add_argument('--segment_range',
                         help=_('Range for the segment.'))
     parser.add_argument('--physical_network',
                         help=_('Name for the physical network.'))
     parser.add_argument('--multicast_ip_range',
                         help=_('Multicast IPv4 range.'))
     parser.add_argument("--add-tenant",
                         action='append', dest='add_tenants',
                         help=_("Add tenant to the network profile "
                                "(This option can be repeated)."))
Пример #49
0
 def success_message(self, router_id, portinfo):
     return (_('Added interface %(port)s to router %(router)s.') %
             {'router': router_id, 'port': portinfo['port_id']})
 def _authenticate_noauth(self):
     if not self.endpoint_url:
         message = _('For "noauth" authentication strategy, the endpoint '
                     'must be specified either in the constructor or '
                     'using --os-url')
         raise exceptions.Unauthorized(message=message)
Пример #51
0
 def success_message(self, router_id, portinfo):
     # portinfo is not used since it is None for router-interface-delete.
     return _('Removed interface from router %s.') % router_id
Пример #52
0
 def add_known_arguments(self, parser):
     parser.add_argument('--policy',
                         metavar='POLICY',
                         help=_('Firewall policy name or ID.'))
Пример #53
0
    def authenticate_user(self):
        """Make sure the user has provided all of the authentication
        info we need.
        """
        if self.options.os_auth_strategy == 'keystone':
            if self.options.os_token or self.options.os_url:
                # Token flow auth takes priority
                if not self.options.os_token:
                    raise exc.CommandError(
                        _("You must provide a token via"
                          " either --os-token or env[OS_TOKEN]"))

                if not self.options.os_url:
                    raise exc.CommandError(
                        _("You must provide a service URL via"
                          " either --os-url or env[OS_URL]"))

            else:
                # Validate password flow auth
                project_info = (self.options.os_tenant_name
                                or self.options.os_tenant_id
                                or (self.options.os_project_name and
                                    (self.options.project_domain_name
                                     or self.options.project_domain_id))
                                or self.options.os_project_id)

                if (not self.options.os_username
                        and not self.options.os_user_id):
                    raise exc.CommandError(
                        _("You must provide a username or user ID via"
                          "  --os-username, env[OS_USERNAME] or"
                          "  --os-user_id, env[OS_USER_ID]"))

                if not self.options.os_password:
                    raise exc.CommandError(
                        _("You must provide a password via"
                          " either --os-password or env[OS_PASSWORD]"))

                if (not project_info):
                    # tenent is deprecated in Keystone v3. Use the latest
                    # terminology instead.
                    raise exc.CommandError(
                        _("You must provide a project_id or project_name ("
                          "with project_domain_name or project_domain_id) "
                          "via "
                          "  --os-project-id (env[OS_PROJECT_ID])"
                          "  --os-project-name (env[OS_PROJECT_NAME]),"
                          "  --os-project-domain-id "
                          "(env[OS_PROJECT_DOMAIN_ID])"
                          "  --os-project-domain-name "
                          "(env[OS_PROJECT_DOMAIN_NAME])"))

                if not self.options.os_auth_url:
                    raise exc.CommandError(
                        _("You must provide an auth url via"
                          " either --os-auth-url or via env[OS_AUTH_URL]"))
            auth_session = self._get_keystone_session()
            auth = auth_session.auth
        else:  # not keystone
            if not self.options.os_url:
                raise exc.CommandError(
                    _("You must provide a service URL via"
                      " either --os-url or env[OS_URL]"))
            auth_session = None
            auth = None

        self.client_manager = clientmanager.ClientManager(
            token=self.options.os_token,
            url=self.options.os_url,
            auth_url=self.options.os_auth_url,
            tenant_name=self.options.os_tenant_name,
            tenant_id=self.options.os_tenant_id,
            username=self.options.os_username,
            user_id=self.options.os_user_id,
            password=self.options.os_password,
            region_name=self.options.os_region_name,
            api_version=self.api_version,
            auth_strategy=self.options.os_auth_strategy,
            # FIXME (bklei) honor deprecated service_type and
            # endpoint type until they are removed
            service_type=self.options.os_service_type
            or self.options.service_type,
            endpoint_type=self.options.os_endpoint_type or self.endpoint_type,
            insecure=self.options.insecure,
            ca_cert=self.options.os_cacert,
            timeout=self.options.http_timeout,
            retries=self.options.retries,
            raise_errors=False,
            session=auth_session,
            auth=auth,
            log_credentials=True)
        return
Пример #54
0
 def get_parser(self, prog_name):
     parser = super(RemoveGatewayRouter, self).get_parser(prog_name)
     parser.add_argument(
         'router_id', metavar='router-id',
         help=_('ID of the router'))
     return parser
Пример #55
0
 def add_known_arguments(self, parser):
     parser.add_argument('--tunnel_id', required=True, help=_('Tunnel id'))
     parser.add_argument('--network_cidr',
                         required=True,
                         help=_('network_cidr'))
Пример #56
0
 def get_parser(self, prog_name):
     parser = super(ListRouterPort, self).get_parser(prog_name)
     parser.add_argument('id',
                         metavar='router',
                         help=_('ID or name of router to look up.'))
     return parser
Пример #57
0
def parse_args_to_dict(values_specs):
    '''It is used to analyze the extra command options to command.

    Besides known options and arguments, our commands also support user to
    put more options to the end of command line. For example,
    list_nets -- --tag x y --key1 value1, where '-- --tag x y --key1 value1'
    is extra options to our list_nets. This feature can support V2.0 API's
    fields selection and filters. For example, to list networks which has name
    'test4', we can have list_nets -- --name=test4.

    value spec is: --key type=int|bool|... value. Type is one of Python
    built-in types. By default, type is string. The key without value is
    a bool option. Key with two values will be a list option.

    '''

    # values_specs for example: '-- --tag x y --key1 type=int value1'
    # -- is a pseudo argument
    values_specs_copy = values_specs[:]
    if values_specs_copy and values_specs_copy[0] == '--':
        del values_specs_copy[0]
    # converted ArgumentParser arguments for each of the options
    _options = {}
    # the argument part for current option in _options
    current_arg = None
    # the string after remove meta info in values_specs
    # for example, '--tag x y --key1 value1'
    _values_specs = []
    # record the count of values for an option
    # for example: for '--tag x y', it is 2, while for '--key1 value1', it is 1
    _value_number = 0
    # list=true
    _list_flag = False
    # action=clear
    _clear_flag = False
    # the current item in values_specs
    current_item = None
    # the str after 'type='
    current_type_str = None
    for _item in values_specs_copy:
        if _item.startswith('--'):
            # Deal with previous argument if any
            _process_previous_argument(current_arg, _value_number,
                                       current_type_str, _list_flag,
                                       _values_specs, _clear_flag,
                                       values_specs)

            # Init variables for current argument
            current_item = _item
            _list_flag = False
            _clear_flag = False
            current_type_str = None
            if "=" in _item:
                _value_number = 1
                _item = _item.split('=')[0]
            else:
                _value_number = 0
            if _item in _options:
                raise exceptions.CommandError(
                    _("Duplicated options %s") % ' '.join(values_specs))
            else:
                _options.update({_item: {}})
            current_arg = _options[_item]
            _item = current_item
        elif _item.startswith('type='):
            if current_arg is None:
                raise exceptions.CommandError(
                    _("Invalid values_specs %s") % ' '.join(values_specs))
            if 'type' not in current_arg:
                current_type_str = _item.split('=', 2)[1]
                current_arg.update({'type': eval(current_type_str)})
                if current_type_str == 'bool':
                    current_arg.update({'type': utils.str2bool})
                elif current_type_str == 'dict':
                    current_arg.update({'type': utils.str2dict})
                continue
        elif _item == 'list=true':
            _list_flag = True
            continue
        elif _item == 'action=clear':
            _clear_flag = True
            continue

        if not _item.startswith('--'):
            # All others are value items
            # Make sure '--' occurs first and allow minus value
            if (not current_item or '=' in current_item
                    or _item.startswith('-') and not is_number(_item)):
                raise exceptions.CommandError(
                    _("Invalid values_specs %s") % ' '.join(values_specs))
            _value_number += 1

        _values_specs.append(_item)

    # Deal with last one argument
    _process_previous_argument(current_arg, _value_number, current_type_str,
                               _list_flag, _values_specs, _clear_flag,
                               values_specs)

    # populate the parser with arguments
    _parser = argparse.ArgumentParser(add_help=False)
    for opt, optspec in six.iteritems(_options):
        _parser.add_argument(opt, **optspec)
    _args = _parser.parse_args(_values_specs)

    result_dict = {}
    for opt in _options.iterkeys():
        _opt = opt.split('--', 2)[1]
        _opt = _opt.replace('-', '_')
        _value = getattr(_args, _opt)
        result_dict.update({_opt: _value})
    return result_dict
Пример #58
0
 def get_parser(self, prog_name):
     parser = super(DisassociateFloatingIPSet, self).get_parser(prog_name)
     parser.add_argument('floatingipset_id',
                         metavar='FLOATINGIPSETID',
                         help=_('ID of the floating IP SET to associate'))
     return parser
Пример #59
0
    def _append_global_identity_args(self, parser):
        # FIXME(bklei): these are global identity (Keystone) arguments which
        # should be consistent and shared by all service clients. Therefore,
        # they should be provided by python-keystoneclient. We will need to
        # refactor this code once this functionality is available in
        # python-keystoneclient.
        #
        # Note: At that time we'll need to decide if we can just abandon
        #       the deprecated args (--service-type and --endpoint-type).

        parser.add_argument(
            '--os-service-type',
            metavar='<os-service-type>',
            default=env('OS_NETWORK_SERVICE_TYPE', default='network'),
            help=_('Defaults to env[OS_NETWORK_SERVICE_TYPE] or network.'))

        parser.add_argument(
            '--os-endpoint-type',
            metavar='<os-endpoint-type>',
            default=env('OS_ENDPOINT_TYPE', default='publicURL'),
            help=_('Defaults to env[OS_ENDPOINT_TYPE] or publicURL.'))

        # FIXME(bklei): --service-type is deprecated but kept in for
        # backward compatibility.
        parser.add_argument('--service-type',
                            metavar='<service-type>',
                            default=env('OS_NETWORK_SERVICE_TYPE',
                                        default='network'),
                            help=_('DEPRECATED! Use --os-service-type.'))

        # FIXME(bklei): --endpoint-type is deprecated but kept in for
        # backward compatibility.
        parser.add_argument('--endpoint-type',
                            metavar='<endpoint-type>',
                            default=env('OS_ENDPOINT_TYPE',
                                        default='publicURL'),
                            help=_('DEPRECATED! Use --os-endpoint-type.'))

        parser.add_argument('--os-auth-strategy',
                            metavar='<auth-strategy>',
                            default=env('OS_AUTH_STRATEGY',
                                        default='keystone'),
                            help=_('DEPRECATED! Only keystone is supported.'))

        parser.add_argument('--os_auth_strategy', help=argparse.SUPPRESS)

        parser.add_argument(
            '--os-auth-url',
            metavar='<auth-url>',
            default=env('OS_AUTH_URL'),
            help=_('Authentication URL, defaults to env[OS_AUTH_URL].'))
        parser.add_argument('--os_auth_url', help=argparse.SUPPRESS)

        project_name_group = parser.add_mutually_exclusive_group()
        project_name_group.add_argument(
            '--os-tenant-name',
            metavar='<auth-tenant-name>',
            default=env('OS_TENANT_NAME'),
            help=_('Authentication tenant name, defaults to '
                   'env[OS_TENANT_NAME].'))
        project_name_group.add_argument(
            '--os-project-name',
            metavar='<auth-project-name>',
            default=utils.env('OS_PROJECT_NAME'),
            help='Another way to specify tenant name. '
            'This option is mutually exclusive with '
            ' --os-tenant-name. '
            'Defaults to env[OS_PROJECT_NAME].')

        parser.add_argument('--os_tenant_name', help=argparse.SUPPRESS)

        project_id_group = parser.add_mutually_exclusive_group()
        project_id_group.add_argument(
            '--os-tenant-id',
            metavar='<auth-tenant-id>',
            default=env('OS_TENANT_ID'),
            help=_('Authentication tenant ID, defaults to '
                   'env[OS_TENANT_ID].'))
        project_id_group.add_argument('--os-project-id',
                                      metavar='<auth-project-id>',
                                      default=utils.env('OS_PROJECT_ID'),
                                      help='Another way to specify tenant ID. '
                                      'This option is mutually exclusive with '
                                      ' --os-tenant-id. '
                                      'Defaults to env[OS_PROJECT_ID].')

        parser.add_argument(
            '--os-username',
            metavar='<auth-username>',
            default=utils.env('OS_USERNAME'),
            help=_('Authentication username, defaults to env[OS_USERNAME].'))
        parser.add_argument('--os_username', help=argparse.SUPPRESS)

        parser.add_argument('--os-user-id',
                            metavar='<auth-user-id>',
                            default=env('OS_USER_ID'),
                            help=_('Authentication user ID (Env: OS_USER_ID)'))

        parser.add_argument('--os_user_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-user-domain-id',
                            metavar='<auth-user-domain-id>',
                            default=utils.env('OS_USER_DOMAIN_ID'),
                            help='OpenStack user domain ID. '
                            'Defaults to env[OS_USER_DOMAIN_ID].')

        parser.add_argument('--os_user_domain_id', help=argparse.SUPPRESS)

        parser.add_argument('--os-user-domain-name',
                            metavar='<auth-user-domain-name>',
                            default=utils.env('OS_USER_DOMAIN_NAME'),
                            help='OpenStack user domain name. '
                            'Defaults to env[OS_USER_DOMAIN_NAME].')

        parser.add_argument('--os_user_domain_name', help=argparse.SUPPRESS)

        parser.add_argument('--os_project_id', help=argparse.SUPPRESS)

        parser.add_argument('--os_project_name', help=argparse.SUPPRESS)

        parser.add_argument('--os-project-domain-id',
                            metavar='<auth-project-domain-id>',
                            default=utils.env('OS_PROJECT_DOMAIN_ID'),
                            help='Defaults to env[OS_PROJECT_DOMAIN_ID].')

        parser.add_argument('--os-project-domain-name',
                            metavar='<auth-project-domain-name>',
                            default=utils.env('OS_PROJECT_DOMAIN_NAME'),
                            help='Defaults to env[OS_PROJECT_DOMAIN_NAME].')

        parser.add_argument('--os-cert',
                            metavar='<certificate>',
                            default=utils.env('OS_CERT'),
                            help=_("Path of certificate file to use in SSL "
                                   "connection. This file can optionally be "
                                   "prepended with the private key. Defaults "
                                   "to env[OS_CERT]."))

        parser.add_argument('--os-cacert',
                            metavar='<ca-certificate>',
                            default=env('OS_CACERT', default=None),
                            help=_(
                                "Specify a CA bundle file to use in "
                                "verifying a TLS (https) server certificate. "
                                "Defaults to env[OS_CACERT]."))

        parser.add_argument('--os-key',
                            metavar='<key>',
                            default=utils.env('OS_KEY'),
                            help=_(
                                "Path of client key to use in SSL "
                                "connection. This option is not necessary "
                                "if your key is prepended to your certificate "
                                "file. Defaults to env[OS_KEY]."))

        parser.add_argument(
            '--os-password',
            metavar='<auth-password>',
            default=utils.env('OS_PASSWORD'),
            help=_('Authentication password, defaults to env[OS_PASSWORD].'))
        parser.add_argument('--os_password', help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
                            metavar='<auth-region-name>',
                            default=env('OS_REGION_NAME'),
                            help=_('Authentication region name, defaults to '
                                   'env[OS_REGION_NAME].'))
        parser.add_argument('--os_region_name', help=argparse.SUPPRESS)

        parser.add_argument(
            '--os-token',
            metavar='<token>',
            default=env('OS_TOKEN'),
            help=_('Authentication token, defaults to env[OS_TOKEN].'))
        parser.add_argument('--os_token', help=argparse.SUPPRESS)

        parser.add_argument(
            '--http-timeout',
            metavar='<seconds>',
            default=env('OS_NETWORK_TIMEOUT', default=None),
            type=float,
            help=_('Timeout in seconds to wait for an HTTP response. Defaults '
                   'to env[OS_NETWORK_TIMEOUT] or None if not specified.'))

        parser.add_argument('--os-url',
                            metavar='<url>',
                            default=env('OS_URL'),
                            help=_('Defaults to env[OS_URL].'))
        parser.add_argument('--os_url', help=argparse.SUPPRESS)

        parser.add_argument(
            '--insecure',
            action='store_true',
            default=env('NEUTRONCLIENT_INSECURE', default=False),
            help=_("Explicitly allow neutronclient to perform \"insecure\" "
                   "SSL (https) requests. The server's certificate will "
                   "not be verified against any certificate authorities. "
                   "This option should be used with caution."))
Пример #60
0
    def get_parser(self, prog_name):
        parser = super(UpdateQuota, self).get_parser(prog_name)
        parser.add_argument('--tenant-id',
                            metavar='tenant-id',
                            help=_('The owner tenant ID.'))
        parser.add_argument('--tenant_id', help=argparse.SUPPRESS)
        parser.add_argument('--network',
                            metavar='networks',
                            help=_('The limit of networks.'))
        parser.add_argument('--subnet',
                            metavar='subnets',
                            help=_('The limit of subnets.'))
        parser.add_argument('--port',
                            metavar='ports',
                            help=_('The limit of ports.'))
        parser.add_argument('--router',
                            metavar='routers',
                            help=_('The limit of routers.'))
        parser.add_argument('--floatingip',
                            metavar='floatingips',
                            help=_('The limit of floating IPs.'))
        parser.add_argument('--security-group',
                            metavar='security_groups',
                            help=_('The limit of security groups.'))
        parser.add_argument('--security-group-rule',
                            metavar='security_group_rules',
                            help=_('The limit of security groups rules.'))
        parser.add_argument('--vip',
                            metavar='vips',
                            help=_('The limit of vips.'))
        parser.add_argument('--pool',
                            metavar='pools',
                            help=_('The limit of pools.'))
        parser.add_argument('--member',
                            metavar='members',
                            help=_('The limit of pool members.'))
        parser.add_argument('--health-monitor',
                            metavar='health_monitors',
                            help=_('The limit of health monitors.'))

        return parser