method get_ip_addrs() returns VolatileValue type (which is not iterable) with IPs and
prefixes, get_all_ips() returns list of strings containing only IPs
Altough this patch is bad, because the function can be implemented in two lines, not five.
So if we want the function, I'll send new patch..
--
Jiri Prochazka
LNST developer (
www.lnst-project.org)
Red Hat Czech s.r.o.
----- Original Message -----
From: "Ondrej Lichtner" <olichtne(a)redhat.com>
To: "Jiri Prochazka" <jprochaz(a)redhat.com>
Cc: lnst-developers(a)lists.fedorahosted.org
Sent: Thursday, January 29, 2015 11:14:22 AM
Subject: Re: [PATCH] Added method to get list of addresses on interface
Do we want this? Isn't the InterfaceAPI method get_ip_addrs()
sufficient?
-Ondrej
On Wed, Jan 28, 2015 at 04:46:15PM +0100, Jiri Prochazka wrote:
closes #78
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Task.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 0aa3d1a..27ba801 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -250,6 +250,22 @@ class HostAPI(object):
iface = self._interfaces[interface_id]
return iface.get_ip_addr(addr_number)
+ def get_all_ips(self, interface_id):
+ """
+ Returns list of all IP addresses of the interface.
+
+ :param interface_id: which interface
+ :type interface_id: string
+
+ :return: list of IP addresses (e.g., ['192.168.1.10',
'2001::10']).
+ :rtype: list of strings
+ """
+ iface = self._interfaces[interface_id]
+ res = []
+ for ip, prefix in iface.get_ip_addrs().get_val():
+ res.append(ip)
+ return res
+
def get_prefix(self, interface_id, addr_number=0):
"""
Returns an IP address prefix (netmask)
--
2.1.0
_______________________________________________
LNST-developers mailing list
LNST-developers(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/lnst-developers