bugfix: Remove dependency on ifconfig 11/14511/1
authorMartin Klozik <martinx.klozik@intel.com>
Fri, 20 May 2016 12:24:15 +0000 (13:24 +0100)
committerMartin Klozik <martinx.klozik@intel.com>
Mon, 23 May 2016 09:55:13 +0000 (10:55 +0100)
VSPERF uses ifconfig at several places to bring up
a networking interface. However ifconfig has been
deprecated by iproute2 package and it is not available
in standard installation of many Linux distributions.
Thus all calls of ifconfig have been replaced by
call of 'ip' tool.

Change-Id: I935eaf85b6082e4641d12cffea3e0882c634e5ea
JIRA: VSPERF-299
Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com>
Reviewed-by: Al Morton <acmorton@att.com>
Reviewed-by: Christian Trautman <ctrautma@redhat.com>
Reviewed-by: Brian Castelli <brian.castelli@spirent.com>
core/vswitch_controller_op2p.py
vnfs/qemu/qemu.py
vswitches/ovs_vanilla.py

index 77797b8..ee8ada8 100644 (file)
@@ -77,11 +77,13 @@ class VswitchControllerOP2P(IVswitchController):
             vtep_ip2 = settings.getValue('VTEP_IP2')
             self._vswitch.add_switch(bridge)
 
-            tasks.run_task(['sudo', 'ifconfig', bridge,
-                            settings.getValue('VTEP_IP1')],
+            tasks.run_task(['sudo', 'ip', 'addr', 'add',
+                            settings.getValue('VTEP_IP1'), 'dev', bridge],
                            self._logger, 'Assign ' +
                            settings.getValue('VTEP_IP1') + ' to ' + bridge,
                            False)
+            tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', bridge, 'up'],
+                           self._logger, 'Bring up ' + bridge, False)
 
             tunnel_type = self._traffic['tunnel_type']
 
@@ -137,10 +139,12 @@ class VswitchControllerOP2P(IVswitchController):
             tgen_ip1 = settings.getValue('TRAFFICGEN_PORT1_IP')
             self._vswitch.add_switch(bridge)
 
-            tasks.run_task(['sudo', 'ifconfig', bridge,
-                            settings.getValue('VTEP_IP1')],
+            tasks.run_task(['sudo', 'ip', 'addr', 'add',
+                            settings.getValue('VTEP_IP1'), 'dev', bridge],
                            self._logger, 'Assign ' +
                            settings.getValue('VTEP_IP1') + ' to ' + bridge, False)
+            tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', bridge, 'up'],
+                           self._logger, 'Bring up ' + bridge, False)
 
             tunnel_type = self._traffic['tunnel_type']
 
@@ -195,10 +199,12 @@ class VswitchControllerOP2P(IVswitchController):
             tgen_ip1 = settings.getValue('TRAFFICGEN_PORT1_IP')
             self._vswitch.add_switch(bridge)
 
-            tasks.run_task(['sudo', 'ifconfig', bridge,
-                            settings.getValue('TUNNEL_INT_BRIDGE_IP')],
+            tasks.run_task(['sudo', 'ip', 'addr', 'add',
+                            settings.getValue('TUNNEL_INT_BRIDGE_IP'), 'dev', bridge],
                            self._logger, 'Assign ' +
                            settings.getValue('TUNNEL_INT_BRIDGE_IP') + ' to ' + bridge, False)
+            tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', bridge, 'up'],
+                           self._logger, 'Bring up ' + bridge, False)
 
             tunnel_type = self._traffic['tunnel_type']
 
index 87f7758..2de8df2 100644 (file)
@@ -384,17 +384,23 @@ class IVnfQemu(IVnf):
         """
         self._configure_disable_firewall()
 
-        self.execute('ifconfig ' + self._net1 + ' ' +
-                     S.getValue('VANILLA_NIC1_IP_CIDR')[self._number])
+        self.execute('ip addr add ' +
+                     S.getValue('VANILLA_NIC1_IP_CIDR')[self._number] +
+                     ' dev ' + self._net1)
+        self.execute('ip link set dev ' + self._net1 + ' up')
 
-        self.execute('ifconfig ' + self._net2 + ' ' +
-                     S.getValue('VANILLA_NIC2_IP_CIDR')[self._number])
+        self.execute('ip addr add ' +
+                     S.getValue('VANILLA_NIC2_IP_CIDR')[self._number] +
+                     ' dev ' + self._net2)
+        self.execute('ip link set dev ' + self._net2 + ' up')
 
         # configure linux bridge
         self.execute('brctl addbr br0')
         self.execute('brctl addif br0 ' + self._net1 + ' ' + self._net2)
-        self.execute('ifconfig br0 ' +
-                     S.getValue('VANILLA_BRIDGE_IP')[self._number])
+        self.execute('ip addr add ' +
+                     S.getValue('VANILLA_BRIDGE_IP')[self._number] +
+                     ' dev br0')
+        self.execute('ip link set dev br0 up')
 
         # Add the arp entries for the IXIA ports and the bridge you are using.
         # Use command line values if provided.
index a6b720a..89023a7 100644 (file)
@@ -94,8 +94,10 @@ class OvsVanilla(IVSwitchOvs):
         params = []
 
         # For PVP only
-        tasks.run_task(['sudo', 'ifconfig', port_name, '0'],
+        tasks.run_task(['sudo', 'ip', 'addr', 'flush', 'dev', port_name],
                        self._logger, 'Remove IP', False)
+        tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', port_name, 'up'],
+                       self._logger, 'Bring up ' + port_name, False)
 
         of_port = bridge.add_port(port_name, params)
         self._current_id += 1
@@ -119,7 +121,9 @@ class OvsVanilla(IVSwitchOvs):
                         tap_name, 'mode', 'tap'],
                        self._logger, 'Creating tap device...', False)
 
-        tasks.run_task(['sudo', 'ifconfig', tap_name, '0'],
+        tasks.run_task(['sudo', 'ip', 'addr', 'flush', 'dev', tap_name],
+                       self._logger, 'Remove IP', False)
+        tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', tap_name, 'up'],
                        self._logger, 'Bring up ' + tap_name, False)
 
         bridge = self._bridges[switch_name]