def test_get_transaction_deployment_info(self):
     cluster = self.cluster_db
     nodes = objects.Cluster.get_nodes_not_for_deletion(cluster)
     deployment_node_info = deployment_serializers.serialize_for_lcm(
         cluster, nodes
     )
     deployment_info = {node['uid']: node for node in deployment_node_info}
     transaction = objects.Transaction.create({
         'cluster_id': cluster.id,
         'status': consts.TASK_STATUSES.ready,
         'name': consts.TASK_NAMES.deployment
     })
     objects.Transaction.attach_deployment_info(
         transaction, deployment_info
     )
     self.assertIsNotNone(
         objects.Transaction.get_deployment_info(transaction)
     )
     resp = self.app.get(
         reverse(
             'TransactionDeploymentInfo',
             kwargs={'transaction_id': transaction.id}),
         headers=self.default_headers
     )
     self.assertEqual(200, resp.status_code)
     self.datadiff(deployment_info, resp.json_body)
 def test_get_transaction_deployment_info(self):
     cluster = self.cluster_db
     nodes = objects.Cluster.get_nodes_not_for_deletion(cluster)
     deployment_node_info = deployment_serializers.serialize_for_lcm(
         cluster, nodes
     )
     deployment_info = {node['uid']: node for node in deployment_node_info}
     transaction = objects.Transaction.create({
         'cluster_id': cluster.id,
         'status': consts.TASK_STATUSES.ready,
         'name': consts.TASK_NAMES.deployment
     })
     objects.Transaction.attach_deployment_info(
         transaction, deployment_info
     )
     self.assertIsNotNone(
         objects.Transaction.get_deployment_info(transaction)
     )
     resp = self.app.get(
         reverse(
             'TransactionDeploymentInfo',
             kwargs={'transaction_id': transaction.id}),
         headers=self.default_headers
     )
     self.assertEqual(200, resp.status_code)
     self.datadiff(deployment_info, resp.json_body)
 def _serialize(self, cluster, nodes):
     if objects.Release.is_lcm_supported(cluster.release):
         return deployment_serializers.serialize_for_lcm(
             cluster, nodes, ignore_customized=True
         )
     graph = orchestrator_graph.AstuteGraph(cluster)
     return deployment_serializers.serialize(
         graph, cluster, nodes, ignore_customized=True)
Example #4
0
 def get_real_expected_state(self):
     """Save expected state based on info from LCM serializer"""
     expected_deployment_info = deployment_serializers.serialize_for_lcm(
         self.cluster, self.nodes_to_deploy)
     self.expected_state = {
         node['uid']: node
         for node in expected_deployment_info
     }
     self.logger.debug('Expected state is %s', self.expected_state)
Example #5
0
 def _serialize(self, cluster, nodes):
     if objects.Release.is_lcm_supported(cluster.release):
         return deployment_serializers.serialize_for_lcm(
             cluster, nodes, ignore_customized=True)
     graph = orchestrator_graph.AstuteGraph(cluster)
     return deployment_serializers.serialize(graph,
                                             cluster,
                                             nodes,
                                             ignore_customized=True)
Example #6
0
 def get_real_expected_state(self):
     """Save expected state based on info from LCM serializer"""
     expected_deployment_info = deployment_serializers.serialize_for_lcm(
         self.cluster,
         self.nodes_to_deploy
     )
     self.expected_state = {node['uid']: node for node in
                            expected_deployment_info}
     self.logger.debug('Expected state is %s', self.expected_state)
Example #7
0
    def _set_info(self, state, info):
        if state == self.EXPECTED:
            self._node_id = None
            if info is None:
                serialized = deployment_serializers.serialize_for_lcm(
                    self._cluster,
                    objects.Cluster.get_nodes_not_for_deletion(self._cluster))
                info = {node['uid']: node for node in serialized}

        self._infos[state] = info or {}
Example #8
0
    def _serialize(self, cluster, nodes):
        if objects.Release.is_lcm_supported(cluster.release):
            serialized = deployment_serializers.serialize_for_lcm(
                cluster, nodes, ignore_customized=True)
        else:
            graph = orchestrator_graph.AstuteGraph(cluster)
            serialized = deployment_serializers.serialize(
                graph, cluster, nodes, ignore_customized=True)

        return _deployment_info_in_compatible_format(
            serialized, utils.parse_bool(web.input(split='0').split))
Example #9
0
    def _set_info(self, state, info):
        if state == self.EXPECTED:
            self._node_id = None
            if info is None:
                serialized = deployment_serializers.serialize_for_lcm(
                    self._cluster,
                    objects.Cluster.get_nodes_not_for_deletion(self._cluster)
                )
                info = {node['uid']: node for node in serialized}

        self._infos[state] = info or {}
Example #10
0
    def _serialize(self, cluster, nodes):
        if objects.Release.is_lcm_supported(cluster.release):
            serialized = deployment_serializers.serialize_for_lcm(
                cluster, nodes, ignore_customized=True
            )
        else:
            graph = orchestrator_graph.AstuteGraph(cluster)
            serialized = deployment_serializers.serialize(
                graph, cluster, nodes, ignore_customized=True)

        return _deployment_info_in_compatible_format(
            serialized, utils.parse_bool(web.input(split='0').split)
        )
Example #11
0
    def _set_info(self, state, info):
        if state == self.EXPECTED:
            self._node_id = None
            if not info:
                info = deployment_serializers.serialize_for_lcm(
                    self._cluster,
                    objects.Cluster.get_nodes_not_for_deletion(self._cluster))
                # TODO(bgaifullin) serializer should return nodes as dict
                info['nodes'] = {n['uid']: n for n in info['nodes']}

        if info:
            common = info['common']
            nodes = info['nodes']
            info = {n: uniondict.UnionDict(common, nodes[n]) for n in nodes}
        else:
            info = {}

        self._infos[state] = info
Example #12
0
    def _set_info(self, state, info):
        if state == self.EXPECTED:
            self._node_id = None
            if not info:
                info = deployment_serializers.serialize_for_lcm(
                    self._cluster,
                    objects.Cluster.get_nodes_not_for_deletion(self._cluster)
                )
                # TODO(bgaifullin) serializer should return nodes as dict
                info['nodes'] = {n['uid']: n for n in info['nodes']}

        if info:
            common = info['common']
            nodes = info['nodes']
            info = {n: uniondict.UnionDict(common, nodes[n]) for n in nodes}
        else:
            info = {}

        self._infos[state] = info
Example #13
0
 def get_deployment_info(cluster, nodes):
     return deployment_serializers.serialize_for_lcm(cluster, nodes)
Example #14
0
 def get_deployment_info(cluster, nodes):
     return deployment_serializers.serialize_for_lcm(cluster, nodes)
 def serialize(self, cluster, nodes, ignore_customized=False):
     return deployment_serializers.serialize_for_lcm(
         cluster, nodes, ignore_customized=ignore_customized)
Example #16
0
def _get_expected_state(cluster, nodes):
    info = deployment_serializers.serialize_for_lcm(cluster, nodes)
    info['nodes'] = {n['uid']: n for n in info['nodes']}
    # Added cluster state
    info['nodes'][None] = {}
    return info
Example #17
0
def _get_expected_state(cluster, nodes):
    info = deployment_serializers.serialize_for_lcm(cluster, nodes)
    info['nodes'] = {n['uid']: n for n in info['nodes']}
    # Added cluster state
    info['nodes'][None] = {}
    return info