Fix i18n messages in neutronclient
Using tools/check_i18n.py to scan source directory, and fix most of
the errors.
- Message internationalization
- First letter must be capital
- Using comma instead of percent in LOG.xxx
Partial-Bug: #1217100
Change-Id: I312f999f97e33d84c3f06fa1caacf32affc26a78
This commit is contained in:
@@ -31,6 +31,7 @@ import httplib2
|
||||
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.common import utils
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -215,7 +216,7 @@ class HTTPClient(httplib2.Http):
|
||||
|
||||
def authenticate(self):
|
||||
if self.auth_strategy != 'keystone':
|
||||
raise exceptions.Unauthorized(message='unknown auth strategy')
|
||||
raise exceptions.Unauthorized(message=_('Unknown auth strategy'))
|
||||
if self.tenant_id:
|
||||
body = {'auth': {'passwordCredentials':
|
||||
{'username': self.username,
|
||||
|
||||
@@ -120,7 +120,7 @@ class EndpointTypeNotFound(NeutronClientException):
|
||||
"""Could not find endpoint type in Service Catalog."""
|
||||
|
||||
def __str__(self):
|
||||
msg = "Could not find endpoint type %s in Service Catalog."
|
||||
msg = _("Could not find endpoint type %s in Service Catalog.")
|
||||
return msg % repr(self.message)
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class AmbiguousEndpoints(NeutronClientException):
|
||||
"""Found more than one matching endpoint in Service Catalog."""
|
||||
|
||||
def __str__(self):
|
||||
return "AmbiguousEndpoints: %s" % repr(self.message)
|
||||
return _("AmbiguousEndpoints: %s") % repr(self.message)
|
||||
|
||||
|
||||
class NeutronCLIError(NeutronClientException):
|
||||
|
||||
@@ -26,6 +26,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from neutronclient.common import _
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.openstack.common import strutils
|
||||
|
||||
@@ -97,8 +98,10 @@ def get_client_class(api_name, version, version_map):
|
||||
try:
|
||||
client_path = version_map[str(version)]
|
||||
except (KeyError, ValueError):
|
||||
msg = "Invalid %s client version '%s'. must be one of: %s" % (
|
||||
(api_name, version, ', '.join(version_map.keys())))
|
||||
msg = _("Invalid %(api_name)s client version '%(version)s'. must be "
|
||||
"one of: %(map_keys)s")
|
||||
msg = msg % {'api_name': api_name, 'version': version,
|
||||
'map_keys': ', '.join(version_map.keys())}
|
||||
raise exceptions.UnsupportedVersion(msg)
|
||||
|
||||
return import_class(client_path)
|
||||
@@ -170,13 +173,13 @@ def http_log_req(_logger, args, kwargs):
|
||||
if 'body' in kwargs and kwargs['body']:
|
||||
string_parts.append(" -d '%s'" % (kwargs['body']))
|
||||
string_parts = safe_encode_list(string_parts)
|
||||
_logger.debug("\nREQ: %s\n" % "".join(string_parts))
|
||||
_logger.debug(_("\nREQ: %s\n"), "".join(string_parts))
|
||||
|
||||
|
||||
def http_log_resp(_logger, resp, body):
|
||||
if not _logger.isEnabledFor(logging.DEBUG):
|
||||
return
|
||||
_logger.debug("RESP:%s %s\n", resp, body)
|
||||
_logger.debug(_("RESP:%(resp)s %(body)s\n"), {'resp': resp, 'body': body})
|
||||
|
||||
|
||||
def _safe_encode_without_obj(data):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.common import utils
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
API_NAME = 'network'
|
||||
@@ -49,7 +50,8 @@ def make_client(instance):
|
||||
ca_cert=instance._ca_cert)
|
||||
return client
|
||||
else:
|
||||
raise exceptions.UnsupportedVersion("API version %s is not supported" %
|
||||
raise exceptions.UnsupportedVersion(_("API version %s is not "
|
||||
"supported") %
|
||||
instance._api_version[API_NAME])
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ def find_resourceid_by_name_or_id(client, resource, name_or_id):
|
||||
def add_show_list_common_argument(parser):
|
||||
parser.add_argument(
|
||||
'-D', '--show-details',
|
||||
help='show detailed info',
|
||||
help=_('Show detailed info'),
|
||||
action='store_true',
|
||||
default=False, )
|
||||
parser.add_argument(
|
||||
@@ -105,8 +105,8 @@ def add_show_list_common_argument(parser):
|
||||
parser.add_argument(
|
||||
'-F', '--field',
|
||||
dest='fields', metavar='FIELD',
|
||||
help='specify the field(s) to be returned by server,'
|
||||
' can be repeated',
|
||||
help=_('Specify the field(s) to be returned by server,'
|
||||
' can be repeated'),
|
||||
action='append',
|
||||
default=[])
|
||||
|
||||
@@ -115,8 +115,8 @@ def add_pagination_argument(parser):
|
||||
parser.add_argument(
|
||||
'-P', '--page-size',
|
||||
dest='page_size', metavar='SIZE', type=int,
|
||||
help=("specify retrieve unit of each request, then split one request "
|
||||
"to several requests"),
|
||||
help=_("Specify retrieve unit of each request, then split one request "
|
||||
"to several requests"),
|
||||
default=None)
|
||||
|
||||
|
||||
@@ -125,16 +125,16 @@ def add_sorting_argument(parser):
|
||||
'--sort-key',
|
||||
dest='sort_key', metavar='FIELD',
|
||||
action='append',
|
||||
help=("sort list by specified fields (This option can be repeated), "
|
||||
"The number of sort_dir and sort_key should match each other, "
|
||||
"more sort_dir specified will be omitted, less will be filled "
|
||||
"with asc as default direction "),
|
||||
help=_("Sort list by specified fields (This option can be repeated), "
|
||||
"The number of sort_dir and sort_key should match each other, "
|
||||
"more sort_dir specified will be omitted, less will be filled "
|
||||
"with asc as default direction "),
|
||||
default=[])
|
||||
parser.add_argument(
|
||||
'--sort-dir',
|
||||
dest='sort_dir', metavar='{asc,desc}',
|
||||
help=("sort list in specified directions "
|
||||
"(This option can be repeated)"),
|
||||
help=_("Sort list in specified directions "
|
||||
"(This option can be repeated)"),
|
||||
action='append',
|
||||
default=[],
|
||||
choices=['asc', 'desc'])
|
||||
@@ -159,7 +159,7 @@ def _process_previous_argument(current_arg, _value_number, current_type_str,
|
||||
if _value_number == 0 and (current_type_str or _list_flag):
|
||||
# This kind of argument should have value
|
||||
raise exceptions.CommandError(
|
||||
"invalid values_specs %s" % ' '.join(values_specs))
|
||||
_("Invalid values_specs %s") % ' '.join(values_specs))
|
||||
if _value_number > 1 or _list_flag or current_type_str == 'list':
|
||||
current_arg.update({'nargs': '+'})
|
||||
elif _value_number == 0:
|
||||
@@ -230,7 +230,7 @@ def parse_args_to_dict(values_specs):
|
||||
_value_number = 0
|
||||
if _item in _options:
|
||||
raise exceptions.CommandError(
|
||||
"duplicated options %s" % ' '.join(values_specs))
|
||||
_("Duplicated options %s") % ' '.join(values_specs))
|
||||
else:
|
||||
_options.update({_item: {}})
|
||||
current_arg = _options[_item]
|
||||
@@ -238,7 +238,7 @@ def parse_args_to_dict(values_specs):
|
||||
elif _item.startswith('type='):
|
||||
if current_arg is None:
|
||||
raise exceptions.CommandError(
|
||||
"invalid values_specs %s" % ' '.join(values_specs))
|
||||
_("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)})
|
||||
@@ -260,7 +260,7 @@ def parse_args_to_dict(values_specs):
|
||||
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))
|
||||
_("Invalid values_specs %s") % ' '.join(values_specs))
|
||||
_value_number += 1
|
||||
|
||||
_values_specs.append(_item)
|
||||
@@ -351,7 +351,7 @@ class NeutronCommand(command.OpenStackCommand):
|
||||
parser = super(NeutronCommand, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--request-format',
|
||||
help=_('the xml or json request format'),
|
||||
help=_('The xml or json request format'),
|
||||
default='json',
|
||||
choices=['json', 'xml', ], )
|
||||
parser.add_argument(
|
||||
@@ -396,7 +396,7 @@ class CreateCommand(NeutronCommand, show.ShowOne):
|
||||
parser = super(CreateCommand, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--tenant-id', metavar='TENANT_ID',
|
||||
help=_('the owner tenant ID'), )
|
||||
help=_('The owner tenant ID'), )
|
||||
parser.add_argument(
|
||||
'--tenant_id',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -438,12 +438,12 @@ class UpdateCommand(NeutronCommand):
|
||||
parser = super(UpdateCommand, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'id', metavar=self.resource.upper(),
|
||||
help='ID or name of %s to update' % self.resource)
|
||||
help=_('ID or name of %s to update') % self.resource)
|
||||
self.add_known_arguments(parser)
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
self.log.debug('run(%s)' % 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)
|
||||
@@ -456,7 +456,7 @@ class UpdateCommand(NeutronCommand):
|
||||
body[self.resource] = _extra_values
|
||||
if not body[self.resource]:
|
||||
raise exceptions.CommandError(
|
||||
"Must specify new values to update %s" % self.resource)
|
||||
_("Must specify new values to update %s") % self.resource)
|
||||
if self.allow_names:
|
||||
_id = find_resourceid_by_name_or_id(
|
||||
neutron_client, self.resource, parsed_args.id)
|
||||
@@ -485,16 +485,16 @@ class DeleteCommand(NeutronCommand):
|
||||
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'
|
||||
help_str = _('ID or name of %s to delete')
|
||||
else:
|
||||
help_str = 'ID of %s to delete'
|
||||
help_str = _('ID of %s to delete')
|
||||
parser.add_argument(
|
||||
'id', metavar=self.resource.upper(),
|
||||
help=help_str % self.resource)
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
self.log.debug('run(%s)' % parsed_args)
|
||||
self.log.debug('run(%s)', parsed_args)
|
||||
neutron_client = self.get_client()
|
||||
neutron_client.format = parsed_args.request_format
|
||||
obj_deleter = getattr(neutron_client,
|
||||
@@ -604,7 +604,7 @@ class ListCommand(NeutronCommand, lister.Lister):
|
||||
for s in info), )
|
||||
|
||||
def get_data(self, parsed_args):
|
||||
self.log.debug('get_data(%s)' % parsed_args)
|
||||
self.log.debug('get_data(%s)', parsed_args)
|
||||
data = self.retrieve_list(parsed_args)
|
||||
self.extend_list(data, parsed_args)
|
||||
return self.setup_columns(data, parsed_args)
|
||||
@@ -624,16 +624,16 @@ class ShowCommand(NeutronCommand, show.ShowOne):
|
||||
parser = super(ShowCommand, self).get_parser(prog_name)
|
||||
add_show_list_common_argument(parser)
|
||||
if self.allow_names:
|
||||
help_str = 'ID or name of %s to look up'
|
||||
help_str = _('ID or name of %s to look up')
|
||||
else:
|
||||
help_str = 'ID of %s to look up'
|
||||
help_str = _('ID of %s to look up')
|
||||
parser.add_argument(
|
||||
'id', metavar=self.resource.upper(),
|
||||
help=help_str % self.resource)
|
||||
return parser
|
||||
|
||||
def get_data(self, parsed_args):
|
||||
self.log.debug('get_data(%s)' % parsed_args)
|
||||
self.log.debug('get_data(%s)', parsed_args)
|
||||
neutron_client = self.get_client()
|
||||
neutron_client.format = parsed_args.request_format
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ class AddNetworkToDhcpAgent(neutronV20.NeutronCommand):
|
||||
parser = super(AddNetworkToDhcpAgent, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'dhcp_agent',
|
||||
help='ID of the DHCP agent')
|
||||
help=_('ID of the DHCP agent'))
|
||||
parser.add_argument(
|
||||
'network',
|
||||
help='network to add')
|
||||
help=_('Network to add'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -59,10 +59,10 @@ class RemoveNetworkFromDhcpAgent(neutronV20.NeutronCommand):
|
||||
parser = super(RemoveNetworkFromDhcpAgent, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'dhcp_agent',
|
||||
help='ID of the DHCP agent')
|
||||
help=_('ID of the DHCP agent'))
|
||||
parser.add_argument(
|
||||
'network',
|
||||
help='network to remove')
|
||||
help=_('Network to remove'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -88,7 +88,7 @@ class ListNetworksOnDhcpAgent(network.ListNetwork):
|
||||
self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'dhcp_agent',
|
||||
help='ID of the DHCP agent')
|
||||
help=_('ID of the DHCP agent'))
|
||||
return parser
|
||||
|
||||
def call_server(self, neutron_client, search_opts, parsed_args):
|
||||
@@ -111,7 +111,7 @@ class ListDhcpAgentsHostingNetwork(neutronV20.ListCommand):
|
||||
self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'network',
|
||||
help='network to query')
|
||||
help=_('Network to query'))
|
||||
return parser
|
||||
|
||||
def extend_list(self, data, parsed_args):
|
||||
@@ -136,10 +136,10 @@ class AddRouterToL3Agent(neutronV20.NeutronCommand):
|
||||
parser = super(AddRouterToL3Agent, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'l3_agent',
|
||||
help='ID of the L3 agent')
|
||||
help=_('ID of the L3 agent'))
|
||||
parser.add_argument(
|
||||
'router',
|
||||
help='router to add')
|
||||
help=_('Router to add'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -163,10 +163,10 @@ class RemoveRouterFromL3Agent(neutronV20.NeutronCommand):
|
||||
parser = super(RemoveRouterFromL3Agent, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'l3_agent',
|
||||
help='ID of the L3 agent')
|
||||
help=_('ID of the L3 agent'))
|
||||
parser.add_argument(
|
||||
'router',
|
||||
help='router to remove')
|
||||
help=_('Router to remove'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -196,7 +196,7 @@ class ListRoutersOnL3Agent(neutronV20.ListCommand):
|
||||
self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'l3_agent',
|
||||
help='ID of the L3 agent to query')
|
||||
help=_('ID of the L3 agent to query'))
|
||||
return parser
|
||||
|
||||
def call_server(self, neutron_client, search_opts, parsed_args):
|
||||
@@ -218,7 +218,7 @@ class ListL3AgentsHostingRouter(neutronV20.ListCommand):
|
||||
parser = super(ListL3AgentsHostingRouter,
|
||||
self).get_parser(prog_name)
|
||||
parser.add_argument('router',
|
||||
help='router to query')
|
||||
help=_('Router to query'))
|
||||
return parser
|
||||
|
||||
def extend_list(self, data, parsed_args):
|
||||
@@ -247,7 +247,7 @@ class ListPoolsOnLbaasAgent(neutronV20.ListCommand):
|
||||
parser = super(ListPoolsOnLbaasAgent, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'lbaas_agent',
|
||||
help='ID of the loadbalancer agent to query')
|
||||
help=_('ID of the loadbalancer agent to query'))
|
||||
return parser
|
||||
|
||||
def call_server(self, neutron_client, search_opts, parsed_args):
|
||||
@@ -272,7 +272,7 @@ class GetLbaasAgentHostingPool(neutronV20.ListCommand):
|
||||
parser = super(GetLbaasAgentHostingPool,
|
||||
self).get_parser(prog_name)
|
||||
parser.add_argument('pool',
|
||||
help='pool to query')
|
||||
help=_('Pool to query'))
|
||||
return parser
|
||||
|
||||
def extend_list(self, data, parsed_args):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListCredential(neutronV20.ListCommand):
|
||||
@@ -46,16 +47,16 @@ class CreateCredential(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'credential_name',
|
||||
help='Name/Ip address for Credential')
|
||||
help=_('Name/Ip address for Credential'))
|
||||
parser.add_argument(
|
||||
'credential_type',
|
||||
help='Type of the Credential')
|
||||
help=_('Type of the Credential'))
|
||||
parser.add_argument(
|
||||
'--username',
|
||||
help='Username for the credential')
|
||||
help=_('Username for the credential'))
|
||||
parser.add_argument(
|
||||
'--password',
|
||||
help='Password for the credential')
|
||||
help=_('Password for the credential'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'credential': {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as cmd_base
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListExt(cmd_base.ListCommand):
|
||||
@@ -40,5 +41,5 @@ class ShowExt(cmd_base.ShowCommand):
|
||||
cmd_base.add_show_list_common_argument(parser)
|
||||
parser.add_argument(
|
||||
'id', metavar='EXT-ALIAS',
|
||||
help='the extension alias')
|
||||
help=_('The extension alias'))
|
||||
return parser
|
||||
|
||||
@@ -50,17 +50,17 @@ class CreateFloatingIP(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'floating_network_id', metavar='FLOATING_NETWORK',
|
||||
help='Network name or id to allocate floating IP from')
|
||||
help=_('Network name or id to allocate floating IP from'))
|
||||
parser.add_argument(
|
||||
'--port-id',
|
||||
help='ID of the port to be associated with the floatingip')
|
||||
help=_('ID of the port to be associated with the floatingip'))
|
||||
parser.add_argument(
|
||||
'--port_id',
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--fixed-ip-address',
|
||||
help=('IP address on the port (only required if port has multiple'
|
||||
'IPs)'))
|
||||
help=_('IP address on the port (only required if port has multiple'
|
||||
'IPs)'))
|
||||
parser.add_argument(
|
||||
'--fixed_ip_address',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -98,14 +98,15 @@ class AssociateFloatingIP(neutronV20.NeutronCommand):
|
||||
parser = super(AssociateFloatingIP, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'floatingip_id', metavar='FLOATINGIP_ID',
|
||||
help='ID of the floating IP to associate')
|
||||
help=_('ID of the floating IP to associate'))
|
||||
parser.add_argument(
|
||||
'port_id', metavar='PORT',
|
||||
help='ID or name of the port to be associated with the floatingip')
|
||||
help=_('ID or name of the port to be associated with the '
|
||||
'floatingip'))
|
||||
parser.add_argument(
|
||||
'--fixed-ip-address',
|
||||
help=('IP address on the port (only required if port has multiple'
|
||||
'IPs)'))
|
||||
help=_('IP address on the port (only required if port has multiple'
|
||||
'IPs)'))
|
||||
parser.add_argument(
|
||||
'--fixed_ip_address',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -138,7 +139,7 @@ class DisassociateFloatingIP(neutronV20.NeutronCommand):
|
||||
parser = super(DisassociateFloatingIP, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'floatingip_id', metavar='FLOATINGIP_ID',
|
||||
help='ID of the floating IP to associate')
|
||||
help=_('ID of the floating IP to associate'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
|
||||
@@ -21,6 +21,7 @@ import argparse
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListFirewall(neutronv20.ListCommand):
|
||||
@@ -50,23 +51,23 @@ class CreateFirewall(neutronv20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'firewall_policy_id', metavar='POLICY',
|
||||
help='firewall policy id')
|
||||
help=_('Firewall policy id'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='name for the firewall')
|
||||
help=_('Name for the firewall'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description for the firewall rule')
|
||||
help=_('Description for the firewall rule'))
|
||||
parser.add_argument(
|
||||
'--shared',
|
||||
action='store_true',
|
||||
help='set shared to True (default False)',
|
||||
help=_('Set shared to True (default False)'),
|
||||
default=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state',
|
||||
action='store_false',
|
||||
help='set admin state up to false')
|
||||
help=_('Set admin state up to false'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_policy_id = neutronv20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -63,24 +63,24 @@ class CreateFirewallPolicy(neutronv20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'name',
|
||||
metavar='NAME',
|
||||
help='name for the firewall policy')
|
||||
help=_('Name for the firewall policy'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description for the firewall policy')
|
||||
help=_('Description for the firewall policy'))
|
||||
parser.add_argument(
|
||||
'--shared',
|
||||
dest='shared',
|
||||
action='store_true',
|
||||
help='to create a shared policy',
|
||||
help=_('To create a shared policy'),
|
||||
default=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--firewall-rules', type=string.split,
|
||||
help='ordered list of whitespace-delimited firewall rule '
|
||||
'names or IDs; e.g., --firewall-rules \"rule1 rule2\"')
|
||||
help=_('Ordered list of whitespace-delimited firewall rule '
|
||||
'names or IDs; e.g., --firewall-rules \"rule1 rule2\"'))
|
||||
parser.add_argument(
|
||||
'--audited',
|
||||
action='store_true',
|
||||
help='to set audited to True',
|
||||
help=_('To set audited to True'),
|
||||
default=argparse.SUPPRESS)
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
@@ -155,15 +155,15 @@ class FirewallPolicyInsertRule(neutronv20.UpdateCommand):
|
||||
parser.add_argument(
|
||||
'--insert-before',
|
||||
metavar='FIREWALL_RULE',
|
||||
help='insert before this rule')
|
||||
help=_('Insert before this rule'))
|
||||
parser.add_argument(
|
||||
'--insert-after',
|
||||
metavar='FIREWALL_RULE',
|
||||
help='insert after this rule')
|
||||
help=_('Insert after this rule'))
|
||||
parser.add_argument(
|
||||
'firewall_rule_id',
|
||||
metavar='FIREWALL_RULE',
|
||||
help='new rule to insert')
|
||||
help=_('New rule to insert'))
|
||||
self.add_known_arguments(parser)
|
||||
return parser
|
||||
|
||||
@@ -205,7 +205,7 @@ class FirewallPolicyRemoveRule(neutronv20.UpdateCommand):
|
||||
parser.add_argument(
|
||||
'firewall_rule_id',
|
||||
metavar='FIREWALL_RULE',
|
||||
help='firewall rule to remove from policy')
|
||||
help=_('Firewall rule to remove from policy'))
|
||||
self.add_known_arguments(parser)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import argparse
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListFirewallRule(neutronv20.ListCommand):
|
||||
@@ -76,43 +77,43 @@ class CreateFirewallRule(neutronv20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='name for the firewall rule')
|
||||
help=_('Name for the firewall rule'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description for the firewall rule')
|
||||
help=_('Description for the firewall rule'))
|
||||
parser.add_argument(
|
||||
'--shared',
|
||||
dest='shared',
|
||||
action='store_true',
|
||||
help='set shared to True (default False)',
|
||||
help=_('Set shared to True (default False)'),
|
||||
default=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--source-ip-address',
|
||||
help='source ip address or subnet')
|
||||
help=_('Source ip address or subnet'))
|
||||
parser.add_argument(
|
||||
'--destination-ip-address',
|
||||
help='destination ip address or subnet')
|
||||
help=_('Destination ip address or subnet'))
|
||||
parser.add_argument(
|
||||
'--source-port',
|
||||
help='source port (integer in [1, 65535] or range in a:b)')
|
||||
help=_('Source port (integer in [1, 65535] or range in a:b)'))
|
||||
parser.add_argument(
|
||||
'--destination-port',
|
||||
help='destination port (integer in [1, 65535] or range in a:b)')
|
||||
help=_('Destination port (integer in [1, 65535] or range in a:b)'))
|
||||
parser.add_argument(
|
||||
'--disabled',
|
||||
dest='enabled',
|
||||
action='store_false',
|
||||
help='to disable this rule',
|
||||
help=_('To disable this rule'),
|
||||
default=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--protocol', choices=['tcp', 'udp', 'icmp', 'any'],
|
||||
required=True,
|
||||
help='protocol for the firewall rule')
|
||||
help=_('Protocol for the firewall rule'))
|
||||
parser.add_argument(
|
||||
'--action',
|
||||
required=True,
|
||||
choices=['allow', 'deny'],
|
||||
help='action for the firewall rule')
|
||||
help=_('Action for the firewall rule'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
@@ -140,7 +141,7 @@ class UpdateFirewallRule(neutronv20.UpdateCommand):
|
||||
parser.add_argument(
|
||||
'--protocol', choices=['tcp', 'udp', 'icmp', 'any'],
|
||||
required=False,
|
||||
help='protocol for the firewall rule')
|
||||
help=_('Protocol for the firewall rule'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
|
||||
@@ -50,43 +50,43 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='set admin state up to false')
|
||||
help=_('Set admin state up to false'))
|
||||
parser.add_argument(
|
||||
'--expected-codes',
|
||||
help='the list of HTTP status codes expected in '
|
||||
'response from the member to declare it healthy. This '
|
||||
'attribute can contain one value, '
|
||||
'or a list of values separated by comma, '
|
||||
'or a range of values (e.g. "200-299"). If this attribute '
|
||||
'is not specified, it defaults to "200". ')
|
||||
help=_('The list of HTTP status codes expected in '
|
||||
'response from the member to declare it healthy. This '
|
||||
'attribute can contain one value, '
|
||||
'or a list of values separated by comma, '
|
||||
'or a range of values (e.g. "200-299"). If this attribute '
|
||||
'is not specified, it defaults to "200". '))
|
||||
parser.add_argument(
|
||||
'--http-method',
|
||||
help='the HTTP method used for requests by the monitor of type '
|
||||
'HTTP.')
|
||||
help=_('The HTTP method used for requests by the monitor of type '
|
||||
'HTTP.'))
|
||||
parser.add_argument(
|
||||
'--url-path',
|
||||
help='the HTTP path used in the HTTP request used by the monitor'
|
||||
' to test a member health. This must be a string '
|
||||
'beginning with a / (forward slash)')
|
||||
help=_('The HTTP path used in the HTTP request used by the monitor'
|
||||
' to test a member health. This must be a string '
|
||||
'beginning with a / (forward slash)'))
|
||||
parser.add_argument(
|
||||
'--delay',
|
||||
required=True,
|
||||
help='the time in seconds between sending probes to members.')
|
||||
help=_('The time in seconds between sending probes to members.'))
|
||||
parser.add_argument(
|
||||
'--max-retries',
|
||||
required=True,
|
||||
help='number of permissible connection failures before changing '
|
||||
'the member status to INACTIVE. [1..10]')
|
||||
help=_('Number of permissible connection failures before changing '
|
||||
'the member status to INACTIVE. [1..10]'))
|
||||
parser.add_argument(
|
||||
'--timeout',
|
||||
required=True,
|
||||
help='maximum number of seconds for a monitor to wait for a '
|
||||
'connection to be established before it times out. The '
|
||||
'value must be less than the delay value.')
|
||||
help=_('Maximum number of seconds for a monitor to wait for a '
|
||||
'connection to be established before it times out. The '
|
||||
'value must be less than the delay value.'))
|
||||
parser.add_argument(
|
||||
'--type',
|
||||
required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
|
||||
help='one of predefined health monitor types')
|
||||
help=_('One of predefined health monitor types'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
@@ -129,10 +129,10 @@ class AssociateHealthMonitor(neutronV20.NeutronCommand):
|
||||
parser = super(AssociateHealthMonitor, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'health_monitor_id', metavar='HEALTH_MONITOR_ID',
|
||||
help='Health monitor to associate')
|
||||
help=_('Health monitor to associate'))
|
||||
parser.add_argument(
|
||||
'pool_id', metavar='POOL',
|
||||
help='ID of the pool to be associated with the health monitor')
|
||||
help=_('ID of the pool to be associated with the health monitor'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -156,10 +156,10 @@ class DisassociateHealthMonitor(neutronV20.NeutronCommand):
|
||||
parser = super(DisassociateHealthMonitor, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'health_monitor_id', metavar='HEALTH_MONITOR_ID',
|
||||
help='Health monitor to associate')
|
||||
help=_('Health monitor to associate'))
|
||||
parser.add_argument(
|
||||
'pool_id', metavar='POOL',
|
||||
help='ID of the pool to be associated with the health monitor')
|
||||
help=_('ID of the pool to be associated with the health monitor'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListMember(neutronV20.ListCommand):
|
||||
@@ -50,23 +51,23 @@ class CreateMember(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'pool_id', metavar='POOL',
|
||||
help='Pool id or name this vip belongs to')
|
||||
help=_('Pool id or name this vip belongs to'))
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='set admin state up to false')
|
||||
help=_('Set admin state up to false'))
|
||||
parser.add_argument(
|
||||
'--weight',
|
||||
help='weight of pool member in the pool (default:1, [0..256])')
|
||||
help=_('Weight of pool member in the pool (default:1, [0..256])'))
|
||||
parser.add_argument(
|
||||
'--address',
|
||||
required=True,
|
||||
help='IP address of the pool member on the pool network. ')
|
||||
help=_('IP address of the pool member on the pool network. '))
|
||||
parser.add_argument(
|
||||
'--protocol-port',
|
||||
required=True,
|
||||
help='port on which the pool member listens for requests or '
|
||||
'connections. ')
|
||||
help=_('Port on which the pool member listens for requests or '
|
||||
'connections. '))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_pool_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
def _format_provider(pool):
|
||||
@@ -55,32 +56,33 @@ class CreatePool(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='set admin state up to false')
|
||||
help=_('Set admin state up to false'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description of the pool')
|
||||
help=_('Description of the pool'))
|
||||
parser.add_argument(
|
||||
'--lb-method',
|
||||
required=True,
|
||||
choices=['ROUND_ROBIN', 'LEAST_CONNECTIONS', 'SOURCE_IP'],
|
||||
help='the algorithm used to distribute load between the members '
|
||||
'of the pool')
|
||||
help=_('The algorithm used to distribute load between the members '
|
||||
'of the pool'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
required=True,
|
||||
help='the name of the pool')
|
||||
help=_('The name of the pool'))
|
||||
parser.add_argument(
|
||||
'--protocol',
|
||||
required=True,
|
||||
choices=['HTTP', 'HTTPS', 'TCP'],
|
||||
help='protocol for balancing')
|
||||
help=_('Protocol for balancing'))
|
||||
parser.add_argument(
|
||||
'--subnet-id', metavar='SUBNET',
|
||||
required=True,
|
||||
help='the subnet on which the members of the pool will be located')
|
||||
help=_('The subnet on which the members of the pool will be '
|
||||
'located'))
|
||||
parser.add_argument(
|
||||
'--provider',
|
||||
help='provider name of loadbalancer service')
|
||||
help=_('Provider name of loadbalancer service'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_subnet_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListVip(neutronV20.ListCommand):
|
||||
@@ -49,38 +50,38 @@ class CreateVip(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'pool_id', metavar='POOL',
|
||||
help='Pool id or name this vip belongs to')
|
||||
help=_('Pool id or name this vip belongs to'))
|
||||
parser.add_argument(
|
||||
'--address',
|
||||
help='IP address of the vip')
|
||||
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')
|
||||
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)')
|
||||
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')
|
||||
help=_('Description of the vip'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
required=True,
|
||||
help='name of the vip')
|
||||
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')
|
||||
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')
|
||||
help=_('Protocol for balancing'))
|
||||
parser.add_argument(
|
||||
'--subnet-id', metavar='SUBNET',
|
||||
required=True,
|
||||
help='the subnet on which to allocate the vip address')
|
||||
help=_('The subnet on which to allocate the vip address'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_pool_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListMeteringLabel(neutronv20.ListCommand):
|
||||
@@ -46,10 +47,10 @@ class CreateMeteringLabel(neutronv20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of metering label to create')
|
||||
help=_('Name of metering label to create'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description of metering label to create')
|
||||
help=_('Description of metering label to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'metering_label': {
|
||||
@@ -97,18 +98,18 @@ class CreateMeteringLabelRule(neutronv20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'label_id', metavar='LABEL',
|
||||
help='Id or Name of the label')
|
||||
help=_('Id or Name of the label'))
|
||||
parser.add_argument(
|
||||
'remote_ip_prefix', metavar='REMOTE_IP_PREFIX',
|
||||
help='cidr to match on')
|
||||
help=_('CIDR to match on'))
|
||||
parser.add_argument(
|
||||
'--direction',
|
||||
default='ingress', choices=['ingress', 'egress'],
|
||||
help='direction of traffic, default:ingress')
|
||||
help=_('Direction of traffic, default:ingress'))
|
||||
parser.add_argument(
|
||||
'--excluded',
|
||||
action='store_true',
|
||||
help='exclude this cidr from the label, default:not excluded')
|
||||
help=_('Exclude this cidr from the label, default:not excluded'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
neutron_client = self.get_client()
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
def _format_subnets(network):
|
||||
@@ -114,7 +115,7 @@ class CreateNetwork(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='Set Admin State Up to false')
|
||||
help=_('Set Admin State Up to false'))
|
||||
parser.add_argument(
|
||||
'--admin_state_down',
|
||||
dest='admin_state', action='store_false',
|
||||
@@ -122,11 +123,11 @@ class CreateNetwork(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--shared',
|
||||
action='store_true',
|
||||
help='Set the network as shared',
|
||||
help=_('Set the network as shared'),
|
||||
default=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of network to create')
|
||||
help=_('Name of network to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'network': {
|
||||
|
||||
@@ -53,23 +53,23 @@ class CreateNetworkProfile(neutronV20.CreateCommand):
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument('name',
|
||||
help='Name for Network Profile')
|
||||
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-'
|
||||
help=_('Sub-type for the segment. Available sub-'
|
||||
'types for overlay segments: native, enhanced; '
|
||||
'For trunk segments: vlan, overlay.')
|
||||
'For trunk segments: vlan, overlay.'))
|
||||
parser.add_argument('--segment_range',
|
||||
help='Range for the Segment')
|
||||
help=_('Range for the Segment'))
|
||||
parser.add_argument('--physical_network',
|
||||
help='Name for the Physical Network')
|
||||
help=_('Name for the Physical Network'))
|
||||
parser.add_argument('--multicast_ip_range',
|
||||
help='Multicast IPv4 Range')
|
||||
help=_('Multicast IPv4 Range'))
|
||||
parser.add_argument("--add-tenant",
|
||||
help="Add tenant to the network profile")
|
||||
help=_("Add tenant to the network profile"))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'network_profile': {'name': parsed_args.name}}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListQoSQueue(neutronV20.ListCommand):
|
||||
@@ -46,24 +47,24 @@ class CreateQoSQueue(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of queue')
|
||||
help=_('Name of queue'))
|
||||
parser.add_argument(
|
||||
'--min',
|
||||
help='min-rate'),
|
||||
help=_('min-rate')),
|
||||
parser.add_argument(
|
||||
'--max',
|
||||
help='max-rate'),
|
||||
help=_('max-rate')),
|
||||
parser.add_argument(
|
||||
'--qos-marking',
|
||||
help='qos marking untrusted/trusted'),
|
||||
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')),
|
||||
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'),
|
||||
help=_('Differentiated Services Code Point')),
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
params = {'name': parsed_args.name,
|
||||
|
||||
@@ -48,14 +48,14 @@ class CreateNetworkGateway(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of network gateway to create')
|
||||
help=_('Name of network gateway to create'))
|
||||
parser.add_argument(
|
||||
'--device',
|
||||
action='append',
|
||||
help='device info for this gateway '
|
||||
help=_('Device info for this gateway '
|
||||
'device_id=<device identifier>,'
|
||||
'interface_name=<name_or_identifier> '
|
||||
'It can be repeated for multiple devices for HA gateways')
|
||||
'It can be repeated for multiple devices for HA gateways'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {
|
||||
@@ -95,18 +95,18 @@ class NetworkGatewayInterfaceCommand(neutronV20.NeutronCommand):
|
||||
self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'net_gateway_id', metavar='NET-GATEWAY-ID',
|
||||
help='ID of the network gateway')
|
||||
help=_('ID of the network gateway'))
|
||||
parser.add_argument(
|
||||
'network_id', metavar='NETWORK-ID',
|
||||
help='ID of the internal network to connect on the gateway')
|
||||
help=_('ID of the internal network to connect on the gateway'))
|
||||
parser.add_argument(
|
||||
'--segmentation-type',
|
||||
help=('L2 segmentation strategy on the external side of '
|
||||
'the gateway (e.g.: VLAN, FLAT)'))
|
||||
help=_('L2 segmentation strategy on the external side of '
|
||||
'the gateway (e.g.: VLAN, FLAT)'))
|
||||
parser.add_argument(
|
||||
'--segmentation-id',
|
||||
help=('Identifier for the L2 segment on the external side '
|
||||
'of the gateway'))
|
||||
help=_('Identifier for the L2 segment on the external side '
|
||||
'of the gateway'))
|
||||
return parser
|
||||
|
||||
def retrieve_ids(self, client, args):
|
||||
|
||||
@@ -57,9 +57,9 @@ class UpdatePolicyProfileV2(neutronV20.UpdateCommand):
|
||||
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")
|
||||
help=_("Add tenant to the policy profile"))
|
||||
parser.add_argument("--remove-tenant",
|
||||
help="Remove tenant from the policy profile")
|
||||
help=_("Remove tenant from the policy profile"))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
|
||||
@@ -21,6 +21,7 @@ import logging
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.common import utils
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
def _format_fixed_ips(port):
|
||||
@@ -55,7 +56,7 @@ class ListRouterPort(neutronV20.ListCommand):
|
||||
parser = super(ListRouterPort, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'id', metavar='router',
|
||||
help='ID or name of router to look up')
|
||||
help=_('ID or name of router to look up'))
|
||||
return parser
|
||||
|
||||
def get_data(self, parsed_args):
|
||||
@@ -80,12 +81,12 @@ class UpdatePortSecGroupMixin(object):
|
||||
group_sg.add_argument(
|
||||
'--security-group', metavar='SECURITY_GROUP',
|
||||
default=[], action='append', dest='security_groups',
|
||||
help='security group associated with the port '
|
||||
'(This option can be repeated)')
|
||||
help=_('Security group associated with the port '
|
||||
'(This option can be repeated)'))
|
||||
group_sg.add_argument(
|
||||
'--no-security-groups',
|
||||
action='store_true',
|
||||
help='associate no security groups with the port')
|
||||
help=_('Associate no security groups with the port'))
|
||||
|
||||
def _resolv_sgid(self, secgroup):
|
||||
return neutronV20.find_resourceid_by_name_or_id(
|
||||
@@ -107,9 +108,9 @@ class UpdateExtraDhcpOptMixin(object):
|
||||
default=[],
|
||||
action='append',
|
||||
dest='extra_dhcp_opts',
|
||||
help='extra dhcp options to be assigned to this port: '
|
||||
'opt_name=<dhcp_option_name>,opt_value=<value>, '
|
||||
'(This option can be repeated.)')
|
||||
help=_('Extra dhcp options to be assigned to this port: '
|
||||
'opt_name=<dhcp_option_name>,opt_value=<value>, '
|
||||
'(This option can be repeated.)'))
|
||||
|
||||
def args2body_extradhcpopt(self, parsed_args, port):
|
||||
ops = []
|
||||
@@ -118,9 +119,9 @@ class UpdateExtraDhcpOptMixin(object):
|
||||
# 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.")
|
||||
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))
|
||||
@@ -147,33 +148,33 @@ class CreatePort(neutronV20.CreateCommand, UpdatePortSecGroupMixin,
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='name of this port')
|
||||
help=_('Name of this port'))
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='set admin state up to 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')
|
||||
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')
|
||||
help=_('Device id of this port'))
|
||||
parser.add_argument(
|
||||
'--device_id',
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--fixed-ip', metavar='ip_address=IP_ADDR',
|
||||
action='append',
|
||||
help='desired IP for this port: '
|
||||
'subnet_id=<name_or_id>,ip_address=<ip>, '
|
||||
'(This option can be repeated.)')
|
||||
help=_('Desired IP for this port: '
|
||||
'subnet_id=<name_or_id>,ip_address=<ip>, '
|
||||
'(This option can be repeated.)'))
|
||||
parser.add_argument(
|
||||
'--fixed_ip',
|
||||
action='append',
|
||||
@@ -184,7 +185,7 @@ class CreatePort(neutronV20.CreateCommand, UpdatePortSecGroupMixin,
|
||||
|
||||
parser.add_argument(
|
||||
'network_id', metavar='NETWORK',
|
||||
help='Network id or name this port belongs to')
|
||||
help=_('Network id or name this port belongs to'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_network_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -43,7 +43,7 @@ class DeleteQuota(neutronV20.NeutronCommand):
|
||||
parser = super(DeleteQuota, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--tenant-id', metavar='tenant-id',
|
||||
help='the owner tenant ID')
|
||||
help=_('The owner tenant ID'))
|
||||
parser.add_argument(
|
||||
'--tenant_id',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -76,7 +76,7 @@ class ListQuota(neutronV20.NeutronCommand, lister.Lister):
|
||||
return parser
|
||||
|
||||
def get_data(self, parsed_args):
|
||||
self.log.debug('get_data(%s)' % parsed_args)
|
||||
self.log.debug('get_data(%s)', parsed_args)
|
||||
neutron_client = self.get_client()
|
||||
search_opts = {}
|
||||
self.log.debug('search options: %s', search_opts)
|
||||
@@ -105,14 +105,14 @@ class ShowQuota(neutronV20.NeutronCommand, show.ShowOne):
|
||||
parser = super(ShowQuota, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--tenant-id', metavar='tenant-id',
|
||||
help='the owner tenant ID')
|
||||
help=_('The owner tenant ID'))
|
||||
parser.add_argument(
|
||||
'--tenant_id',
|
||||
help=argparse.SUPPRESS)
|
||||
return parser
|
||||
|
||||
def get_data(self, parsed_args):
|
||||
self.log.debug('get_data(%s)' % parsed_args)
|
||||
self.log.debug('get_data(%s)', parsed_args)
|
||||
neutron_client = self.get_client()
|
||||
neutron_client.format = parsed_args.request_format
|
||||
tenant_id = get_tenant_id(parsed_args.tenant_id,
|
||||
@@ -150,38 +150,38 @@ class UpdateQuota(neutronV20.NeutronCommand, show.ShowOne):
|
||||
parser = super(UpdateQuota, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--tenant-id', metavar='tenant-id',
|
||||
help='the owner 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')
|
||||
help=_('The limit of networks'))
|
||||
parser.add_argument(
|
||||
'--subnet', metavar='subnets',
|
||||
help='the limit of subnets')
|
||||
help=_('The limit of subnets'))
|
||||
parser.add_argument(
|
||||
'--port', metavar='ports',
|
||||
help='the limit of ports')
|
||||
help=_('The limit of ports'))
|
||||
parser.add_argument(
|
||||
'--router', metavar='routers',
|
||||
help='the limit of routers')
|
||||
help=_('The limit of routers'))
|
||||
parser.add_argument(
|
||||
'--floatingip', metavar='floatingips',
|
||||
help='the limit of floating IPs')
|
||||
help=_('The limit of floating IPs'))
|
||||
parser.add_argument(
|
||||
'--security-group', metavar='security_groups',
|
||||
help='the limit of 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')
|
||||
help=_('The limit of security groups rules'))
|
||||
return parser
|
||||
|
||||
def _validate_int(self, name, value):
|
||||
try:
|
||||
return_value = int(value)
|
||||
except Exception:
|
||||
message = (_('quota limit for %(name)s must be an integer') %
|
||||
message = (_('Quota limit for %(name)s must be an integer') %
|
||||
{'name': name})
|
||||
raise exceptions.NeutronClientException(message=message)
|
||||
return return_value
|
||||
@@ -197,7 +197,7 @@ class UpdateQuota(neutronV20.NeutronCommand, show.ShowOne):
|
||||
return {self.resource: quota}
|
||||
|
||||
def get_data(self, parsed_args):
|
||||
self.log.debug('run(%s)' % parsed_args)
|
||||
self.log.debug('run(%s)', parsed_args)
|
||||
neutron_client = self.get_client()
|
||||
neutron_client.format = parsed_args.request_format
|
||||
_extra_values = neutronV20.parse_args_to_dict(self.values_specs)
|
||||
|
||||
@@ -60,17 +60,17 @@ class CreateRouter(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='Set Admin State Up to 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(
|
||||
'name', metavar='NAME',
|
||||
help='Name of router to create')
|
||||
help=_('Name of router to create'))
|
||||
parser.add_argument(
|
||||
'distributed', action='store_true',
|
||||
help='Create a distributed router (Nicira plugin only)')
|
||||
help=_('Create a distributed router (Nicira plugin only)'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'router': {
|
||||
@@ -111,13 +111,13 @@ class RouterInterfaceCommand(neutronV20.NeutronCommand):
|
||||
parser = super(RouterInterfaceCommand, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'router_id', metavar='router-id',
|
||||
help='ID of the router')
|
||||
help=_('ID of the router'))
|
||||
parser.add_argument(
|
||||
'interface', metavar='INTERFACE',
|
||||
help='The format is "SUBNET|subnet=SUBNET|port=PORT". '
|
||||
help=_('The format is "SUBNET|subnet=SUBNET|port=PORT". '
|
||||
'Either a subnet or port must be specified. '
|
||||
'Both ID and name are accepted as SUBNET or PORT. '
|
||||
'Note that "subnet=" can be omitted when specifying subnet.')
|
||||
'Note that "subnet=" can be omitted when specifying subnet.'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -128,8 +128,8 @@ class RouterInterfaceCommand(neutronV20.NeutronCommand):
|
||||
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.')
|
||||
exceptions.CommandError(_('You must specify either subnet or '
|
||||
'port for INTERFACE parameter.'))
|
||||
else:
|
||||
resource = 'subnet'
|
||||
value = parsed_args.interface
|
||||
@@ -183,13 +183,13 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
|
||||
parser = super(SetGatewayRouter, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'router_id', metavar='router-id',
|
||||
help='ID of the router')
|
||||
help=_('ID of the router'))
|
||||
parser.add_argument(
|
||||
'external_network_id', metavar='external-network-id',
|
||||
help='ID of the external network for the gateway')
|
||||
help=_('ID of the external network for the gateway'))
|
||||
parser.add_argument(
|
||||
'--disable-snat', action='store_true',
|
||||
help='Disable Source NAT on the router gateway')
|
||||
help=_('Disable Source NAT on the router gateway'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -219,7 +219,7 @@ class RemoveGatewayRouter(neutronV20.NeutronCommand):
|
||||
parser = super(RemoveGatewayRouter, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'router_id', metavar='router-id',
|
||||
help='ID of the router')
|
||||
help=_('ID of the router'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
|
||||
@@ -19,6 +19,7 @@ import argparse
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListSecurityGroup(neutronV20.ListCommand):
|
||||
@@ -48,10 +49,10 @@ class CreateSecurityGroup(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of security group')
|
||||
help=_('Name of security group'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description of security group')
|
||||
help=_('Description of security group'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'security_group': {
|
||||
@@ -81,10 +82,10 @@ class UpdateSecurityGroup(neutronV20.UpdateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='Name of security group')
|
||||
help=_('Name of security group'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='description of security group')
|
||||
help=_('Description of security group'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'security_group': {}}
|
||||
@@ -113,7 +114,7 @@ class ListSecurityGroupRule(neutronV20.ListCommand):
|
||||
parser = super(ListSecurityGroupRule, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--no-nameconv', action='store_true',
|
||||
help='Do not convert security group ID to its name')
|
||||
help=_('Do not convert security group ID to its name'))
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -183,39 +184,39 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'security_group_id', metavar='SECURITY_GROUP',
|
||||
help='Security group name or id to add rule.')
|
||||
help=_('Security group name or id to add rule.'))
|
||||
parser.add_argument(
|
||||
'--direction',
|
||||
default='ingress', choices=['ingress', 'egress'],
|
||||
help='direction of traffic: ingress/egress')
|
||||
help=_('Direction of traffic: ingress/egress'))
|
||||
parser.add_argument(
|
||||
'--ethertype',
|
||||
default='IPv4',
|
||||
help='IPv4/IPv6')
|
||||
help=_('IPv4/IPv6'))
|
||||
parser.add_argument(
|
||||
'--protocol',
|
||||
help='protocol of packet')
|
||||
help=_('Protocol of packet'))
|
||||
parser.add_argument(
|
||||
'--port-range-min',
|
||||
help='starting port range')
|
||||
help=_('Starting port range'))
|
||||
parser.add_argument(
|
||||
'--port_range_min',
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--port-range-max',
|
||||
help='ending port range')
|
||||
help=_('Ending port range'))
|
||||
parser.add_argument(
|
||||
'--port_range_max',
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--remote-ip-prefix',
|
||||
help='cidr to match on')
|
||||
help=_('CIDR to match on'))
|
||||
parser.add_argument(
|
||||
'--remote_ip_prefix',
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--remote-group-id', metavar='REMOTE_GROUP',
|
||||
help='remote security group name or id to apply rule')
|
||||
help=_('Remote security group name or id to apply rule'))
|
||||
parser.add_argument(
|
||||
'--remote_group_id',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
@@ -21,6 +21,7 @@ import logging
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.common import utils
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
def _format_allocation_pools(subnet):
|
||||
@@ -76,12 +77,12 @@ class CreateSubnet(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='name of this subnet')
|
||||
help=_('Name of this subnet'))
|
||||
parser.add_argument(
|
||||
'--ip-version',
|
||||
type=int,
|
||||
default=4, choices=[4, 6],
|
||||
help='IP version with default 4')
|
||||
help=_('IP version with default 4'))
|
||||
parser.add_argument(
|
||||
'--ip_version',
|
||||
type=int,
|
||||
@@ -89,16 +90,16 @@ class CreateSubnet(neutronV20.CreateCommand):
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
'--gateway', metavar='GATEWAY_IP',
|
||||
help='gateway ip of this subnet')
|
||||
help=_('Gateway ip of this subnet'))
|
||||
parser.add_argument(
|
||||
'--no-gateway',
|
||||
action='store_true',
|
||||
help='No distribution of gateway')
|
||||
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)')
|
||||
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,
|
||||
@@ -106,22 +107,22 @@ class CreateSubnet(neutronV20.CreateCommand):
|
||||
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)')
|
||||
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)')
|
||||
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')
|
||||
help=_('Disable DHCP for this subnet'))
|
||||
parser.add_argument(
|
||||
'network_id', metavar='NETWORK',
|
||||
help='network id or name this subnet belongs to')
|
||||
help=_('Network id or name this subnet belongs to'))
|
||||
parser.add_argument(
|
||||
'cidr', metavar='CIDR',
|
||||
help='cidr of subnet to create')
|
||||
help=_('CIDR of subnet to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_network_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
@@ -131,9 +132,9 @@ class CreateSubnet(neutronV20.CreateCommand):
|
||||
'ip_version': parsed_args.ip_version, }, }
|
||||
|
||||
if parsed_args.gateway and parsed_args.no_gateway:
|
||||
raise exceptions.CommandError("--gateway option and "
|
||||
raise exceptions.CommandError(_("--gateway option and "
|
||||
"--no-gateway option can "
|
||||
"not be used same time")
|
||||
"not be used same time"))
|
||||
if parsed_args.no_gateway:
|
||||
body['subnet'].update({'gateway_ip': None})
|
||||
if parsed_args.gateway:
|
||||
|
||||
@@ -23,6 +23,7 @@ import logging
|
||||
from neutronclient.common import utils
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListIKEPolicy(neutronv20.ListCommand):
|
||||
@@ -53,31 +54,31 @@ class CreateIKEPolicy(neutronv20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='Description of the IKE policy')
|
||||
help=_('Description of the IKE policy'))
|
||||
parser.add_argument(
|
||||
'--auth-algorithm',
|
||||
default='sha1', choices=['sha1'],
|
||||
help='Authentication algorithm in lowercase. '
|
||||
'default: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')
|
||||
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')
|
||||
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')
|
||||
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')
|
||||
help=_('Perfect Forward Secrecy in lowercase, default:group5'))
|
||||
parser.add_argument(
|
||||
'--lifetime',
|
||||
metavar="units=UNITS,value=VALUE",
|
||||
@@ -85,7 +86,7 @@ class CreateIKEPolicy(neutronv20.CreateCommand):
|
||||
help=vpn_utils.lifetime_help("IKE"))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of the IKE Policy')
|
||||
help=_('Name of the IKE Policy'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
|
||||
|
||||
@@ -64,22 +64,22 @@ class CreateIPsecSiteConnection(neutronv20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
default=True, action='store_false',
|
||||
help='Set admin state up to false')
|
||||
help=_('Set admin state up to false'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='Set friendly name for the connection')
|
||||
help=_('Set friendly name for the connection'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='Set a description for the connection')
|
||||
help=_('Set a description for the connection'))
|
||||
parser.add_argument(
|
||||
'--mtu',
|
||||
default='1500',
|
||||
help='MTU size for the connection, default:1500')
|
||||
help=_('MTU size for the connection, default:1500'))
|
||||
parser.add_argument(
|
||||
'--initiator',
|
||||
default='bi-directional', choices=['bi-directional',
|
||||
'response-only'],
|
||||
help='Initiator state in lowercase, default:bi-directional')
|
||||
help=_('Initiator state in lowercase, default:bi-directional'))
|
||||
parser.add_argument(
|
||||
'--dpd',
|
||||
metavar="action=ACTION,interval=INTERVAL,timeout=TIMEOUT",
|
||||
@@ -88,33 +88,33 @@ class CreateIPsecSiteConnection(neutronv20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--vpnservice-id', metavar='VPNSERVICE',
|
||||
required=True,
|
||||
help='VPNService instance id associated with this connection')
|
||||
help=_('VPNService instance id associated with this connection'))
|
||||
parser.add_argument(
|
||||
'--ikepolicy-id', metavar='IKEPOLICY',
|
||||
required=True,
|
||||
help='IKEPolicy id associated with this connection')
|
||||
help=_('IKEPolicy id associated with this connection'))
|
||||
parser.add_argument(
|
||||
'--ipsecpolicy-id', metavar='IPSECPOLICY',
|
||||
required=True,
|
||||
help='IPsecPolicy id associated with this connection')
|
||||
help=_('IPsecPolicy id associated with this connection'))
|
||||
parser.add_argument(
|
||||
'--peer-address',
|
||||
required=True,
|
||||
help='Peer gateway public IPv4/IPv6 address or FQDN.')
|
||||
help=_('Peer gateway public IPv4/IPv6 address or FQDN.'))
|
||||
parser.add_argument(
|
||||
'--peer-id',
|
||||
required=True,
|
||||
help='Peer router identity for authentication. Can be '
|
||||
'IPv4/IPv6 address, e-mail address, key id, or FQDN.')
|
||||
help=_('Peer router identity for authentication. Can be '
|
||||
'IPv4/IPv6 address, e-mail address, key id, or FQDN.'))
|
||||
parser.add_argument(
|
||||
'--peer-cidr',
|
||||
action='append', dest='peer_cidrs',
|
||||
required=True,
|
||||
help='Remote subnet(s) in CIDR format')
|
||||
help=_('Remote subnet(s) in CIDR format'))
|
||||
parser.add_argument(
|
||||
'--psk',
|
||||
required=True,
|
||||
help='Pre-Shared Key string')
|
||||
help=_('Pre-Shared Key string'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_vpnservice_id = neutronv20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -22,6 +22,7 @@ import logging
|
||||
from neutronclient.common import utils
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListIPsecPolicy(neutronv20.ListCommand):
|
||||
@@ -52,30 +53,30 @@ class CreateIPsecPolicy(neutronv20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='Description of the IPsecPolicy')
|
||||
help=_('Description of the IPsecPolicy'))
|
||||
parser.add_argument(
|
||||
'--transform-protocol',
|
||||
default='esp', choices=['esp', 'ah', 'ah-esp'],
|
||||
help='Transform Protocol in lowercase, default:esp')
|
||||
help=_('Transform Protocol in lowercase, default:esp'))
|
||||
parser.add_argument(
|
||||
'--auth-algorithm',
|
||||
default='sha1', choices=['sha1'],
|
||||
help='Authentication algorithm in lowercase, default: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')
|
||||
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')
|
||||
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')
|
||||
help=_('Perfect Forward Secrecy in lowercase, default:group5'))
|
||||
parser.add_argument(
|
||||
'--lifetime',
|
||||
metavar="units=UNITS,value=VALUE",
|
||||
@@ -83,7 +84,7 @@ class CreateIPsecPolicy(neutronv20.CreateCommand):
|
||||
help=vpn_utils.lifetime_help("IPsec"))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help='Name of the IPsecPolicy')
|
||||
help=_('Name of the IPsecPolicy'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
|
||||
|
||||
@@ -100,17 +100,17 @@ def validate_lifetime_dict(lifetime_dict):
|
||||
|
||||
|
||||
def lifetime_help(policy):
|
||||
lifetime = ("%s Lifetime Attributes."
|
||||
"'units'-seconds,default:seconds. "
|
||||
"'value'-non negative integer, default:3600." % policy)
|
||||
lifetime = _("%s Lifetime Attributes."
|
||||
"'units'-seconds,default:seconds. "
|
||||
"'value'-non negative integer, default:3600.") % policy
|
||||
return lifetime
|
||||
|
||||
|
||||
def dpd_help(policy):
|
||||
dpd = (" %s Dead Peer Detection Attributes. "
|
||||
" 'action'-hold,clear,disabled,restart,restart-by-peer."
|
||||
" 'interval' and 'timeout' are non negative integers. "
|
||||
" 'interval' should be less than 'timeout' value. "
|
||||
" 'action', default:hold 'interval', default:30, "
|
||||
" 'timeout', default:120." % policy)
|
||||
dpd = _(" %s Dead Peer Detection Attributes. "
|
||||
" 'action'-hold,clear,disabled,restart,restart-by-peer."
|
||||
" 'interval' and 'timeout' are non negative integers. "
|
||||
" 'interval' should be less than 'timeout' value. "
|
||||
" 'action', default:hold 'interval', default:30, "
|
||||
" 'timeout', default:120.") % policy.capitalize()
|
||||
return dpd
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
class ListVPNService(neutronv20.ListCommand):
|
||||
@@ -52,19 +53,19 @@ class CreateVPNService(neutronv20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
help='set admin state up to false')
|
||||
help=_('Set admin state up to false'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='Set a name for the vpnservice')
|
||||
help=_('Set a name for the vpnservice'))
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='Set a description for the vpnservice')
|
||||
help=_('Set a description for the vpnservice'))
|
||||
parser.add_argument(
|
||||
'router', metavar='ROUTER',
|
||||
help='Router unique identifier for the vpnservice')
|
||||
help=_('Router unique identifier for the vpnservice'))
|
||||
parser.add_argument(
|
||||
'subnet', metavar='SUBNET',
|
||||
help='Subnet unique identifier for the vpnservice deployment')
|
||||
help=_('Subnet unique identifier for the vpnservice deployment'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
_subnet_id = neutronv20.find_resourceid_by_name_or_id(
|
||||
|
||||
@@ -21,6 +21,7 @@ Import related utilities and helper functions.
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
|
||||
|
||||
def import_class(import_str):
|
||||
@@ -30,7 +31,7 @@ def import_class(import_str):
|
||||
__import__(mod_str)
|
||||
return getattr(sys.modules[mod_str], class_str)
|
||||
except (ValueError, AttributeError):
|
||||
raise ImportError('Class %s cannot be found (%s)' %
|
||||
raise ImportError(_('Class %s cannot be found (%s)') %
|
||||
(class_str,
|
||||
traceback.format_exception(*sys.exc_info())))
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ def safe_encode(text, incoming=None,
|
||||
:raises TypeError: If text is not an isntance of str
|
||||
"""
|
||||
if not isinstance(text, six.string_types):
|
||||
raise TypeError("%s can't be encoded" % type(text))
|
||||
raise TypeError(_("%s can't be encoded") % type(text).capitalize())
|
||||
|
||||
if not incoming:
|
||||
incoming = (sys.stdin.encoding or
|
||||
|
||||
@@ -58,6 +58,7 @@ from neutronclient.neutron.v2_0.vpn import ikepolicy
|
||||
from neutronclient.neutron.v2_0.vpn import ipsec_site_connection
|
||||
from neutronclient.neutron.v2_0.vpn import ipsecpolicy
|
||||
from neutronclient.neutron.v2_0.vpn import vpnservice
|
||||
from neutronclient.openstack.common.gettextutils import _
|
||||
from neutronclient.openstack.common import strutils
|
||||
from neutronclient.version import __version__
|
||||
|
||||
@@ -276,7 +277,7 @@ class HelpAction(argparse.Action):
|
||||
max_len = 0
|
||||
app = self.default
|
||||
parser.print_help(app.stdout)
|
||||
app.stdout.write('\nCommands for API v%s:\n' % app.api_version)
|
||||
app.stdout.write(_('\nCommands for API v%s:\n') % app.api_version)
|
||||
command_manager = app.command_manager
|
||||
for name, ep in sorted(command_manager):
|
||||
factory = ep.load()
|
||||
@@ -332,31 +333,31 @@ class NeutronShell(app.App):
|
||||
action='count',
|
||||
dest='verbose_level',
|
||||
default=self.DEFAULT_VERBOSE_LEVEL,
|
||||
help='Increase verbosity of output. Can be repeated.', )
|
||||
help=_('Increase verbosity of output. Can be repeated.'))
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_const',
|
||||
dest='verbose_level',
|
||||
const=0,
|
||||
help='suppress output except warnings and errors', )
|
||||
help=_('Suppress output except warnings and errors'))
|
||||
parser.add_argument(
|
||||
'-h', '--help',
|
||||
action=HelpAction,
|
||||
nargs=0,
|
||||
default=self, # tricky
|
||||
help="show this help message and exit", )
|
||||
help=_("Show this help message and exit"))
|
||||
parser.add_argument(
|
||||
'--debug',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='show tracebacks on errors', )
|
||||
help=_('Show tracebacks on errors'))
|
||||
# Global arguments
|
||||
parser.add_argument(
|
||||
'--os-auth-strategy', metavar='<auth-strategy>',
|
||||
default=env('OS_AUTH_STRATEGY', default='keystone'),
|
||||
help='Authentication strategy (Env: OS_AUTH_STRATEGY'
|
||||
help=_('Authentication strategy (Env: OS_AUTH_STRATEGY'
|
||||
', default keystone). For now, any other value will'
|
||||
' disable the authentication')
|
||||
' disable the authentication'))
|
||||
parser.add_argument(
|
||||
'--os_auth_strategy',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -364,7 +365,7 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--os-auth-url', metavar='<auth-url>',
|
||||
default=env('OS_AUTH_URL'),
|
||||
help='Authentication URL (Env: OS_AUTH_URL)')
|
||||
help=_('Authentication URL (Env: OS_AUTH_URL)'))
|
||||
parser.add_argument(
|
||||
'--os_auth_url',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -372,7 +373,7 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--os-tenant-name', metavar='<auth-tenant-name>',
|
||||
default=env('OS_TENANT_NAME'),
|
||||
help='Authentication tenant name (Env: OS_TENANT_NAME)')
|
||||
help=_('Authentication tenant name (Env: OS_TENANT_NAME)'))
|
||||
parser.add_argument(
|
||||
'--os_tenant_name',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -380,12 +381,12 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--os-tenant-id', metavar='<auth-tenant-id>',
|
||||
default=env('OS_TENANT_ID'),
|
||||
help='Authentication tenant name (Env: OS_TENANT_ID)')
|
||||
help=_('Authentication tenant name (Env: OS_TENANT_ID)'))
|
||||
|
||||
parser.add_argument(
|
||||
'--os-username', metavar='<auth-username>',
|
||||
default=utils.env('OS_USERNAME'),
|
||||
help='Authentication username (Env: OS_USERNAME)')
|
||||
help=_('Authentication username (Env: OS_USERNAME)'))
|
||||
parser.add_argument(
|
||||
'--os_username',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -393,7 +394,7 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--os-password', metavar='<auth-password>',
|
||||
default=utils.env('OS_PASSWORD'),
|
||||
help='Authentication password (Env: OS_PASSWORD)')
|
||||
help=_('Authentication password (Env: OS_PASSWORD)'))
|
||||
parser.add_argument(
|
||||
'--os_password',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -401,7 +402,7 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--os-region-name', metavar='<auth-region-name>',
|
||||
default=env('OS_REGION_NAME'),
|
||||
help='Authentication region name (Env: OS_REGION_NAME)')
|
||||
help=_('Authentication region name (Env: OS_REGION_NAME)'))
|
||||
parser.add_argument(
|
||||
'--os_region_name',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -409,7 +410,7 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--os-token', metavar='<token>',
|
||||
default=env('OS_TOKEN'),
|
||||
help='Defaults to env[OS_TOKEN]')
|
||||
help=_('Defaults to env[OS_TOKEN]'))
|
||||
parser.add_argument(
|
||||
'--os_token',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -417,12 +418,12 @@ class NeutronShell(app.App):
|
||||
parser.add_argument(
|
||||
'--endpoint-type', metavar='<endpoint-type>',
|
||||
default=env('OS_ENDPOINT_TYPE', default='publicURL'),
|
||||
help='Defaults to env[OS_ENDPOINT_TYPE] or publicURL.')
|
||||
help=_('Defaults to env[OS_ENDPOINT_TYPE] or publicURL.'))
|
||||
|
||||
parser.add_argument(
|
||||
'--os-url', metavar='<url>',
|
||||
default=env('OS_URL'),
|
||||
help='Defaults to env[OS_URL]')
|
||||
help=_('Defaults to env[OS_URL]'))
|
||||
parser.add_argument(
|
||||
'--os_url',
|
||||
help=argparse.SUPPRESS)
|
||||
@@ -431,18 +432,18 @@ class NeutronShell(app.App):
|
||||
'--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]")
|
||||
help=_("Specify a CA bundle file to use in "
|
||||
"verifying a TLS (https) server certificate. "
|
||||
"Defaults to env[OS_CACERT]"))
|
||||
|
||||
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.")
|
||||
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."))
|
||||
|
||||
return parser
|
||||
|
||||
@@ -535,7 +536,7 @@ class NeutronShell(app.App):
|
||||
if self.options.debug:
|
||||
self.log.exception(unicode(err2))
|
||||
else:
|
||||
self.log.error('Could not clean up: %s', unicode(err2))
|
||||
self.log.error(_('Could not clean up: %s'), unicode(err2))
|
||||
if self.options.debug:
|
||||
raise
|
||||
else:
|
||||
@@ -545,7 +546,7 @@ class NeutronShell(app.App):
|
||||
if self.options.debug:
|
||||
self.log.exception(unicode(err3))
|
||||
else:
|
||||
self.log.error('Could not clean up: %s', unicode(err3))
|
||||
self.log.error(_('Could not clean up: %s'), unicode(err3))
|
||||
return result
|
||||
|
||||
def authenticate_user(self):
|
||||
@@ -557,42 +558,42 @@ class NeutronShell(app.App):
|
||||
# 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]")
|
||||
_("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]")
|
||||
_("You must provide a service URL via"
|
||||
" either --os-url or env[OS_URL]"))
|
||||
|
||||
else:
|
||||
# Validate password flow auth
|
||||
if not self.options.os_username:
|
||||
raise exc.CommandError(
|
||||
"You must provide a username via"
|
||||
" either --os-username or env[OS_USERNAME]")
|
||||
_("You must provide a username via"
|
||||
" either --os-username or env[OS_USERNAME]"))
|
||||
|
||||
if not self.options.os_password:
|
||||
raise exc.CommandError(
|
||||
"You must provide a password via"
|
||||
" either --os-password or env[OS_PASSWORD]")
|
||||
_("You must provide a password via"
|
||||
" either --os-password or env[OS_PASSWORD]"))
|
||||
|
||||
if (not self.options.os_tenant_name
|
||||
and not self.options.os_tenant_id):
|
||||
raise exc.CommandError(
|
||||
"You must provide a tenant_name or tenant_id via"
|
||||
" --os-tenant-name, env[OS_TENANT_NAME]"
|
||||
" --os-tenant-id, or via env[OS_TENANT_ID]")
|
||||
_("You must provide a tenant_name or tenant_id via"
|
||||
" --os-tenant-name, env[OS_TENANT_NAME]"
|
||||
" --os-tenant-id, or via env[OS_TENANT_ID]"))
|
||||
|
||||
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]")
|
||||
_("You must provide an auth url via"
|
||||
" either --os-auth-url or via env[OS_AUTH_URL]"))
|
||||
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]")
|
||||
_("You must provide a service URL via"
|
||||
" either --os-url or env[OS_URL]"))
|
||||
|
||||
self.client_manager = clientmanager.ClientManager(
|
||||
token=self.options.os_token,
|
||||
@@ -634,7 +635,7 @@ class NeutronShell(app.App):
|
||||
def clean_up(self, cmd, result, err):
|
||||
self.log.debug('clean_up %s', cmd.__class__.__name__)
|
||||
if err:
|
||||
self.log.debug('got an error: %s', unicode(err))
|
||||
self.log.debug(_('Got an error: %s'), unicode(err))
|
||||
|
||||
def configure_logging(self):
|
||||
"""Create logging handlers for any log output."""
|
||||
|
||||
@@ -1123,7 +1123,7 @@ class Client(object):
|
||||
|
||||
def _handle_fault_response(self, status_code, response_body):
|
||||
# Create exception with HTTP status code and message
|
||||
_logger.debug("Error message: %s", response_body)
|
||||
_logger.debug(_("Error message: %s"), response_body)
|
||||
# Add deserialized error message to exception arguments
|
||||
try:
|
||||
des_error_body = self.deserialize(response_body, status_code)
|
||||
@@ -1190,7 +1190,7 @@ class Client(object):
|
||||
return serializer.Serializer(
|
||||
self.get_attr_metadata()).serialize(data, self.content_type())
|
||||
else:
|
||||
raise Exception("unable to serialize object of type = '%s'" %
|
||||
raise Exception(_("Unable to serialize object of type = '%s'") %
|
||||
type(data))
|
||||
|
||||
def deserialize(self, data, status_code):
|
||||
|
||||
Reference in New Issue
Block a user