blob: ba6a12f8a3549b59016c4736f164d0aaa09786ac [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2016 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
Jon Hall46fdea12017-05-24 15:48:57 -070022"**** Scripted by Antony Silvester ****** "
AntonySilvestera1080f22016-04-26 13:05:57 +053023import json
24from urllib import addbase
25import os
26
27
28import requests
29from requests.auth import HTTPBasicAuth
30
31
32class BgpLs:
33
Jon Hall46fdea12017-05-24 15:48:57 -070034 def __init__( self ):
AntonySilvestera1080f22016-04-26 13:05:57 +053035 self.localAs = 100
36 self.maxSession = 20
37 self.lsCapability = True
38 self.holdTime = 180
39 self.largeAsCapability = False
40 self.flowSpecCapability = 'IPV4'
41 self.flowSpecRpdCapability = False
42 self.remoteAs = 100
43 self.peerHoldTime = 120
44 self.connectMode = 'active'
45 self.bgpPeer = []
46 self.routerId = ''
47 self.peerIp = ''
AntonySilvestera1080f22016-04-26 13:05:57 +053048
Jon Hall46fdea12017-05-24 15:48:57 -070049 def ipValue( self, localip, remoteip ):
AntonySilvestera1080f22016-04-26 13:05:57 +053050 self.routerId = localip
51 self.peerIp = remoteip
Jon Hall46fdea12017-05-24 15:48:57 -070052 return self.routerId, self.peerIp
AntonySilvestera1080f22016-04-26 13:05:57 +053053
Jon Hall46fdea12017-05-24 15:48:57 -070054 def DictoJson( self ):
AntonySilvestera1080f22016-04-26 13:05:57 +053055 Dicdata = {}
Jon Hall46fdea12017-05-24 15:48:57 -070056 org_bgp = []
57 org_bgp.append( { 'peerIp': self.peerIp, 'remoteAs': self.remoteAs,
58 'peerHoldTime': self.peerHoldTime, 'connectMode': self.connectMode } )
AntonySilvestera1080f22016-04-26 13:05:57 +053059 if self.routerId != '':
Jon Hall46fdea12017-05-24 15:48:57 -070060 Dicdata[ 'routerId' ] = self.routerId
AntonySilvestera1080f22016-04-26 13:05:57 +053061 if self.localAs != '':
Jon Hall46fdea12017-05-24 15:48:57 -070062 Dicdata[ 'localAs' ] = self.localAs
AntonySilvestera1080f22016-04-26 13:05:57 +053063 if self.maxSession != '':
Jon Hall46fdea12017-05-24 15:48:57 -070064 Dicdata[ 'maxSession' ] = self.maxSession
AntonySilvestera1080f22016-04-26 13:05:57 +053065 if self.lsCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070066 Dicdata[ 'lsCapability' ] = self.lsCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053067 if self.holdTime != '':
Jon Hall46fdea12017-05-24 15:48:57 -070068 Dicdata[ 'holdTime' ] = self.holdTime
AntonySilvestera1080f22016-04-26 13:05:57 +053069 if self.largeAsCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070070 Dicdata[ 'largeAsCapability' ] = self.largeAsCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053071 if self.flowSpecCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070072 Dicdata[ 'flowSpecCapability' ] = self.flowSpecCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053073 if self.flowSpecRpdCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070074 Dicdata[ 'flowSpecRpdCapability' ] = self.flowSpecRpdCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053075 if self.bgpPeer != '':
Jon Hall46fdea12017-05-24 15:48:57 -070076 Dicdata[ 'bgpPeer' ] = org_bgp
AntonySilvestera1080f22016-04-26 13:05:57 +053077
Jon Hall46fdea12017-05-24 15:48:57 -070078 Dicdata = { 'bgpapp': Dicdata }
79 Dicdata = { 'org.onosproject.provider.bgp.cfg': Dicdata }
80 Dicdata = { 'apps': Dicdata }
81 return json.dumps( Dicdata, indent=4 )
AntonySilvestera1080f22016-04-26 13:05:57 +053082
Jon Hall46fdea12017-05-24 15:48:57 -070083 def Comments( self ):
84 print( "**********************************************************************************\n" )
AntonySilvestera1080f22016-04-26 13:05:57 +053085
Jon Hall46fdea12017-05-24 15:48:57 -070086 def Constants( self ):
87 self.Ne_id_1 = '1111.1111.0011'
AntonySilvestera1080f22016-04-26 13:05:57 +053088 self.Ne_id_2 = '2222.2222.0022'
89 self.Ne_id_3 = '3333.3333.0033'
90 self.Ne_id_4 = '4444.4444.0044'
Jon Hall46fdea12017-05-24 15:48:57 -070091 listnum = [ self.Ne_id_1, self.Ne_id_2, self.Ne_id_3, self.Ne_id_4, ]
92 var = [ self.peerIp ]
93 return var, listnum
AntonySilvestera1080f22016-04-26 13:05:57 +053094
Jon Hall46fdea12017-05-24 15:48:57 -070095 def apps( self ):
AntonySilvestera1080f22016-04-26 13:05:57 +053096 self.app_bgp = 'org.onosproject.bgp'
97 self.app_bgpflow = 'org.onosproject.bgpflow'
Jon Hall46fdea12017-05-24 15:48:57 -070098 self.list1 = [ self.app_bgp, self.app_bgpflow ]
AntonySilvestera1080f22016-04-26 13:05:57 +053099 return self.list1
AntonySilvester02652382016-07-13 16:44:45 +0530100
Jon Hall46fdea12017-05-24 15:48:57 -0700101 def checkLinks( self, linksResp ):
Jon Hall64b17572017-06-06 09:39:19 -0700102 # Declaring the links values
Jon Hall46fdea12017-05-24 15:48:57 -0700103 links = { 'link1_src': "1650.5555.0055", 'link1_dst': "1660.6666.0066",
104 'link2_src': "1630.3333.0033", 'link2_dst': "1620.2222.0022",
105 'link3_src': "1660.6666.0066", 'link3_dst': "1650.5555.0055",
106 'link4_src': "1630.3333.0033", 'link4_dst': "1650.5555.0055",
107 'link5_src': "1640.4444.0044", 'link5_dst': "1610.1111.0011",
108 'link6_src': "1650.5555.0055", 'link4_dst': "1630.3333.0033",
109 'link7_src': "1620.2222.0022", 'link4_dst': "1630.3333.0033",
110 'link8_src': "1620.2222.0022", 'link4_dst': "1610.1111.0011",
111 'link9_src': "1630.3333.0033", 'link4_dst': "1640.4444.0044",
112 'link10_src': "1650.5555.0055", 'link4_dst': "1640.4444.0044",
113 'link11_src': "1610.1111.0011", 'link4_dst': "1640.4444.0044",
114 'link12_src': "1640.4444.0044", 'link4_dst': "1620.2222.0022",
115 'link13_src': "1660.6666.0066", 'link4_dst': "1630.3333.0033",
116 'link14_src': "1640.4444.0044", 'link4_dst': "1660.6666.0066",
117 'link15_src': "1640.4444.0044", 'link4_dst': "1630.3333.0033",
118 'link16_src': "1610.1111.0011", 'link4_dst': "1630.3333.0033",
119 'link17_src': "1630.3333.0033", 'link4_dst': "1610.1111.0011",
120 'link18_src': "1610.1111.0011", 'link4_dst': "1620.2222.0022",
121 'link19_src': "1620.2222.0022", 'link4_dst': "1640.4444.0044",
122 'link20_src': "1630.3333.0033", 'link4_dst': "1660.6666.0066",
123 'link21_src': "1640.4444.0044", 'link4_dst': "1650.5555.0055",
124 'link22_src': "1660.6666.0066", 'link4_dst': "1640.4444.0044"
125 }
AntonySilvester02652382016-07-13 16:44:45 +0530126
Jon Hall64b17572017-06-06 09:39:19 -0700127 # Comparing the Links
Jon Hall46fdea12017-05-24 15:48:57 -0700128 for x in xrange( 22 ):
129 link_src_info = linksResp[ x ][ 'src' ][ 'device' ]
130 link_dst_info = linksResp[ x ][ 'dst' ][ 'device' ]
131 link_src_split = link_src_info.split( "=" )
132 link_src = link_src_split[ 4 ]
133 link_dst_split = link_dst_info.split( "=" )
134 link_dst = link_dst_split[ 4 ]
135 y = x + 1
136 link_src_ref = links[ 'link' + str( y ) + '_src' ]
137 link_dst_ref = links[ 'link' + str( y ) + '_dst' ]
138 if ( link_src == link_src_ref ) and ( link_dst == ( link_dst_ref ) and
139 linksResp[ x ][ 'type' ] == 'DIRECT' and linksResp[ x ][ 'state' ] ==
140 'ACTIVE' ):
AntonySilvester02652382016-07-13 16:44:45 +0530141 return True
142 else:
143 return False