Rename module from hnv_client to hnv

This commit is contained in:
Alexandru Coman 2017-02-06 15:33:22 +02:00
parent 243d3b0732
commit 75cea338f5
No known key found for this signature in database
GPG Key ID: A7B6A9021F704507
44 changed files with 70 additions and 70 deletions

View File

@ -171,7 +171,7 @@ ignored-modules=
# List of class names for which member attributes should not be checked (useful # List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of # for classes with dynamically set attributes). This supports the use of
# qualified names. # qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local, hnv_client.common.model.Model ignored-classes=optparse.Values,thread._local,_thread._local, hnv.common.model.Model
# List of members which are set dynamically and missed by pylint inference # List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular # system, and so shouldn't trigger E1101 when accessed. Python regular

View File

@ -2,7 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
${PYTHON:-python} -m subunit.run discover -t ./ ./hnv_client/tests $LISTOPT $IDOPTION ${PYTHON:-python} -m subunit.run discover -t ./ ./hnv/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE test_id_option=--load-list $IDFILE
test_list_option=--list test_list_option=--list

View File

@ -1,2 +1,2 @@
# hvn-client # python-hnv
Python client for the HNV (Hyper-V Network Virtualization) REST API. Python client for the HNV (Hyper-V Network Virtualization) REST API.

View File

@ -1,7 +1,7 @@
HNV Client HNV Client
========== ==========
.. automodule:: hnv_client.client .. automodule:: hnv.client
:members: :members:
:inherited-members: :inherited-members:
.. autoattribute:: .. autoattribute::

View File

@ -1,6 +1,6 @@
HNV Client's exceptions HNV Client's exceptions
======================= =======================
.. automodule:: hnv_client.common.exception .. automodule:: hnv.common.exception
:members: :members:
.. autoattribute:: .. autoattribute::

4
etc/hnv/README.md Normal file
View File

@ -0,0 +1,4 @@
To generate the sample hnv.conf file, run the following command from the top
level of the python-hnv directory:
oslo-config-generator --config-file etc/python-hnv/hnv-config-generator.conf

View File

@ -0,0 +1,5 @@
[DEFAULT]
output_file = etc/python-hnv/hnv.conf
wrap_width = 80
namespace = hnv.conf
namespace = oslo.log

View File

@ -1,4 +0,0 @@
To generate the sample hnv_client.conf file, run the following command from the top
level of the arestor directory:
oslo-config-generator --config-file etc/hnv_client/hnv_client-config-generator.conf

View File

@ -1,5 +0,0 @@
[DEFAULT]
output_file = etc/hnv_client/hnv_client.conf
wrap_width = 80
namespace = hnv_client
namespace = oslo.log

View File

@ -19,11 +19,11 @@ import uuid
from oslo_log import log as logging from oslo_log import log as logging
from hnv_client.common import constant from hnv.common import constant
from hnv_client.common import exception from hnv.common import exception
from hnv_client.common import model from hnv.common import model
from hnv_client.common import utils from hnv.common import utils
from hnv_client import config as hnv_config from hnv import config as hnv_config
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONFIG = hnv_config.CONFIG CONFIG = hnv_config.CONFIG

View File

@ -17,7 +17,7 @@
class HNVException(Exception): class HNVException(Exception):
"""Base hnv_client exception. """Base HNV client exception.
To correctly use this class, inherit from it and define To correctly use this class, inherit from it and define
a `template` property. a `template` property.

View File

@ -21,7 +21,7 @@ import copy
from oslo_log import log as logging from oslo_log import log as logging
import six import six
from hnv_client.common import exception from hnv.common import exception
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -23,9 +23,9 @@ import requests
import requests_ntlm import requests_ntlm
import six import six
from hnv_client.common import constant from hnv.common import constant
from hnv_client.common import exception from hnv.common import exception
from hnv_client import config as hnv_config from hnv import config as hnv_config
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONFIG = hnv_config.CONFIG CONFIG = hnv_config.CONFIG

View File

@ -16,9 +16,9 @@
from oslo_config import cfg from oslo_config import cfg
from hnv_client.config import factory from hnv.config import factory as options_factory
CONFIG = cfg.CONF CONFIG = cfg.CONF
for option_class in factory.get_options(): for option_class in options_factory.get_options():
option_class(CONFIG).register() option_class(CONFIG).register()

View File

@ -16,7 +16,7 @@
from oslo_config import cfg from oslo_config import cfg
from hnv_client.config import base as config_base from hnv.config import base as config_base
class HVNOptions(config_base.Options): class HVNOptions(config_base.Options):

View File

