Add IxNetwork API Python Binding package 15/54615/14
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Thu, 29 Mar 2018 14:39:49 +0000 (15:39 +0100)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Fri, 4 May 2018 06:59:08 +0000 (06:59 +0000)
Add IxNetwork python package to the requirements list.

This module is needed for the "NSPerf" scenarios using IXIA as traffic
generator, when IxNetwork is the program used to handle the IXIA
generator.

The latest version of this module is 8.40.1124.9 [1]. The license type
is MIT.

[1] https://pypi.python.org/pypi/ixnetwork

JIRA: YARDSTICK-1106

Change-Id: I279933c95994f5120930256a104c4192a0b9900d
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
17 files changed:
ansible/multi_port_baremetal_ixia_correlated_test.yaml
ansible/multi_port_baremetal_ixia_test.yaml
ansible/standalone_ovs_scale_out_ixia_correlated_test.yaml
ansible/standalone_ovs_scale_out_ixia_test.yaml
ansible/standalone_sriov_scale_out_ixia_correlated_test.yaml
ansible/standalone_sriov_scale_out_ixia_test.yaml
docs/testing/user/userguide/13-nsb-installation.rst
docs/testing/user/userguide/code/pod_ixia.yaml [new file with mode: 0644]
etc/yardstick/nodes/pod.yaml.nsb.sample.ixia
etc/yardstick/nodes/standalone/ixia_correlated_template.yaml
etc/yardstick/nodes/standalone/ixia_template.yaml
requirements.txt
samples/vnf_samples/vnf_descriptors/ixia_rfc2544_tpl.yaml
samples/vnf_samples/vnf_descriptors/tg_ixload.yaml
samples/vnf_samples/vnf_descriptors/tg_ixload_4port.yaml
yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py
yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py

index ba92b5c..0d22318 100644 (file)
@@ -42,7 +42,6 @@
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/results"
         version: "8.01.106.3"
       pcis:
index 52bc40b..d2dfaa3 100644 (file)
@@ -42,7 +42,6 @@
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/results"
         version: "8.01.106.3"
       pcis:
index 5166765..b54ea9b 100644 (file)
       user: ""
       password: ""
       key_filename: ~
-      tg_config: 
+      tg_config:
         ixchassis: "1.1.1.127" #ixia chassis ip
         tcl_port: "8009" # tcl server port
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/results"
         version: "8.01.106.3"
       pcis:
index ff66537..cae3734 100644 (file)
@@ -60,7 +60,6 @@
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/results"
         version: "8.01.106.3"
       pcis:
index 45a4a49..0e3a0af 100644 (file)
       user: ""
       password: ""
       key_filename: ~
-      tg_config: 
+      tg_config:
         ixchassis: "1.1.1.127" #ixia chassis ip
         tcl_port: "8009" # tcl server port
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/results"
         version: "8.01.106.3"
       pcis:
index 659dbef..8fb09d9 100644 (file)
@@ -49,7 +49,6 @@
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/results"
         version: "8.01.106.3"
       pcis:
index 1f6c79b..3e0ed0b 100644 (file)
@@ -1058,40 +1058,8 @@ IxLoad
 
   Config ``pod_ixia.yaml``
 
-  .. code-block:: yaml
-
-      nodes:
-          -
-            name: trafficgen_1
-            role: IxNet
-            ip: 1.2.1.1 #ixia machine ip
-            user: user
-            password: r00t
-            key_filename: /root/.ssh/id_rsa
-            tg_config:
-                ixchassis: "1.2.1.7" #ixia chassis ip
-                tcl_port: "8009" # tcl server port
-                lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
-                root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
-                py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-                py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
-                dut_result_dir: "/mnt/ixia"
-                version: 8.1
-            interfaces:
-                xe0:  # logical name from topology.yaml and vnfd.yaml
-                    vpci: "2:5" # Card:port
-                    driver:    "none"
-                    dpdk_port_num: 0
-                    local_ip: "152.16.100.20"
-                    netmask:   "255.255.0.0"
-                    local_mac: "00:98:10:64:14:00"
-                xe1:  # logical name from topology.yaml and vnfd.yaml
-                    vpci: "2:6" # [(Card, port)]
-                    driver:    "none"
-                    dpdk_port_num: 1
-                    local_ip: "152.40.40.20"
-                    netmask:   "255.255.0.0"
-                    local_mac: "00:98:28:28:14:00"
+  .. literalinclude:: code/pod_ixia.yaml
+     :language: console
 
   for sriov/ovs_dpdk pod files, please refer to above Standalone Virtualization for ovs-dpdk/sriov configuration
 
