diff options
Diffstat (limited to 'yardstick/network_services')
6 files changed, 24 insertions, 45 deletions
diff --git a/yardstick/network_services/nfvi/resource.py b/yardstick/network_services/nfvi/resource.py index d71e1e995..18b0d8952 100644 --- a/yardstick/network_services/nfvi/resource.py +++ b/yardstick/network_services/nfvi/resource.py @@ -40,13 +40,11 @@ class ResourceProfile(object): self.cores = cores mgmt_interface = vnfd.get("mgmt-interface") - user = mgmt_interface.get("user") - passwd = mgmt_interface.get("password") - ip_addr = mgmt_interface.get("ip") - self.vnfip = mgmt_interface.get("host", ip_addr) - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - self.connection = ssh.SSH(user, self.vnfip, - password=passwd, port=ssh_port) + # why the host or ip? + self.vnfip = mgmt_interface.get("host", mgmt_interface["ip"]) + self.connection = ssh.SSH.from_node(mgmt_interface, + overrides={"ip": self.vnfip}) + self.connection.wait() def check_if_sa_running(self, process): diff --git a/yardstick/network_services/vnf_generic/vnf/tg_ping.py b/yardstick/network_services/vnf_generic/vnf/tg_ping.py index 2844a5c01..000a91db4 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_ping.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_ping.py @@ -69,12 +69,7 @@ class PingTrafficGen(GenericTrafficGen): self._traffic_process = None mgmt_interface = vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - LOG.debug("Connecting to %s", mgmt_interface["ip"]) - - self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + self.connection = ssh.SSH.from_node(mgmt_interface) self.connection.wait() def _bind_device_kernel(self, connection): @@ -130,10 +125,7 @@ class PingTrafficGen(GenericTrafficGen): def _traffic_runner(self, traffic_profile, filewrapper): mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + self.connection = ssh.SSH.from_node(mgmt_interface) self.connection.wait() external_interface = self.vnfd["vdu"][0]["external-interface"] virtual_interface = external_interface[0]["virtual-interface"] diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py index 37c1a7345..7da4b31e9 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py @@ -55,10 +55,8 @@ class TrexTrafficGenRFC(GenericTrafficGen): self.my_ports = None mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + + self.connection = ssh.SSH.from_node(mgmt_interface) self.connection.wait() @classmethod @@ -166,10 +164,8 @@ class TrexTrafficGenRFC(GenericTrafficGen): def _start_server(self): mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - _server = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + + _server = ssh.SSH.from_node(mgmt_interface) _server.wait() _server.execute("fuser -n tcp %s %s -k > /dev/null 2>&1" % diff --git a/yardstick/network_services/vnf_generic/vnf/tg_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_trex.py index 2731476e0..61182a23b 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_trex.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_trex.py @@ -52,12 +52,9 @@ class TrexTrafficGen(GenericTrafficGen): self.my_ports = None self.client_started = multiprocessing.Value('i', 0) - mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - self.connection = ssh.SSH(mgmt_interface["user"], - mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + mgmt_interface = vnfd["mgmt-interface"] + + self.connection = ssh.SSH.from_node(mgmt_interface) self.connection.wait() @classmethod @@ -198,10 +195,8 @@ class TrexTrafficGen(GenericTrafficGen): def _start_server(self): mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - _server = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + + _server = ssh.SSH.from_node(mgmt_interface) _server.wait() _server.execute("fuser -n tcp %s %s -k > /dev/null 2>&1" % diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py index 8c766f01e..e9e80bdfb 100644 --- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py @@ -120,14 +120,11 @@ class VpeApproxVnf(GenericVNF): def instantiate(self, scenario_cfg, context_cfg): vnf_cfg = scenario_cfg['vnf_options']['vpe']['cfg'] - mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + mgmt_interface = self.vnfd["mgmt-interface"] + self.connection = ssh.SSH.from_node(mgmt_interface) - self.connection.wait() + self.tc_file_name = '{0}.yaml'.format(scenario_cfg['tc']) self.setup_vnf_environment(self.connection) @@ -189,11 +186,10 @@ class VpeApproxVnf(GenericVNF): def _run_vpe(self, filewrapper, vnf_cfg): mgmt_interface = self.vnfd["mgmt-interface"] - ssh_port = mgmt_interface.get("ssh_port", ssh.DEFAULT_PORT) - self.connection = ssh.SSH(mgmt_interface["user"], mgmt_interface["ip"], - password=mgmt_interface["password"], - port=ssh_port) + + self.connection = ssh.SSH.from_node(mgmt_interface) self.connection.wait() + interfaces = self.vnfd["vdu"][0]['external-interface'] port0_ip = ipaddress.ip_interface(six.text_type( "%s/%s" % (interfaces[0]["virtual-interface"]["local_ip"], diff --git a/yardstick/network_services/vnf_generic/vnfdgen.py b/yardstick/network_services/vnf_generic/vnfdgen.py index 64554cdaf..97dd97198 100644 --- a/yardstick/network_services/vnf_generic/vnfdgen.py +++ b/yardstick/network_services/vnf_generic/vnfdgen.py @@ -28,7 +28,9 @@ def generate_vnfd(vnf_model, node): :return: Complete VNF Descriptor that will be taken as input for GenericVNF.__init__ """ + # get is unused as global method inside template node["get"] = get + # Set Node details to default if not defined in pod file rendered_vnfd = TaskTemplate.render(vnf_model, **node) # This is done to get rid of issues with serializing node del node["get"] |