1 # Copyright (c) 2016-2017 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """This module implements stub for publishing results in yardstick format."""
17 from yardstick.network_services.nfvi.resource import ResourceProfile
18 from yardstick.network_services.utils import get_nsb_option
21 LOG = logging.getLogger(__name__)
24 class Collector(object):
25 """Class that handles dictionary of results in yardstick-plot format."""
27 def __init__(self, vnfs, contexts_nodes, timeout=3600):
28 super(Collector, self).__init__()
30 self.nodes = contexts_nodes
31 self.bin_path = get_nsb_option('bin_path', '')
32 self.resource_profiles = {}
34 for ctx_name, nodes in contexts_nodes.items():
35 for node in (node for node in nodes if node.get('collectd')):
36 name = ".".join([node['name'], ctx_name])
37 self.resource_profiles.update(
38 {name: ResourceProfile.make_from_node(node, timeout)}
42 for resource in self.resource_profiles.values():
43 resource.initiate_systemagent(self.bin_path)
45 resource.amqp_process_for_nfvi_kpi()
54 for resource in self.resource_profiles.values():
58 """Returns dictionary of results in yardstick-plot format
60 :return: (dict) dictionary of kpis collected from the VNFs;
61 the keys are the names of the VNFs.
66 # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
67 LOG.debug("collect KPI for vnf %s", vnf.name)
68 results[vnf.name] = vnf.collect_kpi()
70 for node_name, resource in self.resource_profiles.items():
71 LOG.debug("collect KPI for nfvi_node %s", node_name)
72 results[node_name] = {"core": resource.amqp_collect_nfvi_kpi()}
73 LOG.debug("%s collect KPIs %s", node_name, results[node_name]['core'])