Remove references to "dpdk_nic_bind" utility 61/51661/2
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Mon, 5 Feb 2018 11:08:28 +0000 (11:08 +0000)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Mon, 5 Feb 2018 11:52:12 +0000 (11:52 +0000)
In DPDK 16.07 [1], "dpdk_nic_bind" utility was renamed to "dpdk-devbind".
This patch removes all references to this previous naming to avoid
confusions.

[1] https://dpdk-guide.gitlab.io/dpdk-guide/setup/binding.html

JIRA: YARDSTICK-995

Change-Id: I827c4c11c9e9e519f33f21b80459e7d65e51545e
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
ansible/roles/install_dpdk/tasks/main.yml
ansible/roles/install_trex/tasks/main.yml
tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
yardstick/benchmark/contexts/standalone/model.py
yardstick/benchmark/contexts/standalone/ovs_dpdk.py
yardstick/benchmark/contexts/standalone/sriov.py
yardstick/network_services/helpers/dpdkbindnic_helper.py

index 01ad4ba..e82ad83 100644 (file)
     remote_src: yes
     force: yes
     mode: 0755
-
-- name: make dpdk_nic_bind.py for backwards compatibility
-  copy:
-    src: "{{ dpdk_devbind[dpdk_version] }}"
-    dest: "{{ INSTALL_BIN_PATH }}/dpdk_nic_bind.py"
-    remote_src: yes
-    force: yes
-    mode: 0755
index 7ba1fc8..9113c88 100644 (file)
@@ -31,9 +31,6 @@
     dest: "{{ INSTALL_BIN_PATH }}/trex_client"
     state: link
 
-# Don't use trex/scripts/dpdk_nic_bind.py use DPDK usertools/dpdk-devbind.py
-#- command: cp "{{ INSTALL_BIN_PATH }}/trex/scripts/dpdk_nic_bind.py" "{{ INSTALL_BIN_PATH }}"
-
 - name: add scripts to PYTHONPATH
   lineinfile:
     dest: /etc/environment
index 9bb5ed3..e30aee8 100644 (file)
@@ -117,7 +117,7 @@ Other crypto devices
         self.assertEqual(conn, dpdk_bind_helper.ssh_helper)
         self.assertEqual(self.CLEAN_STATUS, dpdk_bind_helper.dpdk_status)
         self.assertIsNone(dpdk_bind_helper.status_nic_row_re)
-        self.assertIsNone(dpdk_bind_helper._dpdk_nic_bind_attr)
+        self.assertIsNone(dpdk_bind_helper._dpdk_devbind)
         self.assertIsNone(dpdk_bind_helper._status_cmd_attr)
 
     def test__dpdk_execute(self):
index 2a2647a..f9a1014 100644 (file)
@@ -343,6 +343,6 @@ class TestAclApproxVnf(unittest.TestCase):
         acl_approx_vnf.used_drivers = {"01:01.0": "i40e",
                                        "01:01.1": "i40e"}
         acl_approx_vnf.vnf_execute = mock.MagicMock()
-        acl_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
+        acl_approx_vnf.dpdk_devbind = "dpdk-devbind.py"
         acl_approx_vnf._resource_collect_stop = mock.Mock()
         self.assertEqual(None, acl_approx_vnf.terminate())
index f2ce18f..62b3c74 100644 (file)
@@ -390,22 +390,6 @@ class TestCgnaptApproxVnf(unittest.TestCase):
         self.assertIsNone(cgnapt_approx_vnf.instantiate(self.scenario_cfg,
                                                         self.context_cfg))
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
-    @mock.patch(SSH_HELPER)
-    def test_terminate(self, ssh, *args):
-        mock_ssh(ssh)
-
-        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
-        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
-        cgnapt_approx_vnf._vnf_process = mock.MagicMock()
-        cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
-        cgnapt_approx_vnf.used_drivers = {"01:01.0": "i40e",
-                                          "01:01.1": "i40e"}
-        cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
-        cgnapt_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
-        cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
-        self.assertEqual(None, cgnapt_approx_vnf.terminate())
-
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
     @mock.patch(SSH_HELPER)
     def test__vnf_up_post(self, ssh, *args):
index cda3852..472052b 100644 (file)
@@ -462,15 +462,3 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
         self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
         with self.assertRaises(RuntimeError):
             udp_replay_approx_vnf.wait_for_instantiate()
-
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
-    @mock.patch(SSH_HELPER)
-    def test_terminate(self, ssh, *args):
-        mock_ssh(ssh)
-
-        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
-        udp_replay_approx_vnf._vnf_process = mock.MagicMock()
-        udp_replay_approx_vnf._vnf_process.terminate = mock.Mock()
-        udp_replay_approx_vnf.used_drivers = {"01:01.0": "i40e", "01:01.1": "i40e"}
-        udp_replay_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
-        self.assertEqual(None, udp_replay_approx_vnf.terminate())
index d128db0..f0a5666 100644 (file)
@@ -348,18 +348,3 @@ pipeline>
                                                     'rules': ""}}
         self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
         self.assertIsNone(vfw_approx_vnf.instantiate(self.scenario_cfg, self.context_cfg))
