def load_configuration(configuration_file):
    default_tokens ={'http_port':9090, 'http_host':'localhost'}
    try:
        #Check config file exists
        if not os.path.isfile(configuration_file):
            return (False, "Error: Configuration file '"+configuration_file+"' does not exists.")
            
        #Read file
        (return_status, code) = af.read_file(configuration_file)
        if not return_status:
            return (return_status, "Error loading configuration file '"+configuration_file+"': "+code)
        #Parse configuration file
        try:
            config = yaml.load(code)
        except yaml.YAMLError, exc:
            error_pos = ""
            if hasattr(exc, 'problem_mark'):
                mark = exc.problem_mark
                error_pos = " at position: (%s:%s)" % (mark.line+1, mark.column+1)
            return (False, "Error loading configuration file '"+configuration_file+"'"+error_pos+": content format error: Failed to parse yaml format")

        #Validate configuration file with the config_schema
        try:
            js_v(config, config_schema)
        except js_e.ValidationError, exc:
            error_pos = ""
            if len(exc.path)>0: error_pos=" at '" + ":".join(map(str, exc.path))+"'"
            return False, "Error loading configuration file '"+configuration_file+"'"+error_pos+": "+exc.message 
        
        #Check default values tokens
        for k,v in default_tokens.items():
            if k not in config: config[k]=v
    
    except Exception,e:
        return (False, "Error loading configuration file '"+configuration_file+"': "+str(e))
                
    return (True, config)
dataset/ETHPy150Open nfvlabs/openmano/openmano/openmanod.py/load_configuration/original