Merge "Add how to add/modify Yardstick Grafana dashboard in user guide"
authorKubi <jean.gaoliang@huawei.com>
Wed, 16 Nov 2016 01:13:33 +0000 (01:13 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Wed, 16 Nov 2016 01:13:33 +0000 (01:13 +0000)
45 files changed:
dashboard/KVMFORNFV-Cyclictest
setup.py
tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml
tests/unit/benchmark/scenarios/networking/test_networkcapacity.py
tests/unit/benchmark/scenarios/networking/test_ping6.py
tests/unit/common/config_sample.yaml [new file with mode: 0644]
tests/unit/common/test_utils.py
yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
yardstick/benchmark/scenarios/availability/attacker/attacker_general.py
yardstick/benchmark/scenarios/availability/attacker/attacker_process.py
yardstick/benchmark/scenarios/availability/monitor/monitor_command.py
yardstick/benchmark/scenarios/availability/monitor/monitor_general.py
yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
yardstick/benchmark/scenarios/availability/operation/operation_general.py
yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py
yardstick/benchmark/scenarios/compute/cachestat.py
yardstick/benchmark/scenarios/compute/computecapacity.py
yardstick/benchmark/scenarios/compute/cpuload.py
yardstick/benchmark/scenarios/compute/cyclictest.py
yardstick/benchmark/scenarios/compute/lmbench.py
yardstick/benchmark/scenarios/compute/memload.py
yardstick/benchmark/scenarios/compute/perf.py
yardstick/benchmark/scenarios/compute/plugintest.py
yardstick/benchmark/scenarios/compute/ramspeed.py
yardstick/benchmark/scenarios/compute/unixbench.py
yardstick/benchmark/scenarios/networking/iperf3.py
yardstick/benchmark/scenarios/networking/netperf.py
yardstick/benchmark/scenarios/networking/netperf_node.py
yardstick/benchmark/scenarios/networking/netutilization.py
yardstick/benchmark/scenarios/networking/networkcapacity.py
yardstick/benchmark/scenarios/networking/ping.py
yardstick/benchmark/scenarios/networking/ping6.py
yardstick/benchmark/scenarios/networking/ping6_setup.bash
yardstick/benchmark/scenarios/networking/pktgen.py
yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
yardstick/benchmark/scenarios/networking/sfc.py
yardstick/benchmark/scenarios/networking/vsperf.py
yardstick/benchmark/scenarios/storage/fio.py
yardstick/benchmark/scenarios/storage/storagecapacity.py
yardstick/cmd/cli.py
yardstick/cmd/commands/plugin.py
yardstick/cmd/commands/task.py
yardstick/common/constants.py [new file with mode: 0644]
yardstick/common/utils.py
yardstick/ssh.py

index 41246d0..36c1ec7 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "id": 6,
+  "id": 42,
   "title": "KVMFORNFV-Cyclictest",
   "tags": [
     "kvmfornfv-cyclictest"
     }
   ],
   "time": {
-    "from": "now-2d",
-    "to": "2016-10-22T04:02:56.969Z"
+    "from": "now-7d",
+    "to": "now"
   },
   "timepicker": {
     "refresh_intervals": [
   "annotations": {
     "list": []
   },
-  "refresh": false,
+  "refresh": "1d",
   "schemaVersion": 12,
   "version": 1,
   "links": [],
index 4fe2596..9bf656b 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -66,5 +66,5 @@ setup(
     scripts=['tools/yardstick-img-modify',
              'tools/yardstick-img-lxd-modify',
              'tools/yardstick-img-dpdk-modify'
-            ]
+             ]
 )
index d6a0533..44c8494 100644 (file)
@@ -18,16 +18,6 @@ test_cases:
     file_name: opnfv_yardstick_tc012.yaml
 -
     file_name: opnfv_yardstick_tc014.yaml
--
-    file_name: opnfv_yardstick_tc027.yaml
-    constraint:
-        installer: compass,fuel
-        pod: huawei-pod1,lf-pod2,ericsson-pod3,ericsson-pod4
-    task_args:
-        huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
-        lf-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
-        ericsson-pod3: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
-        ericsson-pod4: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
 -
     file_name: opnfv_yardstick_tc037.yaml
 -
@@ -114,4 +104,14 @@ test_cases:
     task_args:
         huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
         "host": "node1.LF"}'
+-
+    file_name: opnfv_yardstick_tc027.yaml
+    constraint:
+        installer: compass,fuel
+        pod: huawei-pod1,lf-pod2,ericsson-pod3,ericsson-pod4
+    task_args:
+        huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+        lf-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+        ericsson-pod3: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+        ericsson-pod4: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
 
