Example #1
0
    # Read Controller info from the local configuration file
    ctrl_cfg_path = "../config/ctrl.yml"
    ctrl_cfg = yaml_cfg_load(ctrl_cfg_path)
    if(ctrl_cfg is None):
        print("!!!Error, reason: failed to get Controller configuration")
        exit(1)

    # Following is a hard-coded value used by the Controller
    # for self-identification as a NETCONF node
    NC_NODE_ID = "controller-config"
    # Allocate object instance that represents the Controller
    ctrl = ODLController(ctrl_cfg['ip_addr'], ctrl_cfg['http_port'],
                         ctrl_cfg['admin_name'], ctrl_cfg['admin_pswd'])

    # Hard coded references to the "network-topology" YANG model data schema
    SCHEMA_ID = "network-topology"
    SCHEMA_VERSION = "2013-10-21"
    # Communicate to the Controller and display the result of communication
    result = ctrl.schema_info(NC_NODE_ID, SCHEMA_ID, SCHEMA_VERSION)
    print("\n").strip()
    if(result.status == http.OK):
        print("Controller : '%s:%s'" % (ctrl.ip_addr, ctrl.port))
        print("Node ID    : '%s'" % NC_NODE_ID)
        print("YANG model : '%s@%s'" % (SCHEMA_ID, SCHEMA_VERSION))
        print "\n".strip()
        print result.data
    else:
        print("!!!Error, reason: %s" % result.brief)
    print("\n").strip()
Example #2
0
 for item in nc_dev_cfg:
     node_id = item['name']
     result = ctrl.netconf_node_is_mounted(node_id)
     if(result.status == http.SERVICE_UNAVAILABLE or
        result.status == http.UNAUTHORIZED):
         print("!!!Error, reason: %s" % result.brief)
         print ("\n").strip()
         break
     elif(result.status == http.NOT_FOUND):
         print("'%s' is not mounted" % node_id)
         print("\n").strip()
     elif(result.status == http.OK):
         node = result.data
         assert(isinstance(node, NETCONFNodeTopoInfo))
         if(node.connected):
             result = ctrl.schema_info(node_id, SCHEMA_ID, SCHEMA_VERSION)
             if(result.status == http.OK):
                 print("%s\n" % ("<" * 70)).strip()
                 print("Node ID    : '%s'" % node_id)
                 print("YANG model : '%s@%s'" % (SCHEMA_ID, SCHEMA_VERSION))
                 print("\n").strip()
                 print result.data
                 print("%s" % (">" * 70)).strip()
                 print("\n").strip()
             else:
                 print("!!!Error, reason: %s" % result.brief)
                 print("\n").strip()
         else:
             print("'%s' is disconnected" % node_id)
             print ("\n").strip()
     else: