resource: move make_resource_profile to ResourceProfile 81/45081/1
authorRoss Brattain <ross.b.brattain@intel.com>
Fri, 13 Oct 2017 22:18:16 +0000 (15:18 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Fri, 13 Oct 2017 22:18:51 +0000 (15:18 -0700)
move factory method from Collector to ResourceProfile

Change-Id: I1ddf3cffed7a3b2d45aa9cbffd3c0a5925c325d6
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
yardstick/network_services/collector/subscriber.py
yardstick/network_services/nfvi/resource.py

index d560e1d..4dc5a79 100644 (file)
@@ -23,18 +23,6 @@ LOG = logging.getLogger(__name__)
 class Collector(object):
     """Class that handles dictionary of results in yardstick-plot format."""
 
-    @staticmethod
-    def make_resource_profile(node, timeout):
-        # node dict works as mgmt dict
-        # don't need port names, there is no way we can
-        # tell what port is used on the compute node
-        collectd_options = node["collectd"]
-        plugins = collectd_options.get("plugins", {})
-        interval = collectd_options.get("interval")
-
-        # use default cores = None to MatchAllCores
-        return ResourceProfile(node, plugins=plugins, interval=interval, timeout=timeout)
-
     def __init__(self, vnfs, nodes, traffic_profile, timeout=3600):
         super(Collector, self).__init__()
         self.traffic_profile = traffic_profile
@@ -42,7 +30,7 @@ class Collector(object):
         self.nodes = nodes
         self.timeout = timeout
         self.bin_path = get_nsb_option('bin_path', '')
-        self.resource_profiles = {node_name: self.make_resource_profile(node, self.timeout)
+        self.resource_profiles = {node_name: ResourceProfile.make_from_node(node, self.timeout)
                                   for node_name, node in self.nodes.items()
                                   if node.get("collectd")}
 
index dea754d..5b96aaf 100644 (file)
@@ -82,6 +82,18 @@ class ResourceProfile(object):
         self.mgmt = mgmt
         self.connection = ssh.AutoConnectSSH.from_node(mgmt)
 
+    @classmethod
+    def make_from_node(cls, node, timeout):
+        # node dict works as mgmt dict
+        # don't need port names, there is no way we can
+        # tell what port is used on the compute node
+        collectd_options = node["collectd"]
+        plugins = collectd_options.get("plugins", {})
+        interval = collectd_options.get("interval")
+
+        # use default cores = None to MatchAllCores
+        return cls(node, plugins=plugins, interval=interval, timeout=timeout)
+
     def check_if_sa_running(self, process):
         """ verify if system agent is running """
         try: