本文整理匯總了Python中ryu.ofproto.ofproto_v1_3.OFP_VERSION屬性的典型用法代碼示例。如果您正苦於以下問題:Python ofproto_v1_3.OFP_VERSION屬性的具體用法?Python ofproto_v1_3.OFP_VERSION怎麽用?Python ofproto_v1_3.OFP_VERSION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類ryu.ofproto.ofproto_v1_3
的用法示例。
在下文中一共展示了ofproto_v1_3.OFP_VERSION屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: stats_reply_handler
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def stats_reply_handler(self, ev):
msg = ev.msg
dp = msg.datapath
if dp.id not in self.waiters:
return
if msg.xid not in self.waiters[dp.id]:
return
lock, msgs = self.waiters[dp.id][msg.xid]
msgs.append(msg)
flags = 0
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \
dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
flags = dp.ofproto.OFPSF_REPLY_MORE
elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
flags = dp.ofproto.OFPMPF_REPLY_MORE
if msg.flags & flags:
return
del self.waiters[dp.id][msg.xid]
lock.set()
示例2: get_desc_stats
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_desc_stats(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None:
desc = _ofctl.get_desc_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
body = json.dumps(desc)
return Response(content_type='application/json', body=body)
示例3: get_table_features
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_table_features(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None:
ports = _ofctl.get_table_features(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
body = json.dumps(ports)
return Response(content_type='application/json', body=body)
示例4: get_port_stats
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_port_stats(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None:
ports = _ofctl.get_port_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
body = json.dumps(ports)
return Response(content_type='application/json', body=body)
示例5: get_queue_stats
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_queue_stats(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None:
queues = _ofctl.get_queue_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
body = json.dumps(queues)
return Response(content_type='application/json', body=body)
示例6: get_meter_features
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_meter_features(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None and hasattr(_ofctl, 'get_meter_features'):
meters = _ofctl.get_meter_features(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol or \
request not supported in this OF protocol version')
return Response(status=501)
body = json.dumps(meters)
return Response(content_type='application/json', body=body)
示例7: get_meter_stats
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_meter_stats(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None and hasattr(_ofctl, 'get_meter_stats'):
meters = _ofctl.get_meter_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol or \
request not supported in this OF protocol version')
return Response(status=501)
body = json.dumps(meters)
return Response(content_type='application/json', body=body)
示例8: get_group_features
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_group_features(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None and hasattr(_ofctl, 'get_group_features'):
groups = _ofctl.get_group_features(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol or \
request not supported in this OF protocol version')
return Response(status=501)
body = json.dumps(groups)
return Response(content_type='application/json', body=body)
示例9: get_group_desc
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_group_desc(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None and hasattr(_ofctl, 'get_group_desc'):
groups = _ofctl.get_group_desc(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol or \
request not supported in this OF protocol version')
return Response(status=501)
body = json.dumps(groups)
return Response(content_type='application/json', body=body)
示例10: get_group_stats
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_group_stats(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None and hasattr(_ofctl, 'get_group_stats'):
groups = _ofctl.get_group_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol or \
request not supported in this OF protocol version')
return Response(status=501)
body = json.dumps(groups)
return Response(content_type='application/json', body=body)
示例11: get_port_desc
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def get_port_desc(self, req, dpid, **_kwargs):
if type(dpid) == str and not dpid.isdigit():
LOG.debug('invalid dpid %s', dpid)
return Response(status=400)
dp = self.dpset.get(int(dpid))
if dp is None:
return Response(status=404)
_ofp_version = dp.ofproto.OFP_VERSION
_ofctl = supported_ofctl.get(_ofp_version, None)
if _ofctl is not None:
groups = _ofctl.get_port_desc(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
body = json.dumps(groups)
return Response(content_type='application/json', body=body)
示例12: _stats_reply_handler
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def _stats_reply_handler(self, ev):
msg = ev.msg
dp = msg.datapath
if (dp.id not in self.waiters
or msg.xid not in self.waiters[dp.id]):
return
event, msgs = self.waiters[dp.id][msg.xid]
msgs.append(msg)
if ofproto_v1_3.OFP_VERSION == dp.ofproto.OFP_VERSION:
more = dp.ofproto.OFPMPF_REPLY_MORE
else:
more = dp.ofproto.OFPSF_REPLY_MORE
if msg.flags & more:
return
del self.waiters[dp.id][msg.xid]
event.set()
# for OpenFlow version1.0
示例13: add_flow
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def add_flow(self, in_port=None, out_port=None):
""" Add flow. """
ofp = self.dp.ofproto
parser = self.dp.ofproto_parser
match = parser.OFPMatch(in_port=in_port)
actions = [parser.OFPActionOutput(out_port)]
if ofp.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
mod = parser.OFPFlowMod(
self.dp, match=match, cookie=0, command=ofp.OFPFC_ADD,
actions=actions)
else:
inst = [parser.OFPInstructionActions(
ofp.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(
self.dp, cookie=0, command=ofp.OFPFC_ADD, match=match,
instructions=inst)
return self.send_msg(mod)
示例14: del_flows
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def del_flows(self, cookie=0):
"""
Delete all flow except default flow by using the cookie value.
Note: In OpenFlow 1.0, DELETE and DELETE_STRICT commands can
not be filtered by the cookie value and this value is ignored.
"""
ofp = self.dp.ofproto
parser = self.dp.ofproto_parser
cookie_mask = 0
if cookie:
cookie_mask = 0xffffffffffffffff
if ofp.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
match = parser.OFPMatch()
mod = parser.OFPFlowMod(self.dp, match, cookie, ofp.OFPFC_DELETE)
else:
mod = parser.OFPFlowMod(
self.dp, cookie=cookie, cookie_mask=cookie_mask,
table_id=ofp.OFPTT_ALL, command=ofp.OFPFC_DELETE,
out_port=ofp.OFPP_ANY, out_group=ofp.OFPG_ANY)
return self.send_msg(mod)
示例15: stats_reply_handler
# 需要導入模塊: from ryu.ofproto import ofproto_v1_3 [as 別名]
# 或者: from ryu.ofproto.ofproto_v1_3 import OFP_VERSION [as 別名]
def stats_reply_handler(self, ev):
msg = ev.msg
dp = msg.datapath
if dp.id not in self.waiters:
return
if msg.xid not in self.waiters[dp.id]:
return
lock, msgs = self.waiters[dp.id][msg.xid]
msgs.append(msg)
flags = 0
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
flags = dp.ofproto.OFPSF_REPLY_MORE
elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
flags = dp.ofproto.OFPSF_REPLY_MORE
elif dp.ofproto.OFP_VERSION >= ofproto_v1_3.OFP_VERSION:
flags = dp.ofproto.OFPMPF_REPLY_MORE
if msg.flags & flags:
return
del self.waiters[dp.id][msg.xid]
lock.set()