Beispiel #1
0
    def sethwaddr(self, addr: str) -> None:
        """
        Set hardware address.

        :param addr: hardware address to set to.
        :return: nothing
        """
        if addr is not None:
            addr = utils.validate_mac(addr)
        self.hwaddr = addr
Beispiel #2
0
    def sethwaddr(self, ifindex: int, addr: str) -> None:
        """
        Set hardware address for an interface.

        :param ifindex: index of interface to set hardware address for
        :param addr: hardware address to set
        :return: nothing
        :raises CoreCommandError: when a non-zero exit status occurs
        """
        addr = utils.validate_mac(addr)
        interface = self._netif[ifindex]
        interface.sethwaddr(addr)
        if self.up:
            self.net_client.device_mac(interface.name, addr)
Beispiel #3
0
 def test_validate_mac_exception(self, data: str):
     with pytest.raises(CoreError):
         utils.validate_mac(data)
Beispiel #4
0
 def test_validate_mac(self, data: str, expected: str):
     value = utils.validate_mac(data)
     assert value == expected