From f8bf0ad51b3acd97832f999b8f3744266c345670 Mon Sep 17 00:00:00 2001 From: Hugo Nicodemos Date: Fri, 1 Dec 2017 17:58:11 -0300 Subject: [PATCH] Remove python-oneviewclient from oneview hardware type. This patch removes the ``python-oneviewclient`` library from ``oneview`` hardware type since it was migrated to ``hponeview`` and ``python-ilorest-library``. Change-Id: I3393189abdff6a0e56f54375877cc310d72ff5b1 Closes-Bug: #1693788 --- doc/source/admin/drivers/oneview.rst | 29 ++++++++--------- etc/ironic/ironic.conf.sample | 4 --- ironic/conf/oneview.py | 3 -- ironic/drivers/fake.py | 12 ++----- ironic/drivers/modules/oneview/common.py | 24 -------------- .../drivers/modules/oneview/deploy_utils.py | 2 -- ironic/drivers/modules/oneview/inspect.py | 4 --- ironic/drivers/modules/oneview/management.py | 1 - ironic/drivers/modules/oneview/power.py | 1 - ironic/drivers/oneview.py | 21 ------------ .../drivers/modules/oneview/test_deploy.py | 6 ---- .../modules/oneview/test_management.py | 3 -- .../drivers/modules/oneview/test_power.py | 2 -- .../drivers/third_party_driver_mock_specs.py | 20 ------------ .../unit/drivers/third_party_driver_mocks.py | 32 ------------------- ...python-oneviewclient-b1d345ef861e156e.yaml | 16 ++++++++++ 16 files changed, 33 insertions(+), 147 deletions(-) create mode 100644 releasenotes/notes/remove-python-oneviewclient-b1d345ef861e156e.yaml diff --git a/doc/source/admin/drivers/oneview.rst b/doc/source/admin/drivers/oneview.rst index 2793af870f..9c975aed66 100644 --- a/doc/source/admin/drivers/oneview.rst +++ b/doc/source/admin/drivers/oneview.rst @@ -23,10 +23,9 @@ following classic drivers: Classic Drivers =============== -The ``iscsi_pxe_oneview`` and ``agent_pxe_oneview`` drivers implement the -core interfaces of an ironic Driver [2]_, and use the ``python-oneviewclient`` -[3]_ to provide communication between ironic and OneView through OneView's -REST API. +The ``iscsi_pxe_oneview`` and ``agent_pxe_oneview`` drivers implement the core +interfaces of an ironic Driver [2]_, and use the ``hpOneView`` [3]_ library +to provide communication between ironic and OneView through OneView's REST API. .. note:: Classic drivers will be deprecated in favor of Hardware Types. @@ -39,15 +38,15 @@ process: * The ironic driver for OneView, which can be: * `iscsi_pxe_oneview` or * `agent_pxe_oneview` -* The python-oneviewclient library +* The hpOneView library * The OneView appliance The role of ironic is to serve as a bare metal provider to OneView's managed physical hardware and to provide communication with other necessary OpenStack services such as Nova and Glance. When ironic receives a boot request, it works together with the ironic OneView driver to access a machine in OneView, -the ``python-oneviewclient`` being responsible for the communication with the -OneView appliance. +the ``hpOneView`` being responsible for the communication with the OneView +appliance. From the Newton release on, OneView drivers enables a new feature called **dynamic allocation** of nodes [6]_. In this model, the driver allocates @@ -72,14 +71,14 @@ The following requirements apply for both ``iscsi_pxe_oneview`` and Minimum version supported is 2.0. -* ``python-oneviewclient`` is a python package containing a client to manage - the communication between ironic and OneView. +* ``hpOneView`` is a python package containing a client to manage the + communication between ironic and OneView. - Install the ``python-oneviewclient`` module to enable the communication. - Minimum version required is 2.4.0 but it is recommended to install the most - up-to-date version:: + Install the ``hpOneView`` module to enable the communication. Minimum version + required is 4.4.0 but it is recommended to install the most up-to-date + version:: - $ pip install "python-oneviewclient<3.0.0,>=2.4.0" + $ pip install "hpOneView>=4.4.0" * ``ironic-inspector`` if using hardware inspection. @@ -97,7 +96,7 @@ Tested platforms - Proliant BL460c Gen8 - Proliant BL460c Gen9 - Proliant BL465c Gen8 - - Proliant DL360 Gen9 (starting with python-oneviewclient 2.1.0) + - Proliant DL360 Gen9 Notice that for the driver to work correctly with Gen8 and Gen9 DL servers in general, the hardware also needs to run version 4.2.3 of iLO, with @@ -435,7 +434,7 @@ References ========== .. [1] HP OneView - https://www.hpe.com/us/en/integrated-systems/software.html .. [2] :ref:`architecture_drivers` -.. [3] python-oneviewclient - https://pypi.python.org/pypi/python-oneviewclient +.. [3] hpOneView - https://pypi.python.org/pypi/hpOneView .. [6] Dynamic Allocation in OneView drivers - http://specs.openstack.org/openstack/ironic-specs/specs/not-implemented/oneview-drivers-dynamic-allocation.html .. [7] ironic-oneviewd - https://pypi.python.org/pypi/ironic-oneviewd/ .. [8] ironic-oneview-cli - https://pypi.python.org/pypi/ironic-oneview-cli/ diff --git a/etc/ironic/ironic.conf.sample b/etc/ironic/ironic.conf.sample index 6d4f304010..a45b371f5f 100644 --- a/etc/ironic/ironic.conf.sample +++ b/etc/ironic/ironic.conf.sample @@ -2954,10 +2954,6 @@ # Path to CA certificate. (string value) #tls_cacert_file = -# Max connection retries to check changes on OneView. (integer -# value) -#max_polling_attempts = 12 - # Whether to enable the periodic tasks for OneView driver be # aware when OneView hardware resources are taken and released # by Ironic or OneView users and proactively manage nodes in diff --git a/ironic/conf/oneview.py b/ironic/conf/oneview.py index 6dc5da6bae..77f0710155 100644 --- a/ironic/conf/oneview.py +++ b/ironic/conf/oneview.py @@ -31,9 +31,6 @@ opts = [ help=_('Option to allow insecure connection with OneView.')), cfg.StrOpt('tls_cacert_file', help=_('Path to CA certificate.')), - cfg.IntOpt('max_polling_attempts', - default=12, - help=_('Max connection retries to check changes on OneView.')), cfg.BoolOpt('enable_periodic_tasks', default=True, help=_('Whether to enable the periodic tasks for OneView ' diff --git a/ironic/drivers/fake.py b/ironic/drivers/fake.py index 28ddf1f7f6..27b62e1529 100644 --- a/ironic/drivers/fake.py +++ b/ironic/drivers/fake.py @@ -40,7 +40,6 @@ from ironic.drivers.modules.irmc import inspect as irmc_inspect from ironic.drivers.modules.irmc import management as irmc_management from ironic.drivers.modules.irmc import power as irmc_power from ironic.drivers.modules import iscsi_deploy -from ironic.drivers.modules.oneview import common as oneview_common from ironic.drivers.modules.oneview import management as oneview_management from ironic.drivers.modules.oneview import power as oneview_power from ironic.drivers.modules import pxe @@ -219,19 +218,14 @@ class FakeCIMCDriver(base.BaseDriver): class FakeOneViewDriver(base.BaseDriver): - """Fake OneView driver. For testing purposes. """ + """Fake OneView driver. For testing purposes.""" def __init__(self): - if not importutils.try_import('oneview_client.client'): + if not importutils.try_import('hpOneView.oneview_client'): raise exception.DriverLoadError( driver=self.__class__.__name__, - reason=_("Unable to import python-oneviewclient library")) + reason=_("Unable to import hpOneView library")) - # Checks connectivity to OneView and version compatibility on driver - # initialization - oneview_client = oneview_common.get_oneview_client() - oneview_client.verify_oneview_version() - oneview_client.verify_credentials() self.power = oneview_power.OneViewPower() self.management = oneview_management.OneViewManagement() self.boot = fake.FakeBoot() diff --git a/ironic/drivers/modules/oneview/common.py b/ironic/drivers/modules/oneview/common.py index 2f010e04a5..9bb048516f 100644 --- a/ironic/drivers/modules/oneview/common.py +++ b/ironic/drivers/modules/oneview/common.py @@ -27,11 +27,6 @@ from ironic.drivers import utils LOG = logging.getLogger(__name__) -client = importutils.try_import('oneview_client.client') -oneview_utils = importutils.try_import('oneview_client.utils') -oneview_states = importutils.try_import('oneview_client.states') -oneview_exceptions = importutils.try_import('oneview_client.exceptions') - hponeview_client = importutils.try_import('hpOneView.oneview_client') redfish = importutils.try_import('redfish') client_exception = importutils.try_import('hpOneView.exceptions') @@ -72,25 +67,6 @@ NODE_IN_USE_BY_ONEVIEW = 'node in use by OneView' SERVER_HARDWARE_ALLOCATION_ERROR = 'server hardware allocation error' -def get_oneview_client(): - """Generates an instance of the OneView client. - - Generates an instance of the OneView client using the imported - oneview_client library. - - :returns: an instance of the OneView client - """ - oneview_client = client.Client( - manager_url=CONF.oneview.manager_url, - username=CONF.oneview.username, - password=CONF.oneview.password, - allow_insecure_connections=CONF.oneview.allow_insecure_connections, - tls_cacert_file=CONF.oneview.tls_cacert_file, - max_polling_attempts=CONF.oneview.max_polling_attempts - ) - return oneview_client - - def prepare_manager_url(manager_url): # NOTE(mrtenio) python-oneviewclient uses https or http in the manager_url # while python-hpOneView does not. This will not be necessary when diff --git a/ironic/drivers/modules/oneview/deploy_utils.py b/ironic/drivers/modules/oneview/deploy_utils.py index db17d0cdba..1dc372f46c 100644 --- a/ironic/drivers/modules/oneview/deploy_utils.py +++ b/ironic/drivers/modules/oneview/deploy_utils.py @@ -25,8 +25,6 @@ from ironic.drivers.modules.oneview import common LOG = logging.getLogger(__name__) -oneview_exception = importutils.try_import('oneview_client.exceptions') -oneview_utils = importutils.try_import('oneview_client.utils') client_exception = importutils.try_import('hpOneView.exceptions') diff --git a/ironic/drivers/modules/oneview/inspect.py b/ironic/drivers/modules/oneview/inspect.py index 01e9255335..c3d66e0b99 100644 --- a/ironic/drivers/modules/oneview/inspect.py +++ b/ironic/drivers/modules/oneview/inspect.py @@ -15,7 +15,6 @@ from futurist import periodics from ironic_lib import metrics_utils -from oslo_utils import importutils from ironic.common import exception from ironic.common import states @@ -27,9 +26,6 @@ from ironic.drivers.modules.oneview import deploy_utils METRICS = metrics_utils.get_metrics_logger(__name__) -oneview_exception = importutils.try_import('oneview_client.exceptions') -oneview_utils = importutils.try_import('oneview_client.utils') - class OneViewInspect(inspector.Inspector): """Interface for in band inspection.""" diff --git a/ironic/drivers/modules/oneview/management.py b/ironic/drivers/modules/oneview/management.py index 792db124f5..42ea2af85e 100644 --- a/ironic/drivers/modules/oneview/management.py +++ b/ironic/drivers/modules/oneview/management.py @@ -26,7 +26,6 @@ from ironic.drivers.modules.oneview import common from ironic.drivers.modules.oneview import deploy_utils client_exception = importutils.try_import('hpOneView.exceptions') -oneview_exceptions = importutils.try_import('oneview_client.exceptions') LOG = logging.getLogger(__name__) METRICS = metrics_utils.get_metrics_logger(__name__) diff --git a/ironic/drivers/modules/oneview/power.py b/ironic/drivers/modules/oneview/power.py index 05a1d624e3..b86e12a0dd 100644 --- a/ironic/drivers/modules/oneview/power.py +++ b/ironic/drivers/modules/oneview/power.py @@ -27,7 +27,6 @@ from ironic.drivers.modules.oneview import deploy_utils from ironic.drivers.modules.oneview import management client_exception = importutils.try_import('hpOneView.exceptions') -oneview_exceptions = importutils.try_import('oneview_client.exceptions') LOG = logging.getLogger(__name__) diff --git a/ironic/drivers/oneview.py b/ironic/drivers/oneview.py index 1a7bf93f5a..562d10146c 100644 --- a/ironic/drivers/oneview.py +++ b/ironic/drivers/oneview.py @@ -23,7 +23,6 @@ from ironic.common.i18n import _ from ironic.drivers import base from ironic.drivers import generic from ironic.drivers.modules import noop -from ironic.drivers.modules.oneview import common from ironic.drivers.modules.oneview import deploy from ironic.drivers.modules.oneview import inspect from ironic.drivers.modules.oneview import management @@ -68,11 +67,6 @@ class AgentPXEOneViewDriver(base.BaseDriver): """ def __init__(self): - if not importutils.try_import('oneview_client.client'): - raise exception.DriverLoadError( - driver=self.__class__.__name__, - reason=_("Unable to import python-oneviewclient library")) - if not importutils.try_import('hpOneView.oneview_client'): raise exception.DriverLoadError( driver=self.__class__.__name__, @@ -83,11 +77,6 @@ class AgentPXEOneViewDriver(base.BaseDriver): driver=self.__class__.__name__, reason=_("Unable to import python-ilorest-library")) - # Checks connectivity to OneView and version compatibility on driver - # initialization - oneview_client = common.get_oneview_client() - oneview_client.verify_oneview_version() - oneview_client.verify_credentials() self.power = power.OneViewPower() self.management = management.OneViewManagement() self.boot = pxe.PXEBoot() @@ -106,11 +95,6 @@ class ISCSIPXEOneViewDriver(base.BaseDriver): """ def __init__(self): - if not importutils.try_import('oneview_client.client'): - raise exception.DriverLoadError( - driver=self.__class__.__name__, - reason=_("Unable to import python-oneviewclient library")) - if not importutils.try_import('hpOneView.oneview_client'): raise exception.DriverLoadError( driver=self.__class__.__name__, @@ -121,11 +105,6 @@ class ISCSIPXEOneViewDriver(base.BaseDriver): driver=self.__class__.__name__, reason=_("Unable to import python-ilorest-library")) - # Checks connectivity to OneView and version compatibility on driver - # initialization - oneview_client = common.get_oneview_client() - oneview_client.verify_oneview_version() - oneview_client.verify_credentials() self.power = power.OneViewPower() self.management = management.OneViewManagement() self.boot = pxe.PXEBoot() diff --git a/ironic/tests/unit/drivers/modules/oneview/test_deploy.py b/ironic/tests/unit/drivers/modules/oneview/test_deploy.py index f8cefd8322..ea8c8236df 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_deploy.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_deploy.py @@ -14,7 +14,6 @@ # under the License. import mock -from oslo_utils import importutils from ironic.common import driver_factory from ironic.common import exception @@ -31,8 +30,6 @@ from ironic.tests.unit.db import base as db_base from ironic.tests.unit.db import utils as db_utils from ironic.tests.unit.objects import utils as obj_utils -oneview_models = importutils.try_import('oneview_client.models') - METHODS = ['iter_nodes', 'update_node', 'do_provisioning_action'] PXE_DRV_INFO_DICT = db_utils.get_test_pxe_driver_info() PXE_INST_INFO_DICT = db_utils.get_test_pxe_instance_info() @@ -84,9 +81,6 @@ def _setup_node_in_cleanfailed_state_without_oneview_error(node): class OneViewDriverDeploy(deploy.OneViewPeriodicTasks): oneview_driver = 'fake_oneview' - def __init__(self): - self.oneview_client = mock.MagicMock() - @mock.patch('ironic.objects.Node', spec_set=True, autospec=True) @mock.patch.object(deploy_utils, 'is_node_in_use_by_oneview') diff --git a/ironic/tests/unit/drivers/modules/oneview/test_management.py b/ironic/tests/unit/drivers/modules/oneview/test_management.py index 108267e18a..e09deb0b89 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_management.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_management.py @@ -29,10 +29,7 @@ from ironic.tests.unit.db import base as db_base from ironic.tests.unit.db import utils as db_utils from ironic.tests.unit.objects import utils as obj_utils - client_exception = importutils.try_import('hpOneView.exceptions') -oneview_exceptions = importutils.try_import('oneview_client.exceptions') -oneview_models = importutils.try_import('oneview_client.models') @mock.patch.object(common, 'get_hponeview_client') diff --git a/ironic/tests/unit/drivers/modules/oneview/test_power.py b/ironic/tests/unit/drivers/modules/oneview/test_power.py index 6a8afc2954..b4d86cabcd 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_power.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_power.py @@ -31,8 +31,6 @@ from ironic.tests.unit.db import utils as db_utils from ironic.tests.unit.objects import utils as obj_utils client_exception = importutils.try_import('hpOneView.exceptions') -oneview_models = importutils.try_import('oneview_client.models') -oneview_exceptions = importutils.try_import('oneview_client.exceptions') class OneViewPowerDriverTestCase(db_base.DbTestCase): diff --git a/ironic/tests/unit/drivers/third_party_driver_mock_specs.py b/ironic/tests/unit/drivers/third_party_driver_mock_specs.py index 8126f7add5..762a1c28aa 100644 --- a/ironic/tests/unit/drivers/third_party_driver_mock_specs.py +++ b/ironic/tests/unit/drivers/third_party_driver_mock_specs.py @@ -124,26 +124,6 @@ SCCICLIENT_VIOM_CONF_SPEC = ( 'terminate', ) -ONEVIEWCLIENT_SPEC = ( - 'client', - 'states', - 'exceptions', - 'models', - 'utils', -) - -ONEVIEWCLIENT_CLIENT_CLS_SPEC = ( -) - -ONEVIEWCLIENT_STATES_SPEC = ( - 'ONEVIEW_POWER_OFF', - 'ONEVIEW_POWERING_OFF', - 'ONEVIEW_POWER_ON', - 'ONEVIEW_POWERING_ON', - 'ONEVIEW_RESETTING', - 'ONEVIEW_ERROR', -) - HPE_ONEVIEW_SPEC = ( 'oneview_client', 'resources', diff --git a/ironic/tests/unit/drivers/third_party_driver_mocks.py b/ironic/tests/unit/drivers/third_party_driver_mocks.py index f813a69c07..eaf6f24908 100644 --- a/ironic/tests/unit/drivers/third_party_driver_mocks.py +++ b/ironic/tests/unit/drivers/third_party_driver_mocks.py @@ -25,7 +25,6 @@ Current list of mocked libraries: - proliantutils - pysnmp - scciclient -- oneview_client - hpOneView - pywsman - python-dracclient @@ -69,37 +68,6 @@ if not proliantutils: six.moves.reload_module(sys.modules['ironic.drivers.ilo']) -oneview_client = importutils.try_import('oneview_client') -if not oneview_client: - oneview_client = mock.MagicMock(spec_set=mock_specs.ONEVIEWCLIENT_SPEC) - sys.modules['oneview_client'] = oneview_client - sys.modules['oneview_client.client'] = oneview_client.client - states = mock.MagicMock( - spec_set=mock_specs.ONEVIEWCLIENT_STATES_SPEC, - ONEVIEW_POWER_OFF='Off', - ONEVIEW_POWERING_OFF='PoweringOff', - ONEVIEW_POWER_ON='On', - ONEVIEW_POWERING_ON='PoweringOn', - ONEVIEW_RESETTING='Resetting', - ONEVIEW_ERROR='error') - sys.modules['oneview_client.states'] = states - sys.modules['oneview_client.exceptions'] = oneview_client.exceptions - sys.modules['oneview_client.utils'] = oneview_client.utils - oneview_client.exceptions.OneViewException = type('OneViewException', - (Exception,), {}) - sys.modules['oneview_client.models'] = oneview_client.models - -oneview_client_module = importutils.try_import('oneview_client.client') -# NOTE(vdrok): Always mock the oneview client, as it tries to establish -# connection to oneview right in __init__, and stevedore does not seem to care -# about mocks when it loads a module in mock_the_extension_manager -sys.modules['oneview_client.client'].Client = mock.MagicMock( - spec_set=mock_specs.ONEVIEWCLIENT_CLIENT_CLS_SPEC -) -if 'ironic.drivers.oneview' in sys.modules: - six.moves.reload_module(sys.modules['ironic.drivers.modules.oneview']) - - hpOneView = importutils.try_import('hpOneView') if not hpOneView: hpOneView = mock.MagicMock(spec_set=mock_specs.HPE_ONEVIEW_SPEC) diff --git a/releasenotes/notes/remove-python-oneviewclient-b1d345ef861e156e.yaml b/releasenotes/notes/remove-python-oneviewclient-b1d345ef861e156e.yaml new file mode 100644 index 0000000000..771dd665ec --- /dev/null +++ b/releasenotes/notes/remove-python-oneviewclient-b1d345ef861e156e.yaml @@ -0,0 +1,16 @@ +--- +issues: + - | + The library ``python-ilorest-library`` is a fork of the + ``python-redfish-library`` and imported with same name, hence conflict + when together. ``python-redfish-library`` cannot be used when ``oneview`` + hardware type is in use. +upgrade: + - | + The ``oneview`` hardware type now use ``hpOneView`` and + ``python-ilorest-library`` libraries to communicate with OneView + appliances. The ``python-oneviewclient`` library is no longer used. +upgrade: + - | + Configuration ``[oneview]max_polling_attempts`` is removed since + ``hpOneView`` doesn't support this option.