index e3a0964..e42832f 100644 (file)
@@ -1,56 +1,56 @@
-#!/usr/bin/env python\r
-\r
-##############################################################################\r
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.\r
-#\r
-# All rights reserved. This program and the accompanying materials\r
-# are made available under the terms of the Apache License, Version 2.0\r
-# which accompanies this distribution, and is available at\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-##############################################################################\r
-\r
-# Unittest for yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity\r
-\r
-import mock\r
-import unittest\r
-import os\r
-import json\r
-\r
-from yardstick.benchmark.scenarios.networking import networkcapacity\r
-\r
-SAMPLE_OUTPUT = '{"Number of connections":"308","Number of frames received": "166503"}'\r
-\r
-@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh')\r
-class NetworkCapacityTestCase(unittest.TestCase):\r
-\r
-    def setUp(self):\r
-        self.ctx = {\r
-                'host': {\r
-                    'ip': '172.16.0.137',\r
-                    'user': 'cirros',\r
-                    'password': "root"\r
-                },\r
-        }\r
-\r
-        self.result = {}\r
-\r
-    def test_capacity_successful_setup(self, mock_ssh):\r
-        c = networkcapacity.NetworkCapacity({}, self.ctx)\r
-        mock_ssh.SSH().execute.return_value = (0, '', '')\r
-        c.setup()\r
-        self.assertIsNotNone(c.client)\r
-        self.assertTrue(c.setup_done)\r
-\r
-    def test_capacity_successful(self, mock_ssh):\r
-        c = networkcapacity.NetworkCapacity({}, self.ctx)\r
-\r
-        mock_ssh.SSH().execute.return_value = (0, SAMPLE_OUTPUT, '')\r
-        c.run(self.result)\r
-        expected_result = json.loads(SAMPLE_OUTPUT)\r
-        self.assertEqual(self.result, expected_result)\r
-\r
-    def test_capacity_unsuccessful_script_error(self, mock_ssh):\r
-        c = networkcapacity.NetworkCapacity({}, self.ctx)\r
-\r
-        mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')\r
-        self.assertRaises(RuntimeError, c.run, self.result)\r
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Unittest for yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity
+
+import mock
+import unittest
+import os
+import json
+
+from yardstick.benchmark.scenarios.networking import networkcapacity
+
+SAMPLE_OUTPUT = '{"Number of connections":"308","Number of frames received": "166503"}'
+
+@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh')
+class NetworkCapacityTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.ctx = {
+                'host': {
+                    'ip': '172.16.0.137',
+                    'user': 'cirros',
+                    'password': "root"
+                },
+        }
+
+        self.result = {}
+
+    def test_capacity_successful_setup(self, mock_ssh):
+        c = networkcapacity.NetworkCapacity({}, self.ctx)
+        mock_ssh.SSH().execute.return_value = (0, '', '')
+        c.setup()
+        self.assertIsNotNone(c.client)
+        self.assertTrue(c.setup_done)
+
+    def test_capacity_successful(self, mock_ssh):
+        c = networkcapacity.NetworkCapacity({}, self.ctx)
+
+        mock_ssh.SSH().execute.return_value = (0, SAMPLE_OUTPUT, '')
+        c.run(self.result)
+        expected_result = json.loads(SAMPLE_OUTPUT)
+        self.assertEqual(self.result, expected_result)
+
+    def test_capacity_unsuccessful_script_error(self, mock_ssh):
+        c = networkcapacity.NetworkCapacity({}, self.ctx)
+
+        mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
+        self.assertRaises(RuntimeError, c.run, self.result)
index 995113e..0b8fba2 100644 (file)
@@ -25,12 +25,29 @@ class PingTestCase(unittest.TestCase):
             'host1': {
                 'ip': '172.16.0.137',
                 'user': 'cirros',
+                'role': "Controller",
                 'key_filename': "mykey.key",
                 'password': "root"
                 },
+            'host2': {
+                "ip": "172.16.0.138",
+                "key_filename": "/root/.ssh/id_rsa",
+                "role": "Compute",
+                "name": "node3.IPV6",
+                "user": "root"
+                },
             }
         }
 
+    def test_get_controller_node(self):
+        args = {
+            'options': {'host': 'host1','packetsize': 200, 'ping_count': 5},
+            'sla': {'max_rtt': 50}
+        }
+        p = ping6.Ping6(args, self.ctx)
+        controller_node = p._get_controller_node(['host1','host2'])
+        self.assertEqual(controller_node, 'host1')
+
     @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
     def test_ping_successful_setup(self, mock_ssh):
         args = {
diff --git a/tests/unit/common/config_sample.yaml b/tests/unit/common/config_sample.yaml
new file mode 100644 (file)
index 0000000..8caa19e
--- /dev/null
@@ -0,0 +1,2 @@
+releng:
+    dir:                                /home/opnfv/repos/releng
index 002d049..a64c1f1 100644 (file)
@@ -83,6 +83,33 @@ class ImportModulesFromPackageTestCase(unittest.TestCase):
         mock_importutils.import_module.assert_called_with('bar.baz')
 
 
+class GetParaFromYaml(unittest.TestCase):
+
+    def test_get_para_from_yaml_file_not_exist(self):
+        file_path = '/etc/yardstick/hello.yaml'
+        args = 'hello.world'
+        para = utils.get_para_from_yaml(file_path, args)
+        self.assertIsNone(para)
+
+    def test_get_para_from_yaml_para_not_found(self):
+        file_path = 'config_sample.yaml'
+        file_path = self._get_file_abspath(file_path)
+        args = 'releng.file'
+        self.assertIsNone(utils.get_para_from_yaml(file_path, args))
+
+    def test_get_para_from_yaml_para_exists(self):
+        file_path = 'config_sample.yaml'
+        file_path = self._get_file_abspath(file_path)
+        args = 'releng.dir'
+        para = '/home/opnfv/repos/releng'
+        self.assertEqual(para, utils.get_para_from_yaml(file_path, args))
+
+    def _get_file_abspath(self, filename):
+        curr_path = os.path.dirname(os.path.abspath(__file__))
+        file_path = os.path.join(curr_path, filename)
+        return file_path
+
+
 def main():
     unittest.main()
 
index b35869d..6561f6b 100644 (file)
@@ -31,7 +31,6 @@ def _execute_shell_command(command, stdin=None):
 
 
 class BaremetalAttacker(BaseAttacker):
-
     __attacker_type__ = 'bare-metal-down'
 
     def setup(self):
@@ -39,9 +38,11 @@ class BaremetalAttacker(BaseAttacker):
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
         self.host_ip = ip
@@ -87,10 +88,12 @@ class BaremetalAttacker(BaseAttacker):
             host = self._context.get(jump_host_name, None)
             ip = host.get("ip", None)
             user = host.get("user", "root")
+            ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
             pwd = host.get("pwd", None)
 
             LOG.debug("jump_host ip:%s user:%s" % (ip, user))
-            self.jump_connection = ssh.SSH(user, ip, password=pwd)
+            self.jump_connection = ssh.SSH(user, ip, password=pwd,
+                                           port=ssh_port)
             self.jump_connection.wait(timeout=600)
             LOG.debug("ssh jump host success!")
 
index 816e7e3..5e7716e 100644 (file)
@@ -24,9 +24,11 @@ class GeneralAttacker(BaseAttacker):
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
 
index 5118ad6..0a844f5 100644 (file)
@@ -23,9 +23,11 @@ class ProcessAttacker(BaseAttacker):
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
 
index c285024..b55cc31 100644 (file)
@@ -42,9 +42,11 @@ class MonitorOpenstackCmd(basemonitor.BaseMonitor):
             host = self._context[node_name]
             ip = host.get("ip", None)
             user = host.get("user", "root")
+            ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
             key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-            self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+            self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                      port=ssh_port)
             self.connection.wait(timeout=600)
             LOG.debug("ssh host success!")
 