@ -15,7 +15,7 @@
"""Factory for all the available config options.""" """Factory for all the available config options."""
_OPT_PATHS = ( _OPT_PATHS = (
'hnv_client.config.hnv.HVNOptions', 'hnv.config.client.HVNOptions',
) )

View File

@ -19,8 +19,8 @@ file for Cloudbase-Init.
import collections import collections
from hnv_client.config import base as config_base from hnv.config import base as config_base
from hnv_client.config import factory as config_factory from hnv.config import factory as config_factory
def get_options(): def get_options():

View File

@ -21,8 +21,8 @@ try:
except ImportError: except ImportError:
import mock import mock
from hnv_client.common import exception from hnv.common import exception
from hnv_client.common import model from hnv.common import model
class TestFieldDescriptor(unittest.TestCase): class TestFieldDescriptor(unittest.TestCase):
@ -80,7 +80,7 @@ class TestField(unittest.TestCase):
self.assertIs(field.is_property, mock.sentinel.is_property) self.assertIs(field.is_property, mock.sentinel.is_property)
self.assertIs(field.is_read_only, mock.sentinel.is_read_only) self.assertIs(field.is_read_only, mock.sentinel.is_read_only)
@mock.patch("hnv_client.common.model._FieldDescriptor") @mock.patch("hnv.common.model._FieldDescriptor")
def test_add_to_class(self, mock_field_descriptor): def test_add_to_class(self, mock_field_descriptor):
field = model.Field(name="test_add_to_class", key="test") field = model.Field(name="test_add_to_class", key="test")
model_class = mock.Mock() model_class = mock.Mock()
@ -101,7 +101,7 @@ class TestModelOptions(unittest.TestCase):
self.assertEqual(model_options._name, mock.sentinel.cls.name) self.assertEqual(model_options._name, mock.sentinel.cls.name)
@mock.patch("six.callable") @mock.patch("six.callable")
@mock.patch("hnv_client.common.model._ModelOptions.remove_field") @mock.patch("hnv.common.model._ModelOptions.remove_field")
def _test_add_field(self, mock_remove_field, mock_callable, def _test_add_field(self, mock_remove_field, mock_callable,
callable_default): callable_default):
model_options = model._ModelOptions(self.__class__) model_options = model._ModelOptions(self.__class__)

View File

@ -22,11 +22,11 @@ except ImportError:
import requests import requests
from hnv_client.common import constant from hnv.common import constant
from hnv_client.common import exception from hnv.common import exception
from hnv_client.common import utils as hnv_utils from hnv.common import utils as hnv_utils
from hnv_client import config as hnv_config from hnv import config as hnv_config
from hnv_client.tests import utils as test_utils from hnv.tests import utils as test_utils
CONFIG = hnv_config.CONFIG CONFIG = hnv_config.CONFIG
@ -41,8 +41,8 @@ class TestHNVClient(unittest.TestCase):
return hnv_utils._HNVClient(url, username, password, allow_insecure, return hnv_utils._HNVClient(url, username, password, allow_insecure,
ca_bundle) ca_bundle)
@mock.patch("hnv_client.common.utils._HNVClient._get_headers") @mock.patch("hnv.common.utils._HNVClient._get_headers")
@mock.patch("hnv_client.common.utils._HNVClient._verify_https_request") @mock.patch("hnv.common.utils._HNVClient._verify_https_request")
@mock.patch("requests_ntlm.HttpNtlmAuth") @mock.patch("requests_ntlm.HttpNtlmAuth")
@mock.patch("requests.Session") @mock.patch("requests.Session")
def test_session(self, mock_get_session, mock_auth, mock_verify, def test_session(self, mock_get_session, mock_auth, mock_verify,
@ -75,8 +75,8 @@ class TestHNVClient(unittest.TestCase):
@mock.patch("time.sleep") @mock.patch("time.sleep")
@mock.patch("json.dumps") @mock.patch("json.dumps")
@mock.patch("requests.compat.urljoin") @mock.patch("requests.compat.urljoin")
@mock.patch("hnv_client.common.utils._HNVClient._session") @mock.patch("hnv.common.utils._HNVClient._session")
@mock.patch("hnv_client.common.utils._HNVClient._get_headers") @mock.patch("hnv.common.utils._HNVClient._get_headers")
def _test_http_request(self, mock_headers, mock_session, mock_join, def _test_http_request(self, mock_headers, mock_session, mock_join,
mock_dump, mock_sleep, mock_dump, mock_sleep,
method, body, response, status_code): method, body, response, status_code):
@ -101,7 +101,7 @@ class TestHNVClient(unittest.TestCase):
{"status_code": status_code}) {"status_code": status_code})
client = self._get_client() client = self._get_client()
with test_utils.LogSnatcher("hnv_client.common.utils") as logging: with test_utils.LogSnatcher("hnv.common.utils") as logging:
if isinstance(expected_response, requests.exceptions.SSLError): if isinstance(expected_response, requests.exceptions.SSLError):
self.assertRaises(exception.CertificateVerifyFailed, self.assertRaises(exception.CertificateVerifyFailed,
client._http_request, client._http_request,
@ -209,7 +209,7 @@ class TestHNVClient(unittest.TestCase):
response=response, response=response,
status_code=500) status_code=500)
@mock.patch("hnv_client.common.utils._HNVClient._http_request") @mock.patch("hnv.common.utils._HNVClient._http_request")
def test_get_resource(self, mock_http_request): def test_get_resource(self, mock_http_request):
response = mock.Mock() response = mock.Mock()
response.json = mock.Mock() response.json = mock.Mock()
@ -224,7 +224,7 @@ class TestHNVClient(unittest.TestCase):
self.assertRaises(exception.ServiceException, self.assertRaises(exception.ServiceException,
client.get_resource, mock.sentinel.path) client.get_resource, mock.sentinel.path)
@mock.patch("hnv_client.common.utils._HNVClient._http_request") @mock.patch("hnv.common.utils._HNVClient._http_request")
def test_update_resource(self, mock_http_request): def test_update_resource(self, mock_http_request):
response = mock.Mock() response = mock.Mock()
response.json = mock.Mock() response.json = mock.Mock()
@ -243,7 +243,7 @@ class TestHNVClient(unittest.TestCase):
client.update_resource, client.update_resource,
mock.sentinel.path, mock.sentinel.data) mock.sentinel.path, mock.sentinel.data)
@mock.patch("hnv_client.common.utils._HNVClient._http_request") @mock.patch("hnv.common.utils._HNVClient._http_request")
def test_remove_resource(self, mock_http_request): def test_remove_resource(self, mock_http_request):
mock_http_request.return_value = mock.sentinel.response mock_http_request.return_value = mock.sentinel.response

