loxi-prep: change vendor tests to use action classes from pyloxi
diff --git a/tests/bsn_mirror.py b/tests/bsn_mirror.py
index 87ca463..4a6e970 100644
--- a/tests/bsn_mirror.py
+++ b/tests/bsn_mirror.py
@@ -11,67 +11,6 @@
from oftest.testutils import *
-class bsn_action_mirror(ofp.action.vendor):
- def __init__(self):
- self.type = ofp.OFPAT_VENDOR
- self.len = 24
- self.vendor = 0x005c16c7
- self.subtype = 1
- self.dest_port = 0
- self.vlan_tag = 0
- self.copy_stage = 0
-
- def __assert(self):
- return (True, None)
-
- def pack(self, assertstruct=True):
- return struct.pack("!HHLLLLBBBB", self.type, self.len, self.vendor,
- self.subtype, self.dest_port, self.vlan_tag,
- self.copy_stage, 0, 0, 0)
-
- def unpack(self, binaryString):
- if len(binaryString) < self.len:
- raise Exception("too short")
- x = struct.unpack("!HHLLLLBBBB", binaryString[:self.len])
- if x[0] != self.type:
- raise Exception("wrong type")
- if x[1] != self.len:
- raise Exception("wrong length")
- if x[2] != self.vendor:
- raise Exception("wrong vendor")
- if x[3] != self.subtype:
- raise Exception("wrong subtype")
- self.dest_port = x[4]
- self.vlan_tag = x[5]
- self.copy_stage = x[6]
- return binaryString[self.len:]
-
- def __len__(self):
- return self.len
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vendor != other.vendor: return False
- if self.subtype != other.subtype: return False
- if self.dest_port != other.dest_port: return False
- if self.vlan_tag != other.vlan_tag: return False
- if self.copy_stage != other.copy_stage: return False
- return True
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def show(self, prefix=""):
- outstr = prefix + "action_vendor\n"
- for f in ["type", "len", "vendor", "subtype", "dest_port", "vlan_tag",
- "copy_stage"]:
- outstr += prefix + ("%s: %s\n" % (f, getattr(self, f)))
- return outstr
-
-action_list.action_object_map[ofp.OFPAT_VENDOR] = bsn_action_mirror
-
@nonstandard
class BSNMirrorAction(base_tests.SimpleDataPlane):
"""
@@ -133,10 +72,10 @@
self.assertTrue(p[mirror_ports[1]].config & (1 << 31),
"Mirror port config flag not set in features reply")
- act1 = bsn_action_mirror()
+ act1 = ofp.action.bsn_mirror()
act1.dest_port = mirror_ports[0]
act1.copy_stage = 0
- act2 = bsn_action_mirror()
+ act2 = ofp.action.bsn_mirror()
act2.dest_port = mirror_ports[1]
act2.copy_stage = 0
act3 = ofp.action.output()
diff --git a/tests/nicira_dec_ttl.py b/tests/nicira_dec_ttl.py
index 32d3501..a35d97a 100644
--- a/tests/nicira_dec_ttl.py
+++ b/tests/nicira_dec_ttl.py
@@ -7,20 +7,6 @@
from oftest.testutils import *
-class action_nx_dec_ttl(ofp.action.vendor):
- def __init__(self):
- ofp.action.vendor.__init__(self)
- self.vendor = 0x00002320
-
- def pack(self):
- return ofp.action.vendor.pack(self) + struct.pack("!HHL", 18, 0x0, 0x0)
-
- def __len__(self):
- return 16
-
- def show(self, prefix=''):
- return prefix + 'dec_ttl: ' + '\n' + ofp.action.vendor.show(self)
-
@nonstandard
class TtlDecrement(base_tests.SimpleDataPlane):
def runTest(self):
@@ -35,17 +21,17 @@
flow_match_test(self, config["port_map"],
pkt=simple_tcp_packet(pktlen=100, ip_ttl=2),
exp_pkt=simple_tcp_packet(pktlen=100, ip_ttl=1),
- action_list=[action_nx_dec_ttl()])
+ action_list=[ofp.action.nicira_dec_ttl()])
outpkt = simple_tcp_packet(pktlen=100, ip_ttl=3)
msg = ofp.message.packet_out(in_port=ofp.OFPP_NONE,
data=str(outpkt),
actions=[
- action_nx_dec_ttl(),
+ ofp.action.nicira_dec_ttl(),
ofp.action.output(port=portA),
- action_nx_dec_ttl(),
+ ofp.action.nicira_dec_ttl(),
ofp.action.output(port=portB),
- action_nx_dec_ttl(),
+ ofp.action.nicira_dec_ttl(),
ofp.action.output(port=portC)])
self.controller.message_send(msg)