Beispiel #1
0
 def test_tasks_serialized_correctly(self):
     self.graph = deployment_graph.AstuteGraph(self.cluster)
     self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
     tasks = self.graph.pre_tasks_serialize(self.nodes)
     self.assertEqual(len(tasks), 20)
     tasks_tests = [('shell', ['master']),
                    ('shell', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('copy_files', sorted(self.all_uids)),
                    ('sync', sorted(self.all_uids)),
                    ('shell', sorted(self.all_uids))]
     tasks_output = []
     for task in tasks:
         tasks_output.append((task['type'], sorted(task['uids'])))
     self.assertItemsEqual(tasks_tests, tasks_output)
Beispiel #2
0
    def message(cls, task, nodes):
        logger.debug("%s.message(task=%s)", cls.__class__.__name__, task.uuid)

        for n in nodes:
            if n.pending_roles:
                n.roles += n.pending_roles
                n.pending_roles = []
            n.status = 'provisioned'
            n.progress = 0

        orchestrator_graph = deployment_graph.AstuteGraph(task.cluster)

        serialized_cluster = deployment_serializers.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,
            'deploy',
            'deploy_resp',
            {
                'deployment_info': serialized_cluster
            }
        )
        db().flush()
        return rpc_message
Beispiel #3
0
 def setUp(self):
     super(TestPostTaskSerialization, self).setUp()
     self.nodes = [
         mock.Mock(uid='3', all_roles=['controller']),
         mock.Mock(uid='4', all_roles=['primary-controller'])
     ]
     self.cluster = mock.Mock()
     self.cluster.deployment_tasks = yaml.load(self.TASKS)
     self.control_uids = ['3', '4']
     self.graph = deployment_graph.AstuteGraph(self.cluster)
Beispiel #4
0
    def setUp(self):
        super(TestConditionalTasksSerializers, self).setUp()

        self.nodes = [
            mock.Mock(uid='3', all_roles=['controller']),
            mock.Mock(uid='4', all_roles=['primary-controller'])
        ]

        self.cluster = ContainerMock()
        self.cluster.deployment_tasks = yaml.load(self.TASKS)
        self.graph = deployment_graph.AstuteGraph(self.cluster)
Beispiel #5
0
 def test_tasks_serialized_correctly(self):
     self.graph = deployment_graph.AstuteGraph(self.cluster)
     self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
     tasks = self.graph.pre_tasks_serialize(self.nodes)
     self.assertEqual(len(tasks), 3)
     self.assertEqual(tasks[0]['type'], 'upload_file')
     self.assertItemsEqual(tasks[0]['uids'], self.all_uids)
     self.assertEqual(tasks[1]['type'], 'shell')
     self.assertItemsEqual(tasks[1]['uids'], self.all_uids)
     self.assertEqual(tasks[2]['type'], 'sync')
     self.assertItemsEqual(tasks[2]['uids'], self.all_uids)
Beispiel #6
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
Beispiel #7
0
 def setUp(self):
     super(TestPreTaskSerialization, self).setUp()
     self.nodes = [
         mock.Mock(uid='3', all_roles=['controller']),
         mock.Mock(uid='4', all_roles=['primary-controller']),
         mock.Mock(uid='5', all_roles=['cinder', 'compute'])
     ]
     self.cluster = mock.Mock()
     self.cluster.release.orchestrator_data.repo_metadata = {
         '6.0': '{MASTER_IP}//{OPENSTACK_VERSION}'
     }
     self.cluster.deployment_tasks = yaml.load(self.TASKS)
     self.all_uids = set([n.uid for n in self.nodes])
     self.graph = deployment_graph.AstuteGraph(self.cluster)
Beispiel #8
0
    def message(cls, task, nodes):
        logger.debug("DeploymentTask.message(task=%s)" % task.uuid)

        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 (NODE_STATUSES.deploying, ):
                    n.status = NODE_STATUSES.provisioned
                n.progress = 0
                db().add(n)
        db().flush()

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

        # serialized_cluster = deployment_serializers.serialize(
        #     orchestrator_graph,task.cluster, nodes)
        serialized_cluster = deployment_serializers.serialize(
            task.cluster, nodes)

        pre_deployment = plugins_serializers.pre_deployment_serialize(
            task.cluster, nodes)
        post_deployment = plugins_serializers.post_deployment_serialize(
            task.cluster, nodes)

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

        rpc_message = make_astute_message(
            task, 'deploy', 'deploy_resp', {
                'deployment_info': serialized_cluster,
                'pre_deployment': pre_deployment,
                'post_deployment': post_deployment
            })
        db().commit()
        return rpc_message
 def setUp(self):
     super(TestTasksRemoval, self).setUp()
     self.cluster = mock.Mock()
     self.cluster.deployment_tasks = yaml.load(TASKS + SUBTASKS)
     self.astute = deployment_graph.AstuteGraph(self.cluster)
 def setUp(self):
     super(TestLegacyGraphSerialized, self).setUp()
     self.cluster = mock.Mock()
     self.cluster.deployment_tasks = yaml.load(
         graph_configuration.DEPLOYMENT_CURRENT)
     self.graph = deployment_graph.AstuteGraph(self.cluster)
 def setUp(self):
     super(TestAddDependenciesToNodes, self).setUp()
     self.cluster = mock.Mock()
     self.cluster.deployment_tasks = yaml.load(TASKS + SUBTASKS)
     self.graph = deployment_graph.AstuteGraph(self.cluster)
Beispiel #12
0
 def setUp(self):
     super(TestConditionalTasksSerializers, self).setUp()
     self.graph = deployment_graph.AstuteGraph(self.cluster)
Beispiel #13
0
 def setUp(self):
     super(TestPostTaskSerialization, self).setUp()
     self.control_uids = [n.uid for n in self.nodes
                          if 'controller' in n.roles]
     self.graph = deployment_graph.AstuteGraph(self.cluster)
Beispiel #14
0
 def _serialize(self, cluster, nodes):
     graph = deployment_graph.AstuteGraph(cluster)
     return post_deployment_serialize(graph, cluster, nodes)
Beispiel #15
0
 def _serialize(self, cluster, nodes):
     graph = deployment_graph.AstuteGraph(cluster)
     return deployment_serializers.serialize(graph,
                                             cluster,
                                             nodes,
                                             ignore_customized=True)
Beispiel #16
0
 def setUp(self):
     super(GroupsTraversalTest, self).setUp()
     self.cluster = mock.Mock()
     self.cluster.deployment_tasks = yaml.load(self.GROUPS)
     self.astute = deployment_graph.AstuteGraph(self.cluster)
     self.nodes = []