@@ -1113,10 +1081,10 @@ IxLoad
 IxNetwork
 ---------
 
-1. Software needed: ``IxNetworkAPI<ixnetwork verson>Linux64.bin.tgz``
-   (Download from ixia support site)
-   Install - ``IxNetworkAPI<ixnetwork verson>Linux64.bin.tgz``
-2. Update pod_ixia.yaml file with ixia details.
+IxNetwork testcases use IxNetwork API Python Bindings module, which is
+installed as part of the requirements of the project.
+
+1. Update ``pod_ixia.yaml`` file with ixia details.
 
   .. code-block:: console
 
@@ -1124,44 +1092,12 @@ IxNetwork
 
   Config pod_ixia.yaml
 
-  .. code-block:: yaml
-
-      nodes:
-          -
-            name: trafficgen_1
-            role: IxNet
-            ip: 1.2.1.1 #ixia machine ip
-            user: user
-            password: r00t
-            key_filename: /root/.ssh/id_rsa
-            tg_config:
-                ixchassis: "1.2.1.7" #ixia chassis ip
-                tcl_port: "8009" # tcl server port
-                lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
-                root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
-                py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-                py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
-                dut_result_dir: "/mnt/ixia"
-                version: 8.1
-            interfaces:
-                xe0:  # logical name from topology.yaml and vnfd.yaml
-                    vpci: "2:5" # Card:port
-                    driver:    "none"
-                    dpdk_port_num: 0
-                    local_ip: "152.16.100.20"
-                    netmask:   "255.255.0.0"
-                    local_mac: "00:98:10:64:14:00"
-                xe1:  # logical name from topology.yaml and vnfd.yaml
-                    vpci: "2:6" # [(Card, port)]
-                    driver:    "none"
-                    dpdk_port_num: 1
-                    local_ip: "152.40.40.20"
-                    netmask:   "255.255.0.0"
-                    local_mac: "00:98:28:28:14:00"
+  .. literalinclude:: code/pod_ixia.yaml
+     :language: console
 
   for sriov/ovs_dpdk pod files, please refer to above Standalone Virtualization for ovs-dpdk/sriov configuration
 
-3. Start IxNetwork TCL Server
+2. Start IxNetwork TCL Server
    You will also need to configure the IxNetwork machine to start the IXIA
    IxNetworkTclServer. This can be started like so:
 
@@ -1170,6 +1106,5 @@ IxNetwork
       ``Start->Programs->Ixia->IxNetwork->IxNetwork 7.21.893.14 GA->IxNetworkTclServer``
       (or ``IxNetworkApiServer``)
 
-4. Execute testcase in samplevnf folder e.g.
+3. Execute testcase in samplevnf folder e.g.
    ``<repo>/samples/vnf_samples/nsut/vfw/tc_baremetal_rfc2544_ipv4_1rule_1flow_64B_ixia.yaml``
-
diff --git a/docs/testing/user/userguide/code/pod_ixia.yaml b/docs/testing/user/userguide/code/pod_ixia.yaml
new file mode 100644 (file)
index 0000000..4ab56fe
--- /dev/null
@@ -0,0 +1,31 @@
+nodes:
+-
+    name: trafficgen_1
+    role: IxNet
+    ip: 1.2.1.1 #ixia machine ip
+    user: user
+    password: r00t
+    key_filename: /root/.ssh/id_rsa
+    tg_config:
+        ixchassis: "1.2.1.7" #ixia chassis ip
+        tcl_port: "8009" # tcl server port
+        lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
+        root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
+        py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
+        dut_result_dir: "/mnt/ixia"
+        version: 8.1
+    interfaces:
+        xe0:  # logical name from topology.yaml and vnfd.yaml
+            vpci: "2:5" # Card:port
+            driver:    "none"
+            dpdk_port_num: 0
+            local_ip: "152.16.100.20"
+            netmask:   "255.255.0.0"
+            local_mac: "00:98:10:64:14:00"
+        xe1:  # logical name from topology.yaml and vnfd.yaml
+            vpci: "2:6" # [(Card, port)]
+            driver:    "none"
+            dpdk_port_num: 1
+            local_ip: "152.40.40.20"
+            netmask:   "255.255.0.0"
+            local_mac: "00:98:28:28:14:00"
index 57a8305..1f755dc 100644 (file)
@@ -26,7 +26,6 @@ nodes:
         lib_path: "/opt/ixia/ixos-api/8.01.0.2/lib/ixTcl1.0"
         root_dir: "/opt/ixia/ixos-api/8.01.0.2/"
         py_bin_path: "/opt/ixia/ixload/8.01.106.3/bin/"
-        py_lib_path: "/opt/ixia/ixnetwork/8.01.1029.14/lib/PythonApi"
         dut_result_dir: "/mnt/ixia"
         version: 8.1
     interfaces:
index 7250c4c..ef63ea0 100644 (file)
@@ -26,13 +26,12 @@ nodes:
     user: {{gen.user}}
     password: {{gen.password}}
     key_filename: {{gen.key_filename}}
-    tg_config: 
+    tg_config:
         ixchassis: "{{gen.tg_config.ixchassis}}" #ixia chassis ip
         tcl_port: "{{gen.tg_config.tcl_port}}" # tcl server port
         lib_path: "{{gen.tg_config.lib_path}}"
         root_dir: "{{gen.tg_config.root_dir}}"
         py_bin_path: "{{gen.tg_config.py_bin_path}}"
-        py_lib_path: "{{gen.tg_config.py_lib_path}}"
         dut_result_dir: "{{gen.tg_config.dut_result_dir}}"
         version: "{{gen.tg_config.version}}"
     interfaces:
index 617a651..98ed8c5 100644 (file)
@@ -32,7 +32,6 @@ nodes:
       lib_path: "{{gen.tg_config.lib_path}}"
       root_dir: "{{gen.tg_config.root_dir}}"
       py_bin_path: "{{gen.tg_config.py_bin_path}}"
-      py_lib_path: "{{gen.tg_config.py_lib_path}}"
       dut_result_dir: "{{gen.tg_config.dut_result_dir}}"
       version: "{{gen.tg_config.version}}"
     interfaces:
index 43f0e79..4679bc8 100644 (file)
@@ -26,6 +26,7 @@ flask==0.11.1           # BSD; OSI Approved  BSD License
 functools32==3.2.3.post2; python_version <= "2.7"    # PSF license
 futures==3.1.1;python_version=='2.7'    # BSD; OSI Approved  BSD License
 influxdb==4.1.1         # MIT License; OSI Approved  MIT License
+IxNetwork==8.40.1124.9  # MIT License; OSI Approved  MIT License
 jinja2schema==0.1.4     # OSI Approved  BSD License
 keystoneauth1==3.1.0    # OSI Approved  Apache Software License
 kubernetes==3.0.0a1     # OSI Approved  Apache Software License
index 9b2a152..aca7c21 100644 (file)
@@ -29,7 +29,6 @@ vnfd:vnfd-catalog:
                 tcl_port: '{{tg_config.tcl_port}}' # tcl server port
                 lib_path: '{{tg_config.lib_path}}'
                 root_dir: '{{tg_config.root_dir}}'
-                py_lib_path: '{{tg_config.py_lib_path}}'
                 py_bin_path: '{{tg_config.py_bin_path}}'
                 dut_result_dir: '{{tg_config.dut_result_dir}}'
                 version: '{{tg_config.version}}'
index ad4953f..0324bb8 100644 (file)
@@ -29,7 +29,6 @@ vnfd:vnfd-catalog:
                 tcl_port: '{{tg_config.tcl_port}}' # tcl server port
                 lib_path: '{{tg_config.lib_path}}'
                 root_dir: '{{tg_config.root_dir}}'
-                py_lib_path: '{{tg_config.py_lib_path}}'
                 py_bin_path: '{{tg_config.py_bin_path}}'
                 dut_result_dir: '{{tg_config.dut_result_dir}}'
                 version: '{{tg_config.version}}'
index ffbfbde..def8cdc 100644 (file)
@@ -28,7 +28,6 @@ vnfd:vnfd-catalog:
                 tcl_port: '{{tg_config.tcl_port}}' # tcl server port
                 lib_path: '{{tg_config.lib_path}}'
                 root_dir: '{{tg_config.root_dir}}'
-                py_lib_path: '{{tg_config.py_lib_path}}'
                 dut_result_dir: '{{tg_config.dut_result_dir}}'
                 version: '{{tg_config.version}}'
         vdu:
index 70ce4ff..c538cee 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from __future__ import absolute_import
-from __future__ import print_function
-import sys
 import logging
 
 import re
 from itertools import product
+import IxNetwork
+
 
 log = logging.getLogger(__name__)
 
@@ -135,7 +134,6 @@ class IxNextgen(object):
             port.append(port0)
 
         cfg = {
-            'py_lib_path': tg_cfg["mgmt-interface"]["tg-config"]["py_lib_path"],
             'machine': tg_cfg["mgmt-interface"]["ip"],
             'port': tg_cfg["mgmt-interface"]["tg-config"]["tcl_port"],
             'chassis': tg_cfg["mgmt-interface"]["tg-config"]["ixchassis"],
@@ -186,7 +184,7 @@ class IxNextgen(object):
             self.set_random_ip_multi_attribute(ip, seeds[1], fixed_bits, random_mask, l3_count)
 
     def add_ip_header(self, params, version):
-        for it, ep, i in self.iter_over_get_lists('/traffic', 'trafficItem', "configElement", 1):
+        for _, ep, i in self.iter_over_get_lists('/traffic', 'trafficItem', "configElement", 1):
             iter1 = (v['outer_l3'] for v in params.values() if str(v['id']) == str(i))
             try:
                 l3 = next(iter1, {})
@@ -194,21 +192,13 @@ class IxNextgen(object):
             except (KeyError, IndexError):
                 continue
 
-            for ip, ip_bits, _ in self.iter_over_get_lists(ep, 'stack', 'field'):
+            for _, ip_bits, _ in self.iter_over_get_lists(ep, 'stack', 'field'):
                 self.set_random_ip_multi_attributes(ip_bits, version, seeds, l3)
 
         self.ixnet.commit()
 
     def _connect(self, tg_cfg):
         self._cfg = self.get_config(tg_cfg)
-
-        sys.path.append(self._cfg["py_lib_path"])
-        # Import IxNetwork after getting ixia lib path
-        try:
-            import IxNetwork
-        except ImportError:
-            raise
-
         self.ixnet = IxNetwork.IxNet()
 
         machine = self._cfg['machine']
@@ -292,7 +282,7 @@ class IxNextgen(object):
             self.update_ether_multi_attribute(ether, str(l2.get('srcmac', "00:00:00:00:00:01")))
 
     def ix_update_ether(self, params):
-        for ti, ep, index in self.iter_over_get_lists('/traffic', 'trafficItem',
+        for _, ep, index in self.iter_over_get_lists('/traffic', 'trafficItem',
                                                       "configElement", 1):
             iter1 = (v['outer_l2'] for v in params.values() if str(v['id']) == str(index))
             try:
@@ -300,7 +290,7 @@ class IxNextgen(object):
             except KeyError:
                 continue
 
-            for ip, ether, _ in self.iter_over_get_lists(ep, 'stack', 'field'):
+            for _, ether, _ in self.iter_over_get_lists(ep, 'stack', 'field'):
                 self.update_ether_multi_attributes(ether, l2)
 
         self.ixnet.commit()
index fe750e5..7ca2f0f 100644 (file)
@@ -13,8 +13,9 @@
 # limitations under the License.
 #
 
-import unittest
 import mock
+import IxNetwork
+import unittest
 
 from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IxNextgen
 from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IP_VERSION_4
@@ -30,15 +31,20 @@ class TestIxNextgen(unittest.TestCase):
         ixnet_gen = IxNextgen()
         self.assertIsNone(ixnet_gen._bidir)
 
-    @mock.patch("yardstick.network_services.libs.ixia_libs.IxNet.IxNet.sys")
-    def test_connect(self, *args):
-
+    @mock.patch.object(IxNetwork, 'IxNet')
+    def test_connect(self, mock_ixnet):
+        ixnet_instance = mock.Mock()
+        mock_ixnet.return_value = ixnet_instance
         ixnet_gen = IxNextgen()
-        ixnet_gen.get_config = mock.MagicMock()
-        ixnet_gen.get_ixnet = mock.MagicMock()
+        with mock.patch.object(ixnet_gen, 'get_config') as mock_config:
+            mock_config.return_value = {'machine': 'machine_fake',
+                                        'port': 'port_fake',
+                                        'version': 12345}
+            ixnet_gen._connect(mock.ANY)
 
-        self.assertRaises(ImportError, ixnet_gen._connect,
-                          {"py_lib_path": "/tmp"})
+        ixnet_instance.connect.assert_called_once_with(
+            'machine_fake', '-port', 'port_fake', '-version', '12345')
+        mock_config.assert_called_once()
 
     def test_clear_ixia_config(self):
         ixnet = mock.MagicMock()
@@ -655,13 +661,11 @@ class TestIxNextgen(unittest.TestCase):
                     "version": "test3",
                     "ixchassis": "test4",
                     "tcl_port": "test5",
-                    "py_lib_path": "test6",
                 },
             }
         }
 
         expected = {
-            'py_lib_path': 'test6',
             'machine': 'test1',
             'port': 'test5',
             'chassis': 'test4',