def load_configuration(configuration_file): default_tokens ={'http_port':9080, 'http_host':'localhost', 'of_controller_nets_with_same_vlan':True, 'image_path':'/opt/VNF/images', 'network_vlan_range_start':1000, 'network_vlan_range_end': 4096 } try: #First load configuration from configuration file #Check config file exists if not os.path.isfile(configuration_file): return (False, 'Error: Configuration file '+configuration_file+' does not exists.') #Read and parse file (return_status, code) = af.read_file(configuration_file) if not return_status: return (return_status, "Error loading configuration file '"+configuration_file+"': "+code) 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") 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
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
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
def load_configuration(configuration_file): default_tokens ={'http_port':9080, 'http_host':'localhost', 'of_controller_nets_with_same_vlan':True, 'image_path':'/opt/VNF/images' } try: #First load configuration from configuration file #Check config file exists if not os.path.isfile(configuration_file): return (False, 'Error: Configuration file '+configuration_file+' does not exists.') #Read and parse file (return_status, code) = af.read_file(configuration_file) if not return_status: return (return_status, "Error loading configuration file '"+configuration_file+"': "+code) 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") 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
def load_configuration(configuration_file): default_tokens = { "http_port": 9080, "http_host": "localhost", "of_controller_nets_with_same_vlan": True, "image_path": "/opt/VNF/images", } try: # First load configuration from configuration file # Check config file exists if not os.path.isfile(configuration_file): return (False, "Error: Configuration file " + configuration_file + " does not exists.") # Read and parse file (return_status, code) = af.read_file(configuration_file) if not return_status: return (return_status, "Error loading configuration file '" + configuration_file + "': " + code) 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", ) 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, )