diff options
Diffstat (limited to 'yardstick/common/utils.py')
-rw-r--r-- | yardstick/common/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 7035f3374..f4def8533 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -167,3 +167,22 @@ def parse_ini_file(path): s)} for s in parser.sections()}) return config + + +def get_port_mac(sshclient, port): + cmd = "ifconfig |grep HWaddr |grep %s |awk '{print $5}' " % port + status, stdout, stderr = sshclient.execute(cmd) + + if status: + raise RuntimeError(stderr) + return stdout.rstrip() + + +def get_port_ip(sshclient, port): + cmd = "ifconfig %s |grep 'inet addr' |awk '{print $2}' " \ + "|cut -d ':' -f2 " % port + status, stdout, stderr = sshclient.execute(cmd) + + if status: + raise RuntimeError(stderr) + return stdout.rstrip() |