VPP-1508 Python3 abstract classes
Update the syntax to support abstract classes in python 2 and python 3. Depends on: new style classes -- https://gerrit.fd.io/r/16166 Change-Id: Iad2c1240149f38b3faca1b37ab95d3d210e1daee Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
This commit is contained in:

committed by
Damjan Marion

parent
dd3737284d
commit
3bce8ebfdf
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from abc import abstractmethod, ABCMeta
|
||||
import abc
|
||||
import six
|
||||
|
||||
from scapy.layers.l2 import Ether, Raw
|
||||
from scapy.layers.inet import IP, UDP
|
||||
@ -8,9 +9,9 @@ from scapy.layers.inet import IP, UDP
|
||||
from util import ip4_range
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BridgeDomain(object):
|
||||
""" Bridge domain abstraction """
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
@property
|
||||
def frame_request(self):
|
||||
@ -28,27 +29,27 @@ class BridgeDomain(object):
|
||||
UDP(sport=20000, dport=10000) /
|
||||
Raw('\xa5' * 100))
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def ip_range(self, start, end):
|
||||
""" range of remote ip's """
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def encap_mcast(self, pkt, src_ip, src_mac, vni):
|
||||
""" Encapsulate mcast packet """
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def encapsulate(self, pkt, vni):
|
||||
""" Encapsulate packet """
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def decapsulate(self, pkt):
|
||||
""" Decapsulate packet """
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def check_encapsulation(self, pkt, vni, local_only=False):
|
||||
""" Verify the encapsulation """
|
||||
pass
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import abc
|
||||
import six
|
||||
import unittest
|
||||
|
||||
from scapy.fields import BitField, ByteField, FlagsField, IntField
|
||||
@ -28,6 +31,7 @@ bind_layers(LISP_GPE_Header, IPv6, next_proto=2)
|
||||
bind_layers(LISP_GPE_Header, Ether, next_proto=3)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Driver(object):
|
||||
|
||||
config_order = ['locator-sets',
|
||||
@ -61,7 +65,7 @@ class Driver(object):
|
||||
Raw(payload))
|
||||
return packet
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def run(self):
|
||||
""" testing procedure """
|
||||
pass
|
||||
|
@ -1,9 +1,10 @@
|
||||
""" test framework utilities """
|
||||
|
||||
import abc
|
||||
import socket
|
||||
import six
|
||||
import sys
|
||||
import os.path
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from scapy.utils6 import in6_mactoifaceid
|
||||
|
||||
from scapy.layers.l2 import Ether
|
||||
@ -93,11 +94,9 @@ def check_core_path(logger, core_path):
|
||||
|
||||
|
||||
class NumericConstant(object):
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
desc_dict = {}
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, value):
|
||||
self._value = value
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
import binascii
|
||||
import socket
|
||||
from abc import abstractmethod, ABCMeta
|
||||
import abc
|
||||
|
||||
import six
|
||||
from six import moves
|
||||
|
||||
from util import Host, mk_ll_addr
|
||||
from vpp_papi import mac_ntop
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VppInterface(object):
|
||||
"""Generic VPP interface."""
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
@property
|
||||
def sw_if_index(self):
|
||||
@ -181,7 +182,7 @@ class VppInterface(object):
|
||||
self._hosts_by_ip4[ip4] = host
|
||||
self._hosts_by_ip6[ip6] = host
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def __init__(self, test):
|
||||
self._test = test
|
||||
|
||||
|
@ -1,32 +1,33 @@
|
||||
""" abstract vpp object and object registry """
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
import abc
|
||||
import six
|
||||
|
||||
from six import moves
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VppObject(object):
|
||||
""" Abstract vpp object """
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def add_vpp_config(self):
|
||||
""" Add the configuration for this object to vpp. """
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def query_vpp_config(self):
|
||||
"""Query the vpp configuration.
|
||||
|
||||
:return: True if the object is configured"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def remove_vpp_config(self):
|
||||
""" Remove the configuration for this object from vpp. """
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def object_id(self):
|
||||
""" Return a unique string representing this object. """
|
||||
pass
|
||||
|
@ -1,12 +1,13 @@
|
||||
from scapy.layers.l2 import Dot1Q
|
||||
from abc import abstractmethod, ABCMeta
|
||||
import abc
|
||||
import six
|
||||
from vpp_pg_interface import VppPGInterface
|
||||
from vpp_papi_provider import L2_VTR_OP
|
||||
from vpp_interface import VppInterface
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VppSubInterface(VppPGInterface):
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
@ -42,11 +43,11 @@ class VppSubInterface(VppPGInterface):
|
||||
super(VppSubInterface, self).set_sw_if_index(sw_if_index)
|
||||
self.set_vtr(L2_VTR_OP.L2_DISABLED)
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def create_arp_req(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def create_ndp_req(self):
|
||||
pass
|
||||
|
||||
@ -56,7 +57,7 @@ class VppSubInterface(VppPGInterface):
|
||||
def resolve_ndp(self):
|
||||
super(VppSubInterface, self).resolve_ndp(self.parent)
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def add_dot1_layer(self, pkt):
|
||||
pass
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
from abc import abstractmethod, ABCMeta
|
||||
import abc
|
||||
import six
|
||||
from vpp_pg_interface import is_ipv6_misc
|
||||
from vpp_interface import VppInterface
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VppTunnelInterface(VppInterface):
|
||||
""" VPP tunnel interface abstration """
|
||||
__metaclass__ = ABCMeta
|
||||
""" VPP tunnel interface abstraction """
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, test, parent_if):
|
||||
super(VppTunnelInterface, self).__init__(test)
|
||||
self.parent_if = parent_if
|
||||
|
Reference in New Issue
Block a user