summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Kekane <abhishek.kekane@nttdata.com>2016-11-03 17:23:41 +0530
committerAbhishek Kekane <abhishek.kekane@nttdata.com>2016-11-08 11:33:09 +0530
commitc2898998a7c28e4c6cff2f21acb4846638a810fb (patch)
tree5b6f53e32087b42ab80e166b1b048029df2075d2
parent9e1d4a4f22099219e73c49671a991495d6eae745 (diff)
downloadpython-glanceclient-c2898998a7c28e4c6cff2f21acb4846638a810fb.tar.gz
Move old oslo-incubator code out of openstack/common
As part of the first community-wide goal, teams were asked to remove the openstack/common package of their projects if one existed. This was a byproduct of the old oslo-incubator form of syncing common functionality. Package openstack/common/apiclient is moved to glanceclient/v1 package as it is used by v1 api only. NOTE: Removed glanceclient/common/base.py as it is deprecated and not used anywhere. Closes-Bug: #1639487 Change-Id: Ib3ac09743ce761ab0186e99e1c9de02517f89510
-rw-r--r--.coveragerc1
-rw-r--r--glanceclient/common/base.py35
-rw-r--r--glanceclient/openstack/common/__init__.py0
-rw-r--r--glanceclient/openstack/common/_i18n.py45
-rw-r--r--glanceclient/openstack/common/apiclient/__init__.py0
-rw-r--r--glanceclient/openstack/common/apiclient/auth.py234
-rw-r--r--glanceclient/tests/unit/test_base.py2
-rw-r--r--glanceclient/v1/apiclient/__init__.py (renamed from glanceclient/openstack/__init__.py)0
-rw-r--r--glanceclient/v1/apiclient/base.py (renamed from glanceclient/openstack/common/apiclient/base.py)2
-rw-r--r--glanceclient/v1/apiclient/exceptions.py (renamed from glanceclient/openstack/common/apiclient/exceptions.py)0
-rw-r--r--glanceclient/v1/apiclient/utils.py (renamed from glanceclient/openstack/common/apiclient/utils.py)20
-rw-r--r--glanceclient/v1/image_members.py2
-rw-r--r--glanceclient/v1/images.py2
-rw-r--r--glanceclient/v1/versions.py2
-rw-r--r--tox.ini2
15 files changed, 15 insertions, 332 deletions
diff --git a/.coveragerc b/.coveragerc
index 092ee58..457eb50 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,7 +1,6 @@
[run]
branch = True
source = glanceclient
-omit = glanceclient/openstack/*
[report]
ignore_errors = True
diff --git a/glanceclient/common/base.py b/glanceclient/common/base.py
deleted file mode 100644
index 55f265e..0000000
--- a/glanceclient/common/base.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# 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.
-
-"""
-Base utilities to build API operation managers and objects on top of.
-
-DEPRECATED post v.0.12.0. Use 'glanceclient.openstack.common.apiclient.base'
-instead of this module."
-"""
-
-import warnings
-
-from glanceclient.openstack.common.apiclient import base
-
-
-warnings.warn("The 'glanceclient.common.base' module is deprecated post "
- "v.0.12.0. Use 'glanceclient.openstack.common.apiclient.base' "
- "instead of this one.", DeprecationWarning)
-
-
-getid = base.getid
-Manager = base.ManagerWithFind
-Resource = base.Resource
diff --git a/glanceclient/openstack/common/__init__.py b/glanceclient/openstack/common/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/glanceclient/openstack/common/__init__.py
+++ /dev/null
diff --git a/glanceclient/openstack/common/_i18n.py b/glanceclient/openstack/common/_i18n.py
deleted file mode 100644
index d1339ad..0000000
--- a/glanceclient/openstack/common/_i18n.py
+++ /dev/null
@@ -1,45 +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.
-
-"""oslo.i18n integration module.
-
-See http://docs.openstack.org/developer/oslo.i18n/usage.html
-
-"""
-
-try:
- import oslo_i18n
-
- # NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
- # application name when this module is synced into the separate
- # repository. It is OK to have more than one translation function
- # using the same domain, since there will still only be one message
- # catalog.
- _translators = oslo_i18n.TranslatorFactory(domain='glanceclient')
-
- # The primary translation function using the well-known name "_"
- _ = _translators.primary
-
- # Translators for log levels.
- #
- # The abbreviated names are meant to reflect the usual use of a short
- # name like '_'. The "L" is for "log" and the other letter comes from
- # the level.
- _LI = _translators.log_info
- _LW = _translators.log_warning
- _LE = _translators.log_error
- _LC = _translators.log_critical
-except ImportError:
- # NOTE(dims): Support for cases where a project wants to use
- # code from oslo-incubator, but is not ready to be internationalized
- # (like tempest)
- _ = _LI = _LW = _LE = _LC = lambda x: x
diff --git a/glanceclient/openstack/common/apiclient/__init__.py b/glanceclient/openstack/common/apiclient/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/glanceclient/openstack/common/apiclient/__init__.py
+++ /dev/null
diff --git a/glanceclient/openstack/common/apiclient/auth.py b/glanceclient/openstack/common/apiclient/auth.py
deleted file mode 100644
index 771df04..0000000
--- a/glanceclient/openstack/common/apiclient/auth.py
+++ /dev/null
@@ -1,234 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# Copyright 2013 Spanish National Research Council.
-# All Rights Reserved.
-#
-# 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.
-
-# E0202: An attribute inherited from %s hide this method
-# pylint: disable=E0202
-
-########################################################################
-#
-# THIS MODULE IS DEPRECATED
-#
-# Please refer to
-# https://etherpad.openstack.org/p/kilo-glanceclient-library-proposals for
-# the discussion leading to this deprecation.
-#
-# We recommend checking out the python-openstacksdk project
-# (https://launchpad.net/python-openstacksdk) instead.
-#
-########################################################################
-
-import abc
-import argparse
-import os
-
-import six
-from stevedore import extension
-
-from glanceclient.openstack.common.apiclient import exceptions
-
-
-_discovered_plugins = {}
-
-
-def discover_auth_systems():
- """Discover the available auth-systems.
-
- This won't take into account the old style auth-systems.
- """
- global _discovered_plugins
- _discovered_plugins = {}
-
- def add_plugin(ext):
- _discovered_plugins[ext.name] = ext.plugin
-
- ep_namespace = "glanceclient.openstack.common.apiclient.auth"
- mgr = extension.ExtensionManager(ep_namespace)
- mgr.map(add_plugin)
-
-
-def load_auth_system_opts(parser):
- """Load options needed by the available auth-systems into a parser.
-
- This function will try to populate the parser with options from the
- available plugins.
- """
- group = parser.add_argument_group("Common auth options")
- BaseAuthPlugin.add_common_opts(group)
- for name, auth_plugin in six.iteritems(_discovered_plugins):
- group = parser.add_argument_group(
- "Auth-system '%s' options" % name,
- conflict_handler="resolve")
- auth_plugin.add_opts(group)
-
-
-def load_plugin(auth_system):
- try:
- plugin_class = _discovered_plugins[auth_system]
- except KeyError:
- raise exceptions.AuthSystemNotFound(auth_system)
- return plugin_class(auth_system=auth_system)
-
-
-def load_plugin_from_args(args):
- """Load required plugin and populate it with options.
-
- Try to guess auth system if it is not specified. Systems are tried in
- alphabetical order.
-
- :type args: argparse.Namespace
- :raises: AuthPluginOptionsMissing
- """
- auth_system = args.os_auth_system
- if auth_system:
- plugin = load_plugin(auth_system)
- plugin.parse_opts(args)
- plugin.sufficient_options()
- return plugin
-
- for plugin_auth_system in sorted(six.iterkeys(_discovered_plugins)):
- plugin_class = _discovered_plugins[plugin_auth_system]
- plugin = plugin_class()
- plugin.parse_opts(args)
- try:
- plugin.sufficient_options()
- except exceptions.AuthPluginOptionsMissing:
- continue
- return plugin
- raise exceptions.AuthPluginOptionsMissing(["auth_system"])
-
-
-@six.add_metaclass(abc.ABCMeta)
-class BaseAuthPlugin(object):
- """Base class for authentication plugins.
-
- An authentication plugin needs to override at least the authenticate
- method to be a valid plugin.
- """
-
- auth_system = None
- opt_names = []
- common_opt_names = [
- "auth_system",
- "username",
- "password",
- "tenant_name",
- "token",
- "auth_url",
- ]
-
- def __init__(self, auth_system=None, **kwargs):
- self.auth_system = auth_system or self.auth_system
- self.opts = dict((name, kwargs.get(name))
- for name in self.opt_names)
-
- @staticmethod
- def _parser_add_opt(parser, opt):
- """Add an option to parser in two variants.
-
- :param opt: option name (with underscores)
- """
- dashed_opt = opt.replace("_", "-")
- env_var = "OS_%s" % opt.upper()
- arg_default = os.environ.get(env_var, "")
- arg_help = "Defaults to env[%s]." % env_var
- parser.add_argument(
- "--os-%s" % dashed_opt,
- metavar="<%s>" % dashed_opt,
- default=arg_default,
- help=arg_help)
- parser.add_argument(
- "--os_%s" % opt,
- metavar="<%s>" % dashed_opt,
- help=argparse.SUPPRESS)
-
- @classmethod
- def add_opts(cls, parser):
- """Populate the parser with the options for this plugin.
- """
- for opt in cls.opt_names:
- # use `BaseAuthPlugin.common_opt_names` since it is never
- # changed in child classes
- if opt not in BaseAuthPlugin.common_opt_names:
- cls._parser_add_opt(parser, opt)
-
- @classmethod
- def add_common_opts(cls, parser):
- """Add options that are common for several plugins.
- """
- for opt in cls.common_opt_names:
- cls._parser_add_opt(parser, opt)
-
- @staticmethod
- def get_opt(opt_name, args):
- """Return option name and value.
-
- :param opt_name: name of the option, e.g., "username"
- :param args: parsed arguments
- """
- return (opt_name, getattr(args, "os_%s" % opt_name, None))
-
- def parse_opts(self, args):
- """Parse the actual auth-system options if any.
-
- This method is expected to populate the attribute `self.opts` with a
- dict containing the options and values needed to make authentication.
- """
- self.opts.update(dict(self.get_opt(opt_name, args)
- for opt_name in self.opt_names))
-
- def authenticate(self, http_client):
- """Authenticate using plugin defined method.
-
- The method usually analyses `self.opts` and performs
- a request to authentication server.
-
- :param http_client: client object that needs authentication
- :type http_client: HTTPClient
- :raises: AuthorizationFailure
- """
- self.sufficient_options()
- self._do_authenticate(http_client)
-
- @abc.abstractmethod
- def _do_authenticate(self, http_client):
- """Protected method for authentication.
- """
-
- def sufficient_options(self):
- """Check if all required options are present.
-
- :raises: AuthPluginOptionsMissing
- """
- missing = [opt
- for opt in self.opt_names
- if not self.opts.get(opt)]
- if missing:
- raise exceptions.AuthPluginOptionsMissing(missing)
-
- @abc.abstractmethod
- def token_and_endpoint(self, endpoint_type, service_type):
- """Return token and endpoint.
-
- :param service_type: Service type of the endpoint
- :type service_type: string
- :param endpoint_type: Type of endpoint.
- Possible values: public or publicURL,
- internal or internalURL,
- admin or adminURL
- :type endpoint_type: string
- :returns: tuple of token and endpoint strings
- :raises: EndpointException
- """
diff --git a/glanceclient/tests/unit/test_base.py b/glanceclient/tests/unit/test_base.py
index ddbc3d7..43bb71d 100644
--- a/glanceclient/tests/unit/test_base.py
+++ b/glanceclient/tests/unit/test_base.py
@@ -16,7 +16,7 @@
import testtools
-from glanceclient.openstack.common.apiclient import base
+from glanceclient.v1.apiclient import base
class TestBase(testtools.TestCase):
diff --git a/glanceclient/openstack/__init__.py b/glanceclient/v1/apiclient/__init__.py
index e69de29..e69de29 100644
--- a/glanceclient/openstack/__init__.py
+++ b/glanceclient/v1/apiclient/__init__.py
diff --git a/glanceclient/openstack/common/apiclient/base.py b/glanceclient/v1/apiclient/base.py
index c86613e..cb48096 100644
--- a/glanceclient/openstack/common/apiclient/base.py
+++ b/glanceclient/v1/apiclient/base.py
@@ -45,7 +45,7 @@ import six
from six.moves.urllib import parse
from glanceclient._i18n import _
-from glanceclient.openstack.common.apiclient import exceptions
+from glanceclient.v1.apiclient import exceptions
def getid(obj):
diff --git a/glanceclient/openstack/common/apiclient/exceptions.py b/glanceclient/v1/apiclient/exceptions.py
index 5bda5f0..5bda5f0 100644
--- a/glanceclient/openstack/common/apiclient/exceptions.py
+++ b/glanceclient/v1/apiclient/exceptions.py
diff --git a/glanceclient/openstack/common/apiclient/utils.py b/glanceclient/v1/apiclient/utils.py
index e5d6926..814a37b 100644
--- a/glanceclient/openstack/common/apiclient/utils.py
+++ b/glanceclient/v1/apiclient/utils.py
@@ -29,7 +29,7 @@ from oslo_utils import uuidutils
import six
from glanceclient._i18n import _
-from glanceclient.openstack.common.apiclient import exceptions
+from glanceclient.v1.apiclient import exceptions
def find_resource(manager, name_or_id, **find_args):
@@ -84,17 +84,15 @@ def find_resource(manager, name_or_id, **find_args):
return manager.find(**kwargs)
except exceptions.NotFound:
msg = _("No %(name)s with a name or "
- "ID of '%(name_or_id)s' exists.") % \
- {
- "name": manager.resource_class.__name__.lower(),
- "name_or_id": name_or_id
- }
- raise exceptions.CommandError(msg)
- except exceptions.NoUniqueMatch:
- msg = _("Multiple %(name)s matches found for "
- "'%(name_or_id)s', use an ID to be more specific.") % \
- {
+ "ID of '%(name_or_id)s' exists.") % {
"name": manager.resource_class.__name__.lower(),
"name_or_id": name_or_id
}
+ raise exceptions.CommandError(msg)
+ except exceptions.NoUniqueMatch:
+ msg = _("Multiple %(name)s matches found for "
+ "'%(name_or_id)s', use an ID to be more specific.") % {
+ "name": manager.resource_class.__name__.lower(),
+ "name_or_id": name_or_id
+ }
raise exceptions.CommandError(msg)
diff --git a/glanceclient/v1/image_members.py b/glanceclient/v1/image_members.py
index 79242b5..144eeb5 100644
--- a/glanceclient/v1/image_members.py
+++ b/glanceclient/v1/image_members.py
@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from glanceclient.openstack.common.apiclient import base
+from glanceclient.v1.apiclient import base
class ImageMember(base.Resource):
diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py
index 6697e4e..182f1e5 100644
--- a/glanceclient/v1/images.py
+++ b/glanceclient/v1/images.py
@@ -21,7 +21,7 @@ import six
import six.moves.urllib.parse as urlparse
from glanceclient.common import utils
-from glanceclient.openstack.common.apiclient import base
+from glanceclient.v1.apiclient import base
UPDATE_PARAMS = ('name', 'disk_format', 'container_format', 'min_disk',
'min_ram', 'owner', 'size', 'is_public', 'protected',
diff --git a/glanceclient/v1/versions.py b/glanceclient/v1/versions.py
index d65c2f6..fe4253f 100644
--- a/glanceclient/v1/versions.py
+++ b/glanceclient/v1/versions.py
@@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from glanceclient.openstack.common.apiclient import base
+from glanceclient.v1.apiclient import base
class VersionManager(base.ManagerWithFind):
diff --git a/tox.ini b/tox.ini
index 29a2b24..f333019 100644
--- a/tox.ini
+++ b/tox.ini
@@ -44,7 +44,7 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen
[flake8]
ignore = F403,F812,F821
show-source = True
-exclude = .venv*,.tox,dist,*egg,build,.git,doc,*openstack/common*,*lib/python*,.update-venv
+exclude = .venv*,.tox,dist,*egg,build,.git,doc,*lib/python*,.update-venv
[hacking]
import_exceptions = six.moves,glanceclient._i18n