blob: 17d4df8d04f9b3c3f5854ddcb75e6dc85b6cc151 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
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"""
Jon Hall46fdea12017-05-24 15:48:57 -070021"**** Scripted by Antony Silvester ****** "
AntonySilvestera1080f22016-04-26 13:05:57 +053022import json
23from urllib import addbase
24import os
25
26
27import requests
28from requests.auth import HTTPBasicAuth
29
30
31class BgpLs:
32
Jon Hall46fdea12017-05-24 15:48:57 -070033 def __init__( self ):
AntonySilvestera1080f22016-04-26 13:05:57 +053034 self.localAs = 100
35 self.maxSession = 20
36 self.lsCapability = True
37 self.holdTime = 180
38 self.largeAsCapability = False
39 self.flowSpecCapability = 'IPV4'
40 self.flowSpecRpdCapability = False
41 self.remoteAs = 100
42 self.peerHoldTime = 120
43 self.connectMode = 'active'
44 self.bgpPeer = []
45 self.routerId = ''
46 self.peerIp = ''
AntonySilvestera1080f22016-04-26 13:05:57 +053047
Jon Hall46fdea12017-05-24 15:48:57 -070048 def ipValue( self, localip, remoteip ):
AntonySilvestera1080f22016-04-26 13:05:57 +053049 self.routerId = localip
50 self.peerIp = remoteip
Jon Hall46fdea12017-05-24 15:48:57 -070051 return self.routerId, self.peerIp
AntonySilvestera1080f22016-04-26 13:05:57 +053052
Jon Hall46fdea12017-05-24 15:48:57 -070053 def DictoJson( self ):
AntonySilvestera1080f22016-04-26 13:05:57 +053054 Dicdata = {}
Jon Hall46fdea12017-05-24 15:48:57 -070055 org_bgp = []
56 org_bgp.append( { 'peerIp': self.peerIp, 'remoteAs': self.remoteAs,
57 'peerHoldTime': self.peerHoldTime, 'connectMode': self.connectMode } )
AntonySilvestera1080f22016-04-26 13:05:57 +053058 if self.routerId != '':
Jon Hall46fdea12017-05-24 15:48:57 -070059 Dicdata[ 'routerId' ] = self.routerId
AntonySilvestera1080f22016-04-26 13:05:57 +053060 if self.localAs != '':
Jon Hall46fdea12017-05-24 15:48:57 -070061 Dicdata[ 'localAs' ] = self.localAs
AntonySilvestera1080f22016-04-26 13:05:57 +053062 if self.maxSession != '':
Jon Hall46fdea12017-05-24 15:48:57 -070063 Dicdata[ 'maxSession' ] = self.maxSession
AntonySilvestera1080f22016-04-26 13:05:57 +053064 if self.lsCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070065 Dicdata[ 'lsCapability' ] = self.lsCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053066 if self.holdTime != '':
Jon Hall46fdea12017-05-24 15:48:57 -070067 Dicdata[ 'holdTime' ] = self.holdTime
AntonySilvestera1080f22016-04-26 13:05:57 +053068 if self.largeAsCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070069 Dicdata[ 'largeAsCapability' ] = self.largeAsCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053070 if self.flowSpecCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070071 Dicdata[ 'flowSpecCapability' ] = self.flowSpecCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053072 if self.flowSpecRpdCapability != '':
Jon Hall46fdea12017-05-24 15:48:57 -070073 Dicdata[ 'flowSpecRpdCapability' ] = self.flowSpecRpdCapability
AntonySilvestera1080f22016-04-26 13:05:57 +053074 if self.bgpPeer != '':
Jon Hall46fdea12017-05-24 15:48:57 -070075 Dicdata[ 'bgpPeer' ] = org_bgp
AntonySilvestera1080f22016-04-26 13:05:57 +053076
Jon Hall46fdea12017-05-24 15:48:57 -070077 Dicdata = { 'bgpapp': Dicdata }
78 Dicdata = { 'org.onosproject.provider.bgp.cfg': Dicdata }
79 Dicdata = { 'apps': Dicdata }
80 return json.dumps( Dicdata, indent=4 )
AntonySilvestera1080f22016-04-26 13:05:57 +053081
Jon Hall46fdea12017-05-24 15:48:57 -070082 def Comments( self ):
83 print( "**********************************************************************************\n" )
AntonySilvestera1080f22016-04-26 13:05:57 +053084
Jon Hall46fdea12017-05-24 15:48:57 -070085 def Constants( self ):
86 self.Ne_id_1 = '1111.1111.0011'
AntonySilvestera1080f22016-04-26 13:05:57 +053087 self.Ne_id_2 = '2222.2222.0022'
88 self.Ne_id_3 = '3333.3333.0033'
89 self.Ne_id_4 = '4444.4444.0044'
Jon Hall46fdea12017-05-24 15:48:57 -070090 listnum = [ self.Ne_id_1, self.Ne_id_2, self.Ne_id_3, self.Ne_id_4, ]
91 var = [ self.peerIp ]
92 return var, listnum
AntonySilvestera1080f22016-04-26 13:05:57 +053093
Jon Hall46fdea12017-05-24 15:48:57 -070094 def apps( self ):
AntonySilvestera1080f22016-04-26 13:05:57 +053095 self.app_bgp = 'org.onosproject.bgp'
96 self.app_bgpflow = 'org.onosproject.bgpflow'
Jon Hall46fdea12017-05-24 15:48:57 -070097 self.list1 = [ self.app_bgp, self.app_bgpflow ]
AntonySilvestera1080f22016-04-26 13:05:57 +053098 return self.list1
AntonySilvester02652382016-07-13 16:44:45 +053099
Jon Hall46fdea12017-05-24 15:48:57 -0700100 def checkLinks( self, linksResp ):
Jon Hall64b17572017-06-06 09:39:19 -0700101 # Declaring the links values
Jon Hall46fdea12017-05-24 15:48:57 -0700102 links = { 'link1_src': "1650.5555.0055", 'link1_dst': "1660.6666.0066",
103 'link2_src': "1630.3333.0033", 'link2_dst': "1620.2222.0022",
104 'link3_src': "1660.6666.0066", 'link3_dst': "1650.5555.0055",
105 'link4_src': "1630.3333.0033", 'link4_dst': "1650.5555.0055",
106 'link5_src': "1640.4444.0044", 'link5_dst': "1610.1111.0011",
107 'link6_src': "1650.5555.0055", 'link4_dst': "1630.3333.0033",
108 'link7_src': "1620.2222.0022", 'link4_dst': "1630.3333.0033",
109 'link8_src': "1620.2222.0022", 'link4_dst': "1610.1111.0011",
110 'link9_src': "1630.3333.0033", 'link4_dst': "1640.4444.0044",
111 'link10_src': "1650.5555.0055", 'link4_dst': "1640.4444.0044",
112 'link11_src': "1610.1111.0011", 'link4_dst': "1640.4444.0044",
113 'link12_src': "1640.4444.0044", 'link4_dst': "1620.2222.0022",
114 'link13_src': "1660.6666.0066", 'link4_dst': "1630.3333.0033",
115 'link14_src': "1640.4444.0044", 'link4_dst': "1660.6666.0066",
116 'link15_src': "1640.4444.0044", 'link4_dst': "1630.3333.0033",
117 'link16_src': "1610.1111.0011", 'link4_dst': "1630.3333.0033",
118 'link17_src': "1630.3333.0033", 'link4_dst': "1610.1111.0011",
119 'link18_src': "1610.1111.0011", 'link4_dst': "1620.2222.0022",
120 'link19_src': "1620.2222.0022", 'link4_dst': "1640.4444.0044",
121 'link20_src': "1630.3333.0033", 'link4_dst': "1660.6666.0066",
122 'link21_src': "1640.4444.0044", 'link4_dst': "1650.5555.0055",
123 'link22_src': "1660.6666.0066", 'link4_dst': "1640.4444.0044"
124 }
AntonySilvester02652382016-07-13 16:44:45 +0530125
Jon Hall64b17572017-06-06 09:39:19 -0700126 # Comparing the Links
Devin Lim3d60b442017-08-03 17:59:56 -0700127 if len( linksResp ) != 22:
128 return False
Jon Hall46fdea12017-05-24 15:48:57 -0700129 for x in xrange( 22 ):
130 link_src_info = linksResp[ x ][ 'src' ][ 'device' ]
131 link_dst_info = linksResp[ x ][ 'dst' ][ 'device' ]
132 link_src_split = link_src_info.split( "=" )
133 link_src = link_src_split[ 4 ]
134 link_dst_split = link_dst_info.split( "=" )
135 link_dst = link_dst_split[ 4 ]
136 y = x + 1
137 link_src_ref = links[ 'link' + str( y ) + '_src' ]
138 link_dst_ref = links[ 'link' + str( y ) + '_dst' ]
139 if ( link_src == link_src_ref ) and ( link_dst == ( link_dst_ref ) and
140 linksResp[ x ][ 'type' ] == 'DIRECT' and linksResp[ x ][ 'state' ] ==
141 'ACTIVE' ):
AntonySilvester02652382016-07-13 16:44:45 +0530142 return True
143 else:
144 return False