-
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
-    @mock.patch(SSH_HELPER)
-    def test_terminate(self, ssh, *args):
-        mock_ssh(ssh)
-
-        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
-        vfw_approx_vnf = FWApproxVnf(name, vnfd)
-        vfw_approx_vnf._vnf_process = mock.MagicMock()
-        vfw_approx_vnf.used_drivers = {"01:01.0": "i40e",
-                                       "01:01.1": "i40e"}
-        vfw_approx_vnf.vnf_execute = mock.Mock()
-        vfw_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
-        vfw_approx_vnf._resource_collect_stop = mock.Mock()
-        self.assertIsNone(vfw_approx_vnf.terminate())
index 3017083..14738da 100644 (file)
@@ -310,7 +310,7 @@ class StandaloneContextHelper(object):
         return driver
 
     @classmethod
-    def get_nic_details(cls, connection, networks, dpdk_nic_bind):
+    def get_nic_details(cls, connection, networks, dpdk_devbind):
         for key, ports in networks.items():
             if key == "mgmt":
                 continue
@@ -320,11 +320,11 @@ class StandaloneContextHelper(object):
             driver = cls.get_kernel_module(connection, phy_ports, phy_driver)
 
             # Make sure that ports are bound to kernel drivers e.g. i40e/ixgbe
-            bind_cmd = "{dpdk_nic_bind} --force -b {driver} {port}"
+            bind_cmd = "{dpdk_devbind} --force -b {driver} {port}"
             lshw_cmd = "lshw -c network -businfo | grep '{port}'"
             link_show_cmd = "ip -s link show {interface}"
 
-            cmd = bind_cmd.format(dpdk_nic_bind=dpdk_nic_bind,
+            cmd = bind_cmd.format(dpdk_devbind=dpdk_devbind,
                                   driver=driver, port=ports['phy_port'])
             connection.execute(cmd)
 
index 3755b84..c931d85 100644 (file)
@@ -57,7 +57,7 @@ class OvsDpdkContext(Context):
         self.file_path = None
         self.sriov = []
         self.first_run = True
-        self.dpdk_nic_bind = ""
+        self.dpdk_devbind = ''
         self.vm_names = []
         self.name = None
         self.nfvi_host = []
@@ -116,12 +116,12 @@ class OvsDpdkContext(Context):
         ]
         for cmd in cmd_list:
             self.connection.execute(cmd)
-        bind_cmd = "{dpdk_nic_bind} --force -b {driver} {port}"
+        bind_cmd = "{dpdk_devbind} --force -b {driver} {port}"
         phy_driver = "vfio-pci"
-        for _, port in self.networks.items():
+        for port in self.networks.values():
             vpci = port.get("phy_port")
-            self.connection.execute(bind_cmd.format(dpdk_nic_bind=self.dpdk_nic_bind,
-                                                    driver=phy_driver, port=vpci))
+            self.connection.execute(bind_cmd.format(
+                dpdk_devbind=self.dpdk_devbind, driver=phy_driver, port=vpci))
 
     def start_ovs_serverswitch(self):
         vpath = self.ovs_properties.get("vpath")
@@ -241,7 +241,7 @@ class OvsDpdkContext(Context):
             return
 
         self.connection = ssh.SSH.from_node(self.host_mgmt)
-        self.dpdk_nic_bind = provision_tool(
+        self.dpdk_devbind = provision_tool(
             self.connection,
             os.path.join(get_nsb_option("bin_path"), "dpdk-devbind.py"))
 
@@ -249,9 +249,8 @@ class OvsDpdkContext(Context):
         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.networks = StandaloneContextHelper.get_nic_details(
+            self.connection, self.networks, self.dpdk_devbind)
 
         self.setup_ovs()
         self.start_ovs_serverswitch()
@@ -271,12 +270,12 @@ class OvsDpdkContext(Context):
         self.cleanup_ovs_dpdk_env()
 
         # Bind nics back to kernel
-        bind_cmd = "{dpdk_nic_bind} --force -b {driver} {port}"
+        bind_cmd = "{dpdk_devbind} --force -b {driver} {port}"
         for port in self.networks.values():
             vpci = port.get("phy_port")
             phy_driver = port.get("driver")
-            self.connection.execute(bind_cmd.format(dpdk_nic_bind=self.dpdk_nic_bind,
-                                                    driver=phy_driver, port=vpci))
+            self.connection.execute(bind_cmd.format(
+                dpdk_devbind=self.dpdk_devbind, driver=phy_driver, port=vpci))
 
         # Todo: NFVi undeploy (sriov, vswitch, ovs etc) based on the config.
         for vm in self.vm_names:
index 9d8423b..9cca3e1 100644 (file)
@@ -41,7 +41,7 @@ class SriovContext(Context):
         self.file_path = None
         self.sriov = []
         self.first_run = True
-        self.dpdk_nic_bind = ""
+        self.dpdk_devbind = ''
         self.vm_names = []
         self.name = None
         self.nfvi_host = []
@@ -83,15 +83,14 @@ class SriovContext(Context):
             return
 
         self.connection = ssh.SSH.from_node(self.host_mgmt)
-        self.dpdk_nic_bind = provision_tool(
+        self.dpdk_devbind = provision_tool(
             self.connection,
-            os.path.join(get_nsb_option("bin_path"), "dpdk_nic_bind.py"))
+            os.path.join(get_nsb_option("bin_path"), "dpdk-devbind.py"))
 
         #    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.networks = StandaloneContextHelper.get_nic_details(
+            self.connection, self.networks, self.dpdk_devbind)
         self.nodes = self.setup_sriov_context()
 
         LOG.debug("Waiting for VM to come up...")
