当前位置: 首页>>代码示例>>Python>>正文


Python controller.Controller类代码示例

本文整理汇总了Python中pybvc.controller.controller.Controller的典型用法代码示例。如果您正苦于以下问题:Python Controller类的具体用法?Python Controller怎么用?Python Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ControllerGetSchemas

    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'}]",
        )
开发者ID:jebpublic,项目名称:pybvc,代码行数:32,代码来源:unit_test_controller.py

示例2: test_ControllerGetNodeList

    def test_ControllerGetNodeList(self, controller):

        print ("--------------------------------------------------------- ")
        print ("<< Test ControllerNodeList Start")
        print ("--------------------------------------------------------- ")
        print ("<< Getting list of all nodes registered on the Controller ")

        ctrl = Controller(self.ctrlIpAddr, self.ctrlPortNum, self.ctrlUname, self.ctrlPswd)
        result = ctrl.get_nodes_operational_list()
        status = result.get_status()

        if status.eq(STATUS.OK):
            print "Nodes:"
            nlist = result.get_data()
            for item in nlist:
                print "   * {} *".format(item)
        else:
            print ("\n")
            print ("!!!Failed, reason: %s" % status.brief().lower())
            exit(0)
        print "<  Number of nodes in list: %s > " % len(nlist)
        print "\n"

        # and verify the results
        self.assertEquals(3, len(nlist))
开发者ID:jebpublic,项目名称:pybvc,代码行数:25,代码来源:unit_test_controller.py

示例3: of_demo_3

def of_demo_3():
    f = "cfg.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']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

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

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

    print ("\n")
    print ("<<< Get detailed information about ports on OpenFlow node '%s'"
           % nodeName)
    time.sleep(rundelay)
    ofswitch = OFSwitch(ctrl, nodeName)

    result = ofswitch.get_ports_list()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        ports = result.get_data()
        for port in ports:
            result = ofswitch.get_port_detail_info(port)
            status = result.get_status()
            if(status.eq(STATUS.OK)):
                print ("Port '%s' info:" % port)
                info = result.get_data()
                print json.dumps(info, indent=4)
            else:
                print ("\n")
                print ("!!!Demo terminated, reason: %s"
                       % status.brief().lower())
                exit(0)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print ("\n")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    print (">>> Demo End")
    print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:60,代码来源:demo3.py

示例4: nc_demo_7

