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
20 LOG = logging.getLogger(__name__)
23 class Collector(object):
24 """Class that handles dictionary of results in yardstick-plot format."""
26 def __init__(self, vnfs, nodes, traffic_profile, timeout=3600):
27 super(Collector, self).__init__()
28 self.traffic_profile = traffic_profile
31 self.timeout = timeout
32 self.bin_path = get_nsb_option('bin_path', '')
33 self.resource_profiles = {node_name: ResourceProfile.make_from_node(node, self.timeout)
34 for node_name, node in self.nodes.items()
35 if node.get("collectd")}
38 """Nothing to do, yet"""
39 for resource in self.resource_profiles.values():
40 resource.initiate_systemagent(self.bin_path)
42 resource.amqp_process_for_nfvi_kpi()
45 """Nothing to do, yet"""
46 for resource in self.resource_profiles.values():
50 """Returns dictionary of results in yardstick-plot format
57 # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
58 LOG.debug("collect KPI for %s", vnf.name)
59 results[vnf.name] = vnf.collect_kpi()
61 for node_name, resource in self.resource_profiles.items():
63 # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
64 LOG.debug("collect KPI for %s", node_name)
65 if resource.check_if_system_agent_running("collectd")[0] != 0:
69 results[node_name] = {"core": resource.amqp_collect_nfvi_kpi()}
70 LOG.debug("%s collect KPIs %s", node_name, results[node_name]['core'])
71 # NOTE(elfoley): catch a more specific error
72 except Exception as exc: # pylint: disable=broad-except