Example #1
0
    def read(self, file, variables_cmd):
        conf = Controller.get().CONF
        config = configparser.RawConfigParser()
        config.optionxform = str
        if not os.path.isfile(file):
            raise IOError("file {0} not found".format(file))

        """ Validate option in answer file"""
        config.read(file)
        if not config.has_section('general'):
            raise KeyError("answer file {0} doesn't have general"
                           " section".format(file))
        conf_file = dict(config['general'])
        conf_file.update(variables_cmd)  # override variables
        conf.update(conf_file)

        try:
            Controller.get().validate_groups(conf_file)
        except Exception as e:
            raise e

        all_args = Controller.get().get_all_arguments()
        for non_supported in (set(conf_file) - set(all_args)):
            LOG.warn("clearstack: variable {0} is not"
                     " supported yet".format(non_supported))