[libvirt-test-API][PATCH V2 07/11] Change bridge name as a variable in functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function can get ip when domain has a non-default virual
network
---
 utils/ipget.sh | 7 ++++++-
 utils/utils.py | 7 +++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/utils/ipget.sh b/utils/ipget.sh
index 8d44b14..c2e0983 100755
--- a/utils/ipget.sh
+++ b/utils/ipget.sh
@@ -1,17 +1,22 @@
 #!/bin/sh
 
 mac=$1
+br=$2
 if [[ -z $mac ]]; then
    echo "mac address is null."
    exit 1
 fi
+if [[ -z $br ]]; then
+   echo "bridge name is null."
+   exit 1
+fi
 
 if ! type nmap >/dev/null 2>&1; then
    echo "nmap package needs to be installed."
    exit 1
 fi
 
-ipaddr=`ip route |grep virbr0 |sed -n 1p|awk {'print $1'}`
+ipaddr=`ip route |grep $br |sed -n 1p|awk {'print $1'}`
 
 #if lsmod | grep kvm > /dev/null ;then
 #  ipaddr=`ip route |grep switch |sed -n 1p|awk {'print $1'}`
diff --git a/utils/utils.py b/utils/utils.py
index 147c1ef..f841c27 100644
--- a/utils/utils.py
+++ b/utils/utils.py
@@ -349,7 +349,7 @@ def locate_utils():
     result = re.search('(.*)libvirt-test-API(.*)', pwd)
     return result.group(0) + "/utils"
 
-def mac_to_ip(mac, timeout):
+def mac_to_ip(mac,br,timeout):
     """Map mac address to ip
 
        Return None on FAILURE and the mac address on SUCCESS
@@ -357,10 +357,13 @@ def mac_to_ip(mac, timeout):
     if not mac:
         return None
 
+    if not br:
+        return None
+
     if timeout < 10:
         timeout = 10
 
-    cmd = "sh " + locate_utils() + "/ipget.sh " + mac
+    cmd = "sh " + locate_utils() + "/ipget.sh " + mac + " " + br
 
     while timeout > 0:
         (ret, out) = commands.getstatusoutput(cmd)
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]