Bgpls scripts updated with Links

Change-Id: I000a72601d4e17a8323694310a5ed1053c0792b5
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap
deleted file mode 100755
index 2021f22..0000000
--- a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap
+++ /dev/null
Binary files differ
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap
new file mode 100644
index 0000000..8e3db7d
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap
Binary files differ
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
index 8a83748..5661cb8 100755
--- a/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
@@ -78,3 +78,47 @@
         self.app_bgpflow = 'org.onosproject.bgpflow'
         self.list1 = [self.app_bgp,self.app_bgpflow]
         return self.list1
+
+    def checkLinks(self,linksResp):
+        #Declaring the links values
+        links = {'link1_src' : "1650.5555.0055", 'link1_dst' : "1660.6666.0066",
+             'link2_src' : "1630.3333.0033", 'link2_dst' : "1620.2222.0022",
+             'link3_src' : "1660.6666.0066", 'link3_dst' : "1650.5555.0055",
+             'link4_src' : "1630.3333.0033", 'link4_dst' : "1650.5555.0055",
+             'link5_src' : "1640.4444.0044", 'link5_dst' : "1610.1111.0011",
+             'link6_src' : "1650.5555.0055", 'link4_dst' : "1630.3333.0033",
+             'link7_src' : "1620.2222.0022", 'link4_dst' : "1630.3333.0033",
+             'link8_src' : "1620.2222.0022", 'link4_dst' : "1610.1111.0011",
+             'link9_src' : "1630.3333.0033", 'link4_dst' : "1640.4444.0044",
+             'link10_src' : "1650.5555.0055", 'link4_dst' : "1640.4444.0044",
+             'link11_src' : "1610.1111.0011", 'link4_dst' : "1640.4444.0044",
+             'link12_src' : "1640.4444.0044", 'link4_dst' : "1620.2222.0022",
+             'link13_src' : "1660.6666.0066", 'link4_dst' : "1630.3333.0033",
+             'link14_src' : "1640.4444.0044", 'link4_dst' : "1660.6666.0066",
+             'link15_src' : "1640.4444.0044", 'link4_dst' : "1630.3333.0033",
+             'link16_src' : "1610.1111.0011", 'link4_dst' : "1630.3333.0033",
+             'link17_src' : "1630.3333.0033", 'link4_dst' : "1610.1111.0011",
+             'link18_src' : "1610.1111.0011", 'link4_dst' : "1620.2222.0022",
+             'link19_src' : "1620.2222.0022", 'link4_dst' : "1640.4444.0044",
+             'link20_src' : "1630.3333.0033", 'link4_dst' : "1660.6666.0066",
+             'link21_src' : "1640.4444.0044", 'link4_dst' : "1650.5555.0055",
+             'link22_src' : "1660.6666.0066", 'link4_dst' : "1640.4444.0044"
+        }
+
+        #Comparing the Links
+        for x in xrange(22):
+            link_src_info = linksResp[x]['src']['device']
+            link_dst_info = linksResp[x]['dst']['device']
+            link_src_split = link_src_info.split("=")
+            link_src = link_src_split[4]
+            link_dst_split = link_dst_info.split("=")
+            link_dst = link_dst_split[4]
+            y = x+1
+            link_src_ref = links['link'+str(y)+'_src']
+            link_dst_ref = links['link'+str(y)+'_dst']
+            if (link_src == link_src_ref) and (link_dst == (link_dst_ref) and \
+                linksResp[x]['type'] == 'DIRECT' and linksResp[x]['state'] == \
+                'ACTIVE'):
+                return True
+            else:
+                return False
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
index abd1cfc..259f846 100755
--- a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
@@ -18,36 +18,35 @@
 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
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap")
+time.sleep(15)
+pkts[759][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.send(str(pkts[759][BGPHeader])) # OPEN MESSAGE
 c.recv(4096)
-c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.send(str(pkts[765][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]))
+c.send(str(pkts[768][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[771][BGPHeader]))
+c.send(str(pkts[773][BGPHeader]))
+c.send(str(pkts[775][BGPHeader]))
+c.send(str(pkts[778][BGPHeader]))
+c.send(str(pkts[765][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]))
+time.sleep(15)
+c.send(str(pkts[1168][BGPHeader]))
+c.send(str(pkts[1250][BGPHeader]))
+c.send(str(pkts[1354][BGPHeader]))
 print ("Node Delete msg sent")
 
 
 while True:
     c.recv(4096)
-    c.send(str(pkts[71][BGPHeader]))
+    c.send(str(pkts[765][BGPHeader]))
 
   # c.close()                # Close the connection
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py
new file mode 100755
index 0000000..03a5653
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py
@@ -0,0 +1,45 @@
+#!/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.pcap")
+time.sleep(15)
+pkts[759][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[759][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[765][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[768][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[771][BGPHeader]))
+c.send(str(pkts[773][BGPHeader]))
+c.send(str(pkts[775][BGPHeader]))
+c.send(str(pkts[778][BGPHeader]))
+c.send(str(pkts[765][BGPHeader]))
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[765][BGPHeader]))
+
+  # c.close()                # Close the connection