def nc_demo_7():

    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 a particular configuration module on the Controller")
    moduleType = "opendaylight-rest-connector:rest-connector-impl"
    moduleName = "rest-connector-default-impl"
    print ("    (module type: %s,\n     module name: %s)"
           % (moduleType, moduleName))
    time.sleep(rundelay)
    result = ctrl.get_module_operational_state(moduleType, moduleName)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Module:"
        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 (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:54,代码来源:ctrl_demo7.py

示例5: nc_demo_2

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 (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:53,代码来源:ctrl_demo2.py

示例6: nc_demo_4

def nc_demo_4():

    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"
    name = "opendaylight-md-sal-binding:binding-data-broker"
    print ("<<< Get '%s' service provider info" % name)
    time.sleep(rundelay)
    result = ctrl.get_service_provider_info(name)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Service provider:"
        service = result.get_data()
        print json.dumps(service, 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 (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:51,代码来源:ctrl_demo4.py

示例7: nc_demo_8

def nc_demo_8():

    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 sessions running on the Controller ")
    nodeName = "controller-config"
    time.sleep(rundelay)
    result = ctrl.get_sessions_info(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print "Sessions:"
        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 (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:51,代码来源:ctrl_demo8.py

示例8: test_ControllerGetSchemas_404

    def test_ControllerGetSchemas_404(self, controller):

        print ("--------------------------------------------------------- ")
        print ("<< Test ControllerGetSchemas_HTTP_Error Start")
        print ("--------------------------------------------------------- ")
        print ("<< Creating Controller instance")
        time.sleep(self.rundelay)
        ctrl = Controller(self.ctrlIpAddr, self.ctrlPortNum, self.ctrlUname, self.ctrlPswd)
        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 ("<< Request Status: %s" % status.brief())

        # and verify the results: STATUS.HTTP_ERROR
        self.assertEquals(10, status.status_code)
开发者ID:jebpublic,项目名称:pybvc,代码行数:18,代码来源:unit_test_controller.py

示例9: test_ControllerGetSchemas_no_content

    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)
开发者ID:jebpublic,项目名称:pybvc,代码行数:21,代码来源:unit_test_controller.py

示例10: of_demo_32

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

    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)

    openflow_node_ids = []
    openflow_nodes = []

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



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

    print "\n".strip()
    print ("<<< Get OpenFlow switches information")
    time.sleep(rundelay)

    inv_obj = None
    result = ctrl.build_inventory_object()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        inv_obj = result.get_data()
        assert(isinstance(inv_obj, Inventory))
    else:
        print ("\n")
        print ("!!!Error, failed to obtain inventory info, reason: %s"
               % status.brief().lower())
        exit(0)

    assert(inv_obj)
    openflow_node_ids = inv_obj.get_openflow_node_ids()
    for node_id in openflow_node_ids:
        node = inv_obj.get_openflow_node(node_id)
        assert(isinstance(node, OpenFlowCapableNode))
        openflow_nodes.append(node)

    print "\n".strip()
    print ("<<< OpenFlow switches in the inventory store")
    s1 = 'IP Address'
    s2 = 'OpenFlow Id'
    sym = '-'
    print "\n".strip()
    print "        {0:<15}  {1:<30}".format(s1, s2)
    print "        {0:<15}  {1:<30}".format(sym*15, sym*30)
    for node in openflow_nodes:
        addr = node.get_ip_address()
        node_id = node.get_id()
        print "        {0:<15}  {1:<30}".format(addr, node_id)

    print "\n".strip()
    print ("<<< Get Group Table Information")
    time.sleep(rundelay)
    for node in openflow_nodes:
        assert(isinstance(node, OpenFlowCapableNode))
        print "\n".strip()
        switch_id = node.get_id()
        print ("        Switch '%s'") % switch_id
        print "\n".strip()
        group_features = node.get_group_features()
        assert(isinstance(group_features, GroupFeatures))

        q = 2  # number of list items to be in a single chunk (output string)

        s = 'Max groups'
        alist = group_features.get_max_groups()
        if alist:
            chunks = [alist[x:x+q] for x in xrange(0, len(alist), q)]
            print "            %s     :" % s,
            for i in range(0, len(chunks)):
                n = 0 if i == 0 else len(s) + 19
                print "%s%s" % (" "*n, ", ".join(map(str, chunks[i])))
        else:
            print "            %s     : %s" % (s, "n/a")

        s = 'Group types'
        alist = group_features.get_types()
        if alist:
            chunks = [alist[x:x+q] for x in xrange(0, len(alist), q)]
            print "            %s    :" % s,
            for i in range(0, len(chunks)):
                n = 0 if i == 0 else len(s) + 18
                print "%s%s" % (" "*n, ", ".join(chunks[i]))
#.........这里部分代码省略.........
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:101,代码来源:demo32.py

示例11: print

    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']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    node = NetconfNode(ctrl, nodeName, nodeIpAddr, nodePortNum,
                       nodeUname, nodePswd)

    print (">>> Adding '%s' to the Controller '%s'" % (nodeName, ctrlIpAddr))
    node_configured = False
    result = ctrl.check_node_config_status(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.NODE_CONFIGURED)):
        node_configured = True
        print ("<<< '%s' is already configured on the Controller" % nodeName)
    elif(status.eq(STATUS.DATA_NOT_FOUND)):
        node_configured = False
    else:
        print ("\n")
        print ("!!!Failed, reason: %s" % status.brief().lower())
开发者ID:BillTheBest,项目名称:pybvc,代码行数:31,代码来源:mount.py

示例12: print

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

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

    rundelay = 5

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

    print "\n"
    print ("<<< Get list of OpenFlow nodes connected to the Controller")
    time.sleep(rundelay)
    result = ctrl.get_openflow_nodes_operational_list()
    status = result[0]
    if status.eq(STATUS.OK) == True:
        print ('OpenFlow node names (composed as "openflow:datapathid"):')
        nodenames = result[1]
        #        for node in nodes:
        #            print ("   %s" % node)
        print json.dumps(nodenames, indent=4)
    else:
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:31,代码来源:of_getSwitchInfo.py

示例13: print

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

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

    rundelay = 5

    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 sessions running on the Controller ")
    nodeName = "controller-config"
    time.sleep(rundelay)
    result = ctrl.get_sessions_info(nodeName)
    status = result[0]
    if status.eq(STATUS.OK):
        print "Sessions:"
        slist = result[1]
        print json.dumps(slist, default=lambda o: o.__dict__, sort_keys=True, indent=4)
    else:
        print ("\n")
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:31,代码来源:ctrl_sess.py

示例14: vr_demo_12

def vr_demo_12():

    f = "cfg4.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 device attributes")
        exit(0)

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

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum,
                          nodeUname, nodePswd)
    print ("<<< 'Controller': %s, '%s': %s"
           % (ctrlIpAddr, nodeName, nodeIpAddr))

    print ("\n")
    time.sleep(rundelay)
    node_configured = False
    result = ctrl.check_node_config_status(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.NODE_CONFIGURED)):
        node_configured = True
        print ("<<< '%s' is configured on the Controller" % nodeName)
    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 is False:
        result = ctrl.add_netconf_node(vrouter)
        status = result.get_status()
        if(status.eq(STATUS.OK)):
            print ("<<< '%s' added to the Controller" % nodeName)
        else:
            print ("\n")
            print ("!!!Demo terminated, reason: %s" % status.detailed())
            exit(0)

    print ("\n")
    time.sleep(rundelay)
    result = ctrl.check_node_conn_status(nodeName)
    status = result.get_status()
    if(status.eq(STATUS.NODE_CONNECTED)):
        print ("<<< '%s' is connected to the Controller" % nodeName)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print("\n")
    print ("<<< Show VPN configuration on the '%s'" % nodeName)
    result = vrouter.get_vpn_cfg()
    time.sleep(rundelay)
    status = result.get_status()
    if (status.eq(STATUS.OK)):
        print ("'%s' VPN configuration:" % nodeName)
        cfg = result.get_data()
        data = json.loads(cfg)
        print json.dumps(data, indent=4, sort_keys=True)
    elif (status.eq(STATUS.DATA_NOT_FOUND)):
        print ("No VPN configuration found")
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        ctrl.delete_netconf_node(vrouter)
        exit(0)

    print "\n"
    print (">>> Create new VPN configuration on the '%s'" % (nodeName))

    ca_cert_file = '/config/auth/ca.crt'
    srv_cert_file = '/config/auth/r1.crt'
    srv_key_file = '/config/auth/r1.key'
    crl_file = '/config/auth/r1.crl'
    print (" NOTE: For this demo to succeed the following files "
           "must exist on the '%s'\n"
           "       (empty files can be created for the sake of the demo):\n"
           "         %s\n"
#.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:pybvc,代码行数:101,代码来源:vr_demo12.py

示例15: print

     nodePortNum = d['nodePortNum']
     nodeUname = d['nodeUname']
     nodePswd = d['nodePswd']
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
 print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))
 
 
 print ("\n")
 time.sleep(rundelay)
 result = ctrl.add_netconf_node(vrouter)
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("<<< '%s' added to the Controller" % nodeName)
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief().lower())
     exit(0)
 
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:30,代码来源:vr_demo9.py


注:本文中的pybvc.controller.controller.Controller类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。