xena_port_ip: Add port ip assignment for Xena traffic generator 49/12649/1
authorChristian Trautman <ctrautma@redhat.com>
Mon, 25 Apr 2016 21:43:25 +0000 (17:43 -0400)
committerChristian Trautman <ctrautma@redhat.com>
Mon, 25 Apr 2016 21:43:25 +0000 (17:43 -0400)
Adds port ip set options as part of conf files. Allows for IPv4
address assignment. Adds ipv6 options for later implementation
when available in framework.

*  Adds Xena to documentation area where available traffic gens
   are listed.

JIRA: VSPERF-273

Change-Id: Ia4129222ea95f1d399d5cc0c589c9a99d7b1b81a
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
conf/03_traffic.conf
conf/10_custom.conf
docs/configguide/trafficgen.rst
tools/pkt_gen/xena/xena.py
tools/pkt_gen/xena/xena_json.py

index 9dc03a4..9937294 100644 (file)
@@ -169,3 +169,11 @@ TRAFFICGEN_XENA_USER = ''
 TRAFFICGEN_XENA_PASSWORD = ''
 TRAFFICGEN_XENA_MODULE1 = ''
 TRAFFICGEN_XENA_MODULE2 = ''
+
+# Xena Port IP info
+TRAFFICGEN_XENA_PORT0_IP = '192.168.199.10'
+TRAFFICGEN_XENA_PORT0_CIDR = 24
+TRAFFICGEN_XENA_PORT0_GATEWAY = '192.168.199.1'
+TRAFFICGEN_XENA_PORT1_IP = '192.168.199.11'
+TRAFFICGEN_XENA_PORT1_CIDR = 24
+TRAFFICGEN_XENA_PORT1_GATEWAY = '192.168.199.1'
index 63c75d3..4c9341a 100644 (file)
@@ -70,6 +70,14 @@ TRAFFICGEN_XENA_PASSWORD = ''
 TRAFFICGEN_XENA_MODULE1 = ''
 TRAFFICGEN_XENA_MODULE2 = ''
 
+# Xena Port IP info
+TRAFFICGEN_XENA_PORT0_IP = '192.168.199.10'
+TRAFFICGEN_XENA_PORT0_CIDR = 24
+TRAFFICGEN_XENA_PORT0_GATEWAY = '192.168.199.1'
+TRAFFICGEN_XENA_PORT1_IP = '192.168.199.11'
+TRAFFICGEN_XENA_PORT1_CIDR = 24
+TRAFFICGEN_XENA_PORT1_GATEWAY = '192.168.199.1'
+
 TEST_PARAMS = {'pkt_sizes':'64'}
 
 OPNFV_INSTALLER = "Fuel"
index 41a48f6..f612569 100644 (file)
@@ -14,6 +14,7 @@ VSPERF supports the following traffic generators:
     traffic generator.
   * IXIA (IxNet and IxOS)
   * Spirent TestCenter
+  * Xena Networks
 
 To see the list of traffic gens from the cli:
 
