Changes to reset netcfg to the original state
Change-Id: Ia1b98a435a5d269a9685cbbe4efd632e80fa77d4
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
index ee04e89..195e156 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
@@ -21,6 +21,7 @@
from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator
+import json
class SRBridgingTest ():
@@ -38,6 +39,7 @@
try:
skipPackage = False
init = False
+ originalJSON = None
if not hasattr( main, 'apps' ):
init = True
run.initTest( main )
@@ -93,6 +95,7 @@
# Run the test with physical devices
run.connectToPhysicalNetwork( main, hostDiscovery=False ) # We don't want to do host discovery in the pod
if main.cfgName:
+ originalJSON = main.Cluster.active( 0 ).REST.getNetCfg()
returnValue = run.loadNewJson( main, suffix=suf )
utilities.assert_equals( expect=main.TRUE,
actual=returnValue,
@@ -113,6 +116,8 @@
run.populateHostsVlan( main, main.Network.hosts.keys() )
run.verifyTopology( main, switches, links, onosNodes )
run.pingAll( main )
+ if originalJSON:
+ run.netCfgTransition( main, json.loads(originalJSON) )
except Exception as e:
main.log.exception( "Error in runTest" )
main.skipCase( result="FAIL", msg=e )
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 93af0ee..3aba8fc 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -216,24 +216,28 @@
@staticmethod
def loadNewJson( main, suffix='' ):
- returnValue = main.TRUE
with open( "%s%s.json%s" % ( main.configPath + main.forJson,
main.cfgName, suffix ) ) as cfg:
desiredJSON = json.load ( cfg )
- for device in desiredJSON ["ports"].keys():
- deviceCfg = desiredJSON[ "ports" ][ device ]
- currentJSON = main.Cluster.active( 0 ).REST.getNetCfg( subjectClass = "ports", subjectKey = device )
+ return Testcaselib.netCfgTransition( main, desiredJSON )
- currentJSON = json.loads( currentJSON )
- if currentJSON['interfaces'][0]['ips'] != deviceCfg['interfaces'][0]['ips']:
- currentJSON['interfaces'][0]['ips'] = deviceCfg['interfaces'][0]['ips']
- data = { 'interfaces': currentJSON['interfaces'] }
- A = main.Cluster.active( 0 ).REST.setNetCfg( data , subjectClass = "ports", subjectKey = device )
- returnValue = returnValue and A
- currentJSON['interfaces'] = deviceCfg['interfaces']
+ @staticmethod
+ def netCfgTransition( main, desiredJSON ):
+ returnValue = main.TRUE
+ for device in desiredJSON ["ports"].keys():
+ deviceCfg = desiredJSON[ "ports" ][ device ]
+ currentJSON = main.Cluster.active( 0 ).REST.getNetCfg( subjectClass = "ports", subjectKey = device )
+
+ currentJSON = json.loads( currentJSON )
+ if currentJSON['interfaces'][0]['ips'] != deviceCfg['interfaces'][0]['ips']:
+ currentJSON['interfaces'][0]['ips'] = deviceCfg['interfaces'][0]['ips']
data = { 'interfaces': currentJSON['interfaces'] }
- B = main.Cluster.active( 0 ).REST.setNetCfg( data , subjectClass = "ports", subjectKey = device )
- returnValue = returnValue and B
+ A = main.Cluster.active( 0 ).REST.setNetCfg( data , subjectClass = "ports", subjectKey = device )
+ returnValue = returnValue and A
+ currentJSON['interfaces'] = deviceCfg['interfaces']
+ data = { 'interfaces': currentJSON['interfaces'] }
+ B = main.Cluster.active( 0 ).REST.setNetCfg( data , subjectClass = "ports", subjectKey = device )
+ returnValue = returnValue and B
return returnValue
@staticmethod