View File

@ -23,7 +23,7 @@ class FakeResponse(object):
"""HNV API fake responses.""" """HNV API fake responses."""
def __init__(self): def __init__(self):
self._resources = "hnv_client.tests.fake.response" self._resources = "hnv.tests.fake.response"
self._cache = {} self._cache = {}
def _load_resource(self, resource): def _load_resource(self, resource):

View File

@ -21,12 +21,12 @@ try:
except ImportError: except ImportError:
import mock import mock
from hnv_client import client from hnv import client
from hnv_client.common import constant from hnv.common import constant
from hnv_client.common import exception from hnv.common import exception
from hnv_client import config as hnv_config from hnv import config as hnv_config
from hnv_client.tests.fake import fake_response from hnv.tests.fake import fake_response
from hnv_client.tests import utils as test_utils from hnv.tests import utils as test_utils
CONFIG = hnv_config.CONFIG CONFIG = hnv_config.CONFIG
@ -36,8 +36,8 @@ class TestBaseHNVModel(unittest.TestCase):
def setUp(self): def setUp(self):
client._BaseHNVModel._endpoint = "{parent_id}/{resource_id}" client._BaseHNVModel._endpoint = "{parent_id}/{resource_id}"
@mock.patch("hnv_client.client._BaseHNVModel.from_raw_data") @mock.patch("hnv.client._BaseHNVModel.from_raw_data")
@mock.patch("hnv_client.client._BaseHNVModel._get_client") @mock.patch("hnv.client._BaseHNVModel._get_client")
def test_get(self, mock_get_client, mock_from_raw_data): def test_get(self, mock_get_client, mock_from_raw_data):
mock_from_raw_data.return_value = mock.sentinel.resource mock_from_raw_data.return_value = mock.sentinel.resource
http_client = mock_get_client.return_value = mock.Mock() http_client = mock_get_client.return_value = mock.Mock()
@ -48,8 +48,8 @@ class TestBaseHNVModel(unittest.TestCase):
get_resource.assert_called_once_with("/hnv-client-test") get_resource.assert_called_once_with("/hnv-client-test")
self.assertIs(resource, mock.sentinel.resource) self.assertIs(resource, mock.sentinel.resource)
@mock.patch("hnv_client.client._BaseHNVModel.from_raw_data") @mock.patch("hnv.client._BaseHNVModel.from_raw_data")
@mock.patch("hnv_client.client._BaseHNVModel._get_client") @mock.patch("hnv.client._BaseHNVModel._get_client")
def test_get_all(self, mock_get_client, mock_from_raw_data): def test_get_all(self, mock_get_client, mock_from_raw_data):
mock_from_raw_data.side_effect = range(10) mock_from_raw_data.side_effect = range(10)
@ -63,7 +63,7 @@ class TestBaseHNVModel(unittest.TestCase):
self.assertEqual(resources, range(10)) self.assertEqual(resources, range(10))
@mock.patch("time.sleep") @mock.patch("time.sleep")
@mock.patch("hnv_client.client._BaseHNVModel._get_client") @mock.patch("hnv.client._BaseHNVModel._get_client")
def _test_remove(self, mock_get_client, mock_sleep, def _test_remove(self, mock_get_client, mock_sleep,
loop_count, timeout): loop_count, timeout):
http_client = mock_get_client.return_value = mock.Mock() http_client = mock_get_client.return_value = mock.Mock()
@ -101,9 +101,9 @@ class TestBaseHNVModel(unittest.TestCase):
return {"properties": {"provisioningState": provisioning_state}} return {"properties": {"provisioningState": provisioning_state}}
@mock.patch("time.sleep") @mock.patch("time.sleep")
@mock.patch("hnv_client.client._BaseHNVModel.process_raw_data") @mock.patch("hnv.client._BaseHNVModel.process_raw_data")
@mock.patch("hnv_client.client._BaseHNVModel.dump") @mock.patch("hnv.client._BaseHNVModel.dump")
@mock.patch("hnv_client.client._BaseHNVModel._get_client") @mock.patch("hnv.client._BaseHNVModel._get_client")
def _test_commit(self, mock_get_client, mock_dump, mock_process, def _test_commit(self, mock_get_client, mock_dump, mock_process,
mock_sleep, mock_sleep,
loop_count, timeout, failed, invalid_response): loop_count, timeout, failed, invalid_response):
@ -174,7 +174,7 @@ class TestClient(unittest.TestCase):
self._response = fake_response.FakeResponse() self._response = fake_response.FakeResponse()
def _test_get_resource(self, model, raw_data): def _test_get_resource(self, model, raw_data):
with test_utils.LogSnatcher("hnv_client.common.model") as logging: with test_utils.LogSnatcher("hnv.common.model") as logging:
model.from_raw_data(raw_data) model.from_raw_data(raw_data)
self.assertEqual(logging.output, []) self.assertEqual(logging.output, [])