index dd23d0e..67ac565 100755 (executable)
@@ -142,11 +142,17 @@ class Xena(ITrafficGenerator):
                 settings.getValue('TRAFFICGEN_XENA_PASSWORD')
             )
             j_file.set_port(0, settings.getValue('TRAFFICGEN_XENA_MODULE1'),
-                            settings.getValue('TRAFFICGEN_XENA_PORT1')
-                            )
+                            settings.getValue('TRAFFICGEN_XENA_PORT1'))
             j_file.set_port(1, settings.getValue('TRAFFICGEN_XENA_MODULE2'),
-                            settings.getValue('TRAFFICGEN_XENA_PORT2')
-                            )
+                            settings.getValue('TRAFFICGEN_XENA_PORT2'))
+            j_file.set_port_ip_v4(
+                0, settings.getValue("TRAFFICGEN_XENA_PORT0_IP"),
+                settings.getValue("TRAFFICGEN_XENA_PORT0_CIDR"),
+                settings.getValue("TRAFFICGEN_XENA_PORT0_GATEWAY"))
+            j_file.set_port_ip_v4(
+                1, settings.getValue("TRAFFICGEN_XENA_PORT1_IP"),
+                settings.getValue("TRAFFICGEN_XENA_PORT1_CIDR"),
+                settings.getValue("TRAFFICGEN_XENA_PORT1_GATEWAY"))
             j_file.set_test_options(
                 packet_sizes=self._params['traffic']['l2']['framesize'],
                 iterations=trials, loss_rate=loss_rate,
index 39cc56c..971426c 100644 (file)
@@ -308,6 +308,52 @@ class XenaJSON(object):
         self.json_data['PortHandler']['EntityList'][index]['PortRef'][
             'PortIndex'] = port
 
+    def set_port_ip_v4(self, port, ip_addr, netmask, gateway):
+        """
+        Set the port IP info
+        :param port: port number as int of port to set ip info
+        :param ip_addr: ip address in dot notation format as string
+        :param netmask: cidr number for netmask (ie 24/16/8) as int
+        :param gateway: gateway address in dot notation format
+        :return: None
+        """
+        available_ports = range(len(
+            self.json_data['PortHandler']['EntityList']))
+        if port not in available_ports:
+            raise ValueError("{}{}{}".format(
+                'Port assignment must be an available port ',
+                'number in baseconfig file. Port=', port))
+        self.json_data['PortHandler']['EntityList'][
+            port]["IpV4Address"] = ip_addr
+        self.json_data['PortHandler']['EntityList'][
+            port]["IpV4Gateway"] = gateway
+        self.json_data['PortHandler']['EntityList'][
+            port]["IpV4RoutingPrefix"] = int(netmask)
+
+    def set_port_ip_v6(self, port, ip_addr, netmask, gateway):
+        """
+        Set the port IP info
+        :param port: port number as int of port to set ip info
+        :param ip_addr: ip address as 8 groups of 4 hexadecimal groups separated
+         by a colon.
+        :param netmask: cidr number for netmask (ie 24/16/8) as int
+        :param gateway: gateway address as string in 8 group of 4 hexadecimal
+                        groups separated by a colon.
+        :return: None
+        """
+        available_ports = range(len(
+            self.json_data['PortHandler']['EntityList']))
+        if port not in available_ports:
+            raise ValueError("{}{}{}".format(
+                'Port assignment must be an available port ',
+                'number in baseconfig file. Port=', port))
+        self.json_data['PortHandler']['EntityList'][
+            port]["IpV6Address"] = ip_addr
+        self.json_data['PortHandler']['EntityList'][
+            port]["IpV6Gateway"] = gateway
+        self.json_data['PortHandler']['EntityList'][
+            port]["IpV6RoutingPrefix"] = int(netmask)
+
     def set_test_options(self, packet_sizes, duration, iterations, loss_rate,
                          micro_tpld=False):
         """
@@ -418,6 +464,22 @@ def print_json_report(json_data):
         print("Chassis Password: {}".format(json_data['ChassisManager'][
             'ChassisList'][0]['Password']))
         print("### Port Configuration ###")
+        print("Port 1 IPv4:{}/{} gateway:{}".format(
+            json_data['PortHandler']['EntityList'][0]["IpV4Address"],
+            json_data['PortHandler']['EntityList'][0]["IpV4RoutingPrefix"],
+            json_data['PortHandler']['EntityList'][0]["IpV4Gateway"]))
+        print("Port 1 IPv6:{}/{} gateway:{}".format(
+            json_data['PortHandler']['EntityList'][0]["IpV6Address"],
+            json_data['PortHandler']['EntityList'][0]["IpV6RoutingPrefix"],
+            json_data['PortHandler']['EntityList'][0]["IpV6Gateway"]))
+        print("Port 2 IPv4:{}/{} gateway:{}".format(
+            json_data['PortHandler']['EntityList'][1]["IpV4Address"],
+            json_data['PortHandler']['EntityList'][1]["IpV4RoutingPrefix"],
+            json_data['PortHandler']['EntityList'][1]["IpV4Gateway"]))
+        print("Port 2 IPv6:{}/{} gateway:{}".format(
+            json_data['PortHandler']['EntityList'][1]["IpV6Address"],
+            json_data['PortHandler']['EntityList'][1]["IpV6RoutingPrefix"],
+            json_data['PortHandler']['EntityList'][1]["IpV6Gateway"]))
         print("Port 1: {}/{} group: {}".format(
             json_data['PortHandler']['EntityList'][0]['PortRef']['ModuleIndex'],
             json_data['PortHandler']['EntityList'][0]['PortRef']['PortIndex'],
@@ -512,6 +574,12 @@ if __name__ == "__main__":
     JSON.set_chassis_info('192.168.0.5', 'vsperf')
     JSON.set_port(0, 1, 0)
     JSON.set_port(1, 1, 1)
+    JSON.set_port_ip_v4(0, '192.168.240.10', 32, '192.168.240.1')
+    JSON.set_port_ip_v4(1, '192.168.240.11', 32, '192.168.240.1')
+    JSON.set_port_ip_v6(0, 'a1a1:a2a2:a3a3:a4a4:a5a5:a6a6:a7a7:a8a8', 128,
+                        'a1a1:a2a2:a3a3:a4a4:a5a5:a6a6:a7a7:1111')
+    JSON.set_port_ip_v6(1, 'b1b1:b2b2:b3b3:b4b4:b5b5:b6b6:b7b7:b8b8', 128,
+                        'b1b1:b2b2:b3b3:b4b4:b5b5:b6b6:b7b7:1111')
     JSON.set_header_layer2(dst_mac='dd:dd:dd:dd:dd:dd',
                            src_mac='ee:ee:ee:ee:ee:ee')
     JSON.set_header_vlan(vlan_id=5)