summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py34
-rw-r--r--yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py31
2 files changed, 65 insertions, 0 deletions
diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
index 4e7434c68..6645d45fe 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -1014,3 +1014,37 @@ class IxNextgen(object): # pragma: no cover
'-value', bgp_type)
self.ixnet.commit()
return obj
+
+ def add_interface(self, vport, ip, mac=None, gateway=None):
+ """Add protocol interface to the vport"""
+ log.debug("add_interface: mac='%s', ip='%s', gateway='%s'", mac, ip,
+ gateway)
+ obj = self.ixnet.add(vport, 'interface')
+ self.ixnet.commit()
+
+ if mac is not None:
+ self.ixnet.setMultiAttribute(obj + '/ethernet', '-macAddress', mac)
+
+ ipv4 = self.ixnet.add(obj, 'ipv4')
+ self.ixnet.setMultiAttribute(ipv4, '-ip', ip)
+
+ if gateway is not None:
+ self.ixnet.setMultiAttribute(ipv4, '-gateway', gateway)
+
+ self.ixnet.commit()
+
+ self.ixnet.setMultiAttribute(obj, '-enabled', 'true')
+ self.ixnet.commit()
+
+ return obj
+
+ def add_static_ipv4(self, iface, vport, start_ip, count):
+ """Add static IP range to the interface"""
+ log.debug("add_static_ipv4: start_ip:'%s', count:'%s'",
+ start_ip, count)
+ obj = self.ixnet.add(vport + '/protocols/static', 'ip')
+
+ self.ixnet.setMultiAttribute(obj, '-protocolInterface', iface,
+ '-ipStart', start_ip, '-count', count,
+ '-enabled', 'true')
+ self.ixnet.commit()
diff --git a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
index bf613ca52..c1d902061 100644
--- a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
+++ b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
@@ -351,6 +351,37 @@ class TestIxNextgen(unittest.TestCase):
self.ixnet_gen.ixnet.setAttribute.assert_any_call(
'attr/singleValue', '-value', 'external')
+ def test_add_interface(self):
+ self.ixnet_gen.ixnet.add.return_value = 'obj'
+ self.ixnet_gen.add_interface(vport='vport',
+ ip='10.0.0.2',
+ mac='00:00:00:00:00:00',
+ gateway='10.0.0.1')
+ self.ixnet_gen.ixnet.add.assert_any_call('vport', 'interface')
+ self.ixnet_gen.ixnet.add.assert_any_call('obj', 'ipv4')
+ self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call(
+ 'obj/ethernet', '-macAddress', '00:00:00:00:00:00')
+ self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call(
+ 'obj', '-ip', '10.0.0.2')
+ self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call(
+ 'obj', '-gateway', '10.0.0.1')
+ self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call(
+ 'obj', '-enabled', 'true')
+
+ def test_add_static_ipv4(self):
+ self.ixnet_gen.ixnet.add.return_value = 'obj'
+ self.ixnet_gen.add_static_ipv4(iface='iface',
+ vport='vport',
+ start_ip='10.0.0.0',
+ count='100')
+ self.ixnet_gen.ixnet.add.assert_called_once_with(
+ 'vport/protocols/static', 'ip')
+ self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call(
+ 'obj', '-protocolInterface', 'iface',
+ '-ipStart', '10.0.0.0',
+ '-count', '100',
+ '-enabled', 'true')
+
@mock.patch.object(IxNetwork, 'IxNet')
def test_connect(self, mock_ixnet):
mock_ixnet.return_value = self.ixnet