Example #1
0
        exit(1)

    # Following is a hard-coded value used by the Controller
    # for identification of the NETCONF topology
    NC_TOPO_ID = 'topology-netconf'
    # 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'])

    print("\n").strip()
    print("Controller: '%s:%s'" % (ctrl.ip_addr, ctrl.port))
    print("\n").strip()
    print("NETCONF Topology information")

    # Communicate to the Controller and display the result of communication
    result = ctrl.topology_info(NC_TOPO_ID)
    if(result.status == http.OK):
        assert(isinstance(result.data, NETCONFTopoInfo))
        topo_info = result.data
        print("\n").strip()
        nodes_list = topo_info.nodes_list
        print("  Topology ID : '%s'" % topo_info.identifier)
        print("  Nodes Count : %s" % len(nodes_list))
        nodes_ids = topo_info.nodes_ids
        g = 2
        chunks = [nodes_ids[x:x + g] for x in xrange(0, len(nodes_ids), g)]
        s = "Nodes IDs"
        print("  Nodes IDs   :"),
        for i in range(0, len(chunks)):
            n = 0 if i == 0 else len(s) + 9
            print "%s%s" % (" " * n, ", ".join(chunks[i]))