def _serialize(self, cluster, nodes):
     if objects.Release.is_lcm_supported(cluster.release):
         raise self.http(
             405, msg="The plugin hooks are not supported anymore."
         )
     graph = orchestrator_graph.AstuteGraph(cluster)
     return pre_deployment_serialize(graph, cluster, nodes)
    def test_plugin_depl_task_in_pre_depl(self):
        self.prepare_plugins_for_cluster(
            self.cluster,
            [
                {
                    'name': 'pre_depl_plugin_task',
                    'deployment_tasks': [
                        {
                            'id': 'pre-depl-plugin-task',
                            'type': 'puppet',
                            'role': ['primary-controller'],
                            'requires': ['pre_deployment_start'],
                            'required_for': ['pre_deployment_end'],
                            'parameters': {
                                'puppet_manifest': 'pre_depl_plugin_task',
                                'puppet_modules': 'test',
                                'timeout': 0,
                            }
                        },
                    ],
                },
            ]
        )

        graph = AstuteGraph(self.cluster)
        objects.NodeCollection.prepare_for_deployment(self.cluster.nodes)
        with mock.patch('nailgun.plugins.adapters.glob.glob',
                        mock.Mock(return_value='path/to/test/repos')):
            pre_deployment = stages.pre_deployment_serialize(
                graph, self.cluster, self.cluster.nodes)

        for task_type in (consts.ORCHESTRATOR_TASK_TYPES.sync,
                          consts.ORCHESTRATOR_TASK_TYPES.upload_file):
            self._check_pre_deployment_tasks(pre_deployment, task_type)
Example #3
0
    def message(cls, task, nodes, deployment_tasks=None):
        logger.debug("DeploymentTask.message(task=%s)" % task.uuid)
        deployment_tasks = deployment_tasks or []

        nodes_ids = [n.id for n in nodes]
        for n in db().query(Node).filter_by(
                cluster=task.cluster).order_by(Node.id):

            if n.id in nodes_ids:
                if n.pending_roles:
                    n.roles += n.pending_roles
                    n.pending_roles = []

                # If reciever for some reasons didn't update
                # node's status to provisioned when deployment
                # started, we should do it in nailgun
                if n.status in (consts.NODE_STATUSES.deploying,):
                    n.status = consts.NODE_STATUSES.provisioned
                n.progress = 0
                db().add(n)
        db().flush()

        orchestrator_graph = deployment_graph.AstuteGraph(task.cluster)
        orchestrator_graph.only_tasks(deployment_tasks)

        #NOTE(dshulyak) At this point parts of the orchestration can be empty,
        # it should not cause any issues with deployment/progress and was
        # done by design
        serialized_cluster = deployment_serializers.serialize(
            orchestrator_graph, task.cluster, nodes)
        pre_deployment = stages.pre_deployment_serialize(
            orchestrator_graph, task.cluster, nodes)
        post_deployment = stages.post_deployment_serialize(
            orchestrator_graph, task.cluster, nodes)

        # After serialization set pending_addition to False
        for node in nodes:
            node.pending_addition = False

        rpc_message = make_astute_message(
            task,
            cls._get_deployment_method(task.cluster),
            'deploy_resp',
            {
                'deployment_info': serialized_cluster,
                'pre_deployment': pre_deployment,
                'post_deployment': post_deployment
            }
        )
        db().flush()
        return rpc_message
Example #4
0
    def message(cls, task, nodes, deployment_tasks=None):
        logger.debug("DeploymentTask.message(task=%s)" % task.uuid)
        deployment_tasks = deployment_tasks or []

        nodes_ids = [n.id for n in nodes]
        for n in db().query(Node).filter_by(
                cluster=task.cluster).order_by(Node.id):

            if n.id in nodes_ids:
                if n.pending_roles:
                    n.roles += n.pending_roles
                    n.pending_roles = []

                # If reciever for some reasons didn't update
                # node's status to provisioned when deployment
                # started, we should do it in nailgun
                if n.status in (consts.NODE_STATUSES.deploying,):
                    n.status = consts.NODE_STATUSES.provisioned
                n.progress = 0
                db().add(n)
        db().flush()

        orchestrator_graph = deployment_graph.AstuteGraph(task.cluster)
        orchestrator_graph.only_tasks(deployment_tasks)

        #NOTE(dshulyak) At this point parts of the orchestration can be empty,
        # it should not cause any issues with deployment/progress and was
        # done by design
        serialized_cluster = deployment_serializers.serialize(
            orchestrator_graph, task.cluster, nodes)
        pre_deployment = stages.pre_deployment_serialize(
            orchestrator_graph, task.cluster, nodes)
        post_deployment = stages.post_deployment_serialize(
            orchestrator_graph, task.cluster, nodes)

        # After serialization set pending_addition to False
        for node in nodes:
            node.pending_addition = False

        rpc_message = make_astute_message(
            task,
            cls._get_deployment_method(task.cluster),
            'deploy_resp',
            {
                'deployment_info': serialized_cluster,
                'pre_deployment': pre_deployment,
                'post_deployment': post_deployment
            }
        )
        db().flush()
        return rpc_message
    def test_plugin_depl_task_for_master_not_in_pre_depl(self):
        self.prepare_plugins_for_cluster(
            self.cluster,
            [
                {
                    'name': 'pre_depl_plugin_task',
                    'deployment_tasks': [
                        {
                            'id': 'pre-depl-plugin-task',
                            'type': 'puppet',
                            'role': consts.MASTER_ROLE,
                            'requires': ['pre_deployment_start'],
                            'required_for': ['pre_deployment_end'],
                            'parameters': {
                                'puppet_manifest': 'pre_depl_plugin_task',
                                'puppet_modules': 'test',
                                'timeout': 0,
                            }
                        },
                    ],
                },
                {
                    'name': 'pre_depl_plugin_task_for_master_and_contr',
                    'deployment_tasks': [
                        {
                            'id': 'pre-depl-plugin-task-for-master-and-contr',
                            'type': 'puppet',
                            'groups': [consts.MASTER_ROLE,
                                       'primary-controller'],
                            'requires': ['pre_deployment_start'],
                            'required_for': ['pre_deployment_end'],
                            'parameters': {
                                'puppet_manifest': 'pre_depl_plugin_task',
                                'puppet_modules': 'test',
                                'timeout': 0,
                            }
                        },
                    ],
                },
            ]
        )

        graph = AstuteGraph(self.cluster)
        objects.NodeCollection.prepare_for_deployment(self.cluster.nodes)
        with mock.patch('nailgun.plugins.adapters.glob.glob',
                        mock.Mock(return_value='path/to/test/repos')):
            pre_deployment = stages.pre_deployment_serialize(
                graph, self.cluster, self.cluster.nodes)

        for st in pre_deployment:
            self.assertNotIn(consts.MASTER_ROLE, st['uids'])
Example #6
0
 def _serialize(self, cluster, nodes):
     if objects.Release.is_lcm_supported(cluster.release):
         raise self.http(405,
                         msg="The plugin hooks are not supported anymore.")
     graph = orchestrator_graph.AstuteGraph(cluster)
     return pre_deployment_serialize(graph, cluster, nodes)
Example #7
0
 def _serialize(self, cluster, nodes):
     graph = deployment_graph.AstuteGraph(cluster)
     return pre_deployment_serialize(graph, cluster, nodes)
Example #8
0
 def _serialize(self, cluster, nodes):
     graph = deployment_graph.AstuteGraph(cluster)
     return pre_deployment_serialize(graph, cluster, nodes)