def merge_with_defaults(provider, feature_kind, config_selector): files = load_all_yaml_objs(types.DEFAULT, provider, feature_kind) config_spec = select_first(files, lambda x: x.name == config_selector) if config_selector != 'default': default_config = select_first(files, lambda x: x.name == 'default') merge_objdict(default_config, config_spec) return default_config return config_spec
def run(self): merged_docs = [] for doc in self.docs: files_with_defaults = load_all_yaml_objs(types.DEFAULT, doc.provider, doc.kind) self.logger.info('Merging: ' + doc.kind + ' name: ' + doc.name) merged = self.merge_parent(files_with_defaults, doc) merged_docs.append(merged) return merged_docs
def init(self): defaults = load_all_yaml_objs(types.DEFAULT, self.provider, 'configuration/minimal-cluster-config') defaults[0].specification.name = self.name for i in range(len(defaults)): defaults[i]['version'] = VERSION if self.is_full_config: defaults = self.get_full_config(defaults) save_manifest(defaults, self.name, self.name + '.yml') self.logger.info('Initialized user configuration and saved it to "' + os.path.join(get_build_path(self.name), self.name + '.yml') + '"') return 0
def get_infra_docs(self, input_docs): if self.provider == 'any': # For any we can include the machine documents from the minimal-cluster-config infra = select_all( input_docs, lambda x: x.kind.startswith('infrastructure/machine')) else: # VMs are curently the infrastructure documents the user might interact with for: # - type/size # - distro # - network security rules # ... # So we add the defaults here. # TODO: Check if we want to include possible other infrastructure documents. infra = load_all_yaml_objs(types.DEFAULT, self.provider, 'infrastructure/virtual-machine') return infra
def run(self): try: defaults = load_all_yaml_objs( types.DEFAULT, self.provider, 'configuration/minimal-cluster-config') defaults[0].specification.name = self.name if self.is_full_config: defaults = self.get_full_config(defaults) save_manifest(defaults, self.name, self.name + '.yml') self.logger.info( 'Initialized user configuration and saved it to "' + os.path.join(get_build_path(self.name), self.name + '.yml') + '"') return 0 except Exception as e: self.logger.error( e, exc_info=True ) # TODO extensive debug output might not always be wanted. Make this configurable with input flag? return 1
def init(self): input = load_all_yaml_objs(types.DEFAULT, self.provider, 'configuration/minimal-cluster-config') input[0].specification.name = self.name if self.is_full_config: config = self.get_config_docs(input) config_only = select_all( config, lambda x: not (x.kind.startswith('epiphany-cluster'))) if self.provider == 'any': # for any provider we want to use the default config from minimal-cluster-config cluster_model = select_single( input, lambda x: x.kind == 'epiphany-cluster') else: # for azure|aws provider we want to use the extended defaults cluster-config after dry run. # TODO: We probably wants this comming from seperate documents since Azure and AWS overlap now... cluster_model = select_single( config, lambda x: x.kind == 'epiphany-cluster') infra = self.get_infra_docs(input) docs = [cluster_model, *config_only, *infra] else: docs = [*input] # set the provider and version for all docs for doc in docs: doc['provider'] = self.provider doc['version'] = VERSION # remove SET_BY_AUTOMATION fields remove_value(docs, 'SET_BY_AUTOMATION') # save document save_manifest(docs, self.name, self.name + '.yml') self.logger.info('Initialized new configuration and saved it to "' + os.path.join(get_build_path(self.name), self.name + '.yml') + '"') return 0