From nobody Fri May 3 11:03:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520345888311921.4473060619176; Tue, 6 Mar 2018 06:18:08 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD304C057FAF; Tue, 6 Mar 2018 14:18:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A7515D9CA; Tue, 6 Mar 2018 14:18:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C525A4A46E; Tue, 6 Mar 2018 14:18:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w26EI4h9021029 for ; Tue, 6 Mar 2018 09:18:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4831E10B0F3C; Tue, 6 Mar 2018 14:18:04 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-195.phx2.redhat.com [10.3.116.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDD0410AF9C6; Tue, 6 Mar 2018 14:18:03 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Tue, 6 Mar 2018 09:17:51 -0500 Message-Id: <20180306141752.507189-2-laine@laine.org> In-Reply-To: <20180306141752.507189-1-laine@laine.org> References: <20180306141752.507189-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [tck PATCH v3 1/2] Remove tab characters from Build.PL X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 06 Mar 2018 14:18:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Laine Stump Reviewed-by: Daniel P. Berrang=C3=A9 --- Build.PL | 104 +++++++++++++++++++++++++++++++----------------------------= ---- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/Build.PL b/Build.PL index 63785a5..9593021 100644 --- a/Build.PL +++ b/Build.PL @@ -27,11 +27,11 @@ sub process_pkgdata_files { my $wanted =3D sub { my $dir =3D $File::Find::dir; my $name =3D $File::Find::name; - if (-d) { - $tck_dirs{$name} =3D []; - } elsif (-f && /\.(t|sh|fwall|xml|dat)$/) { - push @{$tck_dirs{$dir}}, $name; - } + if (-d) { + $tck_dirs{$name} =3D []; + } elsif (-f && /\.(t|sh|fwall|xml|dat)$/) { + push @{$tck_dirs{$dir}}, $name; + } }; =20 find($wanted, 'scripts'); @@ -40,19 +40,19 @@ sub process_pkgdata_files { File::Path::mkpath($tck_dir); =20 foreach my $srcdir (keys %tck_dirs) { - next unless @{$tck_dirs{$srcdir}}; + next unless @{$tck_dirs{$srcdir}}; =20 - my $dstdir =3D $srcdir; - $dstdir =3D~ s,scripts/,,; + my $dstdir =3D $srcdir; + $dstdir =3D~ s,scripts/,,; =20 - $dstdir =3D File::Spec->catdir($self->blib, 'pkgdata', $dstdir); - File::Path::mkpath($dstdir); + $dstdir =3D File::Spec->catdir($self->blib, 'pkgdata', $dstdir); + File::Path::mkpath($dstdir); =20 - foreach my $file (@{$tck_dirs{$srcdir}}) { - my $result =3D $self->copy_if_modified(from =3D> $file, - to_dir =3D> $dstdir, - flatten =3D> 1); - } + foreach my $file (@{$tck_dirs{$srcdir}}) { + my $result =3D $self->copy_if_modified(from =3D> $file, + to_dir =3D> $dstdir, + flatten =3D> 1); + } } } =20 @@ -64,52 +64,52 @@ my $b =3D $class->new( dist_author =3D> 'Daniel Berrange ', dist_abstract =3D> 'libvirt Technology Compatability Kit', requires =3D> { - 'perl' =3D> '5.8.0', - 'accessors' =3D> 0, - 'App::Prove' =3D> '3.11', - 'Config::Record' =3D> '1.0.0', - 'Cwd' =3D> 0, - 'Digest' =3D> 0, - 'Digest::MD5' =3D> 0, - 'File::Copy' =3D> 0, - 'File::Path' =3D> 0, - 'File::Slurp' =3D> 0, - 'File::Spec::Functions' =3D> 0, - 'LWP::UserAgent' =3D> 0, - 'IO::String' =3D> 0, - 'IO::Uncompress::Gunzip' =3D> 0, - 'IO::Uncompress::Bunzip2' =3D> 0, - 'TAP::Formatter::HTML' =3D> 0, - 'TAP::Formatter::JUnit' =3D> 0, - 'TAP::Harness' =3D> 3.11, - 'TAP::Harness::Archive' =3D> 0, - 'Test::Exception' =3D> 0, - 'Test::Builder' =3D> 0, - 'Test::More' =3D> 0, - 'Sub::Uplevel' =3D> 0, - 'Sys::Virt' =3D> '0.2.0', - 'XML::Twig' =3D> 0, - 'XML::Writer' =3D> 0, - 'XML::XPath' =3D> 0, + 'perl' =3D> '5.8.0', + 'accessors' =3D> 0, + 'App::Prove' =3D> '3.11', + 'Config::Record' =3D> '1.0.0', + 'Cwd' =3D> 0, + 'Digest' =3D> 0, + 'Digest::MD5' =3D> 0, + 'File::Copy' =3D> 0, + 'File::Path' =3D> 0, + 'File::Slurp' =3D> 0, + 'File::Spec::Functions' =3D> 0, + 'LWP::UserAgent' =3D> 0, + 'IO::String' =3D> 0, + 'IO::Uncompress::Gunzip' =3D> 0, + 'IO::Uncompress::Bunzip2' =3D> 0, + 'TAP::Formatter::HTML' =3D> 0, + 'TAP::Formatter::JUnit' =3D> 0, + 'TAP::Harness' =3D> 3.11, + 'TAP::Harness::Archive' =3D> 0, + 'Test::Exception' =3D> 0, + 'Test::Builder' =3D> 0, + 'Test::More' =3D> 0, + 'Sub::Uplevel' =3D> 0, + 'Sys::Virt' =3D> '0.2.0', + 'XML::Twig' =3D> 0, + 'XML::Writer' =3D> 0, + 'XML::XPath' =3D> 0, }, build_requires =3D> { - 'Test::Pod' =3D> '0', - 'Test::Pod::Coverage' =3D> '0', + 'Test::Pod' =3D> '0', + 'Test::Pod::Coverage' =3D> '0', }, script_files =3D> [ - "bin/libvirt-tck", + "bin/libvirt-tck", ], create_makefile_pl =3D> 'passthrough', meta_add =3D> { - resources =3D> { - license =3D> "http://www.gnu.org/licenses/gpl.html", - homepage =3D> "http://libvirt.org/", - repository =3D> "http://libvirt.org/hg/libvirt-tck", - MailingList =3D> "http://www.redhat.com/mailman/listinfo/libvir-list", - }, + resources =3D> { + license =3D> "http://www.gnu.org/licenses/gpl.html", + homepage =3D> "http://libvirt.org/", + repository =3D> "http://libvirt.org/hg/libvirt-tck", + MailingList =3D> "http://www.redhat.com/mailman/listinfo/libvi= r-list", + }, }, conf_files =3D> { - 'conf/default.cfg' =3D> 'conf/default.cfg', + 'conf/default.cfg' =3D> 'conf/default.cfg', }, PL_files =3D> [ 'perl-Sys-Virt-TCK.spec.PL' ], ); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 11:03:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520345896301495.04296328945054; Tue, 6 Mar 2018 06:18:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9F3EC0587D7; Tue, 6 Mar 2018 14:18:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFE355D6A2; Tue, 6 Mar 2018 14:18:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 754DD4A471; Tue, 6 Mar 2018 14:18:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w26EI5di021036 for ; Tue, 6 Mar 2018 09:18:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1176E10B0F3B; Tue, 6 Mar 2018 14:18:05 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-195.phx2.redhat.com [10.3.116.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 873B610B0F3D; Tue, 6 Mar 2018 14:18:04 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Tue, 6 Mar 2018 09:17:52 -0500 Message-Id: <20180306141752.507189-3-laine@laine.org> In-Reply-To: <20180306141752.507189-1-laine@laine.org> References: <20180306141752.507189-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [tck PATCH v3 2/2] new NetworkHelper function get_network_ip() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 06 Mar 2018 14:18:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function gets the first IP address for the named virtual network. It is returned as a Net::IP object, so that we will have info about its netmask/prefix and can easily get it broadcast address and perform arithmetic on the address. Signed-off-by: Laine Stump Reviewed-by: Daniel P. Berrang=C3=A9 --- Build.PL | 1 + lib/Sys/Virt/TCK/NetworkHelpers.pm | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Build.PL b/Build.PL index 9593021..bf2d7a9 100644 --- a/Build.PL +++ b/Build.PL @@ -79,6 +79,7 @@ my $b =3D $class->new( 'IO::String' =3D> 0, 'IO::Uncompress::Gunzip' =3D> 0, 'IO::Uncompress::Bunzip2' =3D> 0, + 'NetAddr::IP' =3D> 0, 'TAP::Formatter::HTML' =3D> 0, 'TAP::Formatter::JUnit' =3D> 0, 'TAP::Harness' =3D> 3.11, diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkH= elpers.pm index 5f563e5..7bbce62 100644 --- a/lib/Sys/Virt/TCK/NetworkHelpers.pm +++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm @@ -1,4 +1,5 @@ use Sys::Virt::TCK qw(xpath); +use NetAddr::IP qw(:lower); use strict; use utf8; =20 @@ -9,6 +10,27 @@ sub get_first_macaddress { return $mac; } =20 +sub get_network_ip { + my $conn =3D shift; + my $netname =3D shift; + diag "getting ip for network $netname"; + my $net =3D $conn->get_network_by_name($netname); + my $net_ip =3D xpath($net, "string(/network/ip[1]/\@address"); + my $net_mask =3D xpath($net, "string(/network/ip[1]/\@netmask"); + my $net_prefix =3D xpath($net, "string(/network/ip[1]/\@prefix"); + my $ip; + + if ($net_mask) { + $ip =3D NetAddr::IP->new($net_ip, $net_mask); + } elsif ($net_prefix) { + $ip =3D NetAddr::IP->new("$net_ip/$net_mask"); + } else { + $ip =3D NetAddr::IP->new("$net_ip"); + } + return $ip; +} + + sub get_ip_from_leases{ my $conn =3D shift; my $netname =3D shift; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list