commit cd38f11acbaa505bf064a818221fb988bc10def7 Author: Dmitry Tantsur Date: Tue Jun 2 17:09:03 2015 +0200 Initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3e394f --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.*.swp +.tox +*.pyc +build/ +dist/ +*.egg-info/ +.coverage +*~ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..2c69e1b --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include LICENSE +include requirements.txt +include test-requirements.txt +include tox.ini +include *.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..d68782b --- /dev/null +++ b/README.rst @@ -0,0 +1,19 @@ +Ironic-Inspector Client +======================= + +This is a client library and tool for ironic-inspector_. + +Install from PyPI:: + + pip install python-ironic-inspector-client + +Please refer to the `Inspector README`_ for details on usage. + +Please follow usual OpenStack `Gerrit Workflow`_ to submit a patch, see +`Inspector contributing guide`_ for more detail. + + +.. _Gerrit Workflow: http://docs.openstack.org/infra/manual/developers.html#development-workflow +.. _ironic-inspector: https://pypi.python.org/pypi/ironic-discoverd +.. _Inspector README: https://github.com/stackforge/ironic-discoverd/blob/master/README.rst +.. _Inspector contributing guide: https://github.com/stackforge/ironic-discoverd/blob/master/CONTRIBUTING.rst diff --git a/ironic_inspector_client/__init__.py b/ironic_inspector_client/__init__.py new file mode 100644 index 0000000..5e2b32d --- /dev/null +++ b/ironic_inspector_client/__init__.py @@ -0,0 +1,15 @@ +# 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. + +__version_info__ = (1, 0, 0) +__version__ = '%d.%d.%d' % __version_info__ diff --git a/ironic_inspector_client/client.py b/ironic_inspector_client/client.py new file mode 100644 index 0000000..6ac9471 --- /dev/null +++ b/ironic_inspector_client/client.py @@ -0,0 +1,91 @@ +# 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. + +from oslo_utils import netutils +import requests +import six + +from ironic_inspector_client.common.i18n import _ + + +_DEFAULT_URL = 'http://' + netutils.get_my_ipv4() + ':5050/v1' +_ERROR_ENCODING = 'utf-8' + + +def _prepare(base_url, auth_token): + base_url = (base_url or _DEFAULT_URL).rstrip('/') + if not base_url.endswith('v1'): + base_url += '/v1' + headers = {'X-Auth-Token': auth_token} if auth_token else {} + return base_url, headers + + +class ClientError(requests.HTTPError): + """Error returned from a server.""" + def __init__(self, response): + # inspector returns error message in body + msg = response.content.decode(_ERROR_ENCODING) + super(ClientError, self).__init__(msg, response=response) + + @classmethod + def raise_if_needed(cls, response): + """Raise exception if response contains error.""" + if response.status_code >= 400: + raise cls(response) + + +def introspect(uuid, base_url=None, auth_token=None, + new_ipmi_password=None, new_ipmi_username=None): + """Start introspection for a node. + + :param uuid: node uuid + :param base_url: *ironic-inspector* URL in form: http://host:port[/ver], + defaults to ``http://:5050/v1``. + :param auth_token: Keystone authentication token. + :param new_ipmi_password: if set, *ironic-inspector* will update IPMI + password to this value. + :param new_ipmi_username: if new_ipmi_password is set, this values sets + new IPMI user name. Defaults to one in + driver_info. + """ + if not isinstance(uuid, six.string_types): + raise TypeError(_("Expected string for uuid argument, got %r") % uuid) + if new_ipmi_username and not new_ipmi_password: + raise ValueError(_("Setting IPMI user name requires a new password")) + + base_url, headers = _prepare(base_url, auth_token) + params = {'new_ipmi_username': new_ipmi_username, + 'new_ipmi_password': new_ipmi_password} + res = requests.post("%s/introspection/%s" % (base_url, uuid), + headers=headers, params=params) + ClientError.raise_if_needed(res) + + +def get_status(uuid, base_url=None, auth_token=None): + """Get introspection status for a node. + + New in ironic-inspector version 1.0.0. + :param uuid: node uuid. + :param base_url: *ironic-inspector* URL in form: http://host:port[/ver], + defaults to ``http://:5050/v1``. + :param auth_token: Keystone authentication token. + :raises: *requests* library HTTP errors. + """ + if not isinstance(uuid, six.string_types): + raise TypeError(_("Expected string for uuid argument, got %r") % uuid) + + base_url, headers = _prepare(base_url, auth_token) + res = requests.get("%s/introspection/%s" % (base_url, uuid), + headers=headers) + ClientError.raise_if_needed(res) + return res.json() diff --git a/ironic_inspector_client/common/__init__.py b/ironic_inspector_client/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ironic_inspector_client/common/i18n.py b/ironic_inspector_client/common/i18n.py new file mode 100644 index 0000000..d888880 --- /dev/null +++ b/ironic_inspector_client/common/i18n.py @@ -0,0 +1,32 @@ +# Copyright 2015 NEC Corporation +# 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. + +import oslo_i18n + +_translators = oslo_i18n.TranslatorFactory( + domain='python-ironic-inspector-client') + +# 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 diff --git a/ironic_inspector_client/shell.py b/ironic_inspector_client/shell.py new file mode 100644 index 0000000..b59873d --- /dev/null +++ b/ironic_inspector_client/shell.py @@ -0,0 +1,96 @@ +# 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. + +"""OpenStackClient plugin for ironic-inspector.""" + +from __future__ import print_function + +import logging + +from cliff import command +from cliff import show +from openstackclient.common import utils + +from ironic_inspector_client import client + + +LOG = logging.getLogger('ironic_inspector.shell') +API_NAME = 'baremetal-introspection' +API_VERSION_OPTION = 'inspector_api_version' +DEFAULT_VERSION = '1' +API_VERSIONS = { + "1": "ironic_inspector.shell", +} + + +def build_option_parser(parser): + parser.add_argument('--inspector-api-version', + default=utils.env('INSPECTOR_VERSION', + default=DEFAULT_VERSION), + help='inspector API version, only 1 is supported now ' + '(env: INSPECTOR_VERSION).') + return parser + + +class StartCommand(command.Command): + """Start the introspection.""" + + def get_parser(self, prog_name): + parser = super(StartCommand, self).get_parser(prog_name) + _add_common_arguments(parser) + parser.add_argument('--new-ipmi-username', + default=None, + help='if set, *ironic-inspector* will update IPMI ' + 'user name to this value') + parser.add_argument('--new-ipmi-password', + default=None, + help='if set, *ironic-inspector* will update IPMI ' + 'password to this value') + return parser + + def take_action(self, parsed_args): + auth_token = self.app.client_manager.auth_ref.auth_token + client.introspect(parsed_args.uuid, base_url=parsed_args.inspector_url, + auth_token=auth_token, + new_ipmi_username=parsed_args.new_ipmi_username, + new_ipmi_password=parsed_args.new_ipmi_password) + if parsed_args.new_ipmi_password: + print('Setting IPMI credentials requested, please power on ' + 'the machine manually') + + +class StatusCommand(show.ShowOne): + """Get introspection status.""" + + def get_parser(self, prog_name): + parser = super(StatusCommand, self).get_parser(prog_name) + _add_common_arguments(parser) + return parser + + def take_action(self, parsed_args): + auth_token = self.app.client_manager.auth_ref.auth_token + status = client.get_status(parsed_args.uuid, + base_url=parsed_args.inspector_url, + auth_token=auth_token) + return zip(*sorted(status.items())) + + +def _add_common_arguments(parser): + """Add commonly used arguments to a parser.""" + parser.add_argument('uuid', help='baremetal node UUID') + # FIXME(dtantsur): this should be in build_option_parser, but then it won't + # be available in commands + parser.add_argument('--inspector-url', + default=utils.env('INSPECTOR_URL', default=None), + help='inspector URL, defaults to localhost ' + '(env: INSPECTOR_URL).') diff --git a/ironic_inspector_client/test/__init__.py b/ironic_inspector_client/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ironic_inspector_client/test/test_client.py b/ironic_inspector_client/test/test_client.py new file mode 100644 index 0000000..8d597b2 --- /dev/null +++ b/ironic_inspector_client/test/test_client.py @@ -0,0 +1,115 @@ +# 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 unittest + +import mock +from oslo_utils import netutils +from oslo_utils import uuidutils + +from ironic_inspector_client import client + + +@mock.patch.object(client.requests, 'post', autospec=True, + **{'return_value.status_code': 200}) +class TestIntrospect(unittest.TestCase): + def setUp(self): + super(TestIntrospect, self).setUp() + self.uuid = uuidutils.generate_uuid() + self.my_ip = 'http://' + netutils.get_my_ipv4() + ':5050/v1' + + def test(self, mock_post): + client.introspect(self.uuid, base_url="http://host:port", + auth_token="token") + mock_post.assert_called_once_with( + "http://host:port/v1/introspection/%s" % self.uuid, + headers={'X-Auth-Token': 'token'}, + params={'new_ipmi_username': None, 'new_ipmi_password': None} + ) + + def test_invalid_input(self, _): + self.assertRaises(TypeError, client.introspect, 42) + self.assertRaises(ValueError, client.introspect, 'uuid', + new_ipmi_username='user') + + def test_full_url(self, mock_post): + client.introspect(self.uuid, base_url="http://host:port/v1/", + auth_token="token") + mock_post.assert_called_once_with( + "http://host:port/v1/introspection/%s" % self.uuid, + headers={'X-Auth-Token': 'token'}, + params={'new_ipmi_username': None, 'new_ipmi_password': None} + ) + + def test_default_url(self, mock_post): + client.introspect(self.uuid, auth_token="token") + mock_post.assert_called_once_with( + "%(my_ip)s/introspection/%(uuid)s" % + {'my_ip': self.my_ip, 'uuid': self.uuid}, + headers={'X-Auth-Token': 'token'}, + params={'new_ipmi_username': None, 'new_ipmi_password': None} + ) + + def test_set_ipmi_credentials(self, mock_post): + client.introspect(self.uuid, base_url="http://host:port", + auth_token="token", new_ipmi_password='p', + new_ipmi_username='u') + mock_post.assert_called_once_with( + "http://host:port/v1/introspection/%s" % self.uuid, + headers={'X-Auth-Token': 'token'}, + params={'new_ipmi_username': 'u', 'new_ipmi_password': 'p'} + ) + + def test_none_ok(self, mock_post): + client.introspect(self.uuid) + mock_post.assert_called_once_with( + "%(my_ip)s/introspection/%(uuid)s" % + {'my_ip': self.my_ip, 'uuid': self.uuid}, + headers={}, + params={'new_ipmi_username': None, 'new_ipmi_password': None} + ) + + def test_failed(self, mock_post): + mock_post.return_value.status_code = 404 + mock_post.return_value.content = b"boom" + self.assertRaisesRegexp(client.ClientError, "boom", + client.introspect, self.uuid) + + +@mock.patch.object(client.requests, 'get', autospec=True, + **{'return_value.status_code': 200}) +class TestGetStatus(unittest.TestCase): + def setUp(self): + super(TestGetStatus, self).setUp() + self.uuid = uuidutils.generate_uuid() + self.my_ip = 'http://' + netutils.get_my_ipv4() + ':5050/v1' + + def test(self, mock_get): + mock_get.return_value.json.return_value = 'json' + + client.get_status(self.uuid, auth_token='token') + + mock_get.assert_called_once_with( + "%(my_ip)s/introspection/%(uuid)s" % + {'my_ip': self.my_ip, 'uuid': self.uuid}, + headers={'X-Auth-Token': 'token'} + ) + + def test_invalid_input(self, _): + self.assertRaises(TypeError, client.get_status, 42) + + def test_failed(self, mock_post): + mock_post.return_value.status_code = 404 + mock_post.return_value.content = b"boom" + self.assertRaisesRegexp(client.ClientError, "boom", + client.get_status, self.uuid) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..72e6962 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +cliff>=1.10.0 # Apache-2.0 +oslo.i18n>=1.5.0 +oslo.utils>=1.4.0 +python-openstackclient>=1.0.3 +requests>=2.5.2 +six>=1.9.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2ac6a45 --- /dev/null +++ b/setup.py @@ -0,0 +1,46 @@ +import re + +from setuptools import setup + + +try: + # Distributions have to delete *requirements.txt + with open('requirements.txt', 'r') as fp: + install_requires = [re.split(r'[<>=~]', line)[0] + for line in fp if line.strip()] +except EnvironmentError: + print("No requirements.txt, not handling dependencies") + install_requires = [] + + +with open('ironic_inspector_client/__init__.py', 'rb') as fp: + exec(fp.read()) + + +setup( + name = "python-ironic-inspector-client", + version = __version__, + description = open('README.rst', 'r').readline().strip(), + author = "Dmitry Tantsur", + author_email = "dtantsur@redhat.com", + url = "https://pypi.python.org/pypi/python-ironic-inspector-client", + packages = ['ironic_inspector_client', 'ironic_inspector_client.test'], + install_requires = install_requires, + entry_points = { + 'openstack.cli.extension': [ + 'baremetal-introspection = ironic_inspector_client.shell', + ], + 'openstack.baremetal_introspection.v1': [ + "baremetal_introspection_start = ironic_inspector_client.shell:StartCommand", + "baremetal_introspection_status = ironic_inspector_client.shell:StatusCommand", + ], + }, + classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: OpenStack', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: POSIX', + ], + license = 'APL 2.0', +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..cc4cecc --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,7 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +coverage>=3.6 +doc8 # Apache-2.0 +hacking>=0.10.0,<0.11 +mock>=1.0 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..225cebd --- /dev/null +++ b/tox.ini @@ -0,0 +1,27 @@ +[tox] +envlist = py27,py34,pep8 + +[testenv] +usedevelop = True +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = + coverage run --branch --include "ironic_inspector_client*" -m unittest discover ironic_inspector_client.test + coverage report -m --fail-under 90 +setenv = PYTHONDONTWRITEBYTECODE=1 + +[testenv:pep8] +basepython = python2.7 +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = + flake8 ironic_inspector_client + doc8 README.rst + +[flake8] +max-complexity=15 + +[hacking] +import_exceptions = ironic_inspector_client.common.i18n