removed getaddr from node clients, since it was not being used
This commit is contained in:
parent
e4bb315c14
commit
d3d70ecc54
5 changed files with 0 additions and 138 deletions
|
@ -806,32 +806,6 @@ class CoreNode(CoreNodeBase):
|
||||||
if self.up:
|
if self.up:
|
||||||
self.node_net_client.delete_address(interface.name, str(addr))
|
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):
|
def ifup(self, ifindex):
|
||||||
"""
|
"""
|
||||||
Bring an interface up.
|
Bring an interface up.
|
||||||
|
|
|
@ -26,7 +26,6 @@ class VnodeClient(object):
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ctrlchnlname = ctrlchnlname
|
self.ctrlchnlname = ctrlchnlname
|
||||||
self._addr = {}
|
|
||||||
|
|
||||||
def _verify_connection(self):
|
def _verify_connection(self):
|
||||||
"""
|
"""
|
||||||
|
@ -238,48 +237,6 @@ class VnodeClient(object):
|
||||||
"""
|
"""
|
||||||
return self.cmd_output([sh, "-c", cmd])
|
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):
|
def netifstats(self, ifname=None):
|
||||||
"""
|
"""
|
||||||
Retrieve network interface state.
|
Retrieve network interface state.
|
||||||
|
|
|
@ -95,40 +95,6 @@ class DockerClient(object):
|
||||||
if status:
|
if status:
|
||||||
raise CoreCommandError(status, args, output)
|
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):
|
class DockerNode(CoreNode):
|
||||||
apitype = NodeTypes.DOCKER.value
|
apitype = NodeTypes.DOCKER.value
|
||||||
|
|
|
@ -91,40 +91,6 @@ class LxdClient(object):
|
||||||
if status:
|
if status:
|
||||||
raise CoreCommandError(status, args, output)
|
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):
|
class LxcNode(CoreNode):
|
||||||
apitype = NodeTypes.LXC.value
|
apitype = NodeTypes.LXC.value
|
||||||
|
|
|
@ -127,7 +127,6 @@ class TestCore:
|
||||||
assert createclients(session.session_dir)
|
assert createclients(session.session_dir)
|
||||||
|
|
||||||
# check convenience methods for interface information
|
# check convenience methods for interface information
|
||||||
assert client.getaddr("eth0")
|
|
||||||
assert client.netifstats()
|
assert client.netifstats()
|
||||||
|
|
||||||
def test_netif(self, session, ip_prefixes):
|
def test_netif(self, session, ip_prefixes):
|
||||||
|
|
Loading…
Add table
Reference in a new issue