本文整理汇总了Python中framework.controller.controller.Controller类的典型用法代码示例。如果您正苦于以下问题:Python Controller类的具体用法?Python Controller怎么用?Python Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
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 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()
示例2: print
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']
except:
print ("Failed to get Controller device attributes")
exit(0)
openflow_nodes = []
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
rundelay = 2
print "\n"
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
print ("<<< Controller '%s:%s'" % (ctrlIpAddr, ctrlPortNum))
time.sleep(rundelay)
print "\n"
print ("<<< Get OpenFlow Inventory 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")
示例3: print
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print("\n")
print("<<< OpenVPN configuration example: Site-to-Site Mode with TLS")
print("\n")
rundelay = 3
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_onfigured = False
示例4: print
nodeName = d['nodeName']
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.get_status()
if(status.eq(STATUS.OK) == True):
print ("OpenFlow node names (composed as \"openflow:datapathid\"):")
nodenames = result.get_data()
print json.dumps(nodenames, indent=4)
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.brief().lower())
示例5: print
ctrlIpAddr = '172.22.18.186'
ctrlPortNum = '8181'
ctrlUname = 'admin'
ctrlPswd = 'admin'
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
rundelay = 2
print "\n"
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
print ("<<< Controller '%s:%s'" % (ctrlIpAddr, ctrlPortNum))
time.sleep(rundelay)
print "\n"
print ("<<< Get NETCONF Configuration Information")
time.sleep(rundelay)
netconf_cfg_modules = []
result = ctrl.build_netconf_config_objects()
status = result.get_status()
if(status.eq(STATUS.OK) == True):
netconf_cfg_modules = result.get_data()
else:
示例6: print
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']
except:
print ("Failed to get Controller device attributes")
exit(0)
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
rundelay = 3
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:
示例7: 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 (">>> Removing '%s' from the Controller '%s'" % (nodeName, ctrlIpAddr))
result = ctrl.delete_netconf_node(node)
status = result.get_status()
if status.eq(STATUS.OK) == True:
print ("'%s' was successfully removed from the Controller" % nodeName)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
exit(0)
print "\n"
示例8: print
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 notification event streams registered on the Controller")
time.sleep(rundelay)
result = ctrl.get_streams_info()
status = result.get_status()
if(status.eq(STATUS.OK)):
print "Streams:"
slist = result.get_data()
print json.dumps(slist, default=lambda o: o.__dict__, sort_keys=True, indent=4)
else:
print ("\n")
示例9: print
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"
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()
示例10: print
ctrlUname = 'admin'
ctrlPswd = 'admin'
netconf_ids = []
netconf_nodes = []
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
rundelay = 2
print "\n"
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
print ("<<< Controller '%s:%s'" % (ctrlIpAddr, ctrlPortNum))
time.sleep(rundelay)
print "\n"
print ("<<< Get NETCONF Inventory Information")
time.sleep(rundelay)
result = ctrl.get_netconf_nodes_in_config()
status = result.get_status()
if(status.eq(STATUS.OK)):
netconf_ids = result.get_data()
else:
print ("\n")
示例11: print
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.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:
示例12: in
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")
示例13: print
" as add/remove switch, host or link) is detected it will be\n" \
" reported to the screen.\n" \
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"
print "\n".strip()
print description
print "\n".strip()
time.sleep(rundelay)
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
# Identifier of the network topology to be traced
# (name used by Controller for default topology instance)
topo_id = 'flow:1'
print "\n".strip()
print ("<<< 'Controller': %s, Topology Identifier: '%s'" % (ctrlIpAddr, topo_id))
time.sleep(rundelay)
# Data store for the changes
# Can be one of:
# - CONFIGURATION: Logical data store representing configuration
# state of the system and it's components.
# - OPERATIONAL: Logical data store representing operational
# state of the system and it's components
datastore = "OPERATIONAL"
示例14: print
ctrlPswd = d["ctrlPswd"]
nodeName = d["nodeName"]
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 information about OpenFlow node '%s'" % nodeName)
time.sleep(rundelay)
ofswitch = OFSwitch(ctrl, nodeName)
result = ofswitch.get_switch_info()
status = result.get_status()
if status.eq(STATUS.OK) == True:
print ("Node '%s' generic info:" % nodeName)
info = result.get_data()
print json.dumps(info, indent=4)
else:
print ("\n")
示例15: print
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller or NETCONF device attributes")
exit(0)
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
rundelay = 3
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")