index 61efc05..f9ddb25 100644 (file)
@@ -25,6 +25,7 @@ class GeneralMonitor(basemonitor.BaseMonitor):
         host = self._context[self._config["host"]]
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
         self.key = self._config["key"]
         self.monitor_key = self._config["monitor_key"]
@@ -40,7 +41,8 @@ class GeneralMonitor(basemonitor.BaseMonitor):
             self.monitor_key)
         self.monitor_script = self.get_script_fullpath(
             self.monitor_cfg['monitor_script'])
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
 
index 53a6d8e..403ec4d 100644 (file)
@@ -23,9 +23,11 @@ class MonitorProcess(basemonitor.BaseMonitor):
         host = self._context[self._config["host"]]
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
         self.check_script = self.get_script_fullpath(
index e43f6e1..aa28472 100644 (file)
@@ -23,9 +23,11 @@ class GeneralOperaion(BaseOperation):
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
 
index 681fbf6..ae896c2 100644 (file)
@@ -17,7 +17,6 @@ LOG = logging.getLogger(__name__)
 
 
 class GeneralResultChecker(BaseResultChecker):
-
     __result_checker__type__ = "general-result-checker"
 
     def setup(self):
@@ -25,9 +24,11 @@ class GeneralResultChecker(BaseResultChecker):
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
 
index da4aa75..1177020 100644 (file)
@@ -75,11 +75,13 @@ class CACHEstat(base.Scenario):
 
         host = self.context_cfg['host']
         user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get('ip', None)
         key_filename = host.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy scripts to host
index 0d7d761..9d7a923 100644 (file)
@@ -40,10 +40,12 @@ class ComputeCapacity(base.Scenario):
         nodes = self.context_cfg['nodes']
         node = nodes.get('host', None)
         host_user = node.get('user', 'ubuntu')
+        ssh_port = node.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = node.get('ip', None)
         host_pwd = node.get('password', 'root')
         LOG.debug("user:%s, host:%s", host_user, host_ip)
-        self.client = ssh.SSH(host_user, host_ip, password=host_pwd)
+        self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
index f45313e..a7fae44 100644 (file)
@@ -67,10 +67,12 @@ class CPULoad(base.Scenario):
         host = self.context_cfg['host']
         user = host.get('user', 'ubuntu')
         ip = host.get('ip', None)
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # Check if mpstat prog is installed
index 478b0a1..6a1afe2 100644 (file)
@@ -93,10 +93,12 @@ class Cyclictest(base.Scenario):
         host = self.context_cfg["host"]
         user = host.get("user", "root")
         ip = host.get("ip", None)
+        ssh_port = host.get("ssh_port", 5555)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
         LOG.debug("user:%s, host:%s", user, ip)
-        self.guest = ssh.SSH(user, ip, port=5555, key_filename=key_filename)
+        self.guest = ssh.SSH(user, ip, port=ssh_port,
+                             key_filename=key_filename)
         self.guest.wait(timeout=600)
 
     def _run_setup_cmd(self, client, cmd):
index d3e802f..9ceb248 100644 (file)
@@ -77,11 +77,13 @@ class Lmbench(base.Scenario):
             Lmbench.LATENCY_CACHE_SCRIPT)
         host = self.context_cfg["host"]
         user = host.get("user", "ubuntu")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get("ip", None)
         key_filename = host.get('key_filename', "~/.ssh/id_rsa")
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy scripts to host
index bafd896..48088f8 100644 (file)
@@ -48,11 +48,13 @@ class MEMLoad(base.Scenario):
         """Scenario setup."""
         host = self.context_cfg['host']
         user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get('ip', None)
         key_filename = host.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         self.setup_done = True
index f408e9c..6c827ef 100644 (file)
@@ -47,11 +47,13 @@ class Perf(base.Scenario):
             'yardstick.benchmark.scenarios.compute', Perf.TARGET_SCRIPT)
         host = self.context_cfg['host']
         user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get('ip', None)
         key_filename = host.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