@@ -138,7 +137,7 @@ class SriovContext(Context):
         except StopIteration:
             pass
         else:
-            raise ValueError("Duplicate nodes!!! Nodes: %s %s",
+            raise ValueError("Duplicate nodes!!! Nodes: %s %s" %
                              (node, duplicate))
 
         node["name"] = attr_name
index c076131..8c44b26 100644 (file)
@@ -34,11 +34,11 @@ class DpdkBindHelperException(Exception):
 
 
 class DpdkBindHelper(object):
-    DPDK_STATUS_CMD = "{dpdk_nic_bind} --status"
-    DPDK_BIND_CMD = "sudo {dpdk_nic_bind} {force} -b {driver} {vpci}"
+    DPDK_STATUS_CMD = "{dpdk_devbind} --status"
+    DPDK_BIND_CMD = "sudo {dpdk_devbind} {force} -b {driver} {vpci}"
 
-    NIC_ROW_RE = re.compile("([^ ]+) '([^']+)' (?:if=([^ ]+) )?drv=([^ ]+) "
-                            "unused=([^ ]*)(?: (\*Active\*))?")
+    NIC_ROW_RE = re.compile(r"([^ ]+) '([^']+)' (?:if=([^ ]+) )?drv=([^ ]+) "
+                            r"unused=([^ ]*)(?: (\*Active\*))?")
     SKIP_RE = re.compile('(====|<none>|^$)')
     NIC_ROW_FIELDS = ['vpci', 'dev_type', 'iface', 'driver', 'unused', 'active']
 
@@ -64,7 +64,7 @@ class DpdkBindHelper(object):
     def __init__(self, ssh_helper):
         self.dpdk_status = None
         self.status_nic_row_re = None
-        self._dpdk_nic_bind_attr = None
+        self._dpdk_devbind = None
         self._status_cmd_attr = None
 
         self.ssh_helper = ssh_helper
@@ -74,19 +74,19 @@ class DpdkBindHelper(object):
         res = self.ssh_helper.execute(*args, **kwargs)
         if res[0] != 0:
             raise DpdkBindHelperException('{} command failed with rc={}'.format(
-                self._dpdk_nic_bind, res[0]))
+                self.dpdk_devbind, res[0]))
         return res
 
     @property
-    def _dpdk_nic_bind(self):
-        if self._dpdk_nic_bind_attr is None:
-            self._dpdk_nic_bind_attr = self.ssh_helper.provision_tool(tool_file="dpdk-devbind.py")
-        return self._dpdk_nic_bind_attr
+    def dpdk_devbind(self):
+        if self._dpdk_devbind is None:
+            self._dpdk_devbind = self.ssh_helper.provision_tool(tool_file="dpdk-devbind.py")
+        return self._dpdk_devbind
 
     @property
     def _status_cmd(self):
         if self._status_cmd_attr is None:
-            self._status_cmd_attr = self.DPDK_STATUS_CMD.format(dpdk_nic_bind=self._dpdk_nic_bind)
+            self._status_cmd_attr = self.DPDK_STATUS_CMD.format(dpdk_devbind=self.dpdk_devbind)
         return self._status_cmd_attr
 
     def _addline(self, active_list, line):
@@ -139,7 +139,7 @@ class DpdkBindHelper(object):
         # accept single PCI or list of PCI
         if isinstance(pci_addresses, six.string_types):
             pci_addresses = [pci_addresses]
-        cmd = self.DPDK_BIND_CMD.format(dpdk_nic_bind=self._dpdk_nic_bind,
+        cmd = self.DPDK_BIND_CMD.format(dpdk_devbind=self.dpdk_devbind,
                                         driver=driver,
                                         vpci=' '.join(list(pci_addresses)),
                                         force='--force' if force else '')