def test_ControllerGetSchemas(self, controller):

        print ("--------------------------------------------------------- ")
        print ("<< Test ControllerGetSchemas Start")
        print ("--------------------------------------------------------- ")
        print ("<< Creating Controller instance")
        time.sleep(self.rundelay)
        ctrl = Controller(self.ctrlIpAddr, self.ctrlPortNum, self.ctrlUname, self.ctrlPswd)
        print ("<< 'Controller':")
        print ctrl.to_json()

        print ("\n<< Getting list of YANG models supported by the Controller ")
        time.sleep(self.rundelay)
        nodeName = "controller-config"

        result = ctrl.get_schemas(nodeName)
        status = result.get_status()

        if(status.eq(STATUS.OK)):
            slist = result.get_data()
            print "\n<< YANG models list: %s" % slist
            print "\n<< JSON dumps:"
            print json.dumps(slist, default=lambda o: o.__dict__,
                             sort_keys='True', indent=4)
        else:
            print ("\n")
            print ("!!!Demo terminated, reason: %s" % status.brief())

        # and verify the results
        self.assertEquals(str(slist), "[{u'location': [u'NETCONF'], u'identifier': u'threadpool-impl', u'namespace': u'urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl', u'version': u'2013-04-05', u'format': u'ietf-netconf-monitoring:yang'}]")
    def test_ControllerGetSchemas(self, controller):

        print ("--------------------------------------------------------- ")
        print ("<< Test ControllerGetSchemas Start")
        print ("--------------------------------------------------------- ")
        print ("<< Creating Controller instance")
        time.sleep(self.rundelay)
        ctrl = Controller(self.ctrlIpAddr, self.ctrlPortNum, self.ctrlUname, self.ctrlPswd)
        print ("<< 'Controller':")
        print ctrl.to_json()

        print ("\n<< Getting list of YANG models supported by the Controller ")
        time.sleep(self.rundelay)
        nodeName = "controller-config"

        result = ctrl.get_schemas(nodeName)
        status = result.get_status()

        if(status.eq(STATUS.OK)):
            slist = result.get_data()
            print "\n<< YANG models list: %s" % slist
            print "\n<< JSON dumps:"
            print json.dumps(slist, default=lambda o: o.__dict__,
                             sort_keys='True', indent=4)
        else:
            print ("\n")
            print ("!!!Demo terminated, reason: %s" % status.brief())

        # and verify the results
        self.assertEquals(str(slist), "[u'(urn:ietf:params:xml:ns:yang:ietf-network-topology?revision=2015-06-08)ietf-network-topology', u'(urn:opendaylight:flow:errors?revision=2013-11-16)flow-errors', u'(urn:opendaylight:params:xml:ns:yang:topology:pcep?revision=2013-10-24)network-topology-pcep', u'(urn:opendaylight:params:xml:ns:yang:bgp-message?revision=2013-09-19)bgp-message', u'(urn:opendaylight:params:xml:ns:yang:netvirt:providers:config?revision=2016-01-09)netvirt-providers-config', u'(urn:opendaylight:params:xml:ns:yang:controller:netty:timer?revision=2013-11-19)netty-timer']")
Exemple #3
0
def nc_demo_2():

    f = "cfg1.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    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 (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
Exemple #4
0
def nc_demo_3():

    f = "cfg1.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    print ("\n")
    print ("<<< Creating Controller instance")
    time.sleep(rundelay)
    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    print ("'Controller':")
    print ctrl.to_json()

    print "\n"
    print ("<<< Get list of service provider applications "
           "available on the Controller")
    time.sleep(rundelay)
    result = ctrl.get_service_providers_info()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        services = result.get_data()
        print "Service providers:"
        print json.dumps(services, default=lambda o: o.__dict__,
                         sort_keys=True, indent=4)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print ("\n")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    print (">>> Demo End")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
Exemple #5
0
def nc_demo_5():

    f = "cfg1.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    print ("\n")
    print ("<<< Creating Controller instance")
    time.sleep(rundelay)
    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    print ("'Controller':")
    print ctrl.to_json()

    print "\n"
    print ("<<< Show list of all NETCONF operations "
           "supported by the Controller")
    time.sleep(rundelay)
    result = ctrl.get_netconf_operations("controller-config")
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "NETCONF operations:"
        slist = result.get_data()
        print json.dumps(slist, default=lambda o: o.__dict__,
                         sort_keys=True, indent=4)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print ("\n")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    print (">>> Demo End")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    def test_ControllerGetSchemas_no_content(self, controller):

        print ("--------------------------------------------------------- ")
        print ("<< Test ControllerGetSchemas_no_content Start")
        print ("--------------------------------------------------------- ")
        print ("<< Creating Controller instance")
        time.sleep(self.rundelay)
        ctrl = Controller(self.ctrlIpAddr, self.ctrlPortNum, self.ctrlUname, self.ctrlPswd)
        print ("<< 'Controller':")
        print ctrl.to_json()

        print ("\n<< Getting list of YANG models supported by the Controller ")
        time.sleep(self.rundelay)
        nodeName = "controller-config"

        result = ctrl.get_schemas(nodeName)
        status = result.get_status()
        print ("<< Verifying STATUS.DATA_NOT_FOUND ")

        # and verify the results: STATUS.DATA_NOT_FOUND
        self.assertEquals(2, status.status_code)
