Beispiel #1
0
def load_file_from_path(script_dir, path_to_file, file_type, kind):
    if os.path.isfile(path_to_file):
        with open(path_to_file, 'r') as stream:
            return safe_load_all(stream)
    else:
        path_to_file = os.path.join(script_dir, DATA_FOLDER_PATH, 'common',
                                    file_type, kind + '.yml')
        with open(path_to_file, 'r') as stream:
            return safe_load_all(stream)
Beispiel #2
0
    def process_input_docs(self):
        # Load the user input YAML docs from the input file.
        if os.path.isabs(self.file):
            path_to_load = self.file
        else:
            path_to_load = os.path.join(os.getcwd(), self.file)
        user_file_stream = open(path_to_load, 'r')
        self.input_docs = safe_load_all(user_file_stream)

        # Merge the input docs with defaults
        with DefaultMerger(self.input_docs) as doc_merger:
            self.input_docs = doc_merger.run()

        # Get the cluster model.
        self.cluster_model = select_single(
            self.input_docs, lambda x: x.kind == 'epiphany-cluster')
        if self.cluster_model is None:
            raise Exception('No cluster model defined in input YAML file')

        # Validate input documents
        with SchemaValidator(self.cluster_model,
                             self.input_docs) as schema_validator:
            schema_validator.run()
Beispiel #3
0
def load_yamls_file(path_to_file):
    with open(path_to_file, 'r') as stream:
        return safe_load_all(stream)