Adding a control class for app configuration/activation.
Change dhcp/igmp to use this interface for app configuration
diff --git a/src/test/dhcp/dhcpTest.py b/src/test/dhcp/dhcpTest.py
index 52788fc..5be99b7 100644
--- a/src/test/dhcp/dhcpTest.py
+++ b/src/test/dhcp/dhcpTest.py
@@ -6,11 +6,11 @@
import time
import os, sys
import copy
-import json
CORD_TEST_UTILS = 'utils'
test_root = os.getenv('CORD_TEST_ROOT') or './'
sys.path.append(test_root + CORD_TEST_UTILS)
from DHCP import DHCPTest
+from OnosCtrl import OnosCtrl
log.setLevel('INFO')
@@ -24,25 +24,30 @@
"router": "10.1.8.1",
"domain": "8.8.8.8",
"ttl": "63",
- "lease": "300",
- "renew": "150",
- "rebind": "200",
"delay": "2",
- "timeout": "150",
"startip": "10.1.11.51",
"endip": "10.1.11.100"
}
+ app = 'org.onosproject.dhcp'
+
+ def setUp(self):
+ ''' Activate the dhcp app'''
+ self.onos_ctrl = OnosCtrl(self.app)
+ status, _ = self.onos_ctrl.activate()
+ assert_equal(status, True)
+ time.sleep(3)
+
+ def teardown(self):
+ '''Deactivate the dhcp app'''
+ self.onos_ctrl.deactivate()
+
def onos_load_config(self, config):
- json_dict = json.JSONEncoder().encode(config)
- with tempfile.NamedTemporaryFile(delete=False) as temp:
- temp.write(json_dict)
- temp.flush()
- temp.close()
- log.info('Loading DHCP config in file %s to ONOS.' %temp.name)
- os.system('./dhcp_config_load.sh %s' %temp.name)
- os.unlink(temp.name)
- time.sleep(2)
+ status, code = self.onos_ctrl.config(config)
+ if status is False:
+ log.info('JSON request returned status %d' %code)
+ assert_equal(status, True)
+ time.sleep(2)
def onos_dhcp_table_load(self, config = None):
dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } }
@@ -62,15 +67,15 @@
return cip,sip
def test_dhcp_1request(self, iface = 'veth0'):
- config = {'startip':'10.10.10.20', 'endip':'10.10.10.100',
- 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:cb:fe",
+ config = {'startip':'10.10.10.20', 'endip':'10.10.10.69',
+ 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
self.send_recv()
def test_dhcp_Nrequest(self, iface = 'veth0'):
- config = {'startip':'192.168.1.20', 'endip':'192.168.1.100',
+ config = {'startip':'192.168.1.20', 'endip':'192.168.1.69',
'ip':'192.168.1.2', 'mac': "ca:fe:ca:fe:cc:fe",
'subnet': '255.255.255.0', 'broadcast':'192.168.1.255', 'router': '192.168.1.1'}
self.onos_dhcp_table_load(config)