diff options
Diffstat (limited to 'yardstick/benchmark/contexts/standalone.py')
-rw-r--r-- | yardstick/benchmark/contexts/standalone.py | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/yardstick/benchmark/contexts/standalone.py b/yardstick/benchmark/contexts/standalone.py index 8614f0cac..e921437d6 100644 --- a/yardstick/benchmark/contexts/standalone.py +++ b/yardstick/benchmark/contexts/standalone.py @@ -21,6 +21,7 @@ import yaml from yardstick.benchmark.contexts.base import Context from yardstick.common.constants import YARDSTICK_ROOT_PATH +from yardstick.common.utils import import_modules_from_package, itersubclasses LOG = logging.getLogger(__name__) @@ -38,7 +39,8 @@ class StandaloneContext(Context): self.nodes = [] self.networks = {} self.nfvi_node = [] - super(StandaloneContext, self).__init__() + self.nfvi_obj = None + super(self.__class__, self).__init__() def read_config_file(self): """Read from config file""" @@ -48,6 +50,14 @@ class StandaloneContext(Context): cfg = yaml.load(stream) return cfg + def get_nfvi_obj(self): + print("{0}".format(self.nfvi_node[0]['role'])) + context_type = self.get_context_impl(self.nfvi_node[0]['role']) + nfvi_obj = context_type() + nfvi_obj.__init__() + nfvi_obj.parse_pod_and_get_data(self.file_path) + return nfvi_obj + def init(self, attrs): """initializes itself from the supplied arguments""" @@ -69,6 +79,15 @@ class StandaloneContext(Context): if node["role"] == "nfvi_node"]) # add optional static network definition self.networks.update(cfg.get("networks", {})) + for node in cfg["nodes"]: + if str(node["role"]) == "Sriov": + self.nfvi_node.extend([node for node in cfg["nodes"] + if str(node["role"]) == "Sriov"]) + if str(node["role"]) == "ovs-dpdk": + LOG.info("{0}".format(node["role"])) + else: + LOG.debug("Node role is other than SRIOV and OVS") + self.nfvi_obj = self.get_nfvi_obj() LOG.debug("Nodes: %r", self.nodes) LOG.debug("NFVi Node: %r", self.nfvi_node) LOG.debug("Networks: %r", self.networks) @@ -77,13 +96,26 @@ class StandaloneContext(Context): """don't need to deploy""" # Todo: NFVi deploy (sriov, vswitch, ovs etc) based on the config. + self.nfvi_obj.ssh_remote_machine() + if self.nfvi_obj.first_run is True: + self.nfvi_obj.install_req_libs() + + nic_details = self.nfvi_obj.get_nic_details() + print("{0}".format(nic_details)) + self.nfvi_obj.setup_sriov_context( + self.nfvi_obj.sriov[0]['phy_ports'], + nic_details, + self.nfvi_obj.sriov[0]['phy_driver']) pass def undeploy(self): """don't need to undeploy""" # Todo: NFVi undeploy (sriov, vswitch, ovs etc) based on the config. - super(StandaloneContext, self).undeploy() + # self.nfvi_obj = self.get_nfvi_obj() + self.nfvi_obj.ssh_remote_machine() + self.nfvi_obj.destroy_vm() + pass def _get_server(self, attr_name): """lookup server info by name from context @@ -95,7 +127,7 @@ class StandaloneContext(Context): if isinstance(attr_name, collections.Mapping): return None - if self.name.split("-")[0] != attr_name.split(".")[1]: + if self.name != attr_name.split(".")[1]: return None node_name = attr_name.split(".")[0] @@ -146,3 +178,19 @@ class StandaloneContext(Context): "physical_network": network.get("physical_network"), } return result + + def get_context_impl(self, nfvi_type): + """ Find the implementing class from vnf_model["vnf"]["name"] field + + :param vnf_model: dictionary containing a parsed vnfd + :return: subclass of GenericVNF + """ + import_modules_from_package( + "yardstick.benchmark.contexts") + expected_name = nfvi_type + impl = [c for c in itersubclasses(StandaloneContext) + if c.__name__ == expected_name] + try: + return next(iter(impl)) + except StopIteration: + raise ValueError("No implementation for %s", expected_name) |