Beispiel #1
0
    def run(self):
        configuration_docs = []

        def append_config(doc):
            doc['version'] = VERSION
            configuration_docs.append(doc)

        for document_kind in ConfigurationAppender.REQUIRED_DOCS:
            doc = select_first(self.input_docs, lambda x: x.kind == document_kind)
            if doc is None:
                doc = load_yaml_obj(types.DEFAULT, 'common', document_kind)
                self.logger.info("Adding: " + doc.kind)
                append_config(doc)
            else:
                append_config(doc)

        for component_key, component_value in self.cluster_model.specification.components.items():
            if component_value.count < 1:
                continue

            features_map = select_first(configuration_docs, lambda x: x.kind == 'configuration/feature-mapping')
            config_selector = component_value.configuration
            for feature_key in features_map.specification.roles_mapping[component_key]:
                config = select_first(self.input_docs, lambda x: x.kind == 'configuration/' + feature_key and x.name == config_selector)
                if config is not None:
                    append_config(config)
                if config is None:
                    config = select_first(configuration_docs, lambda
                        x: x.kind == 'configuration/' + feature_key and x.name == config_selector)
                if config is None:
                    config = merge_with_defaults('common', 'configuration/' + feature_key, config_selector)
                    self.logger.info("Adding: " + config.kind)
                    append_config(config)

        return configuration_docs
Beispiel #2
0
    def get_virtual_machine(component_value, cluster_model, docs):
        machine_selector = component_value.machine
        model_with_defaults = select_first(docs, lambda x: x.kind == 'infrastructure/virtual-machine' and
                                                                 x.name == machine_selector)
        if model_with_defaults is None:
            model_with_defaults = merge_with_defaults(cluster_model.provider, 'infrastructure/virtual-machine',
                                                      machine_selector)

        return model_with_defaults
Beispiel #3
0
    def run(self):
        configuration_docs = []

        for component_key, component_value in self.cluster_model.specification.components.items(
        ):
            if component_value.count < 1:
                continue

            features_map = select_first(
                self.input_docs,
                lambda x: x.kind == 'configuration/feature-mapping')
            if features_map is None:
                features_map = select_first(
                    configuration_docs,
                    lambda x: x.kind == 'configuration/feature-mapping')

            if features_map is None:
                features_map = load_yaml_obj(types.DEFAULT, 'common',
                                             'configuration/feature-mapping')
                self.logger.info("Adding: " + features_map.kind)
                configuration_docs.append(features_map)

            config_selector = component_value.configuration
            for feature_key in features_map.specification.roles_mapping[
                    component_key]:
                config = select_first(
                    self.input_docs, lambda x: x.kind == 'configuration/' +
                    feature_key and x.name == config_selector)
                if config is None:
                    config = select_first(
                        configuration_docs,
                        lambda x: x.kind == 'configuration/' + feature_key and
                        x.name == config_selector)
                if config is None:
                    config = merge_with_defaults(
                        'common', 'configuration/' + feature_key,
                        config_selector)
                    self.logger.info("Adding: " + config.kind)
                    configuration_docs.append(config)

        return configuration_docs