示例#1
0
    def _start_collectd(cls, connection, bin_path):
        connection.execute('pkill -9 collectd')
        collectd = os.path.join(bin_path, "collectd.sh")
        provision_tool(connection, collectd)
        provision_tool(connection, os.path.join(bin_path, "collectd.conf"))

        # Reset amqp queue
        connection.execute("sudo service rabbitmq-server start")
        connection.execute("sudo rabbitmqctl stop_app")
        connection.execute("sudo rabbitmqctl reset")
        connection.execute("sudo rabbitmqctl start_app")
        connection.execute("sudo service rabbitmq-server restart")

        # Run collectd
        connection.execute(collectd)
        connection.execute(os.path.join(bin_path, "collectd", "collectd"))
示例#2
0
    def deploy(self):
        """don't need to deploy"""

        # Todo: NFVi deploy (sriov, vswitch, ovs etc) based on the config.
        if not self.vm_deploy:
            return

        self.connection = ssh.SSH.from_node(self.host_mgmt)
        self.dpdk_nic_bind = provision_tool(
            self.connection,
            os.path.join(get_nsb_option("bin_path"), "dpdk-devbind.py"))

        # Check dpdk/ovs version, if not present install
        self.check_ovs_dpdk_env()
        #    Todo: NFVi deploy (sriov, vswitch, ovs etc) based on the config.
        StandaloneContextHelper.install_req_libs(self.connection)
        self.networks = StandaloneContextHelper.get_nic_details(
            self.connection, self.networks, self.dpdk_nic_bind)

        self.setup_ovs()
        self.start_ovs_serverswitch()
        self.setup_ovs_bridge_add_flows()
        self.nodes = self.setup_ovs_dpdk_context()
        LOG.debug("Waiting for VM to come up...")
        self.nodes = StandaloneContextHelper.wait_for_vnfs_to_start(
            self.connection, self.servers, self.nodes)
示例#3
0
 def test_provision_tool_no_path(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(1, self.DPDK_PATH, ""))
         ssh.return_value = ssh_mock
         tool_path = utils.provision_tool(ssh_mock, self.DPDK_PATH)
         self.assertEqual(tool_path, self.DPDK_PATH)
示例#4
0
    def instantiate(self, scenario_cfg, context_cfg):
        vnf_cfg = scenario_cfg['vnf_options']['vpe']['cfg']

        mgmt_interface = self.vnfd["mgmt-interface"]
        self.connection = ssh.SSH.from_node(mgmt_interface)

        self.tc_file_name = '{0}.yaml'.format(scenario_cfg['tc'])

        self.setup_vnf_environment(self.connection)

        cores = self._get_cpu_sibling_list()
        self.resource = ResourceProfile(self.vnfd, cores)

        self.connection.execute("pkill vPE_vnf")
        dpdk_nic_bind = \
            provision_tool(self.connection,
                           os.path.join(self.bin_path, "dpdk_nic_bind.py"))

        interfaces = self.vnfd["vdu"][0]['external-interface']
        self.socket = \
            next((0 for v in interfaces
                  if v['virtual-interface']["vpci"][5] == "0"), 1)

        bound_pci = [v['virtual-interface']["vpci"] for v in interfaces]
        for vpci in bound_pci:
            self.connection.execute("%s --force -b igb_uio %s" %
                                    (dpdk_nic_bind, vpci))
        queue_wrapper = \
            QueueFileWrapper(self.q_in, self.q_out, "pipeline>")
        self._vnf_process = multiprocessing.Process(target=self._run_vpe,
                                                    args=(
                                                        queue_wrapper,
                                                        vnf_cfg,
                                                    ))
        self._vnf_process.start()
        buf = []
        time.sleep(WAIT_TIME)  # Give some time for config to load
        while True:
            message = ''
            while self.q_out.qsize() > 0:
                buf.append(self.q_out.get())
                message = ''.join(buf)
                if "pipeline>" in message:
                    LOG.info("VPE VNF is up and running.")
                    queue_wrapper.clear()
                    self._resource_collect_start()
                    return self._vnf_process.exitcode
                if "PANIC" in message:
                    raise RuntimeError("Error starting vPE VNF.")

            LOG.info("Waiting for VNF to start.. ")
            time.sleep(3)
            if not self._vnf_process.is_alive():
                raise RuntimeError("vPE VNF process died.")
示例#5
0
    def setup_vnf_environment(self, connection):
        ''' setup dpdk environment needed for vnf to run '''

        self.__setup_hugepages(connection)
        connection.execute("modprobe uio && modprobe igb_uio")

        exit_status = connection.execute("lsmod | grep -i igb_uio")[0]
        if exit_status == 0:
            return

        dpdk = os.path.join(self.bin_path, "dpdk-16.07")
        dpdk_setup = \
            provision_tool(self.connection,
                           os.path.join(self.bin_path, "nsb_setup.sh"))
        status = connection.execute("ls {} >/dev/null 2>&1".format(dpdk))[0]
        if status:
            connection.execute("bash %s dpdk >/dev/null 2>&1" % dpdk_setup)
示例#6
0
 def ssh_remote_machine(self):
     if self.sriov[0]['auth_type'] == "password":
         self.connection = ssh.SSH(self.user,
                                   self.ssh_ip,
                                   password=self.passwd)
         self.connection.wait()
     else:
         if self.ssh_port is not None:
             ssh_port = self.ssh_port
         else:
             ssh_port = ssh.DEFAULT_PORT
         self.connection = ssh.SSH(self.user,
                                   self.ssh_ip,
                                   port=ssh_port,
                                   key_filename=self.key_filename)
         self.connection.wait()
     self.dpdk_nic_bind = provision_tool(
         self.connection,
         os.path.join(get_nsb_option("bin_path"), "dpdk_nic_bind.py"))
