Beispiel #1
0
def create_openapi_file(yang_file, openapi_file):
    yang_file = search_path_for_file(yang_file)
    try:
        print("Creating openapi spec %s from %s yang file " %
              (openapi_file, yang_file))
        general_utils.run_cmd(
            ['pyang', '-f', 'swagger', yang_file, '-o', openapi_file])
        if os.path.isfile(openapi_file):
            with open(openapi_file, 'r') as file:
                openapi = file.read()
            openapi = openapi.replace("/\"", "\"")
            with open(openapi_file, 'w') as file:
                file.write(openapi)
    except Exception as e:
        print(e)
Beispiel #2
0
def create_yin_file(yang_file, yin_file):
    yang_file = search_path_for_file(yang_file)
    print("Opening %s yang file and placing it in %s" % (yang_file, yin_file))
    general_utils.run_cmd(['pyang', '-o', yin_file, '-f', 'yin', yang_file])
Beispiel #3
0
def create_yin_file(yang_file, yin_file):
    yang_file = search_path_for_file(yang_file)
    general_utils.run_cmd(['pyang', '-o', yin_file, '-f', 'yin', yang_file])