Remove pre-allocation model for OneView drivers
The OneView drivers deprecated support for pre-allocation model in Newton cycle (6.1.0), making the dynamic allocation the default model[0]. This patch removes code pertaining to pre-allocation feature from OneView drivers. The dunamic allocation feature should be used instead. [0] https://specs.openstack.org/openstack/ironic-specs/specs/not-implemented/oneview-drivers-dynamic-allocation.html Change-Id: I7789ffc0ebc6e42f58b184c0781fb3b122c00323 Closes-Bug: 1681509
This commit is contained in:
parent
1fcb6c52a2
commit
bd4bd780ab
@ -1555,17 +1555,11 @@ function enroll_nodes {
|
||||
mac_address=$(echo $hardware_info |awk '{print $5}')
|
||||
local applied_server_profile_uri
|
||||
applied_server_profile_uri=$(echo $hardware_info |awk '{print $6}')
|
||||
local dynamic_allocation
|
||||
dynamic_allocation=$(echo $hardware_info |awk '{print $7}')
|
||||
dynamic_allocation=$(trueorfalse False dynamic_allocation)
|
||||
|
||||
node_options+=" -i server_hardware_uri=$server_hardware_uri"
|
||||
if [[ -n "$applied_server_profile_uri" ]]; then
|
||||
node_options+=" -i applied_server_profile_uri=$applied_server_profile_uri"
|
||||
fi
|
||||
if [[ "$dynamic_allocation" == "True" ]]; then
|
||||
node_options+=" -i dynamic_allocation=$dynamic_allocation"
|
||||
fi
|
||||
|
||||
if [[ "$node_capabilities" ]]; then
|
||||
node_capabilities+=","
|
||||
|
@ -42,14 +42,11 @@ 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 Mitaka version of the ironic OneView drivers only supported what we call
|
||||
**pre-allocation** of nodes, meaning that resources in OneView are allocated
|
||||
prior to the node being made available in ironic. This model is deprecated and
|
||||
will be supported until OpenStack's Pike release. From the Newton release on,
|
||||
OneView drivers enables a new feature called **dynamic allocation** of nodes
|
||||
[6]_. In this model, the driver allocates resources in OneView only at boot
|
||||
time, allowing idle resources in ironic to be used by OneView users, enabling
|
||||
actual resource sharing among ironic and OneView users.
|
||||
From the Newton release on, OneView drivers enables a new feature called
|
||||
**dynamic allocation** of nodes [6]_. In this model, the driver allocates
|
||||
resources in OneView only at boot time, allowing idle resources in ironic
|
||||
to be used by OneView users, enabling actual resource sharing among ironic
|
||||
and OneView users.
|
||||
|
||||
Since OneView can claim nodes in ``available`` state at any time, a set of
|
||||
tasks runs periodically to detect nodes in use by OneView. A node in use by
|
||||
@ -121,12 +118,6 @@ Configuring and enabling the driver
|
||||
2. Update the [oneview] section of your ``ironic.conf`` file with your
|
||||
OneView credentials and CA certificate files information.
|
||||
|
||||
.. note::
|
||||
If you are using the deprecated ``pre-allocation`` feature (i.e.:
|
||||
``dynamic_allocation`` is set to False on all nodes), you can disable the
|
||||
driver periodic tasks by setting ``enable_periodic_tasks=false`` on the
|
||||
[oneview] section of ``ironic.conf``
|
||||
|
||||
.. note::
|
||||
An operator can set the ``periodic_check_interval`` option in the [oneview]
|
||||
section to set the interval between running the periodic check. The default
|
||||
@ -177,12 +168,6 @@ Configuring and enabling the driver
|
||||
2. Update the [oneview] section of your ``ironic.conf`` file with your
|
||||
OneView credentials and CA certificate files information.
|
||||
|
||||
.. note::
|
||||
If you are using the deprecated ``pre-allocation`` feature (i.e.:
|
||||
``dynamic_allocation`` is set to False on all nodes), you can disable the
|
||||
driver periodic tasks by setting ``enable_periodic_tasks=false`` on the
|
||||
[oneview] section of ``ironic.conf``
|
||||
|
||||
.. note::
|
||||
An operator can set the ``periodic_check_interval`` option in the [oneview]
|
||||
section to set the interval between running the periodic check. The default
|
||||
@ -224,9 +209,9 @@ memory size, CPU cores, processor architecture and disk size, of a given
|
||||
hardware. OneView drivers do in-band inspection, that involves booting a
|
||||
ramdisk on the hardware and fetching information directly from it. For that,
|
||||
your cloud controller needs to have the ``ironic-inspector`` component
|
||||
[10]_ running and properly enabled in ironic's configuration file.
|
||||
[9]_ running and properly enabled in ironic's configuration file.
|
||||
|
||||
See [11]_ for more information on how to install and configure
|
||||
See [10]_ for more information on how to install and configure
|
||||
``ironic-inspector``.
|
||||
|
||||
Registering a OneView node in ironic
|
||||
@ -243,12 +228,6 @@ etc. In this case, to be enrolled, the node must have the following parameters:
|
||||
|
||||
- ``server_hardware_uri``: URI of the ``Server Hardware`` on OneView.
|
||||
|
||||
- ``dynamic_allocation``: Boolean value to enable or disable (True/False)
|
||||
``dynamic allocation`` for the given node. If this parameter is not set,
|
||||
the driver will consider the ``pre-allocation`` model to maintain
|
||||
compatibility on ironic upgrade. The support for this key will be dropped
|
||||
in the Pike release, where only dynamic allocation will be used.
|
||||
|
||||
* In ``properties/capabilities``
|
||||
|
||||
- ``server_hardware_type_uri``: URI of the ``Server Hardware Type`` of the
|
||||
@ -294,13 +273,6 @@ from them MUST comply with the following requirements:
|
||||
Node ports should be created considering the **MAC address of the first
|
||||
Interface** of the given ``Server Hardware``.
|
||||
|
||||
.. note::
|
||||
Old versions of ironic using ``pre-allocation`` model (before Newton
|
||||
release) and nodes with `dynamic_allocation` flag disabled shall have their
|
||||
``Server Profiles`` applied during node enrollment and can have their ports
|
||||
created using the `Virtual` MAC addresses provided on ``Server Profile``
|
||||
application.
|
||||
|
||||
To tell ironic which NIC should be connected to the provisioning network, do::
|
||||
|
||||
$ ironic port-create -n $NODE_UUID -a $MAC_ADDRESS
|
||||
@ -319,102 +291,6 @@ Profile``, ``Server Profile Template`` and other OneView entities, refer to
|
||||
power state change. Ironic will NOT change the power state of machines
|
||||
which the Server Profile was applied by another OneView user.
|
||||
|
||||
Migrating from pre-allocation to dynamic allocation
|
||||
===================================================
|
||||
|
||||
The migration of a node from an ironic deployment using ``pre-allocation``
|
||||
model to the new ``dynamic allocation`` model can be done by using
|
||||
``ironic-oneview-cli`` facilities to migrate nodes (further details on [8]_).
|
||||
However, the same results can be achieved using the ironic CLI as explained
|
||||
below.
|
||||
|
||||
Checking if a node can be migrated
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
It is recommended to migrate nodes which are in a stable `provision state`. That
|
||||
means the conductor is not performing an operation with the node, what can
|
||||
impact in the execution of a migration. The possible stable `provision_state`
|
||||
values [9_] are: `enroll`, `manageable`, `available`, `active`, `error`,
|
||||
`clean failed` and `inspect failed`.
|
||||
|
||||
Dynamic allocation mode changes the way a ``Server Profile`` is associated with
|
||||
a node. In ``pre-allocation`` mode, when a node is registered in ironic, there
|
||||
must be a ``Server Profile`` applied to the ``Server Hardware`` represented by
|
||||
the given node what means, from the OneView point of view, the hardware is in
|
||||
use. In the ``dynamic allocation`` mode a ``Server Hardware`` is associated only
|
||||
when the node is in use by the Compute service or the OneView itself. As a
|
||||
result, there are different steps to perform if the node has an instance
|
||||
provisioned, in other words, when the `provisioning_state` is set to `active`.
|
||||
|
||||
.. note::
|
||||
Verify if the node has not already been migrated by checking if there is
|
||||
a `dynamic_allocation` field set to ``True`` in the `driver_info`
|
||||
namespace by doing::
|
||||
|
||||
$ ironic node-show --fields driver_info
|
||||
|
||||
Migrating nodes in `active` state
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
List nodes that are in `active` state doing::
|
||||
|
||||
$ ironic node-list --provision-state active --fields uuid driver_info
|
||||
|
||||
Execute the following steps for each node:
|
||||
|
||||
1. Identify the ``Server Hardware`` UUID looking at ``server_hardware_uri``
|
||||
property (formatted as ``/rest/server-hardware/<server-hardware-uuid>``) in
|
||||
the node's ``driver_info`` namespace doing::
|
||||
|
||||
$ ironic node-show <node-uuid> --fields driver_info
|
||||
|
||||
2. Log into OneView and find the ``Server Hardware`` searching for the
|
||||
``Server Hardware`` UUID identified in step 1. On the overview section,
|
||||
find the applied ``Server Profile`` entry, click on it and copy the
|
||||
``Server Profile`` URI. The copied excerpt should look like
|
||||
``/rest/server-profiles/<server-profile-uuid>``.
|
||||
|
||||
3. Then, set the copied excerpt from the ``Server Profile`` URI to the property
|
||||
``applied_server_profile_uri`` in the ``driver_info`` namespace doing::
|
||||
|
||||
$ ironic node-update <node-uuid> add driver_info/applied_server_profile_uri=<server_profile_uri>
|
||||
|
||||
4. Finally, set the `dynamic_allocation` flag in the ``driver_info`` namespace
|
||||
to ``True`` in order to finish the migration of the node doing::
|
||||
|
||||
$ ironic node-update <node-uuid> add driver_info/dynamic_allocation=True
|
||||
|
||||
Other cases for migration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Remember these steps are valid for nodes in the following states: `enroll`,
|
||||
`manageable`, `available`, `error`, `clean failed` and `inspect failed`. So,
|
||||
list the nodes in a given state, then execute the migration following steps for
|
||||
each node:
|
||||
|
||||
1. Place the node in maintenance mode to prevent ironic from working on the node
|
||||
during the migration doing::
|
||||
|
||||
$ ironic node-set-maintenance --reason "Migrating node to dynamic allocation" <node_uuid> true
|
||||
|
||||
.. note::
|
||||
It's recommended to check if the node's state has not changed as there is no way
|
||||
of locking the node between these commands.
|
||||
|
||||
2. Identify which ``Server Profile`` is associated by checking the property
|
||||
``server_hardware_uri`` in the ``driver_info`` namespace. Using the
|
||||
``server_hardware_uri``, log into OneView and remove the ``Server Profile``.
|
||||
|
||||
3. Set the `dynamic_allocation` to ``True`` in the flag ``driver_info``
|
||||
namespace doing::
|
||||
|
||||
$ ironic node-update $NODE_UUID add driver_info/dynamic_allocation=True
|
||||
|
||||
4. Finally, in order to put the node back into the resource pool, remove the
|
||||
node from maintenance mode doing::
|
||||
|
||||
$ ironic node-set-maintenance <node_uuid> false
|
||||
|
||||
3rd Party Tools
|
||||
===============
|
||||
|
||||
@ -427,8 +303,7 @@ ironic-oneview-cli
|
||||
The ``ironic-oneView`` CLI is a command line interface for management tasks
|
||||
involving OneView nodes. Its features include a facility to create of ironic
|
||||
nodes with all required parameters for OneView nodes, creation of Nova flavors
|
||||
for OneView nodes and, starting from version 0.3.0, the migration of nodes from
|
||||
``pre-allocation`` to the ``dynamic allocation`` model.
|
||||
for OneView nodes.
|
||||
|
||||
For more details on how Ironic-OneView CLI works and how to set it up, see
|
||||
[8]_.
|
||||
@ -437,9 +312,7 @@ ironic-oneviewd
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The ``ironic-oneviewd`` daemon monitors the ironic inventory of resources and
|
||||
provides facilities to operators managing OneView driver deployments. The
|
||||
daemon supports both allocation models (dynamic and pre-allocation) as of
|
||||
version 0.1.0.
|
||||
provides facilities to operators managing OneView driver deployments.
|
||||
|
||||
For more details on how Ironic-OneViewd works and how to set it up, see [7]_.
|
||||
|
||||
@ -453,6 +326,5 @@ References
|
||||
.. [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/
|
||||
.. [9] :ref:`states`
|
||||
.. [10] ironic-inspector - http://docs.openstack.org/developer/ironic-inspector/
|
||||
.. [11] ironic-inspector install - http://docs.openstack.org/developer/ironic-inspector/install.html
|
||||
.. [9] ironic-inspector - http://docs.openstack.org/developer/ironic-inspector/
|
||||
.. [10] ironic-inspector install - http://docs.openstack.org/developer/ironic-inspector/install.html
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import strutils
|
||||
|
||||
from ironic.common import exception
|
||||
from ironic.common.i18n import _, _LE
|
||||
@ -179,22 +178,10 @@ def validate_oneview_resources_compatibility(oneview_client, task):
|
||||
task.node.properties.get('memory_mb'),
|
||||
task.node.properties.get('cpus')
|
||||
)
|
||||
|
||||
# NOTE(thiagop): Support to pre-allocation will be dropped in the Pike
|
||||
# release.
|
||||
# NOTE(mrtenio): The Server Profile Template needs to have a physical
|
||||
# MAC when using dynamic_allocation. This will be the default behavior
|
||||
# in the Pike Release.
|
||||
if is_dynamic_allocation_enabled(task.node):
|
||||
oneview_client.is_node_port_mac_compatible_with_server_hardware(
|
||||
oneview_info, node_ports
|
||||
)
|
||||
oneview_client.validate_server_profile_template_mac_type(spt_uuid)
|
||||
else:
|
||||
oneview_client.check_server_profile_is_applied(oneview_info)
|
||||
oneview_client.is_node_port_mac_compatible_with_server_profile(
|
||||
oneview_info, node_ports
|
||||
)
|
||||
oneview_client.is_node_port_mac_compatible_with_server_hardware(
|
||||
oneview_info, node_ports
|
||||
)
|
||||
oneview_client.validate_server_profile_template_mac_type(spt_uuid)
|
||||
|
||||
except oneview_exceptions.OneViewException as oneview_exc:
|
||||
msg = (_("Error validating node resources with OneView: %s") %
|
||||
@ -272,15 +259,3 @@ def node_has_server_profile(func):
|
||||
)
|
||||
return func(self, *args, **kwargs)
|
||||
return inner
|
||||
|
||||
|
||||
def is_dynamic_allocation_enabled(node):
|
||||
flag = node.driver_info.get('dynamic_allocation')
|
||||
if flag:
|
||||
try:
|
||||
return strutils.bool_from_string(flag, strict=True)
|
||||
except ValueError:
|
||||
msg = (_LE("Invalid dynamic_allocation parameter value "
|
||||
"'%(flag)s' in node's %(node_uuid)s driver_info.") %
|
||||
{"flag": flag, "node_uuid": node.uuid})
|
||||
raise exception.InvalidParameterValue(msg)
|
||||
|
@ -246,27 +246,23 @@ class OneViewIscsiDeploy(iscsi_deploy.ISCSIDeploy, OneViewPeriodicTasks):
|
||||
|
||||
@METRICS.timer('OneViewIscsiDeploy.prepare')
|
||||
def prepare(self, task):
|
||||
if common.is_dynamic_allocation_enabled(task.node):
|
||||
deploy_utils.prepare(self.oneview_client, task)
|
||||
deploy_utils.prepare(self.oneview_client, task)
|
||||
super(OneViewIscsiDeploy, self).prepare(task)
|
||||
|
||||
@METRICS.timer('OneViewIscsiDeploy.tear_down')
|
||||
def tear_down(self, task):
|
||||
if (common.is_dynamic_allocation_enabled(task.node) and
|
||||
not CONF.conductor.automated_clean):
|
||||
if not CONF.conductor.automated_clean:
|
||||
deploy_utils.tear_down(self.oneview_client, task)
|
||||
return super(OneViewIscsiDeploy, self).tear_down(task)
|
||||
|
||||
@METRICS.timer('OneViewIscsiDeploy.prepare_cleaning')
|
||||
def prepare_cleaning(self, task):
|
||||
if common.is_dynamic_allocation_enabled(task.node):
|
||||
deploy_utils.prepare_cleaning(self.oneview_client, task)
|
||||
deploy_utils.prepare_cleaning(self.oneview_client, task)
|
||||
return super(OneViewIscsiDeploy, self).prepare_cleaning(task)
|
||||
|
||||
@METRICS.timer('OneViewIscsiDeploy.tear_down_cleaning')
|
||||
def tear_down_cleaning(self, task):
|
||||
if common.is_dynamic_allocation_enabled(task.node):
|
||||
deploy_utils.tear_down_cleaning(self.oneview_client, task)
|
||||
deploy_utils.tear_down_cleaning(self.oneview_client, task)
|
||||
super(OneViewIscsiDeploy, self).tear_down_cleaning(task)
|
||||
|
||||
|
||||
@ -381,25 +377,21 @@ class OneViewAgentDeploy(OneViewAgentDeployMixin, agent.AgentDeploy,
|
||||
|
||||
@METRICS.timer('OneViewAgentDeploy.prepare')
|
||||
def prepare(self, task):
|
||||
if common.is_dynamic_allocation_enabled(task.node):
|
||||
deploy_utils.prepare(self.oneview_client, task)
|
||||
deploy_utils.prepare(self.oneview_client, task)
|
||||
super(OneViewAgentDeploy, self).prepare(task)
|
||||
|
||||
@METRICS.timer('OneViewAgentDeploy.tear_down')
|
||||
def tear_down(self, task):
|
||||
if (common.is_dynamic_allocation_enabled(task.node) and
|
||||
not CONF.conductor.automated_clean):
|
||||
if not CONF.conductor.automated_clean:
|
||||
deploy_utils.tear_down(self.oneview_client, task)
|
||||
return super(OneViewAgentDeploy, self).tear_down(task)
|
||||
|
||||
@METRICS.timer('OneViewAgentDeploy.prepare_cleaning')
|
||||
def prepare_cleaning(self, task):
|
||||
if common.is_dynamic_allocation_enabled(task.node):
|
||||
deploy_utils.prepare_cleaning(self.oneview_client, task)
|
||||
deploy_utils.prepare_cleaning(self.oneview_client, task)
|
||||
return super(OneViewAgentDeploy, self).prepare_cleaning(task)
|
||||
|
||||
@METRICS.timer('OneViewAgentDeploy.tear_down_cleaning')
|
||||
def tear_down_cleaning(self, task):
|
||||
if common.is_dynamic_allocation_enabled(task.node):
|
||||
deploy_utils.tear_down_cleaning(self.oneview_client, task)
|
||||
deploy_utils.tear_down_cleaning(self.oneview_client, task)
|
||||
super(OneViewAgentDeploy, self).tear_down_cleaning(task)
|
||||
|
@ -234,58 +234,18 @@ class OneViewCommonTestCase(db_base.DbTestCase):
|
||||
def test_validate_oneview_resources_compatibility(
|
||||
self, mock_get_ov_client
|
||||
):
|
||||
oneview_client = mock_get_ov_client()
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
common.validate_oneview_resources_compatibility(oneview_client,
|
||||
task)
|
||||
self.assertTrue(
|
||||
oneview_client.validate_node_server_hardware.called)
|
||||
self.assertTrue(
|
||||
oneview_client.validate_node_server_hardware_type.called)
|
||||
self.assertTrue(
|
||||
oneview_client.validate_node_enclosure_group.called)
|
||||
self.assertTrue(
|
||||
oneview_client.validate_node_server_profile_template.called)
|
||||
self.assertTrue(
|
||||
oneview_client.check_server_profile_is_applied.called)
|
||||
self.assertTrue(
|
||||
oneview_client.
|
||||
is_node_port_mac_compatible_with_server_profile.called)
|
||||
self.assertFalse(
|
||||
oneview_client.
|
||||
is_node_port_mac_compatible_with_server_hardware.called)
|
||||
self.assertFalse(
|
||||
oneview_client.validate_spt_primary_boot_connection.called)
|
||||
self.assertFalse(
|
||||
oneview_client.
|
||||
validate_server_profile_template_mac_type.called)
|
||||
"""Validate compatibility of resources.
|
||||
|
||||
@mock.patch.object(common, 'get_oneview_client', spec_set=True,
|
||||
autospec=True)
|
||||
def test_validate_oneview_resources_compatibility_dynamic_allocation(
|
||||
self, mock_get_ov_client
|
||||
):
|
||||
"""Validate compatibility of resources for Dynamic Allocation model.
|
||||
|
||||
1) Set 'dynamic_allocation' flag as True on node's driver_info
|
||||
2) Check validate_node_server_profile_template method is called
|
||||
3) Check validate_node_server_hardware_type method is called
|
||||
4) Check validate_node_enclosure_group method is called
|
||||
5) Check validate_node_server_hardware method is called
|
||||
6) Check is_node_port_mac_compatible_with_server_hardware method
|
||||
1) Check validate_node_server_profile_template method is called
|
||||
2) Check validate_node_server_hardware_type method is called
|
||||
3) Check validate_node_enclosure_group method is called
|
||||
4) Check validate_node_server_hardware method is called
|
||||
5) Check is_node_port_mac_compatible_with_server_hardware method
|
||||
is called
|
||||
7) Check validate_server_profile_template_mac_type method is called
|
||||
8) Check check_server_profile_is_applied method is not called
|
||||
9) Check is_node_port_mac_compatible_with_server_profile method is
|
||||
not called
|
||||
|
||||
6) Check validate_server_profile_template_mac_type method is called
|
||||
"""
|
||||
oneview_client = mock_get_ov_client()
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
common.validate_oneview_resources_compatibility(oneview_client,
|
||||
task)
|
||||
self.assertTrue(
|
||||
@ -302,118 +262,3 @@ class OneViewCommonTestCase(db_base.DbTestCase):
|
||||
self.assertTrue(
|
||||
oneview_client.
|
||||
validate_server_profile_template_mac_type.called)
|
||||
self.assertFalse(
|
||||
oneview_client.check_server_profile_is_applied.called)
|
||||
self.assertFalse(
|
||||
oneview_client.
|
||||
is_node_port_mac_compatible_with_server_profile.called)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_boolean(self):
|
||||
"""Ensure Dynamic Allocation is enabled when flag is True.
|
||||
|
||||
1) Set 'dynamic_allocation' flag as True on node's driver_info
|
||||
2) Check Dynamic Allocation is enabled for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
self.assertTrue(
|
||||
common.is_dynamic_allocation_enabled(task.node)
|
||||
)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_string(self):
|
||||
"""Ensure Dynamic Allocation is enabled when flag is 'True'.
|
||||
|
||||
1) Set 'dynamic_allocation' flag as True on node's driver_info
|
||||
2) Check Dynamic Allocation is enabled for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = 'True'
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
self.assertTrue(
|
||||
common.is_dynamic_allocation_enabled(task.node)
|
||||
)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_false_boolean(self):
|
||||
"""Ensure Dynamic Allocation is disabled when flag is False.
|
||||
|
||||
1) Set 'dynamic_allocation' flag as False on node's driver_info
|
||||
2) Check Dynamic Allocation is disabled for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = False
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
self.assertFalse(
|
||||
common.is_dynamic_allocation_enabled(task.node)
|
||||
)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_false_string(self):
|
||||
"""Ensure Dynamic Allocation is disabled when flag is 'False'.
|
||||
|
||||
1) Set 'dynamic_allocation' flag as False on node's driver_info
|
||||
2) Check Dynamic Allocation is disabled for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = 'False'
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
self.assertFalse(
|
||||
common.is_dynamic_allocation_enabled(task.node)
|
||||
)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_none_object(self):
|
||||
"""Ensure Dynamic Allocation is disabled when flag is None.
|
||||
|
||||
1) Set 'dynamic_allocation' flag as None on node's driver_info
|
||||
2) Check Dynamic Allocation is disabled for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = None
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
self.assertFalse(
|
||||
common.is_dynamic_allocation_enabled(task.node)
|
||||
)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_without_flag(self):
|
||||
"""Ensure Dynamic Allocation is disabled when node doesn't have flag.
|
||||
|
||||
1) Create a node without 'dynamic_allocation' flag
|
||||
2) Check Dynamic Allocation is disabled for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
self.assertFalse(
|
||||
common.is_dynamic_allocation_enabled(task.node)
|
||||
)
|
||||
|
||||
def test_is_dynamic_allocation_enabled_with_invalid_value_for_flag(self):
|
||||
"""Ensure raises an InvalidParameterValue when flag is invalid.
|
||||
|
||||
1) Create a node with an invalid value for 'dynamic_allocation' flag
|
||||
2) Check if method raises an InvalidParameterValue for the given node
|
||||
|
||||
"""
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = 'invalid flag'
|
||||
task.node.driver_info = driver_info
|
||||
|
||||
self.assertRaises(
|
||||
exception.InvalidParameterValue,
|
||||
common.is_dynamic_allocation_enabled,
|
||||
task.node
|
||||
)
|
||||
|
@ -599,13 +599,16 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase):
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare',
|
||||
spec_set=True, autospec=True)
|
||||
def test_prepare(self, iscsi_deploy_prepare_mock, mock_get_ov_client):
|
||||
@mock.patch.object(deploy_utils, 'allocate_server_hardware_to_ironic')
|
||||
def test_prepare(self, allocate_server_hardware_mock,
|
||||
iscsi_deploy_prepare_mock, mock_get_ov_client):
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
self.node.save()
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
iscsi_deploy_prepare_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertTrue(allocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare',
|
||||
spec_set=True, autospec=True)
|
||||
@ -626,25 +629,6 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase):
|
||||
iscsi_deploy_prepare_mock.assert_called_once_with(
|
||||
mock.ANY, task)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'allocate_server_hardware_to_ironic')
|
||||
def test_prepare_with_dynamic_allocation_enabled(
|
||||
self, allocate_server_hardware_mock,
|
||||
iscsi_deploy_prepare_mock, mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
self.node.save()
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
iscsi_deploy_prepare_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertTrue(allocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'deploy',
|
||||
spec_set=True, autospec=True)
|
||||
def test_deploy(self, iscsi_deploy_mock, mock_get_ov_client):
|
||||
@ -666,14 +650,10 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase):
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'tear_down', spec_set=True,
|
||||
autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'deallocate_server_hardware_from_ironic')
|
||||
def test_tear_down_with_dynamic_allocation_enabled(
|
||||
def test_tear_down_with_automated_clean_disabled(
|
||||
self, deallocate_server_hardware_mock,
|
||||
iscsi_tear_down_mock, mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.save()
|
||||
CONF.conductor.automated_clean = False
|
||||
iscsi_tear_down_mock.return_value = states.DELETED
|
||||
|
||||
@ -684,29 +664,12 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase):
|
||||
self.assertEqual(states.DELETED, returned_state)
|
||||
self.assertTrue(deallocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
def test_prepare_cleaning(self, iscsi_prep_clean_mock, mock_get_ov_client):
|
||||
iscsi_prep_clean_mock.return_value = states.CLEANWAIT
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ret = task.driver.deploy.prepare_cleaning(task)
|
||||
self.assertEqual(states.CLEANWAIT, ret)
|
||||
iscsi_prep_clean_mock.assert_called_once_with(mock.ANY, task)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'allocate_server_hardware_to_ironic')
|
||||
def test_prepare_cleaning_with_dynamic_allocation_enabled(
|
||||
self, allocate_server_hardware_mock,
|
||||
iscsi_prep_clean_mock, mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.save()
|
||||
def test_prepare_cleaning(self, allocate_server_hardware_mock,
|
||||
iscsi_prep_clean_mock, mock_get_ov_client):
|
||||
iscsi_prep_clean_mock.return_value = states.CLEANWAIT
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ret = task.driver.deploy.prepare_cleaning(task)
|
||||
@ -714,27 +677,13 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase):
|
||||
iscsi_prep_clean_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertTrue(allocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'tear_down_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
def test_tear_down_cleaning(self, iscsi_tear_down_clean_mock,
|
||||
mock_get_ov_client):
|
||||
iscsi_tear_down_clean_mock.return_value = states.CLEANWAIT
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.tear_down_cleaning(task)
|
||||
iscsi_tear_down_clean_mock.assert_called_once_with(mock.ANY, task)
|
||||
|
||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'tear_down_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'deallocate_server_hardware_from_ironic')
|
||||
def test_tear_down_cleaning_with_dynamic_allocation_enabled(
|
||||
self, deallocate_server_hardware_mock,
|
||||
iscsi_tear_down_clean_mock, mock_get_ov_client
|
||||
def test_tear_down_cleaning(
|
||||
self, deallocate_server_hardware_mock, iscsi_tear_down_clean_mock,
|
||||
mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.save()
|
||||
iscsi_tear_down_clean_mock.return_value = states.CLEANWAIT
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
@ -781,13 +730,16 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase):
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'prepare',
|
||||
spec_set=True, autospec=True)
|
||||
def test_prepare(self, agent_deploy_prepare_mock, mock_get_ov_client):
|
||||
@mock.patch.object(deploy_utils, 'allocate_server_hardware_to_ironic')
|
||||
def test_prepare(self, allocate_server_hardware_mock,
|
||||
agent_deploy_prepare_mock, mock_get_ov_client):
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
self.node.save()
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
agent_deploy_prepare_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertTrue(allocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'prepare',
|
||||
spec_set=True, autospec=True)
|
||||
@ -808,25 +760,6 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase):
|
||||
agent_deploy_prepare_mock.assert_called_once_with(
|
||||
mock.ANY, task)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'prepare',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'allocate_server_hardware_to_ironic')
|
||||
def test_prepare_with_dynamic_allocation_enabled(
|
||||
self, allocate_server_hardware_mock,
|
||||
agent_deploy_prepare_mock, mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.provision_state = states.DEPLOYING
|
||||
self.node.save()
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
agent_deploy_prepare_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertTrue(allocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'deploy',
|
||||
spec_set=True, autospec=True)
|
||||
def test_deploy(self, agent_deploy_mock, mock_get_ov_client):
|
||||
@ -835,30 +768,15 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase):
|
||||
task.driver.deploy.deploy(task)
|
||||
agent_deploy_mock.assert_called_once_with(mock.ANY, task)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'tear_down', spec_set=True,
|
||||
autospec=True)
|
||||
def test_tear_down(self, agent_tear_down_mock, mock_get_ov_client):
|
||||
agent_tear_down_mock.return_value = states.DELETED
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
returned_state = task.driver.deploy.tear_down(task)
|
||||
agent_tear_down_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertEqual(states.DELETED, returned_state)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'tear_down', spec_set=True,
|
||||
autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'deallocate_server_hardware_from_ironic')
|
||||
def test_tear_down_with_dynamic_allocation_enabled(
|
||||
def test_tear_down_with_automated_clean_disabled(
|
||||
self, deallocate_server_hardware_mock,
|
||||
agent_tear_down_mock, mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.save()
|
||||
CONF.conductor.automated_clean = False
|
||||
agent_tear_down_mock.return_value = states.DELETED
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
returned_state = task.driver.deploy.tear_down(task)
|
||||
@ -866,29 +784,12 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase):
|
||||
self.assertEqual(states.DELETED, returned_state)
|
||||
self.assertTrue(deallocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'prepare_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
def test_prepare_cleaning(self, agent_prep_clean_mock, mock_get_ov_client):
|
||||
agent_prep_clean_mock.return_value = states.CLEANWAIT
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ret = task.driver.deploy.prepare_cleaning(task)
|
||||
self.assertEqual(states.CLEANWAIT, ret)
|
||||
agent_prep_clean_mock.assert_called_once_with(mock.ANY, task)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'prepare_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'allocate_server_hardware_to_ironic')
|
||||
def test_prepare_cleaning_with_dynamic_allocation_enabled(
|
||||
self, allocate_server_hardware_mock,
|
||||
agent_prep_clean_mock, mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.save()
|
||||
def test_prepare_cleaning(self, allocate_server_hardware_mock,
|
||||
agent_prep_clean_mock, mock_get_ov_client):
|
||||
agent_prep_clean_mock.return_value = states.CLEANWAIT
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ret = task.driver.deploy.prepare_cleaning(task)
|
||||
@ -896,29 +797,14 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase):
|
||||
agent_prep_clean_mock.assert_called_once_with(mock.ANY, task)
|
||||
self.assertTrue(allocate_server_hardware_mock.called)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'tear_down_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
def test_tear_down_cleaning(self, agent_tear_down_clean_mock,
|
||||
mock_get_ov_client):
|
||||
agent_tear_down_clean_mock.return_value = states.CLEANWAIT
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.tear_down_cleaning(task)
|
||||
agent_tear_down_clean_mock.assert_called_once_with(mock.ANY, task)
|
||||
|
||||
@mock.patch.object(agent.AgentDeploy, 'tear_down_cleaning',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(deploy_utils, 'deallocate_server_hardware_from_ironic')
|
||||
def test_tear_down_cleaning_with_dynamic_allocation_enabled(
|
||||
self, deallocate_server_hardware_mock,
|
||||
agent_tear_down_clean_mock, mock_get_ov_client
|
||||
def test_tear_down_cleaning(
|
||||
self, deallocate_server_hardware_mock, agent_tear_down_clean_mock,
|
||||
mock_get_ov_client
|
||||
):
|
||||
driver_info = self.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
self.node.driver_info = driver_info
|
||||
self.node.save()
|
||||
agent_tear_down_clean_mock.return_value = states.CLEANWAIT
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.tear_down_cleaning(task)
|
||||
|
@ -65,7 +65,6 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
task.node.driver_info = driver_info
|
||||
task.node.provision_state = states.DEPLOYING
|
||||
self.assertRaises(
|
||||
@ -174,7 +173,6 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
task.node.driver_info = driver_info
|
||||
task.node.provision_state = states.DEPLOYING
|
||||
self.assertRaises(
|
||||
@ -220,7 +218,6 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
task.node.driver_info = driver_info
|
||||
self.assertTrue(
|
||||
deploy_utils.is_node_in_use_by_oneview(oneview_client,
|
||||
@ -278,7 +275,6 @@ class OneViewDeployUtilsTestCase(db_base.DbTestCase):
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
driver_info = task.node.driver_info
|
||||
driver_info['dynamic_allocation'] = True
|
||||
driver_info['applied_server_profile_uri'] = 'same/applied_sp_uri/'
|
||||
task.node.driver_info = driver_info
|
||||
self.assertTrue(
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The pre-allocation model for OneView drivers was deprecated in Newton
|
||||
cycle (Ironic 6.1.0) and all pertaining code was marked for removal
|
||||
during Pike cycle. From now on, OneView drivers works only with dynamic
|
||||
allocation model.
|
Loading…
Reference in New Issue
Block a user