[libvirt] [tck PATCH 1/2] new helper function get_network_ip()

Laine Stump laine at laine.org
Wed Feb 28 18:30:25 UTC 2018


This function gets the first IP address for the named virtual network.

Signed-off-by: Laine Stump <laine at laine.org>
---
 lib/Sys/Virt/TCK/NetworkHelpers.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkHelpers.pm
index 5f563e5..03bc87a 100644
--- a/lib/Sys/Virt/TCK/NetworkHelpers.pm
+++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm
@@ -9,6 +9,16 @@ sub get_first_macaddress {
     return $mac;
 }
 
+sub get_network_ip {
+    my $conn = shift;
+    my $netname = shift;
+    diag "getting ip for network $netname";
+    my $net = $conn->get_network_by_name($netname);
+    my $net_ip = xpath($net, "string(/network/ip[1]/\@address");
+    return $net_ip;
+}
+
+
 sub get_ip_from_leases{
     my $conn = shift;
     my $netname = shift;
-- 
2.14.3




More information about the libvir-list mailing list