diff options
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/availability_zone.py | 5 | ||||
| -rw-r--r-- | openstackclient/common/client_config.py | 71 | ||||
| -rw-r--r-- | openstackclient/common/configuration.py | 5 | ||||
| -rw-r--r-- | openstackclient/common/extension.py | 4 | ||||
| -rw-r--r-- | openstackclient/common/module.py | 3 | ||||
| -rw-r--r-- | openstackclient/common/quota.py | 45 | ||||
| -rw-r--r-- | openstackclient/common/versions.py | 19 |
7 files changed, 52 insertions, 100 deletions
diff --git a/openstackclient/common/availability_zone.py b/openstackclient/common/availability_zone.py index b2385ef7..3b2fa848 100644 --- a/openstackclient/common/availability_zone.py +++ b/openstackclient/common/availability_zone.py @@ -19,7 +19,6 @@ import logging from novaclient import exceptions as nova_exceptions from osc_lib.command import command from osc_lib import utils -import six from openstackclient.i18n import _ @@ -47,11 +46,11 @@ def _xform_compute_availability_zone(az, include_extra): return result if hasattr(az, 'hosts') and az.hosts: - for host, services in six.iteritems(az.hosts): + for host, services in az.hosts.items(): host_info = copy.deepcopy(zone_info) host_info['host_name'] = host - for svc, state in six.iteritems(services): + for svc, state in services.items(): info = copy.deepcopy(host_info) info['service_name'] = svc info['service_status'] = '%s %s %s' % ( diff --git a/openstackclient/common/client_config.py b/openstackclient/common/client_config.py deleted file mode 100644 index a22dd0cb..00000000 --- a/openstackclient/common/client_config.py +++ /dev/null @@ -1,71 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -"""OpenStackConfig subclass for argument compatibility""" - -from osc_lib.cli import client_config - - -# Sublcass OpenStackConfig in order to munge config values -# before auth plugins are loaded -class OSC_Config(client_config.OSC_Config): - - # TODO(dtroyer): Remove _auth_default_domain when the v3otp fix is - # backported to osc-lib, should be in release 1.3.0 - def _auth_default_domain(self, config): - """Set a default domain from available arguments - - Migrated from clientmanager.setup_auth() - """ - - identity_version = config.get('identity_api_version', '') - auth_type = config.get('auth_type', None) - - # TODO(mordred): This is a usability improvement that's broadly useful - # We should port it back up into os-client-config. - default_domain = config.get('default_domain', None) - if (identity_version == '3' and - not auth_type.startswith('v2') and - default_domain): - - # NOTE(stevemar): If PROJECT_DOMAIN_ID or PROJECT_DOMAIN_NAME is - # present, then do not change the behaviour. Otherwise, set the - # PROJECT_DOMAIN_ID to 'OS_DEFAULT_DOMAIN' for better usability. - if ( - auth_type in ("password", "v3password", "v3totp") and - not config['auth'].get('project_domain_id') and - not config['auth'].get('project_domain_name') - ): - config['auth']['project_domain_id'] = default_domain - - # NOTE(stevemar): If USER_DOMAIN_ID or USER_DOMAIN_NAME is present, - # then do not change the behaviour. Otherwise, set the - # USER_DOMAIN_ID to 'OS_DEFAULT_DOMAIN' for better usability. - # NOTE(aloga): this should only be set if there is a username. - # TODO(dtroyer): Move this to os-client-config after the plugin has - # been loaded so we can check directly if the options are accepted. - if ( - auth_type in ("password", "v3password", "v3totp") and - not config['auth'].get('user_domain_id') and - not config['auth'].get('user_domain_name') - ): - config['auth']['user_domain_id'] = default_domain - return config - - def load_auth_plugin(self, config): - """Get auth plugin and validate args""" - - loader = self._get_auth_loader(config) - config = self._validate_auth(config, loader) - auth_plugin = loader.load_from_options(**config['auth']) - return auth_plugin diff --git a/openstackclient/common/configuration.py b/openstackclient/common/configuration.py index 53b30d5f..49ef0e05 100644 --- a/openstackclient/common/configuration.py +++ b/openstackclient/common/configuration.py @@ -15,7 +15,6 @@ from keystoneauth1.loading import base from osc_lib.command import command -import six from openstackclient.i18n import _ @@ -59,9 +58,9 @@ class ShowConfiguration(command.ShowOne): if o.secret ] - for key, value in six.iteritems(info.pop('auth', {})): + for key, value in info.pop('auth', {}).items(): if parsed_args.mask and key.lower() in secret_opts: value = REDACTED info['auth.' + key] = value - return zip(*sorted(six.iteritems(info))) + return zip(*sorted(info.items())) diff --git a/openstackclient/common/extension.py b/openstackclient/common/extension.py index 71206618..1ed2012c 100644 --- a/openstackclient/common/extension.py +++ b/openstackclient/common/extension.py @@ -89,9 +89,9 @@ class ListExtension(command.Lister): LOG.warning(message) if parsed_args.compute or show_all: - compute_client = self.app.client_manager.compute + compute_client = self.app.client_manager.sdk_connection.compute try: - data += compute_client.list_extensions.show_all() + data += compute_client.extensions() except Exception: message = _("Extensions list not supported by Compute API") LOG.warning(message) diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py index 20497f21..f55fdce0 100644 --- a/openstackclient/common/module.py +++ b/openstackclient/common/module.py @@ -19,7 +19,6 @@ import sys from osc_lib.command import command from osc_lib import utils -import six from openstackclient.i18n import _ @@ -113,4 +112,4 @@ class ListModule(command.ShowOne): # Catch all exceptions, just skip it pass - return zip(*sorted(six.iteritems(data))) + return zip(*sorted(data.items())) diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index fb4e8603..c7b3ad07 100644 --- a/openstackclient/common/quota.py +++ b/openstackclient/common/quota.py @@ -21,9 +21,9 @@ import sys from osc_lib.command import command from osc_lib import utils -import six from openstackclient.i18n import _ +from openstackclient.network import common LOG = logging.getLogger(__name__) @@ -457,18 +457,37 @@ class ListQuota(command.Lister, BaseQuota): return ((), ()) -class SetQuota(command.Command): +class SetQuota(common.NetDetectionMixin, command.Command): _description = _("Set quotas for project or class") def _build_options_list(self): - if self.app.client_manager.is_network_endpoint_enabled(): - return itertools.chain(COMPUTE_QUOTAS.items(), - VOLUME_QUOTAS.items(), - NETWORK_QUOTAS.items()) - else: - return itertools.chain(COMPUTE_QUOTAS.items(), - VOLUME_QUOTAS.items(), - NOVA_NETWORK_QUOTAS.items()) + help_fmt = _('New value for the %s quota') + # Compute and volume quota options are always the same + rets = [(k, v, help_fmt % v) for k, v in itertools.chain( + COMPUTE_QUOTAS.items(), + VOLUME_QUOTAS.items(), + )] + # For docs build, we want to produce helps for both neutron and + # nova-network options. They overlap, so we have to figure out which + # need to be tagged as specific to one network type or the other. + if self.is_docs_build: + # NOTE(efried): This takes advantage of the fact that we know the + # nova-net options are a subset of the neutron options. If that + # ever changes, this algorithm will need to be adjusted accordingly + inv_compute = set(NOVA_NETWORK_QUOTAS.values()) + for k, v in NETWORK_QUOTAS.items(): + _help = help_fmt % v + if v not in inv_compute: + # This one is unique to neutron + _help = self.enhance_help_neutron(_help) + rets.append((k, v, _help)) + elif self.is_neutron: + rets.extend( + [(k, v, help_fmt % v) for k, v in NETWORK_QUOTAS.items()]) + elif self.is_nova_network: + rets.extend( + [(k, v, help_fmt % v) for k, v in NOVA_NETWORK_QUOTAS.items()]) + return rets def get_parser(self, prog_name): parser = super(SetQuota, self).get_parser(prog_name) @@ -484,13 +503,13 @@ class SetQuota(command.Command): default=False, help=_('Set quotas for <class>'), ) - for k, v in self._build_options_list(): + for k, v, h in self._build_options_list(): parser.add_argument( '--%s' % v, metavar='<%s>' % v, dest=k, type=int, - help=_('New value for the %s quota') % v, + help=h, ) parser.add_argument( '--volume-type', @@ -643,4 +662,4 @@ class ShowQuota(command.ShowOne, BaseQuota): project_name = project_info['name'] info['project_name'] = project_name - return zip(*sorted(six.iteritems(info))) + return zip(*sorted(info.items())) diff --git a/openstackclient/common/versions.py b/openstackclient/common/versions.py index 3c267bfe..3acd9f73 100644 --- a/openstackclient/common/versions.py +++ b/openstackclient/common/versions.py @@ -45,15 +45,22 @@ class ShowVersions(command.Lister): ) parser.add_argument( '--service', - metavar='<region_name>', - help=_('Show versions for a specific service.'), + metavar='<service>', + help=_('Show versions for a specific service. The argument should ' + 'be either an exact match to what is in the catalog or a ' + 'known official value or alias from ' + 'service-types-authority ' + '(https://service-types.openstack.org/)'), ) parser.add_argument( '--status', - metavar='<region_name>', - help=_('Show versions for a specific status.' - ' [Valid values are SUPPORTED, CURRENT,' - ' DEPRECATED, EXPERIMENTAL]'), + metavar='<status>', + help=_("""Show versions for a specific status. Valid values are: + +- SUPPORTED +- CURRENT +- DEPRECATED +- EXPERIMENTAL""") ) return parser |
