summaryrefslogtreecommitdiff
path: root/ironic/conductor
diff options
context:
space:
mode:
authorDmitry Tantsur <divius.inside@gmail.com>2018-07-16 15:03:42 +0200
committerJim Rollenhagen <jim@jimrollenhagen.com>2018-07-18 21:50:13 +0000
commit597d8a727b1a78a075939e03dbdb8a993765187f (patch)
tree9840dc378bb571ec4274fab8eebf9adc4dd58faa /ironic/conductor
parent072cf9b5609a84bcd318ccd8e5a2cf15c078821b (diff)
downloadironic-597d8a727b1a78a075939e03dbdb8a993765187f.tar.gz
Add reset_interfaces parameter to node's PATCH
Setting it to true when updating the node's driver resets all hardware interfaces to their defaults, unless they're also updated. Change-Id: Ie70dbbed2be0a46f024b859e8141572500fb47c6 Story: #2002868 Task: #22818
Diffstat (limited to 'ironic/conductor')
-rw-r--r--ironic/conductor/manager.py10
-rw-r--r--ironic/conductor/rpcapi.py11
2 files changed, 16 insertions, 5 deletions
diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py
index 5ddab21e4..f760848e0 100644
--- a/ironic/conductor/manager.py
+++ b/ironic/conductor/manager.py
@@ -100,7 +100,7 @@ class ConductorManager(base_manager.BaseConductorManager):
# NOTE(rloo): This must be in sync with rpcapi.ConductorAPI's.
# NOTE(pas-ha): This also must be in sync with
# ironic.common.release_mappings.RELEASE_MAPPING['master']
- RPC_API_VERSION = '1.45'
+ RPC_API_VERSION = '1.46'
target = messaging.Target(version=RPC_API_VERSION)
@@ -144,7 +144,7 @@ class ConductorManager(base_manager.BaseConductorManager):
exception.NodeLocked,
exception.InvalidState,
exception.DriverNotFound)
- def update_node(self, context, node_obj):
+ def update_node(self, context, node_obj, reset_interfaces=False):
"""Update a node with the supplied data.
This method is the main "hub" for PUT and PATCH requests in the API.
@@ -153,6 +153,8 @@ class ConductorManager(base_manager.BaseConductorManager):
:param context: an admin context
:param node_obj: a changed (but not saved) node object.
+ :param reset_interfaces: whether to reset hardware interfaces to their
+ defaults.
:raises: NoValidDefaultForInterface if no default can be calculated
for some interfaces, and explicit values must be provided.
"""
@@ -179,9 +181,13 @@ class ConductorManager(base_manager.BaseConductorManager):
action = _("Node %(node)s can not have %(field)s "
"updated unless it is in one of allowed "
"(%(allowed)s) states or in maintenance mode.")
+ updating_driver = 'driver' in delta
for iface in drivers_base.ALL_INTERFACES:
interface_field = '%s_interface' % iface
if interface_field not in delta:
+ if updating_driver and reset_interfaces:
+ setattr(node_obj, interface_field, None)
+
continue
if not (node_obj.provision_state in allowed_update_states
diff --git a/ironic/conductor/rpcapi.py b/ironic/conductor/rpcapi.py
index c244a6623..b644d8566 100644
--- a/ironic/conductor/rpcapi.py
+++ b/ironic/conductor/rpcapi.py
@@ -94,13 +94,14 @@ class ConductorAPI(object):
| 1.43 - Added do_node_rescue, do_node_unrescue and can_send_rescue
| 1.44 - Added add_node_traits and remove_node_traits.
| 1.45 - Added continue_node_deploy
+ | 1.46 - Added reset_interfaces to update_node
"""
# NOTE(rloo): This must be in sync with manager.ConductorManager's.
# NOTE(pas-ha): This also must be in sync with
# ironic.common.release_mappings.RELEASE_MAPPING['master']
- RPC_API_VERSION = '1.45'
+ RPC_API_VERSION = '1.46'
def __init__(self, topic=None):
super(ConductorAPI, self).__init__()
@@ -186,7 +187,8 @@ class ConductorAPI(object):
cctxt = self.client.prepare(topic=topic or self.topic, version='1.36')
return cctxt.call(context, 'create_node', node_obj=node_obj)
- def update_node(self, context, node_obj, topic=None):
+ def update_node(self, context, node_obj, topic=None,
+ reset_interfaces=False):
"""Synchronously, have a conductor update the node's information.
Update the node's information in the database and return a node object.
@@ -201,13 +203,16 @@ class ConductorAPI(object):
:param context: request context.
:param node_obj: a changed (but not saved) node object.
:param topic: RPC topic. Defaults to self.topic.
+ :param reset_interfaces: whether to reset hardware interfaces to their
+ defaults.
:returns: updated node object, including all fields.
:raises: NoValidDefaultForInterface if no default can be calculated
for some interfaces, and explicit values must be provided.
"""
cctxt = self.client.prepare(topic=topic or self.topic, version='1.1')
- return cctxt.call(context, 'update_node', node_obj=node_obj)
+ return cctxt.call(context, 'update_node', node_obj=node_obj,
+ reset_interfaces=reset_interfaces)
def change_node_power_state(self, context, node_id, new_state,
topic=None, timeout=None):