From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues <lmr@redhat.com>,
Jiri Zupka <jzupka@redhat.com>
Subject: [PATCH 1/4] client.bin.net.net_utils: Introduce get_local_ip()
Date: Tue, 24 May 2011 04:08:08 -0300 [thread overview]
Message-ID: <1306220891-3993-2-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1306220891-3993-1-git-send-email-lmr@redhat.com>
Get ip address in local system which can communicate
with a given ip, that will be useful for subtests like
netperf2.
Signed-off-by: Jiri Zupka <jzupka@redhat.com>
---
client/bin/net/net_utils.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/client/bin/net/net_utils.py b/client/bin/net/net_utils.py
index 868958c..7c96ba0 100644
--- a/client/bin/net/net_utils.py
+++ b/client/bin/net/net_utils.py
@@ -5,6 +5,7 @@ This library is to release in the public repository.
import commands, os, re, socket, sys, time, struct
from autotest_lib.client.common_lib import error
+from autotest_lib.client.bin import utils as client_utils
import utils
TIMEOUT = 10 # Used for socket timeout and barrier timeout
@@ -27,6 +28,22 @@ class network_utils(object):
utils.system('/sbin/ifconfig -a')
+ def get_ip_local(self, query_ip, netmask="24"):
+ """
+ Get ip address in local system which can communicate with query_ip.
+
+ @param query_ip: IP of client which wants to communicate with
+ autotest machine.
+ @return: IP address which can communicate with query_ip
+ """
+ ip = client_utils.system_output("ip addr show to %s/%s" %
+ (query_ip, netmask))
+ ip = re.search(r"inet ([0-9.]*)/",ip)
+ if ip is None:
+ return ip
+ return ip.group(1)
+
+
def disable_ip_local_loopback(self, ignore_status=False):
utils.system("echo '1' > /proc/sys/net/ipv4/route/no_local_loopback",
ignore_status=ignore_status)
--
1.7.5.1
next prev parent reply other threads:[~2011-05-24 7:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-24 7:08 [PATCH 0/4] Make possible to run client tests as subtests Lucas Meneghel Rodrigues
2011-05-24 7:08 ` Lucas Meneghel Rodrigues [this message]
2011-05-24 7:08 ` [PATCH 2/4] client: Make it possible to run subtests in autotest Lucas Meneghel Rodrigues
2011-05-24 7:08 ` [PATCH 3/4] tools: Make html_report to deal with subtest results Lucas Meneghel Rodrigues
2011-05-24 7:08 ` [PATCH 4/4] KVM test: Rewrite netperf in terms of subtest Lucas Meneghel Rodrigues
2011-05-24 14:24 ` [PATCH 0/4] Make possible to run client tests as subtests Lucas Meneghel Rodrigues
2011-06-01 19:31 ` Lucas Meneghel Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306220891-3993-2-git-send-email-lmr@redhat.com \
--to=lmr@redhat.com \
--cc=autotest@test.kernel.org \
--cc=jzupka@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox