defdo_node_deploy(task, conductor_id, configdrive=None, extra_data=None): """Prepare the environment and deploy a node.""" node = task.node
defhandle_failure(e, task, logmsg, errmsg): # NOTE(deva): there is no need to clear conductor_affinity task.process_event('fail') args = {'node': task.node.uuid, 'err': e} LOG.warning(logmsg, args) node.last_error = errmsg % e
try: try: if configdrive: _store_configdrive(node, configdrive) except exception.SwiftOperationError as e: with excutils.save_and_reraise_exception(): handle_failure(e, task, _LW('Error while uploading the configdrive for ' '%(node)s to Swift'), _('Failed to upload the configdrive to Swift. ' 'Error: %s'))
try: task.driver.deploy.prepare(task) except Exception as e: with excutils.save_and_reraise_exception(): handle_failure(e, task, _LW('Error while preparing to deploy to node %(node)s: ' '%(err)s'), _("Failed to prepare to deploy. Error: %s"))
try: new_state = task.driver.deploy.deploy(task, extra_data) except Exception as e: with excutils.save_and_reraise_exception(): handle_failure(e, task, _LW('Error in deploy of node %(node)s: %(err)s'), _("Failed to deploy. Error: %s"))
# Update conductor_affinity to reference this conductor's ID # since there may be local persistent state node.conductor_affinity = conductor_id
# NOTE(deva): Some drivers may return states.DEPLOYWAIT # eg. if they are waiting for a callback if new_state == states.DEPLOYDONE: task.process_event('done') LOG.info(_LI('Successfully deployed node %(node)s with ' 'instance %(instance)s.'), {'node': node.uuid, 'instance': node.instance_uuid}) elif new_state == states.DEPLOYWAIT: task.process_event('wait') else: LOG.error(_LE('Unexpected state %(state)s returned while ' 'deploying node %(node)s.'), {'state': new_state, 'node': node.uuid}) finally: node.save()
classPXEAndIPMIToolDriver(base.BaseDriver): """PXE + IPMITool driver. This driver implements the `core` functionality, combining :class:`ironic.drivers.ipmi.IPMI` for power on/off and reboot with :class:`ironic.driver.pxe.PXE` for image deployment. Implementations are in those respective classes; this class is merely the glue between them. """
except Exception as e: with excutils.save_and_reraise_exception(): LOG.error(_LE('Error injecting data into image ' '%(img_id)s (%(e)s)'), {'img_id': image_uuid, 'e': e})