Exemple #7
0
def nc_demo_10():

    f = "cfg2.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']

        nodeName = d['nodeName']
        nodeIpAddr = d['nodeIpAddr']
        nodePortNum = d['nodePortNum']
        nodeUname = d['nodeUname']
        nodePswd = d['nodePswd']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller or NETCONF device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    print ("\n")
    print ("<<< Creating Controller instance")
    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    print ("'Controller':")
    print ctrl.to_json()

    print "\n"
    print ("<<< Show NETCONF nodes configured on the Controller")
    time.sleep(rundelay)
    result = ctrl.get_netconf_nodes_in_config()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Nodes configured:"
        nlist = result.get_data()
        for item in nlist:
            print "   '{}'".format(item)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    node_configured = False
    result = ctrl.check_node_config_status(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.NODE_CONFIGURED)):
        node_configured = True
    elif(status.eq(STATUS.DATA_NOT_FOUND)):
        node_configured = False
    else:
        print ("\n")
        print "Failed to get configuration status for the '%s'" % nodeName
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    if node_configured:
        print ("\n")
        print ("<<< '%s' is already configured on the Controller" % nodeName)
        print ("Unmounting '%s' from the Controller" % nodeName)
        time.sleep(rundelay)
        result = ctrl.delete_netconf_node(nodename=nodeName)
        status = result.get_status()
        if(status.eq(STATUS.OK)):
            print ("<<< '%s' NETCONF node was successfully removed "
                   "from the Controller" % nodeName)
        else:
            print ("\n")
            print ("!!!Demo terminated, reason: %s" % status.brief())
            exit(0)

    print ("\n")
    time.sleep(rundelay)
    print ("<<< Creating new '%s' NETCONF node" % nodeName)
    node = NetconfNode(ctrl, nodeName, nodeIpAddr, nodePortNum,
                       nodeUname, nodePswd)
    print ("'%s':" % nodeName)
    print node.to_json()

    print ("\n")
    print ("<<< Add '%s' NETCONF node to the Controller" % nodeName)
    time.sleep(rundelay)
    result = ctrl.add_netconf_node(node)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("'%s' NETCONF node was successfully added "
               "to the Controller" % nodeName)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        print status.detailed()
        exit(0)

    print "\n"
    print ("<<< Show NETCONF nodes configured on the Controller")
    time.sleep(rundelay)
    result = ctrl.get_netconf_nodes_in_config()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Nodes configured:"
        nlist = result.get_data()
        for item in nlist:
            print "   '{}'".format(item)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print "\n"
    print ("<<< Find the '%s' NETCONF node on the Controller" % nodeName)
    time.sleep(rundelay)
    result = ctrl.check_node_config_status(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.NODE_CONFIGURED)):
        print ("'%s' node is configured" % nodeName)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print "\n"
    print ("<<< Show connection status for all NETCONF nodes "
           "configured on the Controller")
    time.sleep(rundelay)
    result = ctrl.get_netconf_nodes_conn_status()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Nodes connection status:"
        nlist = result.get_data()
        for item in nlist:
            status = ""
            if (item['connected'] is True):
                status = "connected"
            else:
                status = "not connected"
            print "   '{}' is {}".format(item['node'], status)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print "\n"
    print ("<<< Show connection status for the '%s' NETCONF node" % nodeName)
    time.sleep(rundelay)
    result = ctrl.check_node_conn_status(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.NODE_CONNECTED)):
        print ("'%s' node is connected" % nodeName)
    elif (status.eq(STATUS.NODE_DISONNECTED)):
        print ("'%s' node is not connected" % nodeName)
    elif (status.eq(STATUS.NODE_NOT_FOUND)):
        print ("'%s' node is not found" % nodeName)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print "\n"
    print (">>> Remove '%s' NETCONF node from the Controller" % nodeName)
    time.sleep(rundelay)
    result = ctrl.delete_netconf_node(node)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("'%s' NETCONF node was successfully removed "
               "from the Controller" % nodeName)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print "\n"
    print ("<<< Show NETCONF nodes configured on the Controller")
    time.sleep(rundelay)
    result = ctrl.get_netconf_nodes_in_config()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Nodes configured:"
        nlist = result.get_data()
        for item in nlist:
            print "   '{}'".format(item)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print "\n"
    print ("<<< Show connection status for the '%s' NETCONF node" % nodeName)
    time.sleep(rundelay)
    result = ctrl.check_node_conn_status(nodeName)
    status = result.get_status()
    if (status.eq(STATUS.NODE_CONNECTED)):
        print ("'%s' node is connected" % nodeName)
    elif (status.eq(STATUS.NODE_DISONNECTED)):
        print ("'%s' node is not connected" % nodeName)
    elif (status.eq(STATUS.NODE_NOT_FOUND)):
        print ("'%s' node is not found" % nodeName)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief())
        exit(0)

    print ("\n")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    print (">>> Demo End")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")