View File

@ -21,7 +21,7 @@ import logging as base_logging
from oslo_log import log as oslo_logging from oslo_log import log as oslo_logging
from hnv_client import config as hnv_conf from hnv import config as hnv_conf
CONFIG = hnv_conf.CONFIG CONFIG = hnv_conf.CONFIG
@ -45,7 +45,7 @@ class LogSnatcher(object):
The class can be used as following:: The class can be used as following::
with LogSnatcher('hnv_client.client') as snatcher: with LogSnatcher('hnv.client') as snatcher:
LOG.info("doing stuff") LOG.info("doing stuff")
LOG.info("doing stuff %s", 1) LOG.info("doing stuff %s", 1)
LOG.warn("doing other stuff") LOG.warn("doing other stuff")

View File

@ -1,5 +1,5 @@
[metadata] [metadata]
name = hnv_client name = hnv
version = 0.1.0 version = 0.1.0
summary = Python client for the HNV (Hyper-V Network Virtualization) REST API. summary = Python client for the HNV (Hyper-V Network Virtualization) REST API.
description-file = description-file =
@ -23,7 +23,7 @@ classifier =
[files] [files]
packages = packages =
hnv_client hnv
[global] [global]
setup-hooks = setup-hooks =
@ -31,7 +31,7 @@ setup-hooks =
[entry_points] [entry_points]
oslo.config.opts = oslo.config.opts =
hnv_client = hnv_client.config.options:get_options hnv.conf = hnv.config.options:get_options
[build_sphinx] [build_sphinx]
all_files = 1 all_files = 1

View File

@ -12,11 +12,11 @@ install_command = pip install -U --force-reinstall {opts} {packages}
commands = python setup.py testr --testr-args='{posargs}' commands = python setup.py testr --testr-args='{posargs}'
[testenv:pep8] [testenv:pep8]
commands = flake8 hnv_client {posargs} commands = flake8 hnv {posargs}
deps = flake8 deps = flake8
[testenv:pylint] [testenv:pylint]
commands = pylint hnv_client --rcfile={toxinidir}/.pylintrc {posargs} commands = pylint hnv --rcfile={toxinidir}/.pylintrc {posargs}
deps = pylint deps = pylint
[testenv:cover] [testenv:cover]