summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules
diff options
context:
space:
mode:
authorCharlle Daniel <charlledaniel@lsd.ufcg.edu.br>2016-11-21 17:46:23 -0300
committerJim Rollenhagen <jim@jimrollenhagen.com>2017-02-03 14:44:28 -0500
commited5f5637193136b14dec749834c61a2729547274 (patch)
tree804f36f21bf6e23656537f1a64b898ab4666274d /ironic/drivers/modules
parent31c3b7476c1f25f61452da6cd57143ecf6d45b44 (diff)
downloadironic-ed5f5637193136b14dec749834c61a2729547274.tar.gz
Ensures that OneView nodes are free for use by Ironic
Following the requirement. The validation is used within "OneViewPower.validate". As a result it enforces that a machine is owned by OneView, thus it cannot be powered on or off by the Ironic driver. Raising an exception when the node is owned by Oneview. Conflicts: ironic/drivers/modules/oneview/power.py ironic/tests/unit/drivers/modules/oneview/test_deploy_utils.py Change-Id: Ibf500577b7a3b5976fd49fd217c1be3d3e9c0f46 Closes-Bug: 1627034 Co-Authored-By: Stenio Araujo <steniaraujo@lsd.ufcg.edu.br> (cherry picked from commit 2505cb58f74b05c534a6a513080919063cc65fa9)
Diffstat (limited to 'ironic/drivers/modules')
-rw-r--r--ironic/drivers/modules/oneview/power.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/ironic/drivers/modules/oneview/power.py b/ironic/drivers/modules/oneview/power.py
index dc4ebcfd8..d72b41e2c 100644
--- a/ironic/drivers/modules/oneview/power.py
+++ b/ironic/drivers/modules/oneview/power.py
@@ -23,7 +23,7 @@ from ironic.common import states
from ironic.conductor import task_manager
from ironic.drivers import base
from ironic.drivers.modules.oneview import common
-
+from ironic.drivers.modules.oneview import deploy_utils
LOG = logging.getLogger(__name__)
@@ -44,17 +44,26 @@ class OneViewPower(base.PowerInterface):
enclosure_group_uri. Also, checks if the server profile of the node is
applied, if NICs are valid for the server profile of the node, and if
the server hardware attributes (ram, memory, vcpus count) are
- consistent with OneView.
+ consistent with OneView. It validates if the node is being used by
+ Oneview.
:param task: a task from TaskManager.
:raises: MissingParameterValue if a required parameter is missing.
:raises: InvalidParameterValue if parameters set are inconsistent with
resources in OneView
+ :raises: InvalidParameterValue if the node in use by OneView.
+ :raises: OneViewError if not possible to get OneView's information
+ for the given node, if not possible to retrieve Server
+ Hardware from OneView.
"""
common.verify_node_info(task.node)
try:
common.validate_oneview_resources_compatibility(task)
+
+ if deploy_utils.is_node_in_use_by_oneview(task.node):
+ raise exception.InvalidParameterValue(
+ _("Node %s is in use by OneView.") % task.node.uuid)
except exception.OneViewError as oneview_exc:
raise exception.InvalidParameterValue(oneview_exc)
@@ -62,7 +71,6 @@ class OneViewPower(base.PowerInterface):
"""Gets the current power state.
:param task: a TaskManager instance.
- :param node: The Node.
:returns: one of :mod:`ironic.common.states` POWER_OFF,
POWER_ON or ERROR.
:raises: OneViewError if fails to retrieve power state of OneView
@@ -87,7 +95,6 @@ class OneViewPower(base.PowerInterface):
"""Turn the current power state on or off.
:param task: a TaskManager instance.
- :param node: The Node.
:param power_state: The desired power state POWER_ON, POWER_OFF or
REBOOT from :mod:`ironic.common.states`.
:raises: InvalidParameterValue if an invalid power state was specified.
@@ -124,7 +131,6 @@ class OneViewPower(base.PowerInterface):
"""Reboot the node
:param task: a TaskManager instance.
- :param node: The Node.
:raises: PowerStateFailure if the final state of the node is not
POWER_ON.
"""