Fix various pylint 1.5.4 warnings
[csit.git] / resources / libraries / python / SFC / VerifyPacket.py
index fd72bb2..a13c760 100644 (file)
@@ -20,11 +20,9 @@ import ipaddress
 
 from scapy.layers.inet import IP, UDP
 from scapy.all import Raw
-from resources.libraries.python.constants import Constants as con
 from resources.libraries.python.SFC.SFCConstants import SFCConstants as sfccon
 from resources.libraries.python.SFC.TunnelProtocol import VxLAN, VxLANGPE, NSH
 
-from robot.api import logger
 
 def valid_ipv4(ipaddr):
     """Check if IP address has the correct IPv4 address format.
@@ -68,7 +66,6 @@ class VerifyPacket(object):
 
         :param payload_data: the payload data in the packet.
         :type payload_data: str
-        :returns: none
         :raises RuntimeError: If the vxlan protocol field verify fails.
         """
         # get the vxlan packet and check it
@@ -89,7 +86,6 @@ class VerifyPacket(object):
         :param test_type: the functional test type.
         :type payload_data: str
         :type test_type: str
-        :returns: none
         :raises RuntimeError: If the vxlangpe and nsh protocol
                               field verify fails.
         """
@@ -108,9 +104,13 @@ class VerifyPacket(object):
 
         # get the NSH packet and check it
         nsh_pkt = NSH(payload_data[8:32])
-        if nsh_pkt.flags != sfccon.NSH_FLAGS:
-            raise RuntimeError("Unexpected NSH flags: {0}".
-                               format(nsh_pkt.flags))
+        if nsh_pkt.Version != 0:
+            raise RuntimeError("Unexpected NSH version: {0}".
+                               format(nsh_pkt.Version))
+
+        if nsh_pkt.OAM != 0 and nsh_pkt.OAM != 1:
+            raise RuntimeError("Unexpected NSH OAM: {0}".
+                               format(nsh_pkt.OAM))
 
         if nsh_pkt.length != sfccon.NSH_HEADER_LENGTH:
             raise RuntimeError("NSH length {0} incorrect".
@@ -169,7 +169,6 @@ class VerifyPacket(object):
         :type ether: scapy.Ether
         :type frame_size: Integer
         :type test_type: str
-        :returns: none
         :raises RuntimeError: If the packet field verify fails.
         """
 
@@ -185,9 +184,9 @@ class VerifyPacket(object):
 
         recv_pkt_len = len(ether)
         if recv_pkt_len != expect_pkt_len:
-            raise RuntimeError("Received packet size {0} not " \
-                               "the expect size {1}".format(recv_pkt_len, \
-                               expect_pkt_len))
+            raise RuntimeError("Received packet size {0} not "
+                               "the expect size {1}".format(recv_pkt_len,
+                                                            expect_pkt_len))
 
         if not ether.haslayer(IP):
             raise RuntimeError("Not a IPv4 packet")