本文整理汇总了Python中pybvc.openflowdev.ofswitch.OFSwitch.get_configured_group_ids方法的典型用法代码示例。如果您正苦于以下问题:Python OFSwitch.get_configured_group_ids方法的具体用法?Python OFSwitch.get_configured_group_ids怎么用?Python OFSwitch.get_configured_group_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybvc.openflowdev.ofswitch.OFSwitch
的用法示例。
在下文中一共展示了OFSwitch.get_configured_group_ids方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: of_demo_36
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_configured_group_ids [as 别名]
def of_demo_36():
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 36 Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
ofswitch = OFSwitch(ctrl, nodeName)
print "\n".strip()
print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
(ctrlIpAddr, nodeName))
grp_ids_cfg = []
grp_ids_oper = []
print "\n".strip()
print ("<<< Get OpenFlow Groups Information")
time.sleep(rundelay)
result = ofswitch.get_configured_group_ids()
status = result.get_status()
if(status.eq(STATUS.OK)):
grp_ids_cfg = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
grp_ids_cfg = []
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.detailed())
exit(0)
result = ofswitch.get_operational_group_ids()
status = result.get_status()
if(status.eq(STATUS.OK)):
grp_ids_oper = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
grp_ids_oper = []
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.detailed())
exit(0)
# Show current state of the Group Table in the Controller's
# configuration and operational data stores
print_groups(grp_ids_cfg, grp_ids_oper)
# Create new group
group_id = 15
group_type = OFPGT_FF
group_name = "Example of 'link fast failover' group"
watch_port1 = 110
watch_port2 = 111
watch_port3 = 112
out_port1 = 110
out_port2 = 111
out_port3 = 112
print "\n".strip()
print ("<<< Create Group")
print "\n".strip()
print (" Group Type : %s\n"
" Group ID : %s\n"
" Group Name : \"%s\"" %
(group_type.strip('group-').upper(),
group_id, group_name))
print (" Buckets :")
print (" [0] watch-port: %s" %
watch_port1)
print (" actions: Output (%s)" %
out_port1)
print (" [1] watch-port: %s" %
watch_port2)
print (" actions: Output (%s)" %
out_port2)
print (" [2] watch-port: %s" %
watch_port3)
print (" actions: Output (%s)" %
out_port3)
time.sleep(rundelay)
# Allocate a placeholder for the group entry
group_entry = GroupEntry(group_id, group_type)
group_entry.set_group_name(group_name)
#.........这里部分代码省略.........
示例2: of_demo_34
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_configured_group_ids [as 别名]
def of_demo_34():
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)
openflow_node_ids = []
openflow_nodes = []
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo 34 Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
ofswitch = OFSwitch(ctrl, nodeName)
print "\n".strip()
print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'"
% (ctrlIpAddr, nodeName))
grp_ids_cfg = []
grp_ids_oper = []
print "\n".strip()
print ("<<< Get OpenFlow Groups Information")
time.sleep(rundelay)
result = ofswitch.get_configured_group_ids()
status = result.get_status()
if(status.eq(STATUS.OK)):
grp_ids_cfg = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
grp_ids_cfg = []
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.detailed())
exit(0)
result = ofswitch.get_operational_group_ids()
status = result.get_status()
if(status.eq(STATUS.OK)):
grp_ids_oper = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
grp_ids_oper = []
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.detailed())
exit(0)
# Show current state of the Group Table in the Controller's
# configuration and operational data stores
print_groups(grp_ids_cfg, grp_ids_oper)
# Create new group
group_id = 13
group_type = OFPGT_SELECT
group_name = "Example of 'load balancing' group"
weight1 = 60
weight2 = 30
weight3 = 10
out_port1 = 110
out_port2 = 111
out_port3 = 112
print "\n".strip()
print ("<<< Create Group")
print "\n".strip()
print (" Group Type : %s\n"
" Group ID : %s\n"
" Group Name : \"%s\"" % (group_type.strip('group-').upper(),
group_id, group_name))
print (" Buckets :")
print (" [0] weight : %s"
% weight1)
print (" actions: Output (%s)"
% out_port1)
print (" [1] weight : %s"
% weight2)
print (" actions: Output (%s)"
% out_port2)
print (" [2] weight : %s"
% weight3)
print (" actions: Output (%s)"
% out_port3)
time.sleep(rundelay)
#.........这里部分代码省略.........
示例3: Controller
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_configured_group_ids [as 别名]
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
ofswitch = OFSwitch(ctrl, nodeName)
print "\n".strip()
print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr,
nodeName))
grp_ids_cfg = []
grp_ids_oper = []
print "\n".strip()
print ("<<< Get OpenFlow Groups Information")
time.sleep(rundelay)
result = ofswitch.get_configured_group_ids()
status = result.get_status()
if(status.eq(STATUS.OK)):
grp_ids_cfg = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
grp_ids_cfg = []
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.detailed())
exit(0)
result = ofswitch.get_operational_group_ids()
status = result.get_status()
if(status.eq(STATUS.OK)):
grp_ids_oper = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):