[Goldeneye] BGPLS scripts

Change-Id: I1c263f5dc5b36c776c32f959278b88c848d46a9f
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.params b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.params
new file mode 100755
index 0000000..34dba48
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.params
@@ -0,0 +1,43 @@
+<PARAMS>
+#**** Scripted by Antony Silvester  - antony.silvester@huawei.com ******
+#This Test check the bgp_ls functionality
+#List of test cases:
+#CASE1: Compile ONOS and push it to the test machines
+#CASE2: Discovery the topology using BGPLS
+#CASE3: Addition of new Node to existing topology
+#CASE4: Deletion of Node
+#Case5: Uninstalling the app
+
+
+    <testcases>1,2,3,4,5</testcases>
+
+    <DEPENDENCY>
+        <path>/tests/FUNCbgpls/Dependencies/</path>
+    </DEPENDENCY>
+
+    <ENV>
+        <cellName>bgp_ls</cellName>
+        <cellApps>drivers,openflow,proxyarp,mobility</cellApps>
+    </ENV>
+
+    <CTRL>
+        <ip1>OC1</ip1>
+        <port1>6653</port1>
+    </CTRL>
+
+    <HTTP>
+        <port>8181</port>
+        <path>/onos/</path>
+    </HTTP>
+
+    <GIT>
+        <pull>False</pull>
+        <branch>master</branch>
+    </GIT>
+
+   <SCAPY>
+        <HOSTNAMES>OCN</HOSTNAMES>
+    </SCAPY>
+
+
+</PARAMS>
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
new file mode 100755
index 0000000..362d378
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
@@ -0,0 +1,578 @@
+"""
+**** Scripted by Antony Silvester  - antony.silvester@huawei.com ******
+
+
+This Test check the bgp_ls functionality
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Discovery the topology using BGPLS
+CASE3: Addition of new Node to existing topology
+CASE4: Deletion of Node
+Case5: Uninstalling the app
+
+
+"""
+
+
+class FUNCbgpls:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE1( self, main ):
+        """
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-uninstall
+        git pull
+        mvn clean install
+        onos-package
+        onos-install -f
+        onos-wait-for-start
+        start cli sessions
+        start BGPLS apps
+
+        """
+
+        import os
+        main.log.info( "ONOS Single node start " +
+                         "Scapy Tool - initialization" )
+        main.case( "Setting up test environment" )
+        main.caseExplanation = "Setup the test environment including " +\
+                                "installing ONOS, start ONOS."
+
+
+        PULLCODE = False
+        if main.params[ 'GIT' ][ 'pull' ] == 'True':
+            PULLCODE = True
+        gitBranch = main.params[ 'GIT' ][ 'branch' ]
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+
+        main.log.info( "Removing raft logs" )
+        main.ONOSbench.onosRemoveRaftLogs()
+
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.log.info( "Uninstalling ONOS" )
+        for node in main.nodes:
+            main.ONOSbench.onosUninstall( node.ip_address )
+
+        main.step( "Create cell file" )
+        cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
+
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       scapy_ip,
+                                       cellAppString, ipList )
+
+        main.step( "Applying cell variable to environment" )
+        cellResult = main.ONOSbench.setCell( cellName )
+
+        verifyResult = main.ONOSbench.verifyCell()
+
+        # Make sure ONOS process is not running
+        main.log.info( "Killing any ONOS processes" )
+        killResults = main.TRUE
+        for node in main.nodes:
+            killed = main.ONOSbench.onosKill( node.ip_address )
+            killResults = killResults and killed
+
+        cleanInstallResult = main.TRUE
+        gitPullResult = main.FALSE
+        main.step( "Git checkout and pull" + gitBranch )
+        if PULLCODE:
+            main.ONOSbench.gitCheckout( gitBranch )
+            gitPullResult = main.ONOSbench.gitPull()
+            # values of 1 or 3 are good
+            utilities.assert_lesser( expect=0, actual=gitPullResult,
+                                      onpass="Git pull successful",
+                                      onfail="Git pull failed" )
+
+        #main.ONOSbench.getVersion( report=True )
+
+        main.step( "Using mvn clean install" )
+        cleanInstallResult = main.TRUE
+        if PULLCODE and gitPullResult == main.TRUE:
+            cleanInstallResult = main.ONOSbench.cleanInstall()
+        else:
+            main.log.warn( "Did not pull new code so skipping mvn" +
+                           "clean install" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cleanInstallResult,
+                                 onpass="MCI successful",
+                                 onfail="MCI failed" )
+
+        main.step( "Creating ONOS package" )
+        packageResult = main.ONOSbench.onosPackage()
+        utilities.assert_equals( expect=main.TRUE,
+                                     actual=packageResult,
+                                     onpass="Successfully created ONOS package",
+                                     onfail="Failed to create ONOS package" )
+
+        main.step( "Installing ONOS package" )
+        onosInstallResult = main.ONOSbench.onosInstall(
+                options="-f", node=main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+                                 onpass="ONOS install successful",
+                                 onfail="ONOS install failed" )
+
+        main.step( "Checking if ONOS is up yet" )
+        print main.nodes[0].ip_address
+        for i in range( 2 ):
+            onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
+            if onos1Isup:
+                break
+        utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
+                                 onpass="ONOS startup successful",
+                                 onfail="ONOS startup failed" )
+        main.log.step( "Starting ONOS CLI sessions" )
+        print main.nodes[0].ip_address
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+
+        main.step( "App Ids check" )
+        appCheck = main.ONOScli1.appToIDCheck()
+
+        if appCheck !=main.TRUE:
+            main.log.warn( main.CLIs[0].apps() )
+            main.log.warn( main.CLIs[0].appIDs() )
+            utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+                                 onpass="App Ids seem to be correct",
+                                 onfail="Something is wrong with app Ids" )
+        if cliResults == main.FALSE:
+            main.log.error( "Failed to start ONOS,stopping test" )
+            main.cleanup()
+            main.exit()
+
+
+
+
+
+    def CASE2( self, main ):
+        """
+        Discovery the topology using BGPLS
+        """
+        import os , sys
+        import re
+        import time
+
+        main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
+
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        Ne_id = bgplsConfig.Constants()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+        bgplsConfig.ipValue(ipList,scapy_ip)
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Apply cell to environment" )
+        bgplsConfig.Comments()
+
+        bgplsConfig.Comments()
+        main.log.info( "Sending BGPLS information " )
+        bgplsConfig.Comments()
+
+
+        main.Scapy1.handle.sendline( "sudo python  OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
+        dependencies/Scapyfiles/Topo_discovery.py" )
+        bgplsConfig.Comments()
+        main.log.info( "Enable BGPlS plugin in ONOS" )
+        bgplsConfig.Comments()
+
+
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address)
+
+        main.step( "Getting connected to ONOS" )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+        installResults = main.ONOScli1.activateApp( app[0])
+
+        main.step( "Install onos-app-bgp" )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgp successful",
+                                 onfail="Install onos-app-bgp failed" )
+
+        bgpls_post = bgplsConfig.DictoJson()
+
+        bgplsConfig.Comments()
+        main.log.info( "BGPLS RestConf input" )
+        bgplsConfig.Comments()
+
+        print (bgpls_post)
+        main.ONOSrest.user_name = "karaf"
+        main.ONOSrest.pwd = "karaf"
+        Poststatus, result = main.ONOSrest.send( ipList, httpport, '/network/configuration/', method="POST",data=bgpls_post)
+        main.step( "Configure BGP through RESTCONF" )
+
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Port Success",
+                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Check Network devices are Updated in ONOS " )
+        bgplsConfig.Comments()
+        time.sleep(15)
+
+        response = main.ONOScli1.devices()
+        main.step( "Check the nodes are discovered" )
+        if response.find( Ne_id[1][0]) and response.find(Ne_id[1][1]) and response.find(Ne_id[1][2]) != -1:
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + "  sucess",
+                                 onfail="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + " failed" )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Kill Scapy process" )
+        bgplsConfig.Comments()
+
+        main.Scapy1.handle.sendline( "\x03" )
+        time.sleep(90) #This Sleep time gives time for the socket to close.
+
+
+
+
+    def CASE3( self, main ):
+        """
+        Addition of new Node to existing topology
+        """
+        import os , sys
+        import re
+        import time
+
+        main.case( "Testcase 3: Addition of New Node to existing topology" )
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        Ne_id = bgplsConfig.Constants()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv( main.params ['SCAPY'] ['HOSTNAMES'] )
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+
+        bgplsConfig.ipValue(ipList,scapy_ip)
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        bgplsConfig.Comments()
+        main.log.info( "Sending BGPLS Packet " )
+        bgplsConfig.Comments()
+
+        main.Scapy1.handle.sendline( "sudo python  OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
+        dependencies/Scapyfiles/Update_Node.py" )
+        bgplsConfig.Comments()
+        main.log.info( "Enable BGPlS plugin in ONOS" )
+        bgplsConfig.Comments()
+
+        main.step( "UnInstall onos-app-bgp" )
+        installResults = main.ONOScli1.deactivateApp( app[0] )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Uninstall  onos-app-bgp successful",
+                                 onfail="Uninstall  onos-app-bgp failed" )
+
+        installResults = main.ONOScli1.activateApp( app[0])
+        main.step( "Install onos-app-bgp" )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgp successful",
+                                 onfail="Install onos-app-bgp failed" )
+
+
+        bgpls_post = bgplsConfig.DictoJson()
+
+        bgplsConfig.Comments()
+        main.log.info( "BGPLS RestConf input" )
+        bgplsConfig.Comments()
+
+        bgplsConfig.Comments()
+        main.log.info( "Check Network devices are Updated in ONOS " )
+        bgplsConfig.Comments()
+        time.sleep(120)
+
+        response = main.ONOScli1.devices()
+        main.step( "Check Newly added Node is getting updated" )
+
+        if response.find( Ne_id[1][3]) != -1:
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Node " + str( Ne_id[1][3] ) + " update  sucess",
+                                 onfail="Node " + str( Ne_id[1][3]) + " update failed" )
+        bgplsConfig.Comments()
+        main.log.info( "Kill Scapy process" )
+        bgplsConfig.Comments()
+        main.Scapy1.handle.sendline( "\x03" )
+
+
+
+    def CASE4( self, main ):
+        """
+        Deletion of  Node
+        """
+        import os , sys
+        import re
+        import time
+        main.case( "TestCase 4: Deletion of Node from existing Topology" )
+
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        Ne_id = bgplsConfig.Constants()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+        bgplsConfig.Comments()
+        main.log.info( "Blocked due to this defect : ONOS-3920 " )
+        bgplsConfig.Comments()
+
+        '''
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+        bgplsConfig = BgpLs()
+        bgplsConfig.ipValue(ipList,scapy_ip)
+
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       scapy_ip,
+                                       cellAppString, ipList , onosUser="karaf" )
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Apply cell to environment" )
+        bgplsConfig.Comments()
+        cellResult = main.ONOSbench.setCell( cellName )
+
+        bgplsConfig.Comments()
+        main.log.info( "Sending BGPLS information " )
+        bgplsConfig.Comments()
+
+
+        main.Scapy1.handle.sendline( "sudo python  OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
+        #main.Scapy1.handle.expect( "sdn:" )
+        #main.Scapy1.handle.sendline( "rocks" )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Enable BGPlS plugin in ONOS" )
+        bgplsConfig.Comments()
+
+
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address)
+
+        main.step( "Getting connected to ONOS" )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+        installResults = main.ONOScli1.activateApp( app[0])
+
+        main.step( "Install onos-app-bgp" )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgp successful",
+                                 onfail="Install onos-app-bgp failed" )
+
+        main.step( "Install onos-app-bgpflow" )
+        installResults = main.ONOScli1.activateApp( app[1] )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgpflow successful",
+                                 onfail="Install onos-app-bgpflow failed" )
+
+
+        bgpls_post = bgplsConfig.DictoJson()
+
+        bgplsConfig.Comments()
+        main.log.info( "BGPLS RestConf input" )
+        bgplsConfig.Comments()
+
+        print (bgpls_post)
+        main.ONOSrest.user_name = "karaf"
+        main.ONOSrest.pwd = "karaf"
+        Poststatus, result = main.ONOSrest.send( ipList,httpport,'', path + 'v1/network/configuration/',
+                                                 'POST', None, bgpls_post, debug=True )
+
+        main.step( "Configure BGP through RESTCONF" )
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Port Success",
+                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Check Network devices is deleted from  ONOS " )
+        bgplsConfig.Comments()
+        time.sleep(15)
+
+        response = main.ONOScli1.devices()
+
+        main.step( "Check whehther Node is deleted successfully" )
+
+        if response.find(Ne_id[3]) != -1:
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.FALSE,
+                                 actual=stepResult,
+                                 onpass="Node " + str( Ne_id[3] ) + " Deletion sucess",
+                                 onfail="Node " + str( Ne_id[3] ) + " Deletion  failed" )
+
+        bgplsConfig.Comments()
+        main.log.info( "Kill Scapy process" )
+        bgplsConfig.Comments()
+
+        main.Scapy1.handle.sendline( "\x03" )
+        '''
+
+
+    def CASE5( self, main ):
+        """
+        Uninstalling the app
+        """
+        import os,sys
+        import re
+        import time
+
+        main.case( "TestCase 5: UnInstalling of app" )
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
+
+        bgplsConfig = BgpLs()
+        bgplsConfig.ipValue(ipList,scapy_ip)
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       scapy_ip,
+                                       cellAppString, ipList , onosUser="karaf" )
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Apply cell to environment" )
+        bgplsConfig.Comments()
+        cellResult = main.ONOSbench.setCell( cellName )
+
+        bgplsConfig.Comments()
+        main.log.info( "Logging into ONOS CLI " )
+        bgplsConfig.Comments()
+
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+
+        bgplsConfig.Comments()
+        main.log.info( "Uninstall onos-app-bgp" )
+        bgplsConfig.Comments()
+        main.step( "UnInstall onos-app-bgp" )
+        installResults = main.ONOScli1.deactivateApp( app[0] )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Uninstall  onos-app-bgp successful",
+                                 onfail="Uninstall  onos-app-bgp failed" )
+
+
+
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
new file mode 100755
index 0000000..fc1bf21
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
@@ -0,0 +1,52 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOS1>
+            <host>OC1</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOSrest>
+            <host>OC1</host>
+            <user>sdn</user>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOSrest>
+
+       <Scapy1>
+            <host>OCN</host>
+           <user>sdn</user>
+            <password>rocks</password>
+            <type>ScapyCliDriver</type>
+            <connect_order>5</connect_order>
+        </Scapy1>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FUNC/FUNCbgpls/README b/TestON/tests/FUNC/FUNCbgpls/README
new file mode 100755
index 0000000..2ecb554
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/README
@@ -0,0 +1,42 @@
+
+ONOS BGPLS Feature Scripts
+***************************
+
+Brief :
+*******
+        BGPLS as a southbound plug-in in ONOS controller to collect the
+        topology information of the network. This network topology can be
+        used by some applications like PCE would benefit from visibility
+        outside one area or Autonomous System (AS) in order to make better
+        decisions for path computation.
+
+
+Prerequisites:
+**************
+
+1] Scapy should be installed and running in OCN.
+2] The Scapy version should be 2.3.1 and above.
+3] Then  git clone https://github.com/secdev/scapy.git
+4] cd to scapy folder and run --- > sudo python setup.py install
+5] Test TOPO :  OCN --- OCI
+6] OnosSystemTest folder should be under ~/
+
+
+Things to know :
+****************
+
+1] We use Scapy tool, to send the BGPLS packet to ONOS.
+2] The packets are already pre-captured.
+3] ONOS reads those packet and displays the topology.
+4] We query the devices information in ONOS to check the devices/links are learn
+
+
+Steps :
+*******
+
+  1] run FUNCbgpls
+
+
+***************************************************************END************************************************************************
+
+
diff --git a/TestON/tests/FUNC/FUNCbgpls/__init__.py b/TestON/tests/FUNC/FUNCbgpls/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/__init__.py
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap
new file mode 100755
index 0000000..2021f22
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap
Binary files differ
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap
new file mode 100755
index 0000000..e831d22
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap
Binary files differ
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
new file mode 100755
index 0000000..8a83748
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
@@ -0,0 +1,80 @@
+"""**** Scripted by Antony Silvester ****** """
+import json
+from urllib import addbase
+import os
+
+
+import requests
+from requests.auth import HTTPBasicAuth
+
+
+class BgpLs:
+
+    def __init__(self):
+        self.localAs = 100
+        self.maxSession = 20
+        self.lsCapability = True
+        self.holdTime = 180
+        self.largeAsCapability = False
+        self.flowSpecCapability = 'IPV4'
+        self.flowSpecRpdCapability = False
+        self.remoteAs = 100
+        self.peerHoldTime = 120
+        self.connectMode = 'active'
+        self.bgpPeer = []
+        self.routerId = ''
+        self.peerIp = ''
+        #self.org_bgp = []
+
+    def ipValue(self,localip,remoteip):
+        self.routerId = localip
+        self.peerIp = remoteip
+        return self.routerId , self.peerIp
+
+    def DictoJson(self):
+        Dicdata = {}
+        org_bgp =[]
+        org_bgp.append({'peerIp': self.peerIp , 'remoteAs':self.remoteAs,
+                        'peerHoldTime':self.peerHoldTime , 'connectMode':self.connectMode })
+        if self.routerId != '':
+            Dicdata['routerId'] = self.routerId
+        if self.localAs != '':
+            Dicdata['localAs'] = self.localAs
+        if self.maxSession != '':
+            Dicdata['maxSession'] = self.maxSession
+        if self.lsCapability != '':
+            Dicdata['lsCapability'] = self.lsCapability
+        if self.holdTime != '':
+            Dicdata['holdTime'] = self.holdTime
+        if self.largeAsCapability != '':
+            Dicdata['largeAsCapability'] = self.largeAsCapability
+        if self.flowSpecCapability != '':
+            Dicdata['flowSpecCapability'] = self.flowSpecCapability
+        if self.flowSpecRpdCapability != '':
+            Dicdata['flowSpecRpdCapability'] = self.flowSpecRpdCapability
+        if self.bgpPeer != '':
+            Dicdata['bgpPeer'] = org_bgp
+
+        Dicdata = {'bgpapp':Dicdata}
+        Dicdata = {'org.onosproject.provider.bgp.cfg':Dicdata}
+        Dicdata = {'apps':Dicdata}
+        return json.dumps(Dicdata,indent=4)
+
+
+    def  Comments(self):
+        print("**********************************************************************************\n")
+
+    def Constants(self):
+        self.Ne_id_1 =  '1111.1111.0011'
+        self.Ne_id_2 = '2222.2222.0022'
+        self.Ne_id_3 = '3333.3333.0033'
+        self.Ne_id_4 = '4444.4444.0044'
+        listnum = [self.Ne_id_1,self.Ne_id_2,self.Ne_id_3,self.Ne_id_4,]
+        var = [self.peerIp]
+        return var,listnum
+
+    def apps(self):
+        self.app_bgp = 'org.onosproject.bgp'
+        self.app_bgpflow = 'org.onosproject.bgpflow'
+        self.list1 = [self.app_bgp,self.app_bgpflow]
+        return self.list1
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
new file mode 100755
index 0000000..abd1cfc
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python           # This is server.py file
+from scapy.all import *
+import socket               # Import socket module
+import time                 # Import Time module
+import sys
+import os
+
+path = os.getcwd()
+sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies')   #Setting the path for BgpLS
+from Nbdata import BgpLs
+
+obj = BgpLs()
+returnlist = obj.Constants()
+peerIp = returnlist[0][0]
+
+load_contrib('bgp')
+s = socket.socket()         # Create a socket object
+host = peerIp # Get local machine name
+port = 179                # Reserve a port for your service.
+s.bind((host, port))        # Bind to the port
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
+pkts[69][BGPOpen].bgp_id = peerIp
+
+s.listen(5)                   # Now wait for client connection.
+
+print("starting Connecting to ONOS peer")
+c, addr = s.accept()     # Establish connection with client.
+print 'Got connection from ONOS :', addr
+c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[72][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[74][BGPHeader]))
+c.send(str(pkts[71][BGPHeader]))
+
+time.sleep(10)               # Waiting for 120 seconds for update message.
+
+c.send(str(pkts[298][BGPHeader]))
+c.send(str(pkts[860][BGPHeader]))   # UPDATE MESSAGES with new node
+c.send(str(pkts[865][BGPHeader]))
+print ("New Node update msg sent")
+
+time.sleep(5)
+c.send(str(pkts[890][BGPHeader]))
+print ("Node Delete msg sent")
+
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[71][BGPHeader]))
+
+  # c.close()                # Close the connection
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Topo_discovery.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Topo_discovery.py
new file mode 100755
index 0000000..a7daf91
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Topo_discovery.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python           # This is server.py file
+from scapy.all import *
+import socket               # Import socket module
+import time                 # Import Time module
+import sys
+import os
+
+path = os.getcwd()
+sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies')   #Setting the path for BgpLS
+from Nbdata import BgpLs
+
+obj = BgpLs()
+returnlist = obj.Constants()
+peerIp = returnlist[0][0]
+
+load_contrib('bgp')
+s = socket.socket()         # Create a socket object
+host = peerIp # Get local machine name
+port = 179                # Reserve a port for your service.
+s.bind((host, port))        # Bind to the port
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
+pkts[69][BGPOpen].bgp_id = peerIp
+
+s.listen(5)                 # Now wait for client connection.
+
+print("starting Connecting to ONOS peer")
+c, addr = s.accept()     # Establish connection with client.
+print 'Got connection from ONOS :', addr
+c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[72][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[74][BGPHeader]))
+c.send(str(pkts[71][BGPHeader]))
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[71][BGPHeader]))
+
+  # c.close()                # Close the connection
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Update_Node.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Update_Node.py
new file mode 100755
index 0000000..3a40d6c
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Update_Node.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python           # This is server.py file
+from scapy.all import *
+import socket               # Import socket module
+import time                 # Import Time module
+import sys
+import os
+
+path = os.getcwd()
+sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies')   #Setting the path for BgpLS
+from Nbdata import BgpLs
+
+obj = BgpLs()
+returnlist = obj.Constants()
+peerIp = returnlist[0][0]
+
+load_contrib('bgp')
+s = socket.socket()         # Create a socket object
+host = peerIp # Get local machine name
+port = 179                # Reserve a port for your service.
+s.bind((host, port))        # Bind to the port
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
+pkts[69][BGPOpen].bgp_id = peerIp
+
+s.listen(5)                 # Now wait for client connection.
+
+print("starting Connecting to ONOS peer")
+c, addr = s.accept()     # Establish connection with client.
+print 'Got connection from ONOS :', addr
+c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[72][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[74][BGPHeader]))
+c.send(str(pkts[71][BGPHeader]))
+
+time.sleep(10)               # Waiting for 120 seconds for update message.
+
+c.send(str(pkts[298][BGPHeader]))
+c.send(str(pkts[860][BGPHeader]))   # UPDATE MESSAGES with new node
+c.send(str(pkts[865][BGPHeader]))
+print ("New Node update msg sent")
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[71][BGPHeader]))
+
+  # c.close()                # Close the connection
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/__init__.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/__init__.py
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/__init__.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/__init__.py