示例#7
0
    def _bind_device_kernel(self, connection):
        dpdk_nic_bind = \
            provision_tool(self.connection,
                           os.path.join(self.bin_path, "dpdk_nic_bind.py"))

        drivers = {
            intf["virtual-interface"]["vpci"]:
            intf["virtual-interface"]["driver"]
            for intf in self.vnfd["vdu"][0]["external-interface"]
        }

        commands = \
            ['"{0}" --force -b "{1}" "{2}"'.format(dpdk_nic_bind, value, key)
             for key, value in drivers.items()]
        for command in commands:
            connection.execute(command)

        for index, out in enumerate(self.vnfd["vdu"][0]["external-interface"]):
            vpci = out["virtual-interface"]["vpci"]
            net = "find /sys/class/net -lname '*{}*' -printf '%f'".format(vpci)
            out = connection.execute(net)[1]
            ifname = out.split('/')[-1].strip('\n')
            self.vnfd["vdu"][0]["external-interface"][index][
                "virtual-interface"]["local_iface_name"] = ifname
示例#8
0
 def provision_tool(self, tool_path, tool_file=None):
     return provision_tool(self, tool_path, tool_file)
示例#9
0
    def _run_vpe(self, filewrapper, vnf_cfg):
        mgmt_interface = self.vnfd["mgmt-interface"]

        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"],
                           interfaces[0]["virtual-interface"]["netmask"])))
        port1_ip = ipaddress.ip_interface(
            six.text_type("%s/%s" %
                          (interfaces[1]["virtual-interface"]["local_ip"],
                           interfaces[1]["virtual-interface"]["netmask"])))
        dst_port0_ip = ipaddress.ip_interface(
            u"%s/%s" % (interfaces[0]["virtual-interface"]["dst_ip"],
                        interfaces[0]["virtual-interface"]["netmask"]))
        dst_port1_ip = ipaddress.ip_interface(
            u"%s/%s" % (interfaces[1]["virtual-interface"]["dst_ip"],
                        interfaces[1]["virtual-interface"]["netmask"]))

        vpe_vars = {
            "port0_local_ip": port0_ip.ip.exploded,
            "port0_dst_ip": dst_port0_ip.ip.exploded,
            "port0_local_ip_hex": self._ip_to_hex(port0_ip.ip.exploded),
            "port0_prefixlen": port0_ip.network.prefixlen,
            "port0_netmask": port0_ip.network.netmask.exploded,
            "port0_netmask_hex":
            self._ip_to_hex(port0_ip.network.netmask.exploded),
            "port0_local_mac": interfaces[0]["virtual-interface"]["local_mac"],
            "port0_dst_mac": interfaces[0]["virtual-interface"]["dst_mac"],
            "port0_gateway": self._get_ports_gateway(interfaces[0]["name"]),
            "port0_local_network": port0_ip.network.network_address.exploded,
            "port0_prefix": port0_ip.network.prefixlen,
            "port1_local_ip": port1_ip.ip.exploded,
            "port1_dst_ip": dst_port1_ip.ip.exploded,
            "port1_local_ip_hex": self._ip_to_hex(port1_ip.ip.exploded),
            "port1_prefixlen": port1_ip.network.prefixlen,
            "port1_netmask": port1_ip.network.netmask.exploded,
            "port1_netmask_hex":
            self._ip_to_hex(port1_ip.network.netmask.exploded),
            "port1_local_mac": interfaces[1]["virtual-interface"]["local_mac"],
            "port1_dst_mac": interfaces[1]["virtual-interface"]["dst_mac"],
            "port1_gateway": self._get_ports_gateway(interfaces[1]["name"]),
            "port1_local_network": port1_ip.network.network_address.exploded,
            "port1_prefix": port1_ip.network.prefixlen,
            "port0_local_ip6": self._get_port0localip6(),
            "port1_local_ip6": self._get_port1localip6(),
            "port0_prefixlen6": self._get_port0prefixlen6(),
            "port1_prefixlen6": self._get_port1prefixlen6(),
            "port0_gateway6": self._get_port0gateway6(),
            "port1_gateway6": self._get_port1gateway6(),
            "port0_dst_ip_hex6": self._get_port0localip6(),
            "port1_dst_ip_hex6": self._get_port1localip6(),
            "port0_dst_netmask_hex6": self._get_port0prefixlen6(),
            "port1_dst_netmask_hex6": self._get_port1prefixlen6(),
            "bin_path": self.bin_path,
            "socket": self.socket
        }

        for cfg in os.listdir(vnf_cfg):
            vpe_config = ""
            with open(os.path.join(vnf_cfg, cfg), 'r') as vpe_cfg:
                vpe_config = vpe_cfg.read()

            self._provide_config_file(cfg, vpe_config, vpe_vars)

        LOG.info("Provision and start the vPE")
        tool_path = provision_tool(self.connection,
                                   os.path.join(self.bin_path, "vPE_vnf"))
        cmd = VPE_PIPELINE_COMMAND.format(cfg_file="/tmp/vpe_config",
                                          script="/tmp/vpe_script",
                                          tool_path=tool_path)
        self.connection.run(cmd,
                            stdin=filewrapper,
                            stdout=filewrapper,
                            keep_stdin_open=True,
                            pty=True)