Bump hacking
hacking 3.2.x is quite old. Bump it to the version currently used by neutron. Change-Id: I69b4633b46a84d9dd7c6995a76379cf1072a304c
This commit is contained in:
parent
57e1270e16
commit
0309145258
@ -21,8 +21,9 @@ import numbers
|
||||
from os_ken.base import app_manager
|
||||
|
||||
from os_ken.controller import ofp_event
|
||||
from os_ken.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER,\
|
||||
DEAD_DISPATCHER
|
||||
from os_ken.controller.handler import CONFIG_DISPATCHER
|
||||
from os_ken.controller.handler import DEAD_DISPATCHER
|
||||
from os_ken.controller.handler import MAIN_DISPATCHER
|
||||
from os_ken.controller.handler import set_ev_cls
|
||||
|
||||
from . import event
|
||||
|
@ -29,8 +29,9 @@ from os_ken import utils
|
||||
from os_ken.controller import ofp_event
|
||||
from os_ken.controller.controller import OpenFlowController
|
||||
from os_ken.controller.handler import set_ev_handler
|
||||
from os_ken.controller.handler import HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER,\
|
||||
MAIN_DISPATCHER
|
||||
from os_ken.controller.handler import CONFIG_DISPATCHER
|
||||
from os_ken.controller.handler import HANDSHAKE_DISPATCHER
|
||||
from os_ken.controller.handler import MAIN_DISPATCHER
|
||||
from os_ken.ofproto import ofproto_parser
|
||||
|
||||
|
||||
|
@ -115,8 +115,8 @@ class tcp(packet_base.PacketBase):
|
||||
from os_ken.ofproto.ofproto_common import OFP_TCP_PORT, OFP_SSL_PORT_OLD
|
||||
if bgp.TCP_SERVER_PORT in [src_port, dst_port]:
|
||||
return bgp.BGPMessage
|
||||
elif(src_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD] or
|
||||
dst_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD]):
|
||||
elif (src_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD] or
|
||||
dst_port in [OFP_TCP_PORT, OFP_SSL_PORT_OLD]):
|
||||
return openflow.openflow
|
||||
elif src_port == zebra.ZEBRA_PORT:
|
||||
return zebra._ZebraMessageFromZebra
|
||||
|
@ -159,7 +159,7 @@ VRRP_V2_MAX_ADVER_INT_MAX = 0xff
|
||||
|
||||
|
||||
def is_ipv6(ip_address):
|
||||
assert type(ip_address) == str
|
||||
assert isinstance(ip_address, str)
|
||||
try:
|
||||
addrconv.ipv4.text_to_bin(ip_address)
|
||||
except:
|
||||
@ -595,11 +595,11 @@ class vrrpv3(vrrp):
|
||||
@staticmethod
|
||||
def serialize_static(vrrp_, prev):
|
||||
if isinstance(prev, ipv4.ipv4):
|
||||
assert type(vrrp_.ip_addresses[0]) == str
|
||||
assert isinstance(vrrp_.ip_addresses[0], str)
|
||||
conv = addrconv.ipv4.text_to_bin
|
||||
ip_address_pack_raw = vrrpv3._IPV4_ADDRESS_PACK_STR_RAW
|
||||
elif isinstance(prev, ipv6.ipv6):
|
||||
assert type(vrrp_.ip_addresses[0]) == str
|
||||
assert isinstance(vrrp_.ip_addresses[0], str)
|
||||
conv = addrconv.ipv6.text_to_bin
|
||||
ip_address_pack_raw = vrrpv3._IPV6_ADDRESS_PACK_STR_RAW
|
||||
else:
|
||||
|
@ -865,7 +865,7 @@ class Port(object):
|
||||
if new_state is not PORT_STATE_DISABLE:
|
||||
self.ofctl.set_port_status(self.ofport, new_state)
|
||||
|
||||
if(new_state is PORT_STATE_FORWARD
|
||||
if (new_state is PORT_STATE_FORWARD
|
||||
or (self.state is PORT_STATE_FORWARD
|
||||
and (new_state is PORT_STATE_DISABLE
|
||||
or new_state is PORT_STATE_BLOCK))):
|
||||
|
@ -370,7 +370,7 @@ def obj_python_attrs(msg_):
|
||||
# ofp parser implementations.
|
||||
if hasattr(msg_, '_fields'):
|
||||
for k in msg_._fields:
|
||||
yield(k, getattr(msg_, k))
|
||||
yield (k, getattr(msg_, k))
|
||||
return
|
||||
base = getattr(msg_, '_base_attributes', [])
|
||||
opt = getattr(msg_, '_opt_attributes', [])
|
||||
|
@ -160,20 +160,20 @@ OFPTMPEF_LIFETIME = 1 << 2 # Using flow entry lifetime.
|
||||
# struct ofp_table_mod_prop_eviction
|
||||
OFP_TABLE_MOD_PROP_EVICTION_PACK_STR = '!HHI'
|
||||
OFP_TABLE_MOD_PROP_EVICTION_SIZE = 8
|
||||
assert(calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EVICTION_SIZE)
|
||||
assert (calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EVICTION_SIZE)
|
||||
|
||||
# struct ofp_table_mod_prop_vacancy
|
||||
OFP_TABLE_MOD_PROP_VACANCY_PACK_STR = '!HHBBBx'
|
||||
OFP_TABLE_MOD_PROP_VACANCY_SIZE = 8
|
||||
assert(calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_VACANCY_SIZE)
|
||||
assert (calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_VACANCY_SIZE)
|
||||
|
||||
# struct ofp_table_mod_prop_experimenter
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR = '!HHII'
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE = 12
|
||||
assert(calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
|
||||
assert (calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
|
||||
|
||||
# struct ofp_table_mod
|
||||
OFP_TABLE_MOD_PACK_STR = '!B3xI'
|
||||
|
@ -162,20 +162,20 @@ OFPTMPEF_LIFETIME = 1 << 2 # Using flow entry lifetime.
|
||||
# struct ofp_table_mod_prop_eviction
|
||||
OFP_TABLE_MOD_PROP_EVICTION_PACK_STR = '!HHI'
|
||||
OFP_TABLE_MOD_PROP_EVICTION_SIZE = 8
|
||||
assert(calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EVICTION_SIZE)
|
||||
assert (calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EVICTION_SIZE)
|
||||
|
||||
# struct ofp_table_mod_prop_vacancy
|
||||
OFP_TABLE_MOD_PROP_VACANCY_PACK_STR = '!HHBBBx'
|
||||
OFP_TABLE_MOD_PROP_VACANCY_SIZE = 8
|
||||
assert(calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_VACANCY_SIZE)
|
||||
assert (calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_VACANCY_SIZE)
|
||||
|
||||
# struct ofp_table_mod_prop_experimenter
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR = '!HHII'
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE = 12
|
||||
assert(calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
|
||||
assert (calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
|
||||
OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
|
||||
|
||||
# struct ofp_table_mod
|
||||
OFP_TABLE_MOD_PACK_STR = '!B3xI'
|
||||
|
@ -368,8 +368,8 @@ def add_evpn_local(route_type, route_dist, next_hop, **kwargs):
|
||||
"""Adds EVPN route from VRF identified by *route_dist*.
|
||||
"""
|
||||
|
||||
if(route_type in [EVPN_ETH_AUTO_DISCOVERY, EVPN_ETH_SEGMENT]
|
||||
and kwargs['esi'] == 0):
|
||||
if (route_type in [EVPN_ETH_AUTO_DISCOVERY, EVPN_ETH_SEGMENT]
|
||||
and kwargs['esi'] == 0):
|
||||
raise ConfigValueError(conf_name=EVPN_ESI,
|
||||
conf_value=kwargs['esi'])
|
||||
|
||||
|
@ -428,7 +428,7 @@ class Destination(object, metaclass=abc.ABCMeta):
|
||||
Returns *True* if any of the known paths were found to be old and
|
||||
removed/deleted.
|
||||
"""
|
||||
assert(source and hasattr(source, 'version_num'))
|
||||
assert (source and hasattr(source, 'version_num'))
|
||||
removed_paths = []
|
||||
# Iterate over the paths in reverse order as we want to delete paths
|
||||
# whose source is this peer.
|
||||
@ -438,7 +438,7 @@ class Destination(object, metaclass=abc.ABCMeta):
|
||||
if (path.source == source and
|
||||
path.source_version_num < source_ver_num):
|
||||
# If this peer is source of any paths, remove those path.
|
||||
del(self._known_path_list[path_idx])
|
||||
del self._known_path_list[path_idx]
|
||||
removed_paths.append(path)
|
||||
return removed_paths
|
||||
|
||||
@ -485,7 +485,7 @@ class Destination(object, metaclass=abc.ABCMeta):
|
||||
# If we do not have any old but one new path
|
||||
# it becomes best path.
|
||||
self._known_path_list.append(self._new_path_list[0])
|
||||
del(self._new_path_list[0])
|
||||
del self._new_path_list[0]
|
||||
return self._known_path_list[0], BPR_ONLY_PATH
|
||||
|
||||
# If we have a new version of old/known path we use it and delete old
|
||||
@ -496,7 +496,7 @@ class Destination(object, metaclass=abc.ABCMeta):
|
||||
self._known_path_list.extend(self._new_path_list)
|
||||
|
||||
# Clear new paths as we copied them.
|
||||
del(self._new_path_list[:])
|
||||
del self._new_path_list[:]
|
||||
|
||||
# If we do not have any paths to this destination, then we do not have
|
||||
# new best path.
|
||||
@ -528,7 +528,7 @@ class Destination(object, metaclass=abc.ABCMeta):
|
||||
if not self._known_path_list:
|
||||
LOG.debug('Found %s withdrawals for path(s) that did not get'
|
||||
' installed.', len(self._withdraw_list))
|
||||
del(self._withdraw_list[:])
|
||||
del self._withdraw_list[:]
|
||||
return
|
||||
|
||||
# If we have some known paths and some withdrawals, we find matches and
|
||||
@ -1193,7 +1193,7 @@ class AttributeMap(object):
|
||||
|
||||
def __init__(self, filters, attr_type, attr_value):
|
||||
|
||||
assert all(isinstance(f, Filter) for f in filters),\
|
||||
assert all(isinstance(f, Filter) for f in filters), \
|
||||
'all the items in filters must be an instance of Filter sub-class'
|
||||
self.filters = filters
|
||||
self.attr_type = attr_type
|
||||
|
@ -51,7 +51,7 @@ class OutgoingRoute(object):
|
||||
'next_sink_out_route', 'prev_sink_out_route')
|
||||
|
||||
def __init__(self, path, for_route_refresh=False):
|
||||
assert(path)
|
||||
assert path
|
||||
|
||||
self.sink = None
|
||||
|
||||
@ -145,7 +145,7 @@ class SentRoute(object):
|
||||
"""
|
||||
|
||||
def __init__(self, path, peer, filtered=None, timestamp=None):
|
||||
assert(path and hasattr(peer, 'version_num'))
|
||||
assert (path and hasattr(peer, 'version_num'))
|
||||
|
||||
self.path = path
|
||||
|
||||
@ -175,7 +175,7 @@ class ReceivedRoute(object):
|
||||
"""
|
||||
|
||||
def __init__(self, path, peer, filtered=None, timestamp=None):
|
||||
assert(path and hasattr(peer, 'version_num'))
|
||||
assert (path and hasattr(peer, 'version_num'))
|
||||
|
||||
self.path = path
|
||||
|
||||
|
@ -66,24 +66,24 @@ class CircularListType(object):
|
||||
self.list_type.node_init(self.head)
|
||||
|
||||
def __getattr__(self, name):
|
||||
if(name == self.list_type.next_name):
|
||||
if name == self.list_type.next_name:
|
||||
return self._next_slot_
|
||||
|
||||
if(name == self.list_type.prev_name):
|
||||
if name == self.list_type.prev_name:
|
||||
return self._prev_slot_
|
||||
|
||||
raise AttributeError(name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if(name in CircularListType.List.__slots__):
|
||||
if name in CircularListType.List.__slots__:
|
||||
object.__setattr__(self, name, value)
|
||||
return
|
||||
|
||||
if(name == self.list_type.next_name):
|
||||
if name == self.list_type.next_name:
|
||||
self._next_slot_ = value
|
||||
return
|
||||
|
||||
if(name == self.list_type.prev_name):
|
||||
if name == self.list_type.prev_name:
|
||||
self._prev_slot_ = value
|
||||
return
|
||||
|
||||
@ -124,7 +124,7 @@ class CircularListType(object):
|
||||
def pop_first(self):
|
||||
"""Remove the first item in the list and return it."""
|
||||
node = self.list_type.node_next(self.head)
|
||||
if(node is self.head):
|
||||
if node is self.head:
|
||||
return None
|
||||
|
||||
self.remove(node)
|
||||
@ -141,7 +141,7 @@ class CircularListType(object):
|
||||
# current node safely.
|
||||
node = self.list_type.node_next(self.head)
|
||||
next = self.list_type.node_next(node)
|
||||
while(node is not self.head):
|
||||
while node is not self.head:
|
||||
yield node
|
||||
|
||||
node = next
|
||||
@ -176,7 +176,7 @@ class CircularListType(object):
|
||||
return self.create()
|
||||
|
||||
def node_init(self, node):
|
||||
assert(not self.node_is_on_list(node))
|
||||
assert (not self.node_is_on_list(node))
|
||||
|
||||
# Set the node to point to itself as the previous and next
|
||||
# entries.
|
||||
@ -219,7 +219,7 @@ class CircularListType(object):
|
||||
"""
|
||||
next = self.node_next(node)
|
||||
if next == node or next is None:
|
||||
assert(self.node_prev(node) is next)
|
||||
assert (self.node_prev(node) is next)
|
||||
return False
|
||||
|
||||
return True
|
||||
@ -227,11 +227,11 @@ class CircularListType(object):
|
||||
def node_insert_after(self, node, new_node):
|
||||
"""Insert the new node after node."""
|
||||
|
||||
assert(not self.node_is_on_list(new_node))
|
||||
assert(node is not new_node)
|
||||
assert (not self.node_is_on_list(new_node))
|
||||
assert (node is not new_node)
|
||||
|
||||
next = self.node_next(node)
|
||||
assert(next is not None)
|
||||
assert (next is not None)
|
||||
self.node_set_next(node, new_node)
|
||||
self.node_set_prev(new_node, node)
|
||||
|
||||
@ -241,11 +241,11 @@ class CircularListType(object):
|
||||
def node_insert_before(self, node, new_node):
|
||||
"""Insert the new node before node."""
|
||||
|
||||
assert(not self.node_is_on_list(new_node))
|
||||
assert(node is not new_node)
|
||||
assert (not self.node_is_on_list(new_node))
|
||||
assert (node is not new_node)
|
||||
|
||||
prev = self.node_prev(node)
|
||||
assert(prev is not None)
|
||||
assert (prev is not None)
|
||||
self.node_set_prev(node, new_node)
|
||||
self.node_set_next(new_node, node)
|
||||
|
||||
|
@ -79,11 +79,11 @@ class TestOfproto_Parser(unittest.TestCase):
|
||||
self.bufFeaturesReply)
|
||||
LOG.debug(msg)
|
||||
|
||||
self.assertTrue(isinstance(msg, ofproto_v1_0_parser.OFPSwitchFeatures))
|
||||
self.assertIsInstance(msg, ofproto_v1_0_parser.OFPSwitchFeatures)
|
||||
LOG.debug(msg.ports[65534])
|
||||
self.assertTrue(isinstance(msg.ports[1], ofproto_v1_0_parser.OFPPhyPort))
|
||||
self.assertTrue(isinstance(msg.ports[2], ofproto_v1_0_parser.OFPPhyPort))
|
||||
self.assertTrue(isinstance(msg.ports[65534], ofproto_v1_0_parser.OFPPhyPort))
|
||||
self.assertIsInstance(msg.ports[1], ofproto_v1_0_parser.OFPPhyPort)
|
||||
self.assertIsInstance(msg.ports[2], ofproto_v1_0_parser.OFPPhyPort)
|
||||
self.assertIsInstance(msg.ports[65534], ofproto_v1_0_parser.OFPPhyPort)
|
||||
|
||||
def testPacketIn(self):
|
||||
(version,
|
||||
@ -98,7 +98,7 @@ class TestOfproto_Parser(unittest.TestCase):
|
||||
xid,
|
||||
self.bufPacketIn)
|
||||
LOG.debug(msg)
|
||||
self.assertTrue(isinstance(msg, ofproto_v1_0_parser.OFPPacketIn))
|
||||
self.assertIsInstance(msg, ofproto_v1_0_parser.OFPPacketIn)
|
||||
|
||||
def test_check_msg_len(self):
|
||||
(version,
|
||||
|
@ -259,13 +259,13 @@ class Test_Parser_OFPMatch(testscenarios.WithScenarios, unittest.TestCase):
|
||||
match.serialize(b, 0)
|
||||
match2 = match.parser(bytes(b), 0)
|
||||
for k, v in d.items():
|
||||
self.assertTrue(k in match)
|
||||
self.assertTrue(k in match2)
|
||||
self.assertIn(k, match)
|
||||
self.assertIn(k, match2)
|
||||
self.assertEqual(match[k], v)
|
||||
self.assertEqual(match2[k], v)
|
||||
for k, v in match.iteritems():
|
||||
self.assertTrue(k in d)
|
||||
self.assertIn(k, d)
|
||||
self.assertEqual(d[k], v)
|
||||
for k, v in match2.iteritems():
|
||||
self.assertTrue(k in d)
|
||||
self.assertIn(k, d)
|
||||
self.assertEqual(d[k], v)
|
||||
|
@ -176,13 +176,13 @@ class Test_Parser_OFPStats(testscenarios.WithScenarios, unittest.TestCase):
|
||||
stats.serialize(b, 0)
|
||||
stats2 = stats.parser(bytes(b), 0)
|
||||
for k, v in d.items():
|
||||
self.assertTrue(k in stats)
|
||||
self.assertTrue(k in stats2)
|
||||
self.assertIn(k, stats)
|
||||
self.assertIn(k, stats2)
|
||||
self.assertEqual(stats[k], v)
|
||||
self.assertEqual(stats2[k], v)
|
||||
for k, v in stats.iteritems():
|
||||
self.assertTrue(k in d)
|
||||
self.assertIn(k, d)
|
||||
self.assertEqual(d[k], v)
|
||||
for k, v in stats2.iteritems():
|
||||
self.assertTrue(k in d)
|
||||
self.assertIn(k, d)
|
||||
self.assertEqual(d[k], v)
|
||||
|
@ -94,23 +94,23 @@ class TestBFD(unittest.TestCase):
|
||||
pkt = packet.Packet(buf)
|
||||
i = iter(pkt)
|
||||
|
||||
self.assertEqual(type(next(i)), ethernet.ethernet)
|
||||
self.assertEqual(type(next(i)), ipv4.ipv4)
|
||||
self.assertEqual(type(next(i)), udp.udp)
|
||||
self.assertEqual(type(bfd.bfd.parser(next(i))[0]), bfd.bfd)
|
||||
self.assertIsInstance(next(i), ethernet.ethernet)
|
||||
self.assertIsInstance(next(i), ipv4.ipv4)
|
||||
self.assertIsInstance(next(i), udp.udp)
|
||||
self.assertIsInstance(bfd.bfd.parser(next(i))[0], bfd.bfd)
|
||||
|
||||
def test_parse_with_auth_simple(self):
|
||||
buf = self.data_auth_simple
|
||||
pkt = packet.Packet(buf)
|
||||
i = iter(pkt)
|
||||
|
||||
self.assertEqual(type(next(i)), ethernet.ethernet)
|
||||
self.assertEqual(type(next(i)), ipv4.ipv4)
|
||||
self.assertEqual(type(next(i)), udp.udp)
|
||||
self.assertIsInstance(next(i), ethernet.ethernet)
|
||||
self.assertIsInstance(next(i), ipv4.ipv4)
|
||||
self.assertIsInstance(next(i), udp.udp)
|
||||
|
||||
bfd_obj = bfd.bfd.parser(next(i))[0]
|
||||
self.assertEqual(type(bfd_obj), bfd.bfd)
|
||||
self.assertEqual(type(bfd_obj.auth_cls), bfd.SimplePassword)
|
||||
self.assertIsInstance(bfd_obj, bfd.bfd)
|
||||
self.assertIsInstance(bfd_obj.auth_cls, bfd.SimplePassword)
|
||||
self.assertTrue(bfd_obj.authenticate(self.auth_keys))
|
||||
|
||||
def test_parse_with_auth_md5(self):
|
||||
@ -118,13 +118,13 @@ class TestBFD(unittest.TestCase):
|
||||
pkt = packet.Packet(buf)
|
||||
i = iter(pkt)
|
||||
|
||||
self.assertEqual(type(next(i)), ethernet.ethernet)
|
||||
self.assertEqual(type(next(i)), ipv4.ipv4)
|
||||
self.assertEqual(type(next(i)), udp.udp)
|
||||
self.assertIsInstance(next(i), ethernet.ethernet)
|
||||
self.assertIsInstance(next(i), ipv4.ipv4)
|
||||
self.assertIsInstance(next(i), udp.udp)
|
||||
|
||||
bfd_obj = bfd.bfd.parser(next(i))[0]
|
||||
self.assertEqual(type(bfd_obj), bfd.bfd)
|
||||
self.assertEqual(type(bfd_obj.auth_cls), bfd.KeyedMD5)
|
||||
self.assertIsInstance(bfd_obj, bfd.bfd)
|
||||
self.assertIsInstance(bfd_obj.auth_cls, bfd.KeyedMD5)
|
||||
self.assertTrue(bfd_obj.authenticate(self.auth_keys))
|
||||
|
||||
def test_parse_with_auth_sha1(self):
|
||||
@ -132,13 +132,13 @@ class TestBFD(unittest.TestCase):
|
||||
pkt = packet.Packet(buf)
|
||||
i = iter(pkt)
|
||||
|
||||
self.assertEqual(type(next(i)), ethernet.ethernet)
|
||||
self.assertEqual(type(next(i)), ipv4.ipv4)
|
||||
self.assertEqual(type(next(i)), udp.udp)
|
||||
self.assertIsInstance(next(i), ethernet.ethernet)
|
||||
self.assertIsInstance(next(i), ipv4.ipv4)
|
||||
self.assertIsInstance(next(i), udp.udp)
|
||||
|
||||
bfd_obj = bfd.bfd.parser(next(i))[0]
|
||||
self.assertEqual(type(bfd_obj), bfd.bfd)
|
||||
self.assertEqual(type(bfd_obj.auth_cls), bfd.KeyedSHA1)
|
||||
self.assertIsInstance(bfd_obj, bfd.bfd)
|
||||
self.assertIsInstance(bfd_obj.auth_cls, bfd.KeyedSHA1)
|
||||
self.assertTrue(bfd_obj.authenticate(self.auth_keys))
|
||||
|
||||
def test_serialize(self):
|
||||
|
@ -130,11 +130,11 @@ class Test_dhcp_offer(unittest.TestCase):
|
||||
corrupt_buf = self.buf[:-4]
|
||||
pkt, _, rest = dhcp.dhcp.parser(corrupt_buf)
|
||||
|
||||
self.assertTrue(isinstance(pkt, dhcp.dhcp))
|
||||
self.assertTrue(isinstance(pkt.options, dhcp.options))
|
||||
self.assertIsInstance(pkt, dhcp.dhcp)
|
||||
self.assertIsInstance(pkt.options, dhcp.options)
|
||||
for opt in pkt.options.option_list[:-1]:
|
||||
self.assertTrue(isinstance(opt, dhcp.option))
|
||||
self.assertTrue(isinstance(pkt.options.option_list[-1], bytes))
|
||||
self.assertIsInstance(opt, dhcp.option)
|
||||
self.assertIsInstance(pkt.options.option_list[-1], bytes)
|
||||
|
||||
buf = pkt.serialize()
|
||||
self.assertEqual(str(buf), str(corrupt_buf))
|
||||
|
@ -70,8 +70,8 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
pkt = packet.Packet(buf)
|
||||
i = iter(pkt)
|
||||
|
||||
self.assertEqual(type(next(i)), ethernet.ethernet)
|
||||
self.assertEqual(type(next(i)), lldp.lldp)
|
||||
self.assertIsInstance(next(i), ethernet.ethernet)
|
||||
self.assertIsInstance(next(i), lldp.lldp)
|
||||
|
||||
def test_tlv(self):
|
||||
tlv = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
@ -246,9 +246,9 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
pkt = packet.Packet(buf)
|
||||
i = iter(pkt)
|
||||
|
||||
self.assertEqual(type(next(i)), ethernet.ethernet)
|
||||
self.assertIsInstance(next(i), ethernet.ethernet)
|
||||
lldp_pkt = next(i)
|
||||
self.assertEqual(type(lldp_pkt), lldp.lldp)
|
||||
self.assertIsInstance(lldp_pkt, lldp.lldp)
|
||||
|
||||
tlvs = lldp_pkt.tlvs
|
||||
|
||||
|
@ -368,7 +368,7 @@ class TestPacket(unittest.TestCase):
|
||||
self.assertEqual(packet_utils.checksum(t), 0)
|
||||
|
||||
# payload
|
||||
self.assertTrue('payload' in protocols)
|
||||
self.assertIn('payload', protocols)
|
||||
self.assertEqual(self.payload, protocols['payload'])
|
||||
|
||||
# to string
|
||||
@ -518,7 +518,7 @@ class TestPacket(unittest.TestCase):
|
||||
self.assertEqual(packet_utils.checksum(t), 0)
|
||||
|
||||
# payload
|
||||
self.assertTrue('payload' in protocols)
|
||||
self.assertIn('payload', protocols)
|
||||
self.assertEqual(self.payload, protocols['payload'])
|
||||
|
||||
# to string
|
||||
@ -939,7 +939,7 @@ class TestPacket(unittest.TestCase):
|
||||
self.assertEqual(packet_utils.checksum(t), 0x62)
|
||||
|
||||
# payload
|
||||
self.assertTrue('payload' in protocols)
|
||||
self.assertIn('payload', protocols)
|
||||
self.assertEqual(self.payload, protocols['payload'])
|
||||
|
||||
# to string
|
||||
@ -1071,7 +1071,7 @@ class TestPacket(unittest.TestCase):
|
||||
self.assertEqual(packet_utils.checksum(t), 0x62)
|
||||
|
||||
# payload
|
||||
self.assertTrue('payload' in protocols)
|
||||
self.assertIn('payload', protocols)
|
||||
self.assertEqual(self.payload, protocols['payload'])
|
||||
|
||||
# to string
|
||||
@ -1544,7 +1544,7 @@ class TestPacket(unittest.TestCase):
|
||||
i = ipv4.ipv4()
|
||||
u = udp.udp(self.src_port, self.dst_port)
|
||||
pkt = e / i / u
|
||||
self.assertTrue(isinstance(pkt, packet.Packet))
|
||||
self.assertTrue(isinstance(pkt.protocols[0], ethernet.ethernet))
|
||||
self.assertTrue(isinstance(pkt.protocols[1], ipv4.ipv4))
|
||||
self.assertTrue(isinstance(pkt.protocols[2], udp.udp))
|
||||
self.assertIsInstance(pkt, packet.Packet)
|
||||
self.assertIsInstance(pkt.protocols[0], ethernet.ethernet)
|
||||
self.assertIsInstance(pkt.protocols[1], ipv4.ipv4)
|
||||
self.assertIsInstance(pkt.protocols[2], udp.udp)
|
||||
|
@ -133,13 +133,13 @@ class Test_itag(unittest.TestCase):
|
||||
|
||||
e = p.get_protocols(ethernet.ethernet)
|
||||
self.assertTrue(e)
|
||||
self.assertTrue(isinstance(e, list))
|
||||
self.assertIsInstance(e, list)
|
||||
self.assertEqual(e[0].ethertype, ether.ETH_TYPE_8021AD)
|
||||
self.assertEqual(e[1].ethertype, ether.ETH_TYPE_8021AD)
|
||||
|
||||
sv = p.get_protocols(vlan.svlan)
|
||||
self.assertTrue(sv)
|
||||
self.assertTrue(isinstance(sv, list))
|
||||
self.assertIsInstance(sv, list)
|
||||
self.assertEqual(sv[0].ethertype, ether.ETH_TYPE_8021Q)
|
||||
self.assertEqual(sv[1].ethertype, ether.ETH_TYPE_8021Q)
|
||||
|
||||
|
@ -465,10 +465,10 @@ class LLDPPacket(object):
|
||||
pkt = packet.Packet(data)
|
||||
i = iter(pkt)
|
||||
eth_pkt = next(i)
|
||||
assert type(eth_pkt) == ethernet.ethernet
|
||||
assert isinstance(eth_pkt, ethernet.ethernet)
|
||||
|
||||
lldp_pkt = next(i)
|
||||
if type(lldp_pkt) != lldp.lldp:
|
||||
if not isinstance(lldp_pkt, lldp.lldp):
|
||||
raise LLDPPacket.LLDPUnknownFormat()
|
||||
|
||||
tlv_chassis_id = lldp_pkt.tlvs[0]
|
||||
|
@ -1,4 +1,4 @@
|
||||
hacking>=3.2.0,<3.3.0 # Apache-2.0
|
||||
hacking>=6.1.0,<6.2.0 # Apache-2.0
|
||||
|
||||
coverage>=4.4.1 # Apache-2.0
|
||||
python-subunit>=1.0.0 # Apache-2.0/BSD
|
||||
|
Loading…
Reference in New Issue
Block a user