Ejemplo n.º 1
0
def start_deploy(task, manager, configdrive=None, event='deploy'):
    """Start deployment or rebuilding on a node.

    This function does not check the node suitability for deployment, it's left
    up to the caller.

    :param task: a TaskManager instance.
    :param manager: a ConductorManager to run tasks on.
    :param configdrive: a configdrive, if requested.
    :param event: event to process: deploy or rebuild.
    """
    node = task.node

    if event == 'rebuild':
        # Note(gilliard) Clear these to force the driver to
        # check whether they have been changed in glance
        # NOTE(vdrok): If image_source is not from Glance we should
        # not clear kernel and ramdisk as they're input manually
        if glance_utils.is_glance_image(
                node.instance_info.get('image_source')):
            instance_info = node.instance_info
            instance_info.pop('kernel', None)
            instance_info.pop('ramdisk', None)
            node.instance_info = instance_info

    # Infer the image type to make sure the deploy driver
    # validates only the necessary variables for different
    # image types.
    # NOTE(sirushtim): The iwdi variable can be None. It's up to
    # the deploy driver to validate this.
    iwdi = images.is_whole_disk_image(task.context, node.instance_info)
    driver_internal_info = node.driver_internal_info
    driver_internal_info['is_whole_disk_image'] = iwdi
    node.driver_internal_info = driver_internal_info
    node.save()

    try:
        task.driver.power.validate(task)
        task.driver.deploy.validate(task)
        utils.validate_instance_info_traits(task.node)
        conductor_steps.validate_deploy_templates(task, skip_missing=True)
    except exception.InvalidParameterValue as e:
        raise exception.InstanceDeployFailure(
            _("Failed to validate deploy or power info for node "
              "%(node_uuid)s. Error: %(msg)s") % {
                  'node_uuid': node.uuid,
                  'msg': e
              },
            code=e.code)

    try:
        task.process_event(event,
                           callback=manager._spawn_worker,
                           call_args=(do_node_deploy, task,
                                      manager.conductor.id, configdrive),
                           err_handler=utils.provisioning_error_handler)
    except exception.InvalidState:
        raise exception.InvalidStateRequested(action=event,
                                              node=task.node.uuid,
                                              state=task.node.provision_state)
Ejemplo n.º 2
0
def continue_node_deploy(task):
    """Continue deployment after finishing an async deploy step.

    This function calculates which step has to run next and passes control
    into do_next_deploy_step. On the first run, deploy steps and templates are
    also validated.

    :param task: a TaskManager instance with an exclusive lock
    """
    node = task.node

    # Agent is now running, we're ready to validate the remaining steps
    if not node.driver_internal_info.get('steps_validated'):
        try:
            conductor_steps.validate_deploy_templates(task)
            conductor_steps.set_node_deployment_steps(task,
                                                      reset_current=False)
        except exception.IronicException as exc:
            msg = _('Failed to validate the final deploy steps list '
                    'for node %(node)s: %(exc)s') % {
                        'node': node.uuid,
                        'exc': exc
                    }
            return utils.deploying_error_handler(task, msg)

        info = node.driver_internal_info
        info['steps_validated'] = True
        node.driver_internal_info = info
        node.save()

    next_step_index = utils.update_next_step_index(task, 'deploy')

    do_next_deploy_step(task, next_step_index)
Ejemplo n.º 3
0
 def test_skip_missing(self, mock_validated):
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         result = conductor_steps.validate_deploy_templates(
             task, skip_missing=True)
         self.assertIsNone(result)
         mock_validated.assert_called_once_with(task, skip_missing=True)
Ejemplo n.º 4
0
 def test_ok(self, mock_validated):
     with task_manager.acquire(
             self.context, self.node.uuid, shared=False) as task:
         result = conductor_steps.validate_deploy_templates(task)
         self.assertIsNone(result)
         mock_validated.assert_called_once_with(task)