예제 #1
0
    def addaddr(self, addr: str) -> None:
        """
        Add address.

        :param addr: address to add
        :return: nothing
        """
        addr = utils.validate_ip(addr)
        self.addrlist.append(addr)
예제 #2
0
파일: physical.py 프로젝트: walterhil/core
    def addaddr(self, addr: str) -> None:
        """
        Add address to to network interface.

        :param addr: address to add
        :return: nothing
        :raises CoreCommandError: when there is a command exception
        """
        addr = utils.validate_ip(addr)
        if self.up:
            self.net_client.create_address(self.name, addr)
        self.interface.addaddr(addr)
예제 #3
0
파일: physical.py 프로젝트: walterhil/core
    def addaddr(self, ifindex: int, addr: str) -> None:
        """
        Add an address to an interface.

        :param ifindex: index of interface to add address to
        :param addr: address to add
        :return: nothing
        """
        addr = utils.validate_ip(addr)
        interface = self._netif[ifindex]
        if self.up:
            self.net_client.create_address(interface.name, addr)
        interface.addaddr(addr)
예제 #4
0
    def addaddr(self, ifindex: int, addr: str) -> None:
        """
        Add interface address.

        :param ifindex: index of interface to add address to
        :param addr: address to add to interface
        :return: nothing
        """
        addr = utils.validate_ip(addr)
        interface = self._netif[ifindex]
        interface.addaddr(addr)
        if self.up:
            # ipv4 check
            broadcast = None
            if netaddr.valid_ipv4(addr):
                broadcast = "+"
            self.node_net_client.create_address(interface.name, addr,
                                                broadcast)
예제 #5
0
 def test_validate_ip_exception(self, data: str):
     with pytest.raises(CoreError):
         utils.validate_ip("")
예제 #6
0
 def test_validate_ip(self, data: str, expected: str):
     value = utils.validate_ip(data)
     assert value == expected