index e41fb83..e7ec91c 100644 (file)
@@ -30,10 +30,12 @@ class PluginTest(base.Scenario):
         nodes = self.context_cfg['nodes']
         node = nodes.get('host1', None)
         host_user = node.get('user', 'ubuntu')
+        host_ssh_port = node.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = node.get('ip', None)
         host_pwd = node.get('password', 'root')
         LOG.debug("user:%s, host:%s", host_user, host_ip)
-        self.client = ssh.SSH(host_user, host_ip, password=host_pwd)
+        self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
+                              port=host_ssh_port)
         self.client.wait(timeout=600)
 
         self.setup_done = True
index 819ef76..bc33f8a 100644 (file)
@@ -87,11 +87,13 @@ class Ramspeed(base.Scenario):
 
         host = self.context_cfg["host"]
         user = host.get("user", "ubuntu")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get("ip", None)
         key_filename = host.get('key_filename', "~/.ssh/id_rsa")
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy scripts to host
index e6318b9..e629934 100644 (file)
@@ -67,11 +67,13 @@ class Unixbench(base.Scenario):
 
         host = self.context_cfg["host"]
         user = host.get("user", "ubuntu")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get("ip", None)
         key_filename = host.get('key_filename', "~/.ssh/id_rsa")
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy scripts to host
@@ -152,5 +154,6 @@ def _test():  # pragma: no cover
     p.run(result)
     print result
 
+
 if __name__ == '__main__':
     _test()
index bb41c3d..13fa015 100644 (file)
@@ -56,21 +56,24 @@ For more info see http://software.es.net/iperf
     def setup(self):
         host = self.context_cfg['host']
         host_user = host.get('user', 'ubuntu')
+        host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = host.get('ip', None)
         host_key_filename = host.get('key_filename', '~/.ssh/id_rsa')
         target = self.context_cfg['target']
         target_user = target.get('user', 'ubuntu')
+        target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         target_ip = target.get('ip', None)
         target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, target:%s", target_user, target_ip)
         self.target = ssh.SSH(target_user, target_ip,
-                              key_filename=target_key_filename)
+                              key_filename=target_key_filename,
+                              port=target_ssh_port)
         self.target.wait(timeout=600)
 
         LOG.info("user:%s, host:%s", host_user, host_ip)
         self.host = ssh.SSH(host_user, host_ip,
-                            key_filename=host_key_filename)
+                            key_filename=host_key_filename, port=host_ssh_port)
         self.host.wait(timeout=600)
 
         cmd = "iperf3 -s -D"
index dcd4ef7..08901e1 100755 (executable)
@@ -62,22 +62,26 @@ class Netperf(base.Scenario):
             Netperf.TARGET_SCRIPT)
         host = self.context_cfg['host']
         host_user = host.get('user', 'ubuntu')
+        host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = host.get('ip', None)
         host_key_filename = host.get('key_filename', '~/.ssh/id_rsa')
         target = self.context_cfg['target']
         target_user = target.get('user', 'ubuntu')
+        target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         target_ip = target.get('ip', None)
         target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
 
         # netserver start automatically during the vm boot
         LOG.info("user:%s, target:%s", target_user, target_ip)
         self.server = ssh.SSH(target_user, target_ip,
-                              key_filename=target_key_filename)
+                              key_filename=target_key_filename,
+                              port=target_ssh_port)
         self.server.wait(timeout=600)
 
         LOG.info("user:%s, host:%s", host_user, host_ip)
         self.client = ssh.SSH(host_user, host_ip,
-                              key_filename=host_key_filename)
+                              key_filename=host_key_filename,
+                              port=host_ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
@@ -174,5 +178,6 @@ def _test():
     netperf.run(result)
     print result
 
+
 if __name__ == '__main__':
     _test()
index 87aa8d7..1578da7 100755 (executable)
@@ -63,9 +63,11 @@ class NetperfNode(base.Scenario):
             NetperfNode.TARGET_SCRIPT)
         host = self.context_cfg['host']
         host_user = host.get('user', 'ubuntu')
+        host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = host.get('ip', None)
         target = self.context_cfg['target']
         target_user = target.get('user', 'ubuntu')
+        target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         target_ip = target.get('ip', None)
         self.target_ip = target.get('ip', None)
         host_password = host.get('password', None)
@@ -75,12 +77,12 @@ class NetperfNode(base.Scenario):
         # netserver start automatically during the vm boot
         LOG.info("user:%s, target:%s", target_user, target_ip)
         self.server = ssh.SSH(target_user, target_ip,
-                              password=target_password)
+                              password=target_password, port=target_ssh_port)
         self.server.wait(timeout=600)
 
         LOG.info("user:%s, host:%s", host_user, host_ip)
         self.client = ssh.SSH(host_user, host_ip,
-                              password=host_password)
+                              password=host_password, port=host_ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
index ea43e60..ecde756 100644 (file)
@@ -70,11 +70,13 @@ class NetUtilization(base.Scenario):
         """Scenario setup."""
         host = self.context_cfg['host']
         user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get('ip', None)
         key_filename = host.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         self.setup_done = True
