aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py4
-rw-r--r--yardstick/network_services/nfvi/resource.py32
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py4
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py4
4 files changed, 23 insertions, 21 deletions
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index cb26fd085..072f06edf 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -108,13 +108,13 @@ class TestResourceProfile(unittest.TestCase):
def test_get_cpu_data(self):
reskey = ["", "cpufreq", "cpufreq-0"]
value = "metric:10"
- val = self.resource_profile.get_cpu_data(reskey, value)
+ val = self.resource_profile.get_cpu_data(reskey[1], reskey[2], value)
self.assertIsNotNone(val)
def test_get_cpu_data_error(self):
reskey = ["", "", ""]
value = "metric:10"
- val = self.resource_profile.get_cpu_data(reskey, value)
+ val = self.resource_profile.get_cpu_data(reskey[0], reskey[1], value)
self.assertEqual(val, ('error', 'Invalid', '', ''))
def test__start_collectd(self):
diff --git a/yardstick/network_services/nfvi/resource.py b/yardstick/network_services/nfvi/resource.py
index ce09b6597..2fb4a8e8e 100644
--- a/yardstick/network_services/nfvi/resource.py
+++ b/yardstick/network_services/nfvi/resource.py
@@ -73,18 +73,18 @@ class ResourceProfile(object):
@classmethod
def parse_simple_resource(cls, key, value):
- return {'/'.join(key): value.split(":")[1]}
+ reskey = "/".join(rkey for rkey in key if "nsb_stats" not in rkey)
+ return {reskey: value.split(":")[1]}
@classmethod
- def get_cpu_data(cls, key_split, value):
+ def get_cpu_data(cls, res_key0, res_key1, value):
""" Get cpu topology of the host """
pattern = r"-(\d+)"
- if "cpufreq" in key_split[0]:
- metric = key_split[0]
- source = key_split[1]
+
+ if 'cpufreq' in res_key0:
+ metric, source = res_key0, res_key1
else:
- metric = key_split[1]
- source = key_split[0]
+ metric, source = res_key1, res_key0
match = re.search(pattern, source, re.MULTILINE)
if not match:
@@ -128,7 +128,8 @@ class ResourceProfile(object):
res_key1 = next(res_key_iter)
if "cpu" in res_key0 or "intel_rdt" in res_key0:
- cpu_key, name, metric, testcase = self.get_cpu_data(key_split, value)
+ cpu_key, name, metric, testcase = \
+ self.get_cpu_data(res_key0, res_key1, value)
if cpu_key in core_list:
result["cpu"].setdefault(cpu_key, {}).update({name: metric})
@@ -136,16 +137,16 @@ class ResourceProfile(object):
result["memory"].update({res_key1: value.split(":")[0]})
elif "hugepages" in res_key0:
- result["hugepages"].update(self.parse_hugepages(key, value))
+ result["hugepages"].update(self.parse_hugepages(key_split, value))
elif "dpdkstat" in res_key0:
- result["dpdkstat"].update(self.parse_dpdkstat(key, value))
+ result["dpdkstat"].update(self.parse_dpdkstat(key_split, value))
elif "virt" in res_key1:
- result["virt"].update(self.parse_virt(key, value))
+ result["virt"].update(self.parse_virt(key_split, value))
elif "ovs_stats" in res_key0:
- result["ovs_stats"].update(self.parse_ovs_stats(key, value))
+ result["ovs_stats"].update(self.parse_ovs_stats(key_split, value))
result["timestamp"] = testcase
@@ -153,13 +154,16 @@ class ResourceProfile(object):
def amqp_process_for_nfvi_kpi(self):
""" amqp collect and return nfvi kpis """
- if self.amqp_client is None:
+ if self.amqp_client is None and self.enable:
self.amqp_client = \
multiprocessing.Process(target=self.run_collectd_amqp)
self.amqp_client.start()
def amqp_collect_nfvi_kpi(self):
""" amqp collect and return nfvi kpis """
+ if not self.enable:
+ return {}
+
metric = {}
while not self._queue.empty():
metric.update(self._queue.get())
@@ -193,8 +197,6 @@ class ResourceProfile(object):
def _start_collectd(self, connection, bin_path):
LOG.debug("Starting collectd to collect NFVi stats")
- # temp disable
- return
connection.execute('sudo pkill -9 collectd')
collectd = os.path.join(bin_path, "collectd.sh")
provision_tool(connection, collectd)
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
index 4abe06059..78d2bd8ba 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
@@ -63,8 +63,8 @@ class IxiaResourceHelper(ClientResourceHelper):
def _build_ports(self):
# self.generate_port_pairs(self.topology)
- self.priv_ports = [int(x[0][-1]) for x in self.tg_port_pairs]
- self.pub_ports = [int(x[1][-1]) for x in self.tg_port_pairs]
+ self.priv_ports = [int(x[0][2:]) for x in self.tg_port_pairs]
+ self.pub_ports = [int(x[1][2:]) for x in self.tg_port_pairs]
self.my_ports = list(set(self.priv_ports).union(set(self.pub_ports)))
def get_stats(self, *args, **kwargs):
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py
index 548060849..d94a9a6e6 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py
@@ -52,8 +52,8 @@ class TrexRfcResourceHelper(TrexResourceHelper):
def _build_ports(self):
self.tg_port_pairs, self.networks = MultiPortConfig.get_port_pairs(
self.vnfd_helper.interfaces)
- self.priv_ports = [int(x[0][-1]) for x in self.tg_port_pairs]
- self.pub_ports = [int(x[1][-1]) for x in self.tg_port_pairs]
+ self.priv_ports = [int(x[0][2:]) for x in self.tg_port_pairs]
+ self.pub_ports = [int(x[1][2:]) for x in self.tg_port_pairs]
self.my_ports = list(set(chain(self.priv_ports, self.pub_ports)))
def _run_traffic_once(self, traffic_profile):