diff options
Diffstat (limited to 'ironic/conductor')
-rw-r--r-- | ironic/conductor/manager.py | 10 | ||||
-rw-r--r-- | ironic/conductor/rpcapi.py | 11 |
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): |