aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/main.py
diff options
context:
space:
mode:
authorHans Feldt <hans.feldt@ericsson.com>2015-06-16 09:27:31 +0200
committerHans Feldt <hans.feldt@ericsson.com>2015-06-16 13:56:12 +0000
commitfa7bf41e69214d73b756b68fb58ec57dc6e208be (patch)
tree75d16a5164319ea2fce0e0fdd014e4dc60e6d826 /yardstick/main.py
parentdd5c9319cfc3f4dd7bfce2073d29d03d646ac65c (diff)
Add support for single server ping test
A simple test case is added that will ping an external server on the internet. See samples/ping-ext-ip.yaml Change-Id: I15eb3cb6ab9e5c1cf280f2aade2bf4c9646d6cd4 JIRA: - Signed-off-by: Hans Feldt <hans.feldt@ericsson.com>
Diffstat (limited to 'yardstick/main.py')
-rwxr-xr-xyardstick/main.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/yardstick/main.py b/yardstick/main.py
index 942b46be9..8f017431b 100755
--- a/yardstick/main.py
+++ b/yardstick/main.py
@@ -43,6 +43,7 @@ import sys
import yaml
import atexit
import pkg_resources
+import ipaddress
from yardstick.benchmark.context.model import Context
from yardstick.benchmark.runners import base as base_runner
@@ -93,6 +94,15 @@ def atexit_handler():
context.undeploy()
+def is_ip_addr(addr):
+ '''check if string addr is an IP address'''
+ try:
+ ipaddress.ip_address(addr)
+ return True
+ except ValueError:
+ return False
+
+
def run_one_scenario(scenario_cfg, output_file):
'''run one scenario using context'''
key_filename = pkg_resources.resource_filename(
@@ -107,19 +117,22 @@ def run_one_scenario(scenario_cfg, output_file):
runner_cfg['output_filename'] = output_file
if "target" in scenario_cfg:
- target = Context.get_server(scenario_cfg["target"])
-
- # get public IP for target server, some scenarios require it
- if target.public_ip:
- runner_cfg['target'] = target.public_ip
-
- # TODO scenario_cfg["ipaddr"] is bad naming
- if host.context != target.context:
- # target is in another context, get its public IP
- scenario_cfg["ipaddr"] = target.public_ip
+ if is_ip_addr(scenario_cfg["target"]):
+ scenario_cfg["ipaddr"] = scenario_cfg["target"]
else:
- # target is in the same context, get its private IP
- scenario_cfg["ipaddr"] = target.private_ip
+ target = Context.get_server(scenario_cfg["target"])
+
+ # get public IP for target server, some scenarios require it
+ if target.public_ip:
+ runner_cfg['target'] = target.public_ip
+
+ # TODO scenario_cfg["ipaddr"] is bad naming
+ if host.context != target.context:
+ # target is in another context, get its public IP
+ scenario_cfg["ipaddr"] = target.public_ip
+ else:
+ # target is in the same context, get its private IP
+ scenario_cfg["ipaddr"] = target.private_ip
runner = base_runner.Runner.get(runner_cfg)