本文整理汇总了Python中opserver_util.OpServerUtils.tunnel_type_to_str方法的典型用法代码示例。如果您正苦于以下问题:Python OpServerUtils.tunnel_type_to_str方法的具体用法?Python OpServerUtils.tunnel_type_to_str怎么用?Python OpServerUtils.tunnel_type_to_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opserver_util.OpServerUtils
的用法示例。
在下文中一共展示了OpServerUtils.tunnel_type_to_str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import tunnel_type_to_str [as 别名]
#.........这里部分代码省略.........
if self._SOURCE_PORT in flow_dict and flow_dict[self._SOURCE_PORT] is not None:
source_port = flow_dict[self._SOURCE_PORT]
else:
source_port = "Source Port: NA"
# Destination port
if self._DESTINATION_PORT in flow_dict and flow_dict[self._DESTINATION_PORT] is not None:
destination_port = flow_dict[self._DESTINATION_PORT]
else:
destination_port = "Destination Port: NA"
# Protocol
if self._PROTOCOL in flow_dict and flow_dict[self._PROTOCOL] is not None:
protocol = OpServerUtils.ip_protocol_to_str(int(flow_dict[self._PROTOCOL]))
else:
protocol = "Protocol: NA"
# Action
if self._ACTION in flow_dict and flow_dict[self._ACTION] is not None:
action = flow_dict[self._ACTION]
else:
action = ""
# Agg packets and bytes
if (
VizConstants.FLOW_TABLE_AGG_BYTES in flow_dict
and flow_dict[VizConstants.FLOW_TABLE_AGG_BYTES] is not None
):
agg_bytes = int(flow_dict[VizConstants.FLOW_TABLE_AGG_BYTES])
else:
agg_bytes = "Agg Bytes: NA"
if (
VizConstants.FLOW_TABLE_AGG_PKTS in flow_dict
and flow_dict[VizConstants.FLOW_TABLE_AGG_PKTS] is not None
):
agg_pkts = int(flow_dict[VizConstants.FLOW_TABLE_AGG_PKTS])
else:
agg_pkts = "Agg Packets: NA"
# SG rule UUID
if self._SG_RULE_UUID in flow_dict and flow_dict[self._SG_RULE_UUID] is not None:
sg_rule_uuid = flow_dict[self._SG_RULE_UUID]
else:
sg_rule_uuid = None
# NW ACE UUID
if self._NW_ACE_UUID in flow_dict and flow_dict[self._NW_ACE_UUID] is not None:
nw_ace_uuid = flow_dict[self._NW_ACE_UUID]
else:
nw_ace_uuid = None
# VRouter IP
if self._VROUTER_IP in flow_dict and flow_dict[self._VROUTER_IP] is not None:
vrouter_ip = "/" + flow_dict[self._VROUTER_IP]
else:
vrouter_ip = ""
# Other VRouter IP
if self._OTHER_VROUTER_IP in flow_dict and flow_dict[self._OTHER_VROUTER_IP] is not None:
other_vrouter_ip = " [DST-VR:" + flow_dict[self._OTHER_VROUTER_IP] + "]"
else:
other_vrouter_ip = ""
if self._VMI_UUID in flow_dict and (flow_dict[self._VMI_UUID] is not None):
src_vmi_uuid = " [SRC VMI UUID:" + flow_dict[self._VMI_UUID] + "]"
else:
src_vmi_uuid = " [SRC VMI UUID: None]"
# Underlay info
if self._UNDERLAY_PROTO in flow_dict and flow_dict[self._UNDERLAY_PROTO] is not None:
tunnel_proto = "T:" + OpServerUtils.tunnel_type_to_str(flow_dict[self._UNDERLAY_PROTO])
else:
tunnel_proto = None
if self._UNDERLAY_SPORT in flow_dict and flow_dict[self._UNDERLAY_SPORT] is not None:
tunnel_sport = "Src Port:" + str(flow_dict[self._UNDERLAY_SPORT]) + " "
if tunnel_proto:
tunnel_info = tunnel_proto + "/" + tunnel_sport
else:
tunnel_info = tunnel_sport
else:
tunnel_sport = None
if tunnel_proto:
tunnel_info = tunnel_proto
else:
tunnel_info = ""
print "[SRC-VR:{0}{1}] {2} {3} ({4} -- {5}) {6} " "{7}:{8}:{9}:{10} ---> {11}:{12}:{13}{14} <{15} P ({16} B)>" " : SG:{17} ACL:{18} {19}{20}".format(
vrouter,
vrouter_ip,
direction,
action,
setup_ts,
teardown_ts,
protocol,
source_vn,
source_ip,
source_port,
src_vmi_uuid,
destination_vn,
destination_ip,
destination_port,
other_vrouter_ip,
agg_pkts,
agg_bytes,
sg_rule_uuid,
nw_ace_uuid,
tunnel_info,
flow_uuid,
)
示例2: display
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import tunnel_type_to_str [as 别名]
#.........这里部分代码省略.........
else:
protocol = 'Protocol: NA'
# Action
if self._ACTION in flow_dict and\
flow_dict[self._ACTION] is not None:
action = flow_dict[self._ACTION]
else:
action = ''
# Agg packets and bytes
if VizConstants.FLOW_TABLE_AGG_BYTES in flow_dict and\
flow_dict[VizConstants.FLOW_TABLE_AGG_BYTES] is not None:
agg_bytes = int(flow_dict[VizConstants.FLOW_TABLE_AGG_BYTES])
else:
agg_bytes = 'Agg Bytes: NA'
if VizConstants.FLOW_TABLE_AGG_PKTS in flow_dict and\
flow_dict[VizConstants.FLOW_TABLE_AGG_PKTS] is not None:
agg_pkts = int(flow_dict[VizConstants.FLOW_TABLE_AGG_PKTS])
else:
agg_pkts = 'Agg Packets: NA'
# SG rule UUID
if self._SG_RULE_UUID in flow_dict and\
flow_dict[self._SG_RULE_UUID] is not None:
sg_rule_uuid = flow_dict[self._SG_RULE_UUID]
else:
sg_rule_uuid = None
# NW ACE UUID
if self._NW_ACE_UUID in flow_dict and\
flow_dict[self._NW_ACE_UUID] is not None:
nw_ace_uuid = flow_dict[self._NW_ACE_UUID]
else:
nw_ace_uuid = None
# VRouter IP
if self._VROUTER_IP in flow_dict and\
flow_dict[self._VROUTER_IP] is not None:
vrouter_ip = '/' + flow_dict[self._VROUTER_IP]
else:
vrouter_ip = ''
# Other VRouter IP
if self._OTHER_VROUTER_IP in flow_dict and\
flow_dict[self._OTHER_VROUTER_IP] is not None:
other_vrouter_ip = ' [DST-VR:' + flow_dict[self._OTHER_VROUTER_IP] + ']'
else:
other_vrouter_ip = ''
if self._VMI_UUID in flow_dict and (
flow_dict[self._VMI_UUID] is not None):
src_vmi_uuid = ' [SRC VMI UUID:' + flow_dict[self._VMI_UUID] + ']'
else:
src_vmi_uuid = ' [SRC VMI UUID: None]'
# Underlay info
if self._UNDERLAY_PROTO in flow_dict and\
flow_dict[self._UNDERLAY_PROTO] is not None:
tunnel_proto = 'T:' + OpServerUtils.tunnel_type_to_str(flow_dict[self._UNDERLAY_PROTO])
else:
tunnel_proto = None
if self._UNDERLAY_SPORT in flow_dict and\
flow_dict[self._UNDERLAY_SPORT] is not None:
tunnel_sport = 'Src Port:' + str(flow_dict[self._UNDERLAY_SPORT]) + ' '
if tunnel_proto:
tunnel_info = tunnel_proto + '/' + tunnel_sport
else:
tunnel_info = tunnel_sport
else:
tunnel_sport = None
if tunnel_proto:
tunnel_info = tunnel_proto
else:
tunnel_info = ''
# Drop Reason
if self._DROP_REASON in flow_dict and\
flow_dict[self._DROP_REASON] is not None:
drop_reason = flow_dict[self._DROP_REASON]
else:
drop_reason = ''
output_dict = {}
output_dict['vrouter'] = vrouter
output_dict['vrouter_ip'] = vrouter_ip
output_dict['direction'] = direction
output_dict['action'] = action
output_dict['drop_reason'] = drop_reason
output_dict['setup_ts'] = setup_ts
output_dict['teardown_ts'] = teardown_ts
output_dict['protocol'] = protocol
output_dict['source_vn'] = source_vn
output_dict['source_ip'] = source_ip
output_dict['source_port'] = source_port
output_dict['src_vmi_uuid'] = src_vmi_uuid
output_dict['destination_vn'] = destination_vn
output_dict['destination_ip'] = destination_ip
output_dict['destination_port'] = destination_port
output_dict['other_vrouter_ip'] = other_vrouter_ip
output_dict['agg_pkts'] = agg_pkts
output_dict['agg_bytes'] = agg_bytes
output_dict['sg_rule_uuid'] = sg_rule_uuid
output_dict['nw_ace_uuid'] = nw_ace_uuid
output_dict['tunnel_info'] = tunnel_info
output_dict['flow_uuid'] = flow_uuid
self.output(output_dict)
示例3: display
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import tunnel_type_to_str [as 别名]
#.........这里部分代码省略.........
direction = 'Direction: NA'
# Flow UUID
if VizConstants.FLOW_TABLE_UUID in flow_dict:
flow_uuid = flow_dict[VizConstants.FLOW_TABLE_UUID]
else:
flow_uuid = 'UUID: NA'
# Source VN
if self._SOURCE_VN in flow_dict:
source_vn = flow_dict[self._SOURCE_VN]
else:
source_vn = 'Source VN: NA'
# Destination VN
if self._DESTINATION_VN in flow_dict:
destination_vn = flow_dict[self._DESTINATION_VN]
else:
destination_vn = 'Destination VN: NA'
# Source IP
if self._SOURCE_IP in flow_dict:
source_ip = flow_dict[self._SOURCE_IP]
else:
source_ip = 'Source IP: NA'
# Destination IP
if self._DESTINATION_IP in flow_dict:
destination_ip = flow_dict[self._DESTINATION_IP]
else:
destination_ip = 'Destination IP: NA'
# Source port
if self._SOURCE_PORT in flow_dict:
source_port = flow_dict[self._SOURCE_PORT]
else:
source_port = 'Source Port: NA'
# Destination port
if self._DESTINATION_PORT in flow_dict:
destination_port = flow_dict[self._DESTINATION_PORT]
else:
destination_port = 'Destination Port: NA'
# Protocol
if self._PROTOCOL in flow_dict:
protocol = OpServerUtils.ip_protocol_to_str(
int(flow_dict[self._PROTOCOL]))
else:
protocol = 'Protocol: NA'
# Action
if self._ACTION in flow_dict:
action = flow_dict[self._ACTION]
else:
action = ''
# Agg packets and bytes
if VizConstants.FLOW_TABLE_AGG_BYTES in flow_dict:
agg_bytes = int(flow_dict[VizConstants.FLOW_TABLE_AGG_BYTES])
else:
agg_bytes = 'Agg Bytes: NA'
if VizConstants.FLOW_TABLE_AGG_PKTS in flow_dict:
agg_pkts = int(flow_dict[VizConstants.FLOW_TABLE_AGG_PKTS])
else:
agg_pkts = 'Agg Packets: NA'
# SG rule UUID
if self._SG_RULE_UUID in flow_dict:
sg_rule_uuid = flow_dict[self._SG_RULE_UUID]
else:
sg_rule_uuid = None
# NW ACE UUID
if self._NW_ACE_UUID in flow_dict:
nw_ace_uuid = flow_dict[self._NW_ACE_UUID]
else:
nw_ace_uuid = None
# VRouter IP
if self._VROUTER_IP in flow_dict:
vrouter_ip = '/' + flow_dict[self._VROUTER_IP]
else:
vrouter_ip = ''
# Other VRouter IP
if self._OTHER_VROUTER_IP in flow_dict:
other_vrouter_ip = ' [DST-VR:' + flow_dict[self._OTHER_VROUTER_IP] + ']'
else:
other_vrouter_ip = ''
# Underlay info
if self._UNDERLAY_PROTO in flow_dict:
tunnel_proto = 'T:' + OpServerUtils.tunnel_type_to_str(flow_dict[self._UNDERLAY_PROTO])
else:
tunnel_proto = None
if self._UNDERLAY_SPORT in flow_dict:
tunnel_sport = 'Src Port:' + str(flow_dict[self._UNDERLAY_SPORT]) + ' '
if tunnel_proto:
tunnel_info = tunnel_proto + '/' + tunnel_sport
else:
tunnel_info = tunnel_sport
else:
tunnel_sport = None
if tunnel_proto:
tunnel_info = tunnel_proto
else:
tunnel_info = ''
print '[SRC-VR:{0}{1}] {2} {3} ({4} -- {5}) {6} '\
'{7}:{8}:{9} ---> {10}:{11}:{12}{13} <{14} P ({15} B)>'\
' : SG:{16} ACL:{17} {18}{19}'.format(
vrouter, vrouter_ip, direction, action, setup_ts, teardown_ts,
protocol, source_vn, source_ip, source_port, destination_vn,
destination_ip, destination_port, other_vrouter_ip, agg_pkts,
agg_bytes, sg_rule_uuid, nw_ace_uuid, tunnel_info, flow_uuid)