index 57d3b50..438452e 100644 (file)
@@ -1,69 +1,71 @@
-##############################################################################\r
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.\r
-#\r
-# All rights reserved. This program and the accompanying materials\r
-# are made available under the terms of the Apache License, Version 2.0\r
-# which accompanies this distribution, and is available at\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-##############################################################################\r
-import pkg_resources\r
-import logging\r
-import json\r
-\r
-import yardstick.ssh as ssh\r
-from yardstick.benchmark.scenarios import base\r
-\r
-LOG = logging.getLogger(__name__)\r
-\r
-\r
-class NetworkCapacity(base.Scenario):\r
-    """Measure Network capacity and scale.\r
-\r
-    This scenario reads network status including number of connections,\r
-    number of frames sent/received.\r
-    """\r
-    __scenario_type__ = "NetworkCapacity"\r
-    TARGET_SCRIPT = "networkcapacity.bash"\r
-\r
-    def __init__(self, scenario_cfg, context_cfg):\r
-        self.scenario_cfg = scenario_cfg\r
-        self.context_cfg = context_cfg\r
-        self.setup_done = False\r
-\r
-    def setup(self):\r
-        """scenario setup"""\r
-        self.target_script = pkg_resources.resource_filename(\r
-            "yardstick.benchmark.scenarios.networking",\r
-            NetworkCapacity.TARGET_SCRIPT)\r
-\r
-        host = self.context_cfg['host']\r
-        if host is None:\r
-            raise RuntimeError('No right node.please check the configuration')\r
-        host_user = host.get('user', 'ubuntu')\r
-        host_ip = host.get('ip', None)\r
-        host_pwd = host.get('password', None)\r
-\r
-        LOG.debug("user:%s, host:%s", host_user, host_ip)\r
-        self.client = ssh.SSH(host_user, host_ip, password=host_pwd)\r
-        self.client.wait(timeout=600)\r
-\r
-        # copy script to host\r
-        self.client.run("cat > ~/networkcapacity.sh",\r
-                        stdin=open(self.target_script, 'rb'))\r
-\r
-        self.setup_done = True\r
-\r
-    def run(self, result):\r
-        """execute the benchmark"""\r
-\r
-        if not self.setup_done:\r
-            self.setup()\r
-\r
-        cmd = "sudo bash networkcapacity.sh"\r
-\r
-        LOG.debug("Executing command: %s", cmd)\r
-        status, stdout, stderr = self.client.execute(cmd)\r
-        if status:\r
-            raise RuntimeError(stderr)\r
-\r
-        result.update(json.loads(stdout))\r
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import pkg_resources
+import logging
+import json
+
+import yardstick.ssh as ssh
+from yardstick.benchmark.scenarios import base
+
+LOG = logging.getLogger(__name__)
+
+
+class NetworkCapacity(base.Scenario):
+    """Measure Network capacity and scale.
+
+    This scenario reads network status including number of connections,
+    number of frames sent/received.
+    """
+    __scenario_type__ = "NetworkCapacity"
+    TARGET_SCRIPT = "networkcapacity.bash"
+
+    def __init__(self, scenario_cfg, context_cfg):
+        self.scenario_cfg = scenario_cfg
+        self.context_cfg = context_cfg
+        self.setup_done = False
+
+    def setup(self):
+        """scenario setup"""
+        self.target_script = pkg_resources.resource_filename(
+            "yardstick.benchmark.scenarios.networking",
+            NetworkCapacity.TARGET_SCRIPT)
+
+        host = self.context_cfg['host']
+        if host is None:
+            raise RuntimeError('No right node.please check the configuration')
+        host_user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
+        host_ip = host.get('ip', None)
+        host_pwd = host.get('password', None)
+
+        LOG.debug("user:%s, host:%s", host_user, host_ip)
+        self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
+                              port=ssh_port)
+        self.client.wait(timeout=600)
+
+        # copy script to host
+        self.client.run("cat > ~/networkcapacity.sh",
+                        stdin=open(self.target_script, 'rb'))
+
+        self.setup_done = True
+
+    def run(self, result):
+        """execute the benchmark"""
+
+        if not self.setup_done:
+            self.setup()
+
+        cmd = "sudo bash networkcapacity.sh"
+
+        LOG.debug("Executing command: %s", cmd)
+        status, stdout, stderr = self.client.execute(cmd)
+        if status:
+            raise RuntimeError(stderr)
+
+        result.update(json.loads(stdout))
index 54c1922..2becdaf 100644 (file)
@@ -39,6 +39,7 @@ class Ping(base.Scenario):
             'yardstick.benchmark.scenarios.networking', Ping.TARGET_SCRIPT)
         host = self.context_cfg['host']
         user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get('ip', None)
         key_filename = host.get('key_filename', '/root/.ssh/id_rsa')
         password = host.get('password', None)
@@ -46,11 +47,13 @@ class Ping(base.Scenario):
         if password is not None:
             LOG.info("Log in via pw, user:%s, host:%s, pw:%s",
                      user, ip, password)
-            self.connection = ssh.SSH(user, ip, password=password)
+            self.connection = ssh.SSH(user, ip, password=password,
+                                      port=ssh_port)
         else:
             LOG.info("Log in via key, user:%s, host:%s, key_filename:%s",
                      user, ip, key_filename)
-            self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+            self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                      port=ssh_port)
 
         self.connection.wait()
 
index 91183be..9aa94c4 100644 (file)
@@ -51,18 +51,19 @@ class Ping6(base.Scenario):  # pragma: no cover
         # ssh host
         node = self.nodes.get(node_name, None)
         user = node.get('user', 'ubuntu')
+        ssh_port = node.get("ssh_port", ssh.DEFAULT_PORT)
         ip = node.get('ip', None)
         pwd = node.get('password', None)
         key_fname = node.get('key_filename', '/root/.ssh/id_rsa')
-
         if pwd is not None:
             LOG.debug("Log in via pw, user:%s, host:%s, password:%s",
                       user, ip, pwd)
-            self.client = ssh.SSH(user, ip, password=pwd)
+            self.client = ssh.SSH(user, ip, password=pwd, port=ssh_port)
         else:
             LOG.debug("Log in via key, user:%s, host:%s, key_filename:%s",
                       user, ip, key_fname)
-            self.client = ssh.SSH(user, ip, key_filename=key_fname)
+            self.client = ssh.SSH(user, ip, key_filename=key_fname,
+                                  port=ssh_port)
         self.client.wait(timeout=60)
 
     def _pre_setup(self):
@@ -73,6 +74,14 @@ class Ping6(base.Scenario):  # pragma: no cover
             status, stdout, stderr = self.client.execute(
                 "sudo bash pre_setup.sh")
 
+    def _get_controller_node(self, host_list):
+        for host_name in host_list:
+            node = self.nodes.get(host_name, None)
+            node_role = node.get('role', None)
+            if node_role == 'Controller':
+                return host_name
+        return None
+
     def setup(self):
         '''scenario setup'''
         self.setup_script = pkg_resources.resource_filename(
@@ -102,9 +111,12 @@ class Ping6(base.Scenario):  # pragma: no cover
         if pre_setup:
             self._pre_setup()
 
-        # ssh host1
-        self._ssh_host(self.host_list[0])
-
+        # log in a contronller node to setup
+        controller_node_name = self._get_controller_node(self.host_list)
+        LOG.debug("The Controller Node is: %s", controller_node_name)
+        if controller_node_name is None:
+            LOG.exception("Can't find controller node in the context!!!")
+        self._ssh_host(controller_node_name)
         self.client.run("cat > ~/metadata.txt",
                         stdin=open(self.ping6_metadata_script, "rb"))
 
index fb6da4f..592ced3 100644 (file)
@@ -15,8 +15,13 @@ openrc=$1
 external_network=$2
 echo "openrc=$openrc"
 echo "external_network=$external_network"
+echo "nameserver 8.8.4.4" >> /etc/resolv.conf
 source $openrc
-wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2 >/dev/null 2>&1
+
+fedora_img="Fedora-Cloud-Base-22-20150521.x86_64.qcow2"
+if [ ! -f "$fedora_img" ]; then
+    wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/${fedora_img} >/dev/null 2>&1
+fi
 
 glance image-create --name 'Fedora22' --disk-format qcow2 \
 --container-format bare --file ./Fedora-Cloud-Base-22-20150521.x86_64.qcow2
index 9dac4c9..3e10576 100644 (file)
@@ -49,21 +49,25 @@ class Pktgen(base.Scenario):
             Pktgen.TARGET_SCRIPT)
         host = self.context_cfg['host']
         host_user = host.get('user', 'ubuntu')
+        host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = host.get('ip', None)
         host_key_filename = host.get('key_filename', '~/.ssh/id_rsa')
         target = self.context_cfg['target']
         target_user = target.get('user', 'ubuntu')
+        target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         target_ip = target.get('ip', None)
         target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
 
         LOG.info("user:%s, target:%s", target_user, target_ip)
         self.server = ssh.SSH(target_user, target_ip,
-                              key_filename=target_key_filename)
+                              key_filename=target_key_filename,
+                              port=target_ssh_port)
         self.server.wait(timeout=600)
 
         LOG.info("user:%s, host:%s", host_user, host_ip)
         self.client = ssh.SSH(host_user, host_ip,
-                              key_filename=host_key_filename)
+                              key_filename=host_key_filename,
+                              port=host_ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
@@ -169,5 +173,6 @@ def _test():
     p.run(result)
     print result
 
+
 if __name__ == '__main__':
     _test()
index 86585ec..189cc78 100644 (file)
@@ -45,15 +45,18 @@ class PktgenDPDKLatency(base.Scenario):
             PktgenDPDKLatency.TESTPMD_SCRIPT)
         host = self.context_cfg['host']
         host_user = host.get('user', 'ubuntu')
+        host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
         host_ip = host.get('ip', None)
         host_key_filename = host.get('key_filename', '~/.ssh/id_rsa')
         target = self.context_cfg['target']
         target_user = target.get('user', 'ubuntu')
+        target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         target_ip = target.get('ip', None)
         target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
         LOG.info("user:%s, target:%s", target_user, target_ip)
         self.server = ssh.SSH(target_user, target_ip,
-                              key_filename=target_key_filename)
+                              key_filename=target_key_filename,
+                              port=target_ssh_port)
         self.server.wait(timeout=600)
 
         # copy script to host
@@ -62,7 +65,8 @@ class PktgenDPDKLatency(base.Scenario):
 
         LOG.info("user:%s, host:%s", host_user, host_ip)
         self.client = ssh.SSH(host_user, host_ip,
-                              key_filename=host_key_filename)
+                              key_filename=host_key_filename,
+                              port=host_ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
index a126bb5..9494e70 100644 (file)
@@ -41,12 +41,14 @@ class Sfc(base.Scenario):  # pragma: no cover
 
         target = self.context_cfg['target']
         target_user = target.get('user', 'root')
+        target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         target_pwd = target.get('password', 'opnfv')
         target_ip = target.get('ip', None)
 
         ''' webserver start automatically during the vm boot '''
         LOG.info("user:%s, target:%s", target_user, target_ip)
-        self.server = ssh.SSH(target_user, target_ip, password=target_pwd)
+        self.server = ssh.SSH(target_user, target_ip, password=target_pwd,
+                              port=target_ssh_port)
         self.server.wait(timeout=600)
         self.server.run("cat > ~/server.sh",
                         stdin=open(self.server_script, "rb"))
@@ -59,11 +61,13 @@ class Sfc(base.Scenario):  # pragma: no cover
 
         target = self.context_cfg['target']
         SF1_user = target.get('user', 'root')
+        SF1_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         SF1_pwd = target.get('password', 'opnfv')
         SF1_ip = ips[0]
 
         LOG.info("user:%s, host:%s", SF1_user, SF1_ip)
-        self.server = ssh.SSH(SF1_user, SF1_ip, password=SF1_pwd)
+        self.server = ssh.SSH(SF1_user, SF1_ip, password=SF1_pwd,
+                              port=SF1_ssh_port)
         self.server.wait(timeout=600)
         cmd_SF1 = ("nohup python vxlan_tool.py -i eth0 "
                    "-d forward -v off -b 80 &")
@@ -74,11 +78,13 @@ class Sfc(base.Scenario):  # pragma: no cover
             LOG.debug("HTTP firewall started")
 
         SF2_user = target.get('user', 'root')
+        SF2_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
         SF2_pwd = target.get('password', 'opnfv')
         SF2_ip = ips[1]
 
         LOG.info("user:%s, host:%s", SF2_user, SF2_ip)
-        self.server = ssh.SSH(SF2_user, SF2_ip, password=SF2_pwd)
+        self.server = ssh.SSH(SF2_user, SF2_ip, password=SF2_pwd,
+                              port=SF2_ssh_port)
         self.server.wait(timeout=600)
         cmd_SF2 = ("nohup python vxlan_tool.py -i eth0 "
                    "-d forward -v off -b 22 &")
@@ -95,11 +101,13 @@ class Sfc(base.Scenario):  # pragma: no cover
         ''' Creating client and server VMs to perform the test'''
         host = self.context_cfg['host']
         host_user = host.get('user', 'root')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         host_pwd = host.get('password', 'opnfv')
         host_ip = host.get('ip', None)
 
         LOG.info("user:%s, host:%s", host_user, host_ip)
-        self.client = ssh.SSH(host_user, host_ip, password=host_pwd)
+        self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         if not self.setup_done:  # pragma: no cover
index d312308..82db1e2 100644 (file)
@@ -104,6 +104,7 @@ class Vsperf(base.Scenario):
         '''scenario setup'''
         vsperf = self.context_cfg['host']
         vsperf_user = vsperf.get('user', 'ubuntu')
+        vsperf_ssh_port = vsperf.get('ssh_port', ssh.DEFAULT_PORT)
         vsperf_password = vsperf.get('password', 'ubuntu')
         vsperf_ip = vsperf.get('ip', None)
 
@@ -118,7 +119,7 @@ class Vsperf(base.Scenario):
         # copy vsperf conf to VM
         LOG.info("user:%s, host:%s", vsperf_user, vsperf_ip)
         self.client = ssh.SSH(vsperf_user, vsperf_ip,
-                              password=vsperf_password)
+                              password=vsperf_password, port=vsperf_ssh_port)
         # traffic generation could last long
         self.client.wait(timeout=1800)
 
index a8d27fa..0e41536 100644 (file)
@@ -60,11 +60,13 @@ class Fio(base.Scenario):
             Fio.TARGET_SCRIPT)
         host = self.context_cfg["host"]
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         ip = host.get("ip", None)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
         LOG.info("user:%s, host:%s", user, ip)
-        self.client = ssh.SSH(user, ip, key_filename=key_filename)
+        self.client = ssh.SSH(user, ip, key_filename=key_filename,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
index 49e3a03..bed45fa 100644 (file)
@@ -54,11 +54,13 @@ class StorageCapacity(base.Scenario):
         if host is None:
             raise RuntimeError('No right node.Please check the configuration')
         host_user = host.get('user', 'ubuntu')
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         host_ip = host.get('ip', None)
         host_pwd = host.get('password', 'root')
         LOG.debug("user:%s, host:%s", host_user, host_ip)
 
-        self.client = ssh.SSH(host_user, host_ip, password=host_pwd)
+        self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
+                              port=ssh_port)
         self.client.wait(timeout=600)
 
         # copy script to host
index dd74836..f2406bf 100644 (file)
@@ -101,8 +101,7 @@ class YardstickCLI():
             cmd_subparsers = subparser.add_subparsers(title='subcommands')
             self._find_actions(cmd_subparsers, command_object)
 
-    def main(self, argv):
-        '''run the command line interface'''
+    def _register_cli_opt(self):
 
         # register subcommands to parse additional command line arguments
         def parser(subparsers):
@@ -114,10 +113,14 @@ class YardstickCLI():
                                          handler=parser)
         CONF.register_cli_opt(category_opt)
 
+    def _load_cli_config(self, argv):
+
         # load CLI args and config files
         CONF(argv, project="yardstick", version=self._version,
              default_config_files=find_config_files(CONFIG_SEARCH_PATHS))
 
+    def _handle_global_opts(self):
+
         # handle global opts
         logger = logging.getLogger('yardstick')
         logger.setLevel(logging.WARNING)
@@ -128,6 +131,34 @@ class YardstickCLI():
         if CONF.debug:
             logger.setLevel(logging.DEBUG)
 
+    def _dispath_func_notask(self):
+
         # dispatch to category parser
         func = CONF.category.func
         func(CONF.category)
