move old apiclient code out of openstack/common

As part of the first community-wide goal [1], 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.

[1] http://governance.openstack.org/goals/ocata/remove-incubated-oslo-code.html

Change-Id: Ic6447da0ab3be843d231f9761d1767ed77fd81a2
This commit is contained in:
Steve Martinelli 2016-11-08 10:34:52 -05:00
parent a75b4cbe02
commit 9283ededba
22 changed files with 43 additions and 66 deletions

View File

@ -3,7 +3,6 @@ source = muranoclient
omit =
.tox/*
muranoclient/tests/*
muranoclient/openstack/*
[report]
ignore_errors = True
ignore_errors = True

View File

@ -24,7 +24,7 @@ import os
import six
from stevedore import extension
from muranoclient.openstack.common.apiclient import exceptions
from muranoclient.apiclient import exceptions
_discovered_plugins = {}
@ -41,7 +41,7 @@ def discover_auth_systems():
def add_plugin(ext):
_discovered_plugins[ext.name] = ext.plugin
ep_namespace = "muranoclient.openstack.common.apiclient.auth"
ep_namespace = "muranoclient.apiclient.auth"
mgr = extension.ExtensionManager(ep_namespace)
mgr.map(add_plugin)
@ -143,8 +143,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
@ -153,8 +152,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)
@ -191,8 +189,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

@ -31,8 +31,8 @@ from oslo_utils import uuidutils
import six
from six.moves.urllib import parse
from muranoclient.apiclient import exceptions
from muranoclient.i18n import _
from muranoclient.openstack.common.apiclient import exceptions
def getid(obj):
@ -462,8 +462,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:
@ -481,7 +480,7 @@ class Resource(object):
def __getattr__(self, k):
if k not in self.__dict__:
#NOTE(bcwaldon): disallow lazy-loading if already loaded once
# NOTE(bcwaldon): disallow lazy-loading if already loaded once
if not self.is_loaded():
self.get()
return self.__getattr__(k)

View File

@ -36,9 +36,8 @@ from oslo_log import log as logging
from oslo_utils import importutils
import requests
from muranoclient.apiclient import exceptions
from muranoclient.i18n import _
from muranoclient.openstack.common.apiclient import exceptions
_logger = logging.getLogger(__name__)
@ -63,7 +62,7 @@ class HTTPClient(object):
into terminal and send the same request with curl.
"""
user_agent = "muranoclient.openstack.common.apiclient"
user_agent = "muranoclient.apiclient"
def __init__(self,
auth_plugin,
@ -354,8 +353,7 @@ class BaseClient(object):
"Must be one of: %(version_map)s") % {
'api_name': api_name,
'version': version,
'version_map': ', '.join(version_map.keys())
}
'version_map': ', '.join(version_map.keys())}
raise exceptions.UnsupportedVersion(msg)
return importutils.import_class(client_path)

View File

@ -28,8 +28,7 @@ from muranoclient.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
@ -107,8 +106,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")
@ -426,7 +424,7 @@ def from_response(response, url, method):
"""
req_id = response.headers.get("x-openstack-request-id")
#NOTE(hdd) true for older versions of nova and cinder
# NOTE(hdd): true for older versions of nova and cinder
if not req_id:
req_id = response.headers.get("x-compute-request-id")
kwargs = {

View File

@ -30,7 +30,7 @@ import requests
import six
from six.moves.urllib import parse
from muranoclient.openstack.common.apiclient import client
from muranoclient.apiclient import client
def assert_has_keys(dct, required=None, optional=None):
@ -48,8 +48,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__()
@ -86,13 +85,12 @@ class FakeHTTPClient(client.HTTPClient):
def __init__(self, *args, **kwargs):
self.callstack = []
self.fixtures = kwargs.pop("fixtures", None) or {}
if not args and not "auth_plugin" in kwargs:
if not args and "auth_plugin" not in kwargs:
args = (None, )
super(FakeHTTPClient, self).__init__(*args, **kwargs)
def assert_called(self, url, method, body=None, pos=-1):
"""Assert than an API method was just called.
"""
"""Assert than an API method was just called."""
expected = (url, method)
called = self.callstack[pos][0:2]
assert self.callstack, \
@ -107,8 +105,7 @@ class FakeHTTPClient(client.HTTPClient):
(self.callstack[pos][3], body))
def assert_called_anytime(self, url, method, 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 = (url, method)
assert self.callstack, \

View File

@ -22,7 +22,7 @@ import copy
import six
from muranoclient.openstack.common.apiclient import exceptions
from muranoclient.apiclient import exceptions
# Python 2.4 compat

View File

@ -1,17 +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.
import six
six.add_move(six.MovedModule('mox', 'mox', 'mox3.mox'))

View File

@ -15,9 +15,9 @@
from osc_lib import utils
from oslo_log import log as logging
from muranoclient.apiclient import exceptions as exc
from muranoclient.glance import client as art_client
from muranoclient.i18n import _
from muranoclient.openstack.common.apiclient import exceptions as exc
LOG = logging.getLogger(__name__)

View File

@ -14,10 +14,11 @@
import json
from muranoclient.openstack.common.apiclient import exceptions
from osc_lib.command import command
from oslo_log import log as logging
from muranoclient.apiclient import exceptions
LOG = logging.getLogger(__name__)

View File

@ -14,11 +14,12 @@
import textwrap
from muranoclient.openstack.common.apiclient import exceptions
from osc_lib.command import command
from osc_lib import utils
from oslo_log import log as logging
from muranoclient.apiclient import exceptions
LOG = logging.getLogger(__name__)

View File

@ -18,14 +18,15 @@ import sys
import uuid
import jsonpatch
from muranoclient.common import utils as murano_utils
from muranoclient.openstack.common.apiclient import exceptions
from osc_lib.command import command
from osc_lib import utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from muranoclient.apiclient import exceptions
from muranoclient.common import utils as murano_utils
LOG = logging.getLogger(__name__)

View File

@ -18,14 +18,16 @@ import shutil
import tempfile
import zipfile
from muranoclient.openstack.common.apiclient import exceptions
from muranoclient.v1.package_creator import hot_package
from muranoclient.v1.package_creator import mpl_package
from osc_lib.command import command
from osc_lib import exceptions as exc
from osc_lib import utils
from oslo_log import log as logging
from muranoclient.apiclient import exceptions
from muranoclient.v1.package_creator import hot_package
from muranoclient.v1.package_creator import mpl_package
LOG = logging.getLogger(__name__)

View File

@ -35,10 +35,11 @@ import six
import six.moves.urllib.parse as urlparse
import muranoclient
from muranoclient.apiclient import exceptions as exc
from muranoclient import client as murano_client
from muranoclient.common import utils
from muranoclient.glance import client as art_client
from muranoclient.openstack.common.apiclient import exceptions as exc
logger = logging.getLogger(__name__)

View File

@ -15,7 +15,7 @@
import os
import shutil
from muranoclient.openstack.common.apiclient import exceptions
from muranoclient.apiclient import exceptions
from muranoclient.tests.unit import base
from muranoclient.v1.package_creator import hot_package
from muranoclient.v1.package_creator import mpl_package

View File

@ -33,9 +33,9 @@ import requests_mock
import six
from testtools import matchers
from muranoclient.apiclient import exceptions
from muranoclient.common import exceptions as common_exceptions
from muranoclient.common import utils
from muranoclient.openstack.common.apiclient import exceptions
import muranoclient.shell
from muranoclient.tests.unit import base
from muranoclient.tests.unit import test_utils

View File

@ -19,7 +19,7 @@ import tempfile
import yaml
import muranoclient
from muranoclient.openstack.common.apiclient import exceptions
from muranoclient.apiclient import exceptions
def generate_manifest(args):

View File

@ -19,8 +19,8 @@ import tempfile
import yaml
import muranoclient
from muranoclient.apiclient import exceptions
from muranoclient.common import utils
from muranoclient.openstack.common.apiclient import exceptions
def prepare_package(args):

View File

@ -28,9 +28,9 @@ from oslo_utils import strutils
import six
import six.moves
from muranoclient.apiclient import exceptions
from muranoclient.common import exceptions as common_exceptions
from muranoclient.common import utils
from muranoclient.openstack.common.apiclient import exceptions
from muranoclient.v1.package_creator import hot_package
from muranoclient.v1.package_creator import mpl_package

View File

@ -46,4 +46,4 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen
[flake8]
show-source = true
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools