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."""
27 def make_resource_profile(node, timeout):
28 # node dict works as mgmt dict
29 # don't need port names, there is no way we can
30 # tell what port is used on the compute node
31 collectd_options = node["collectd"]
32 plugins = collectd_options.get("plugins", {})
33 interval = collectd_options.get("interval")
35 # use default cores = None to MatchAllCores
36 return ResourceProfile(node, plugins=plugins, interval=interval, timeout=timeout)
38 def __init__(self, vnfs, nodes, traffic_profile, timeout=3600):
39 super(Collector, self).__init__()
40 self.traffic_profile = traffic_profile
43 self.timeout = timeout
44 self.bin_path = get_nsb_option('bin_path', '')
45 self.resource_profiles = {node_name: self.make_resource_profile(node, self.timeout)
46 for node_name, node in self.nodes.items()
47 if node.get("collectd")}
50 """Nothing to do, yet"""
51 for resource in self.resource_profiles.values():
52 resource.initiate_systemagent(self.bin_path)
54 resource.amqp_process_for_nfvi_kpi()
57 """Nothing to do, yet"""
58 for resource in self.resource_profiles.values():
62 """Returns dictionary of results in yardstick-plot format
69 # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
70 LOG.debug("collect KPI for %s", vnf.name)
71 results[vnf.name] = vnf.collect_kpi()
73 for node_name, resource in self.resource_profiles.items():
75 # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
76 LOG.debug("collect KPI for %s", node_name)
77 if resource.check_if_sa_running("collectd")[0] != 0:
81 results[node_name] = {"core": resource.amqp_collect_nfvi_kpi()}
82 LOG.debug("%s collect KPIs %s", node_name, results[node_name]['core'])