"""
  MAC Types

"""

from util import mactobinary


class VppMacAddress():
    def __init__(self, addr):
        self.address = addr

    def encode(self):
        return {
            'bytes': self.bytes
        }

    @property
    def bytes(self):
        return mactobinary(self.address)

    @property
    def address(self):
        return self.addr.address

    def __str__(self):
        return self.address

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.address == other.addres
        elif hasattr(other, "bytes"):
            # vl_api_mac_addres_t
            return self.bytes == other.bytes
        else:
            raise Exception("Comparing VppMacAddress:%s"
                            "with unknown type: %s" %
                            (self, other))
        return False

"""
  MAC Types

"""

from util import mactobinary


class VppMacAddress():
    def __init__(self, addr):
        self.address = addr

    def encode(self):
        return {
            'bytes': self.bytes
        }

    @property
    def bytes(self):
        return mactobinary(self.address)

    @property
    def address(self):
        return self.address

    @address.setter
    def address(self, value):
        self.address = value

    def __str__(self):
        return self.address

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.address == other.address
        elif hasattr(other, "bytes"):
            # vl_api_mac_addres_t
            return self.bytes == other.bytes
        else:
            raise TypeError("Comparing VppMacAddress:%s"
                            "with unknown type: %s" %
                            (self, other))
        return False

Fix L2BD arp termination Test Case
Fix L2BD arp termination Test Case

==============================================================================
L2BD arp termination Test Case
==============================================================================
12:02:21,850 Couldn't stat : /tmp/vpp-unittest-TestL2bdArpTerm-_h44qo/stats.sock
L2BD arp term - add 5 hosts, verify arp responses                        OK
L2BD arp term - delete 3 hosts, verify arp responses                     OK
L2BD arp term - recreate BD1, readd 3 hosts, verify arp responses        OK
L2BD arp term - 2 IP4 addrs per host                                     OK
L2BD arp term - create and update 10 IP4-mac pairs                       OK
L2BD arp/ND term - hosts with both ip4/ip6                               OK
L2BD ND term - Add and Del hosts, verify ND replies                      OK
L2BD ND term - Add and update IP+mac, verify ND replies                  OK
L2BD arp term - send garps, verify arp event reports                     OK
L2BD arp term - send duplicate garps, verify suppression                 OK
L2BD arp term - disable ip4 arp events,send garps, verify no events      OK
L2BD ND term - send NS packets verify reports                            OK
L2BD ND term - send duplicate ns, verify suppression                     OK
L2BD ND term - disable ip4 arp events,send ns, verify no events          OK

==============================================================================
TEST RESULTS:
     Scheduled tests: 14
      Executed tests: 14
        Passed tests: 14
==============================================================================

Test run was successful

Change-Id: I6bb1ced11b88080ffaa845d22b0bc471c4f91683
Signed-off-by: Paul Vinciguerra <b92f79aabe4c9c18085c7347110a52af0898a0ef@vinciconsulting.com>
