Example #1
0
    def execute(self, filters, force=False, graph_type=None, **kwargs):
        self.check_running_task(consts.TASK_NAMES.deployment)

        task = Task(name=consts.TASK_NAMES.deployment,
                    cluster=self.cluster,
                    status=consts.TASK_STATUSES.pending)
        db().add(task)

        nodes_to_update = objects.Cluster.get_nodes_to_update_config(
            self.cluster, filters.get('node_ids'), filters.get('node_role'))

        message = self._call_silently(
            task,
            self.get_deployment_task(),
            nodes_to_update,
            graph_type=graph_type,
            method_name='message',
            force=force
        )

        # locking task
        task = objects.Task.get_by_uid(
            task.id,
            fail_if_not_found=True,
            lock_for_update=True
        )

        if task.is_completed():
            return task

        # locking nodes
        objects.NodeCollection.lock_nodes(nodes_to_update)

        task.cache = copy.copy(message)
        task.cache['nodes'] = [n.id for n in nodes_to_update]

        for node in nodes_to_update:
            node.status = consts.NODE_STATUSES.deploying
            node.progress = 0

        db().commit()

        rpc.cast('naily', message)

        return task
Example #2
0
    def execute(self, filters, force=False, **kwargs):
        self.check_running_task(consts.TASK_NAMES.deployment)

        task = Task(name=consts.TASK_NAMES.deployment,
                    cluster=self.cluster,
                    status=consts.TASK_STATUSES.pending)
        db().add(task)

        nodes_to_update = objects.Cluster.get_nodes_to_update_config(
            self.cluster, filters.get('node_ids'), filters.get('node_role'))

        message = self._call_silently(
            task,
            self.get_deployment_task(),
            nodes_to_update,
            method_name='message',
            force=force
        )

        # locking task
        task = objects.Task.get_by_uid(
            task.id,
            fail_if_not_found=True,
            lock_for_update=True
        )

        if task.is_completed():
            return task

        # locking nodes
        objects.NodeCollection.lock_nodes(nodes_to_update)

        task.cache = copy.copy(message)
        task.cache['nodes'] = [n.id for n in nodes_to_update]

        for node in nodes_to_update:
            node.status = consts.NODE_STATUSES.deploying
            node.progress = 0

        db().commit()

        rpc.cast('naily', message)

        return task