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.

The package, apiclient, was moved to a top level location
and cliutils was moved to the common module. There are no oslo
specific libraries, the recommended solution is to move it
in tree and maintain it there.

Change-Id: I0603d3c1419a5344bee8e43cfbe794c26641960a
This commit is contained in:
Steve Martinelli 2016-10-31 11:13:46 -04:00
parent e6daa3df81
commit a93f8b04b1
20 changed files with 44 additions and 67 deletions

View File

@ -3,10 +3,7 @@ branch = True
source = cloudkittyclient
omit =
cloudkittyclient/tests/*,
cloudkittyclient/openstack/*,
cloudkittyclient/i18n.py,
cloudkittyclient/common/client.py,
cloudkittyclient/common/exceptions.py
cloudkittyclient/i18n.py
[report]
ignore_errors = True

View File

@ -37,7 +37,7 @@ import os
import six
from stevedore import extension
from cloudkittyclient.openstack.common.apiclient import exceptions
from cloudkittyclient.apiclient import exceptions
_discovered_plugins = {}
@ -54,7 +54,7 @@ def discover_auth_systems():
def add_plugin(ext):
_discovered_plugins[ext.name] = ext.plugin
ep_namespace = "cloudkittyclient.openstack.common.apiclient.auth"
ep_namespace = "cloudkittyclient.apiclient.auth"
mgr = extension.ExtensionManager(ep_namespace)
mgr.map(add_plugin)
@ -156,8 +156,7 @@ class BaseAuthPlugin(object):
@classmethod
def add_opts(cls, parser):
"""Populate the parser with the options for this plugin.
"""
"""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
@ -166,8 +165,7 @@ class BaseAuthPlugin(object):
@classmethod
def add_common_opts(cls, parser):
"""Add options that are common for several plugins.
"""
"""Add options that are common for several plugins."""
for opt in cls.common_opt_names:
cls._parser_add_opt(parser, opt)
@ -204,8 +202,7 @@ class BaseAuthPlugin(object):
@abc.abstractmethod
def _do_authenticate(self, http_client):
"""Protected method for authentication.
"""
"""Protected method for authentication."""
def sufficient_options(self):
"""Check if all required options are present.

View File

@ -44,8 +44,8 @@ from oslo_utils import strutils
import six
from six.moves.urllib import parse
from cloudkittyclient.apiclient import exceptions
from cloudkittyclient.i18n import _
from cloudkittyclient.openstack.common.apiclient import exceptions
def getid(obj):
@ -467,8 +467,7 @@ class Resource(object):
@property
def human_id(self):
"""Human-readable ID which can be used for bash completion.
"""
"""Human-readable ID which can be used for bash completion."""
if self.HUMAN_ID:
name = getattr(self, self.NAME_ATTR, None)
if name is not None:

View File

@ -38,8 +38,9 @@ from oslo_utils import encodeutils
from oslo_utils import importutils
import requests
from cloudkittyclient.apiclient import exceptions
from cloudkittyclient.i18n import _
from cloudkittyclient.openstack.common.apiclient import exceptions
_logger = logging.getLogger(__name__)
SENSITIVE_HEADERS = ('X-Auth-Token', 'X-Subject-Token',)
@ -64,7 +65,7 @@ class HTTPClient(object):
into terminal and send the same request with curl.
"""
user_agent = "cloudkittyclient.openstack.common.apiclient"
user_agent = "cloudkittyclient.apiclient"
def __init__(self,
auth_plugin,

View File

@ -42,8 +42,7 @@ from cloudkittyclient.i18n import _
class ClientException(Exception):
"""The base exception class for all exceptions this library raises.
"""
"""The base exception class for all exceptions this library raises."""
pass
@ -118,8 +117,7 @@ class AmbiguousEndpoints(EndpointException):
class HttpError(ClientException):
"""The base exception class for all HTTP exceptions.
"""
"""The base exception class for all HTTP exceptions."""
http_status = 0
message = _("HTTP Error")

View File

@ -43,7 +43,7 @@ import requests
import six
from six.moves.urllib import parse
from cloudkittyclient.openstack.common.apiclient import client
from cloudkittyclient.apiclient import client
def assert_has_keys(dct, required=None, optional=None):
@ -59,8 +59,7 @@ def assert_has_keys(dct, required=None, optional=None):
class TestResponse(requests.Response):
"""Wrap requests.Response and provide a convenient initialization.
"""
"""Wrap requests.Response and provide a convenient initialization."""
def __init__(self, data):
super(TestResponse, self).__init__()
@ -99,15 +98,14 @@ class FakeHTTPClient(client.HTTPClient):
super(FakeHTTPClient, self).__init__(*args, **kwargs)
def assert_called(self, method, url, body=None, pos=-1):
"""Assert than an API method was just called.
"""
"""Assert than an API method was just called."""
expected = (method, url)
called = self.callstack[pos][0:2]
assert self.callstack, \
"Expected %s %s but no calls were made." % expected
msg = "Expected %s %s but no calls were made." % expected
assert self.callstack, msg
assert expected == called, 'Expected %s %s; got %s %s' % \
(expected + called)
msg = 'Expected %s %s; got %s %s' % (expected + called)
assert expected == called, msg
if body is not None:
if self.callstack[pos][3] != body:
@ -115,12 +113,11 @@ class FakeHTTPClient(client.HTTPClient):
(self.callstack[pos][3], body))
def assert_called_anytime(self, method, url, body=None):
"""Assert than an API method was called anytime in the test.
"""
"""Assert than an API method was called anytime in the test."""
expected = (method, url)
assert self.callstack, \
"Expected %s %s but no calls were made." % expected
msg = "Expected %s %s but no calls were made." % expected
assert self.callstack, msg
found = False
entry = None
@ -129,8 +126,8 @@ class FakeHTTPClient(client.HTTPClient):
found = True
break
assert found, 'Expected %s %s; got %s' % \
(method, url, self.callstack)
msg = 'Expected %s %s; got %s' % (method, url, self.callstack)
assert found, msg
if body is not None:
assert entry[3] == body, "%s != %s" % (entry[3], body)

View File

@ -28,8 +28,8 @@ from oslo_utils import encodeutils
from oslo_utils import uuidutils
import six
from cloudkittyclient.apiclient import exceptions
from cloudkittyclient.i18n import _
from cloudkittyclient.openstack.common.apiclient import exceptions
def find_resource(manager, name_or_id, **find_args):
@ -84,17 +84,13 @@ 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
}
"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
}
"'%(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)

View File

@ -22,11 +22,11 @@ from keystoneclient import session
from oslo_utils import strutils
import six.moves.urllib.parse as urlparse
from cloudkittyclient.apiclient import auth
from cloudkittyclient.apiclient import client
from cloudkittyclient.apiclient import exceptions
from cloudkittyclient.common import utils
from cloudkittyclient import exc
from cloudkittyclient.openstack.common.apiclient import auth
from cloudkittyclient.openstack.common.apiclient import client
from cloudkittyclient.openstack.common.apiclient import exceptions
def _discover_auth_versions(session, auth_url):

View File

@ -22,9 +22,9 @@ import copy
from six.moves.urllib import parse
from cloudkittyclient.apiclient import base
from cloudkittyclient import exc
from cloudkittyclient.i18n import _
from cloudkittyclient.openstack.common.apiclient import base
def getid(obj):

View File

@ -26,9 +26,9 @@ from oslo_utils import importutils
import prettytable
import six
from cloudkittyclient.common import cliutils
from cloudkittyclient import exc
from cloudkittyclient.i18n import _
from cloudkittyclient.openstack.common import cliutils
def import_versioned_module(version, submodule=None):

View File

@ -28,9 +28,9 @@ from stevedore import extension
import cloudkittyclient
from cloudkittyclient import client as ckclient
from cloudkittyclient.common import cliutils
from cloudkittyclient.common import utils
from cloudkittyclient import exc
from cloudkittyclient.openstack.common import cliutils
from cloudkittyclient.v1.collector import shell as collector_shell
from cloudkittyclient.v1.report import shell as report_shell
from cloudkittyclient.v1.storage import shell as storage_shell

View File

@ -132,7 +132,7 @@ class ClientTest(utils.BaseTestCase):
'user_agent': None,
'debug': None,
}
cls = 'cloudkittyclient.openstack.common.apiclient.client.HTTPClient'
cls = 'cloudkittyclient.apiclient.client.HTTPClient'
with mock.patch(cls) as mocked:
self.create_client(env)
mocked.assert_called_with(**expected)

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cloudkittyclient.openstack.common.apiclient import client
from cloudkittyclient.openstack.common.apiclient import fake_client
from cloudkittyclient.apiclient import client
from cloudkittyclient.apiclient import fake_client
from cloudkittyclient.tests import utils
import cloudkittyclient.v1.core

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cloudkittyclient.openstack.common.apiclient import client
from cloudkittyclient.openstack.common.apiclient import fake_client
from cloudkittyclient.apiclient import client
from cloudkittyclient.apiclient import fake_client
from cloudkittyclient.tests import utils
from cloudkittyclient.v1.rating import hashmap

View File

@ -1,8 +0,0 @@
[DEFAULT]
# The list of modules to copy from oslo-incubator.git
module=apiclient
module=cliutils
# The base module to hold the copy of openstack.common
base=cloudkittyclient

View File

@ -31,7 +31,7 @@ commands = python setup.py build_sphinx
show-source = True
ignore = E123,E125,H803
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
[hacking]
import_exceptions = cloudkittyclient.i18n