Example #1
0
 
 print ("\n")
 print ("<<< Creating Controller instance")
 time.sleep(rundelay)
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 print ("'Controller':")
 print ctrl.to_json()
 
 
 print "\n"
 yangModelName = "flow-topology-discovery"
 yangModelVerson = "2013-08-19"
 print ("<<< Retrieve '%s' YANG model definition from the Controller" % yangModelName)
 time.sleep(rundelay)
 nodeName = "controller-config"
 result = ctrl.get_schema(nodeName, yangModelName, yangModelVerson)
 status = result.get_status()
 if(status.eq(STATUS.OK)):
     print ("YANG model:")
     schema = result.get_data()
     print schema
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief())
     exit(0)
 
 
 print ("\n")
 print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
 print (">>> Demo End")
 print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
Example #2
0
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage(sys.argv[0])
        elif opt in ("-i", "--identifier"):
            model_identifier = arg
        elif opt in ("-v", "--version"):
            model_version = arg
        else:
            print("Error: failed to parse option %s" % opt)
            usage(sys.argv[0])

    if(model_identifier == None) or (model_version == None):
        print("Error: incomplete command")
        usage(sys.argv[0])

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    print ("<<< 'Controller': %s" % (ctrlIpAddr))
    result = ctrl.get_schema("controller-config", model_identifier, model_version)
    status = result.get_status()
    if(status.eq(STATUS.OK) == True):
        print "YANG model definition:"
        schema = result.get_data()
        print schema.encode('utf-8', 'replace')
    else:
        print ("\n")
        print ("!!!Failed, reason: %s" % status.brief().lower())
        print ("%s" % status.detailed())
        exit(0)

    print ("\n")