diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 8ab5adea..69aa575c 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -806,32 +806,6 @@ class CoreNode(CoreNodeBase): if self.up: self.node_net_client.delete_address(interface.name, str(addr)) - def delalladdr(self, ifindex, address_types=None): - """ - Delete all addresses from an interface. - - :param int ifindex: index of interface to delete address types from - :param tuple[str] address_types: address types to delete - :return: nothing - :raises CoreCommandError: when a non-zero exit status occurs - """ - if not address_types: - address_types = self.valid_address_types - - interface_name = self.ifname(ifindex) - addresses = self.client.getaddr(interface_name, rescan=True) - - for address_type in address_types: - if address_type not in self.valid_address_types: - raise ValueError( - "addr type must be in: %s" % " ".join(self.valid_address_types) - ) - for address in addresses[address_type]: - self.deladdr(ifindex, address) - - # update cached information - self.client.getaddr(interface_name, rescan=True) - def ifup(self, ifindex): """ Bring an interface up. diff --git a/daemon/core/nodes/client.py b/daemon/core/nodes/client.py index 4bfef967..00833ef4 100644 --- a/daemon/core/nodes/client.py +++ b/daemon/core/nodes/client.py @@ -26,7 +26,6 @@ class VnodeClient(object): """ self.name = name self.ctrlchnlname = ctrlchnlname - self._addr = {} def _verify_connection(self): """ @@ -238,48 +237,6 @@ class VnodeClient(object): """ return self.cmd_output([sh, "-c", cmd]) - def getaddr(self, ifname, rescan=False): - """ - Get address for interface on node. - - :param str ifname: interface name to get address for - :param bool rescan: rescan flag - :return: interface information - :rtype: dict - """ - if ifname in self._addr and not rescan: - return self._addr[ifname] - - interface = {"ether": [], "inet": [], "inet6": [], "inet6link": []} - args = [constants.IP_BIN, "addr", "show", "dev", ifname] - p, stdin, stdout, stderr = self.popen(args) - stdin.close() - - for line in stdout: - line = line.strip().split() - if line[0] == "link/ether": - interface["ether"].append(line[1]) - elif line[0] == "inet": - interface["inet"].append(line[1]) - elif line[0] == "inet6": - if line[3] == "global": - interface["inet6"].append(line[1]) - elif line[3] == "link": - interface["inet6link"].append(line[1]) - else: - logging.warning("unknown scope: %s" % line[3]) - - err = stderr.read() - stdout.close() - stderr.close() - status = p.wait() - if status: - logging.warning("nonzero exist status (%s) for cmd: %s", status, args) - if err: - logging.warning("error output: %s", err) - self._addr[ifname] = interface - return interface - def netifstats(self, ifname=None): """ Retrieve network interface state. diff --git a/daemon/core/nodes/docker.py b/daemon/core/nodes/docker.py index eecc1175..7bf041e0 100644 --- a/daemon/core/nodes/docker.py +++ b/daemon/core/nodes/docker.py @@ -95,40 +95,6 @@ class DockerClient(object): if status: raise CoreCommandError(status, args, output) - def getaddr(self, ifname, rescan=False): - """ - Get address for interface on node. - - :param str ifname: interface name to get address for - :param bool rescan: rescan flag - :return: interface information - :rtype: dict - """ - if ifname in self._addr and not rescan: - return self._addr[ifname] - - interface = {"ether": [], "inet": [], "inet6": [], "inet6link": []} - args = ["ip", "addr", "show", "dev", ifname] - status, output = self.ns_cmd(args) - for line in output: - line = line.strip().split() - if line[0] == "link/ether": - interface["ether"].append(line[1]) - elif line[0] == "inet": - interface["inet"].append(line[1]) - elif line[0] == "inet6": - if line[3] == "global": - interface["inet6"].append(line[1]) - elif line[3] == "link": - interface["inet6link"].append(line[1]) - else: - logging.warning("unknown scope: %s" % line[3]) - - if status: - logging.warning("nonzero exist status (%s) for cmd: %s", status, args) - self._addr[ifname] = interface - return interface - class DockerNode(CoreNode): apitype = NodeTypes.DOCKER.value diff --git a/daemon/core/nodes/lxd.py b/daemon/core/nodes/lxd.py index ff1e60b8..30c021ce 100644 --- a/daemon/core/nodes/lxd.py +++ b/daemon/core/nodes/lxd.py @@ -91,40 +91,6 @@ class LxdClient(object): if status: raise CoreCommandError(status, args, output) - def getaddr(self, ifname, rescan=False): - """ - Get address for interface on node. - - :param str ifname: interface name to get address for - :param bool rescan: rescan flag - :return: interface information - :rtype: dict - """ - if ifname in self._addr and not rescan: - return self._addr[ifname] - - interface = {"ether": [], "inet": [], "inet6": [], "inet6link": []} - args = ["ip", "addr", "show", "dev", ifname] - status, output = self.ns_cmd_output(args) - for line in output: - line = line.strip().split() - if line[0] == "link/ether": - interface["ether"].append(line[1]) - elif line[0] == "inet": - interface["inet"].append(line[1]) - elif line[0] == "inet6": - if line[3] == "global": - interface["inet6"].append(line[1]) - elif line[3] == "link": - interface["inet6link"].append(line[1]) - else: - logging.warning("unknown scope: %s" % line[3]) - - if status: - logging.warning("nonzero exist status (%s) for cmd: %s", status, args) - self._addr[ifname] = interface - return interface - class LxcNode(CoreNode): apitype = NodeTypes.LXC.value diff --git a/daemon/tests/test_core.py b/daemon/tests/test_core.py index f5f2c3e3..47c2a716 100644 --- a/daemon/tests/test_core.py +++ b/daemon/tests/test_core.py @@ -127,7 +127,6 @@ class TestCore: assert createclients(session.session_dir) # check convenience methods for interface information - assert client.getaddr("eth0") assert client.netifstats() def test_netif(self, session, ip_prefixes):