+
+    def _dispath_func_task(self, task_id, timestamp):
+
+        # dispatch to category parser
+        func = CONF.category.func
+        func(CONF.category, task_id=task_id, timestamp=timestamp)
+
+    def main(self, argv):    # pragma: no cover
+        '''run the command line interface'''
+        self._register_cli_opt()
+
+        self._load_cli_config(argv)
+
+        self._handle_global_opts()
+
+        self._dispath_func_notask()
+
+    def api(self, argv, task_id, timestamp):    # pragma: no cover
+        '''run the api interface'''
+        self._register_cli_opt()
+
+        self._load_cli_config(argv)
+
+        self._handle_global_opts()
+
+        self._dispath_func_task(task_id, timestamp)
index 9936942..10e5cdf 100644 (file)
@@ -84,6 +84,7 @@ class PluginCommands(object):
             'yardstick.resources', 'scripts/install/' + target_script)
 
         deployment_user = deployment.get("user")
+        deployment_ssh_port = deployment.get("ssh_port", ssh.DEFAULT_PORT)
         deployment_ip = deployment.get("ip")
         deployment_password = deployment.get("password")
 
@@ -92,12 +93,14 @@ class PluginCommands(object):
 
             LOG.info("user:%s, host:%s", deployment_user, installer_ip)
             self.client = ssh.SSH(deployment_user, installer_ip,
-                                  password=deployment_password)
+                                  password=deployment_password,
+                                  port=deployment_ssh_port)
             self.client.wait(timeout=600)
         else:
             LOG.info("user:%s, host:%s", deployment_user, deployment_ip)
             self.client = ssh.SSH(deployment_user, deployment_ip,
-                                  password=deployment_password)
+                                  password=deployment_password,
+                                  port=deployment_ssh_port)
             self.client.wait(timeout=600)
 
         # copy script to host
@@ -113,6 +116,7 @@ class PluginCommands(object):
             'yardstick.resources', 'scripts/remove/' + target_script)
 
         deployment_user = deployment.get("user")
+        deployment_ssh_port = deployment.get("ssh_port", ssh.DEFAULT_PORT)
         deployment_ip = deployment.get("ip")
         deployment_password = deployment.get("password")
 
@@ -121,12 +125,14 @@ class PluginCommands(object):
 
             LOG.info("user:%s, host:%s", deployment_user, installer_ip)
             self.client = ssh.SSH(deployment_user, installer_ip,
-                                  password=deployment_password)
+                                  password=deployment_password,
+                                  port=deployment_ssh_port)
             self.client.wait(timeout=600)
         else:
             LOG.info("user:%s, host:%s", deployment_user, deployment_ip)
             self.client = ssh.SSH(deployment_user, deployment_ip,
-                                  password=deployment_password)
+                                  password=deployment_password,
+                                  port=deployment_ssh_port)
             self.client.wait(timeout=600)
 
         # copy script to host
@@ -145,6 +151,7 @@ class PluginCommands(object):
 
 class PluginParser(object):
     '''Parser for plugin configration files in yaml format'''
+
     def __init__(self, path):
         self.path = path
 
index b38e084..a10a2a8 100644 (file)
@@ -51,7 +51,7 @@ class TaskCommands(object):
              output_file_default, default=output_file_default)
     @cliargs("--suite", help="process test suite file instead of a task file",
              action="store_true")
-    def do_start(self, args):
+    def do_start(self, args, **kwargs):
         '''Start a benchmark scenario.'''
 
         atexit.register(atexit_handler)
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
new file mode 100644 (file)
index 0000000..40b29a7
--- /dev/null
@@ -0,0 +1,3 @@
+CONFIG_SAMPLE = '/etc/yardstick/config.yaml'
+
+RELENG_DIR = 'releng.dir'
index c482b4d..d639fb6 100644 (file)
@@ -17,6 +17,7 @@
 
 import os
 import sys
+import yaml
 from oslo_utils import importutils
 
 import yardstick
@@ -68,3 +69,25 @@ def import_modules_from_package(package):
             new_package = ".".join(root.split(os.sep)).split("....")[1]
             module_name = "%s.%s" % (new_package, filename[:-3])
             try_append_module(module_name, sys.modules)
+
+
+def get_para_from_yaml(file_path, args):
+
+    def func(a, b):
+        if a is None:
+            return None
+        return a.get(b)
+
+    if os.path.exists(file_path):
+        with open(file_path) as f:
+            value = yaml.safe_load(f)
+            value = reduce(func, args.split('.'), value)
+
+            if value is None:
+                print 'parameter not found'
+                return None
+
+            return value
+    else:
+        print 'file not exist'
+        return None
index cf890df..8b71fe6 100644 (file)
@@ -69,6 +69,8 @@ import logging
 
 LOG = logging.getLogger(__name__)
 
+DEFAULT_PORT = 22
+
 
 class SSHError(Exception):
     pass
@@ -81,7 +83,7 @@ class SSHTimeout(SSHError):
 class SSH(object):
     """Represent ssh connection."""
 
-    def __init__(self, user, host, port=22, pkey=None,
+    def __init__(self, user, host, port=DEFAULT_PORT, pkey=None,
                  key_filename=None, password=None):
         """Initialize SSH client.
 
@@ -95,7 +97,8 @@ class SSH(object):
 
         self.user = user
         self.host = host
-        self.port = port
+        # we may get text port from YAML, convert to int
+        self.port = int(port)
         self.pkey = self._get_pkey(pkey) if pkey else None
         self.password = password
         self.key_filename = key_filename