Example #1
0
    def serialize(self):
        configs = self.configs
        if configs is None:
            configs = objects.OpenstackConfig.find_configs_for_nodes(
                self.cluster, self.nodes)

        node_configs = defaultdict(lambda: defaultdict(dict))
        nodes_to_update = dict((node.id, node) for node in self.nodes)

        for config in configs:

            if config.config_type == consts.OPENSTACK_CONFIG_TYPES.cluster:
                for node_id in nodes_to_update:
                    node_configs[node_id]['cluster'] = config.configuration

            elif config.config_type == consts.OPENSTACK_CONFIG_TYPES.role:
                for node in self.nodes:
                    if config.node_role in node.roles:
                        node_configs[node.id]['role'].update(
                            config.configuration)

            elif config.config_type == consts.OPENSTACK_CONFIG_TYPES.node:
                if config.node_id in nodes_to_update:
                    fqdn = objects.Node.get_node_fqdn(
                        nodes_to_update[config.node_id])
                    node_configs[config.node_id][fqdn] = config.configuration

        for node_id in node_configs:
            for config_dest in node_configs[node_id]:
                path = os.path.join(consts.OVERRIDE_CONFIG_BASE_PATH,
                                    config_dest + '.yaml')
                data = {'configuration': node_configs[node_id][config_dest]}
                node = nodes_to_update[node_id]
                yield templates.make_upload_task(
                    [node.uid], path=path, data=yaml.safe_dump(data))
Example #2
0
    def serialize(self):
        nodes = deployment_serializers.get_nodes_not_for_deletion(self.cluster)
        uids = [n.uid for n in nodes]

        serialized_nodes = self._serialize_nodes(nodes)
        data = yaml.safe_dump({
            'nodes': serialized_nodes,
        })

        path = self.task['parameters']['path']
        yield templates.make_upload_task(uids, path=path, data=data)
Example #3
0
    def serialize(self):
        nodes = deployment_serializers.get_nodes_not_for_deletion(
            self.cluster)
        uids = [n.uid for n in nodes]

        serialized_nodes = self._serialize_nodes(nodes)
        data = yaml.safe_dump({
            'nodes': serialized_nodes,
        })

        path = self.task['parameters']['path']
        yield templates.make_upload_task(uids, path=path, data=data)
    def serialize(self):
        q_nodes = objects.Cluster.get_nodes_not_for_deletion(self.cluster)
        # task can be executed only on deployed nodes
        nodes = set(q_nodes.filter_by(status=consts.NODE_STATUSES.ready))
        # add nodes scheduled for deployment since they could be filtered out
        # above and task must be run also on them
        nodes.update(self.nodes)

        uids = [n.uid for n in nodes]

        # every node must have data about every other good node in cluster
        serialized_nodes = self._serialize_nodes(nodes)
        data = yaml.safe_dump({
            'nodes': serialized_nodes,
        })

        path = self.task['parameters']['path']
        yield templates.make_upload_task(uids, path=path, data=data)
Example #5
0
    def serialize(self):
        q_nodes = objects.Cluster.get_nodes_not_for_deletion(self.cluster)
        # task can be executed only on deployed nodes
        nodes = set(q_nodes.filter_by(status=consts.NODE_STATUSES.ready))
        # add nodes scheduled for deployment since they could be filtered out
        # above and task must be run also on them
        nodes.update(self.nodes)

        uids = [n.uid for n in nodes]

        # every node must have data about every other good node in cluster
        serialized_nodes = self._serialize_nodes(nodes)
        data = yaml.safe_dump({
            'nodes': serialized_nodes,
        })

        path = self.task['parameters']['path']
        yield templates.make_upload_task(uids, path=path, data=data)
Example #6
0
    def serialize(self):
        configs = self.configs
        if configs is None:
            configs = objects.OpenstackConfigCollection.find_configs_for_nodes(
                self.cluster, self.nodes)

        node_configs = defaultdict(lambda: defaultdict(dict))
        nodes_to_update = dict((node.id, node) for node in self.nodes)

        for config in configs:

            if config.config_type == consts.OPENSTACK_CONFIG_TYPES.cluster:
                for node_id in nodes_to_update:
                    node_configs[node_id]['cluster'] = config.configuration

            elif config.config_type == consts.OPENSTACK_CONFIG_TYPES.role:
                for node in self.nodes:
                    if config.node_role in node.all_roles:
                        utils.dict_update(
                            node_configs[node.id]['role'],
                            config.configuration,
                            level=1
                        )

            elif config.config_type == consts.OPENSTACK_CONFIG_TYPES.node:
                if config.node_id in nodes_to_update:
                    fqdn = objects.Node.get_node_fqdn(
                        nodes_to_update[config.node_id])
                    node_configs[config.node_id][fqdn] = config.configuration

        for node_id in node_configs:
            for config_dest in node_configs[node_id]:
                path = os.path.join(consts.OVERRIDE_CONFIG_BASE_PATH,
                                    config_dest + '.yaml')
                # Converts config from MutableDict to dict
                # needs for further serialization to yaml
                data = {
                    'configuration': dict(node_configs[node_id][config_dest])}
                node = nodes_to_update[node_id]
                yield templates.make_upload_task(
                    [node.uid], path=path, data=yaml.safe_dump(data))
    def serialize(self):
        configs = self.configs
        if configs is None:
            configs = objects.OpenstackConfigCollection.find_configs_for_nodes(
                self.cluster, self.nodes)

        node_configs = defaultdict(lambda: defaultdict(dict))
        nodes_to_update = dict((node.id, node) for node in self.nodes)

        for config in configs:

            if config.config_type == consts.OPENSTACK_CONFIG_TYPES.cluster:
                for node_id in nodes_to_update:
                    node_configs[node_id]['cluster'] = config.configuration

            elif config.config_type == consts.OPENSTACK_CONFIG_TYPES.role:
                for node in self.nodes:
                    if config.node_role in node.all_roles:
                        utils.dict_update(node_configs[node.id]['role'],
                                          config.configuration,
                                          level=1)

            elif config.config_type == consts.OPENSTACK_CONFIG_TYPES.node:
                if config.node_id in nodes_to_update:
                    fqdn = objects.Node.get_node_fqdn(
                        nodes_to_update[config.node_id])
                    node_configs[config.node_id][fqdn] = config.configuration

        for node_id in node_configs:
            for config_dest in node_configs[node_id]:
                path = os.path.join(consts.OVERRIDE_CONFIG_BASE_PATH,
                                    config_dest + '.yaml')
                # Converts config from MutableDict to dict
                # needs for further serialization to yaml
                data = {
                    'configuration': dict(node_configs[node_id][config_dest])
                }
                node = nodes_to_update[node_id]
                yield templates.make_upload_task([node.uid],
                                                 path=path,
                                                 data=yaml.safe_dump(data))