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


Python OpServerUtils.ip_protocol_to_str方法代码示例

本文整理汇总了Python中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_util.OpServerUtils的用法示例。


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

示例1: display

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import ip_protocol_to_str [as 别名]

#.........这里部分代码省略.........
            # Destination VN
            if self._DESTINATION_VN in flow_dict and\
                flow_dict[self._DESTINATION_VN] is not None:
                destination_vn = flow_dict[self._DESTINATION_VN]
            else:
                destination_vn = 'Destination VN: NA'
            # Source IP 
            if self._SOURCE_IP in flow_dict and\
                flow_dict[self._SOURCE_IP] is not None:
                source_ip = flow_dict[self._SOURCE_IP]
            else:
                source_ip = 'Source IP: NA'
            # Destination IP 
            if self._DESTINATION_IP in flow_dict and\
                flow_dict[self._DESTINATION_IP] is not None:
                destination_ip = flow_dict[self._DESTINATION_IP]
            else:
                destination_ip = 'Destination IP: NA'
            # Source port 
            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
开发者ID:Pojen-Huang,项目名称:contrail-controller,代码行数:70,代码来源:flow.py

示例2: display

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from 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 and flow_dict[self._SETUP_TIME] is not None:
                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 and flow_dict[self._TEARDOWN_TIME] is not None:
                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 and flow_dict[self._VROUTER] is not None:
                vrouter = flow_dict[self._VROUTER]
            else:
                vrouter = "VRouter: NA"
            # Direction
            if self._DIRECTION in flow_dict and flow_dict[self._DIRECTION] is not None:
                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 and flow_dict[VizConstants.FLOW_TABLE_UUID] is not None:
                flow_uuid = flow_dict[VizConstants.FLOW_TABLE_UUID]
            else:
                flow_uuid = "UUID: NA"
            # Source VN
            if self._SOURCE_VN in flow_dict and flow_dict[self._SOURCE_VN] is not None:
                source_vn = flow_dict[self._SOURCE_VN]
            else:
                source_vn = "Source VN: NA"
            # Destination VN
            if self._DESTINATION_VN in flow_dict and flow_dict[self._DESTINATION_VN] is not None:
                destination_vn = flow_dict[self._DESTINATION_VN]
            else:
                destination_vn = "Destination VN: NA"
            # Source IP
            if self._SOURCE_IP in flow_dict and flow_dict[self._SOURCE_IP] is not None:
                source_ip = flow_dict[self._SOURCE_IP]
            else:
                source_ip = "Source IP: NA"
            # Destination IP
            if self._DESTINATION_IP in flow_dict and flow_dict[self._DESTINATION_IP] is not None:
                destination_ip = flow_dict[self._DESTINATION_IP]
            else:
                destination_ip = "Destination IP: NA"
            # Source port
            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
#.........这里部分代码省略.........
开发者ID:numansiddique,项目名称:contrail-controller,代码行数:103,代码来源:flow.py

示例3: display

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from 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:Juniper,项目名称:contrail-dev-controller,代码行数:103,代码来源:flow.py

示例4: display

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from 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:anandhk-juniper,项目名称:contrail-controller,代码行数:103,代码来源:flow.py


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