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


Python OpServerUtils.ip_protocol_to_str方法代码示例

本文整理汇总了Python中opserver.opserver_util.OpServerUtils.ip_protocol_to_str方法的典型用法代码示例。如果您正苦于以下问题:Python OpServerUtils.ip_protocol_to_str方法的具体用法?Python OpServerUtils.ip_protocol_to_str怎么用?Python OpServerUtils.ip_protocol_to_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opserver.opserver_util.OpServerUtils的用法示例。


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

示例1: display

# 需要导入模块: from opserver.opserver_util import OpServerUtils [as 别名]
# 或者: from opserver.opserver_util.OpServerUtils import ip_protocol_to_str [as 别名]
 def display(self, result):
     if result == [] or result is None:
         return
     flow_dict_list = result
 
     for flow_dict in flow_dict_list:
         # Setup time
         if self._SETUP_TIME in flow_dict:
             setup_time = int(flow_dict[self._SETUP_TIME])
             if setup_time != 0:
                 setup_dt = datetime.datetime.fromtimestamp(
                     setup_time /
                     OpServerUtils.USECS_IN_SEC)
                 setup_dt += datetime.timedelta(
                     microseconds=
                     (setup_time %
                      OpServerUtils.USECS_IN_SEC))
                 setup_ts = setup_dt.strftime(
                     OpServerUtils.TIME_FORMAT_STR)
             else:
                 setup_ts = 'Setup Time: NA'
         else:
             setup_ts = 'Setup Time: NA'
         # Teardown time
         if self._TEARDOWN_TIME in flow_dict:
             teardown_time = int(flow_dict[ 
                 self._TEARDOWN_TIME])
             if teardown_time != 0:
                 teardown_dt = datetime.datetime.fromtimestamp(
                     teardown_time /
                     OpServerUtils.USECS_IN_SEC)
                 teardown_dt += datetime.timedelta(
                     microseconds=
                     (teardown_time %
                      OpServerUtils.USECS_IN_SEC))
                 teardown_ts = teardown_dt.strftime(
                     OpServerUtils.TIME_FORMAT_STR)
             else:
                 teardown_ts = 'Active'
         else:
             teardown_ts = 'Active'
         # VRouter
         if self._VROUTER in flow_dict:
             vrouter = flow_dict[self._VROUTER]
         else:
             vrouter = 'VRouter: NA'
         # Direction 
         if self._DIRECTION in flow_dict:
             direction = int(flow_dict[self._DIRECTION])
             if direction == 1:
                 direction = 'ingress'
             elif direction == 0:
                 direction = 'egress'
             else:
                 direction = 'Direction: Invalid'
         else:
             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:
#.........这里部分代码省略.........
开发者ID:Doude,项目名称:contrail-controller,代码行数:103,代码来源:flow.py


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