blob: e89047e572988db516e66148664690b84c5ee7e5 [file] [log] [blame]
timlindbergef8d55d2013-09-27 12:50:13 -07001#!/usr/bin/env python
2
3import time
4import pexpect
kelvin-onlabbbe46482015-01-16 10:44:28 -08005import sys
timlindbergef8d55d2013-09-27 12:50:13 -07006import json
timlindbergef8d55d2013-09-27 12:50:13 -07007from drivers.common.clidriver import CLI
8
timlindbergef8d55d2013-09-27 12:50:13 -07009
kelvin-onlabbbe46482015-01-16 10:44:28 -080010class QuaggaCliDriver( CLI ):
11
12 def __init__( self ):
13 super( CLI, self ).__init__()
timlindbergef8d55d2013-09-27 12:50:13 -070014
pingping-linc6b86fa2014-12-01 16:18:10 -080015 # TODO: simplify this method
kelvin-onlabbbe46482015-01-16 10:44:28 -080016 def connect( self, **connectargs ):
timlindbergef8d55d2013-09-27 12:50:13 -070017 for key in connectargs:
kelvin-onlabbbe46482015-01-16 10:44:28 -080018 vars( self )[ key ] = connectargs[ key ]
pingping-lin763ee042015-05-20 17:45:30 -070019 self.name = self.options[ 'name' ]
20 self.handle = super( QuaggaCliDriver, self ).connect(
21 user_name=self.user_name,
22 ip_address="127.0.0.1",
23 port=self.port,
24 pwd=self.pwd )
25 if self.handle:
26 return self.handle
27 else:
28 main.log.info( "NO HANDLE" )
29 return main.FALSE
pingping-linc6b86fa2014-12-01 16:18:10 -080030
pingping-lin763ee042015-05-20 17:45:30 -070031 def connectQuagga( self ):
kelvin-onlabbbe46482015-01-16 10:44:28 -080032 self.name = self.options[ 'name' ]
33 # self.handle = super( QuaggaCliDriver,self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -080034 # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
kelvin-onlabbbe46482015-01-16 10:44:28 -080035 # pwd=self.pwd )
pingping-lin4e7b0d32015-01-27 18:06:22 -080036 self.handle = super( QuaggaCliDriver, self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -080037 user_name=self.user_name,
38 ip_address="1.1.1.1",
39 port=self.port,
40 pwd=self.pwd )
pingping-lina600d9b2015-01-30 13:57:26 -080041 #main.log.info( "connect parameters:" + str( self.user_name ) + ";"
42 # + str( self.ip_address ) + ";" + str( self.port )
43 # + ";" + str(self.pwd ) )
timlindbergef8d55d2013-09-27 12:50:13 -070044
pingping-linc6b86fa2014-12-01 16:18:10 -080045 if self.handle:
kelvin-onlabbbe46482015-01-16 10:44:28 -080046 # self.handle.expect( "",timeout=10 )
47 # self.handle.expect( "\$",timeout=10 )
48 self.handle.sendline( "telnet localhost 2605" )
49 # self.handle.expect( "Password:", timeout=5 )
50 self.handle.expect( "Password:" )
51 self.handle.sendline( "hello" )
52 # self.handle.expect( "bgpd", timeout=5 )
53 self.handle.expect( "bgpd" )
54 self.handle.sendline( "enable" )
55 # self.handle.expect( "bgpd#", timeout=5 )
56 self.handle.expect( "bgpd#" )
timlindbergef8d55d2013-09-27 12:50:13 -070057 return self.handle
kelvin-onlabbbe46482015-01-16 10:44:28 -080058 else:
59 main.log.info( "NO HANDLE" )
timlindbergef8d55d2013-09-27 12:50:13 -070060 return main.FALSE
61
pingping-linc1c696e2015-01-27 13:46:44 -080062 def loginQuagga( self, ip_address ):
kelvin-onlabbbe46482015-01-16 10:44:28 -080063 self.name = self.options[ 'name' ]
64 self.handle = super( QuaggaCliDriver, self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -080065 user_name=self.user_name, ip_address=ip_address,
kelvin-onlabbbe46482015-01-16 10:44:28 -080066 port=self.port, pwd=self.pwd )
pingping-linc1c696e2015-01-27 13:46:44 -080067 main.log.info( "connect parameters:" + str( self.user_name ) + ";"
pingping-lin4e7b0d32015-01-27 18:06:22 -080068 + str( self.ip_address ) + ";" + str( self.port )
69 + ";" + str( self.pwd ) )
pingping-lin8b306ac2014-11-17 18:13:51 -080070
71 if self.handle:
kelvin-onlabbbe46482015-01-16 10:44:28 -080072 # self.handle.expect( "" )
73 # self.handle.expect( "\$" )
74 self.handle.sendline( "telnet localhost 2605" )
75 # self.handle.expect( "Password:", timeout=5 )
76 self.handle.expect( "Password:" )
77 self.handle.sendline( "hello" )
78 # self.handle.expect( "bgpd", timeout=5 )
79 self.handle.expect( "bgpd" )
80 self.handle.sendline( "enable" )
81 # self.handle.expect( "bgpd#", timeout=5 )
82 self.handle.expect( "bgpd#" )
pingping-linc1c696e2015-01-27 13:46:44 -080083 main.log.info( "I am in quagga on host " + str( ip_address ) )
pingping-lin8b306ac2014-11-17 18:13:51 -080084
85 return self.handle
86 else:
kelvin-onlabbbe46482015-01-16 10:44:28 -080087 main.log.info( "NO HANDLE" )
pingping-lin8b306ac2014-11-17 18:13:51 -080088 return main.FALSE
89
kelvin-onlabd3b64892015-01-20 13:26:24 -080090 def enterConfig( self, asn ):
kelvin-onlabbbe46482015-01-16 10:44:28 -080091 main.log.info( "I am in enter_config method!" )
timlindbergef8d55d2013-09-27 12:50:13 -070092 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -080093 self.handle.sendline( "" )
94 self.handle.expect( "bgpd#" )
pingping-lin763ee042015-05-20 17:45:30 -070095 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -080096 main.log.warn( "Probably not currently in enable mode!" )
timlindbergef8d55d2013-09-27 12:50:13 -070097 self.disconnect()
98 return main.FALSE
kelvin-onlabbbe46482015-01-16 10:44:28 -080099 self.handle.sendline( "configure terminal" )
100 self.handle.expect( "config", timeout=5 )
101 routerAS = "router bgp " + str( asn )
timlindbergef8d55d2013-09-27 12:50:13 -0700102 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800103 self.handle.sendline( routerAS )
104 self.handle.expect( "config-router", timeout=5 )
timlindbergef8d55d2013-09-27 12:50:13 -0700105 return main.TRUE
pingping-lin763ee042015-05-20 17:45:30 -0700106 except Exception:
timlindbergef8d55d2013-09-27 12:50:13 -0700107 return main.FALSE
pingping-lin8b306ac2014-11-17 18:13:51 -0800108
kelvin-onlabd3b64892015-01-20 13:26:24 -0800109 def generatePrefixes( self, net, numRoutes ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800110 main.log.info( "I am in generate_prefixes method!" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800111
pingping-lin4e7b0d32015-01-27 18:06:22 -0800112 # each IP prefix is composed by "net" + "." + m + "." + n + "." + x
pingping-lin8b306ac2014-11-17 18:13:51 -0800113 # the length of each IP prefix is 24
114 routes = []
kelvin-onlabd3b64892015-01-20 13:26:24 -0800115 routesGen = 0
pingping-lin8b306ac2014-11-17 18:13:51 -0800116 m = numRoutes / 256
117 n = numRoutes % 256
118
kelvin-onlabbbe46482015-01-16 10:44:28 -0800119 for i in range( 0, m ):
120 for j in range( 0, 256 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800121 network = str( net ) + "." + str( i ) + "." + str( j ) \
122 + ".0/24"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800123 routes.append( network )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800124 routesGen = routesGen + 1
pingping-lin8b306ac2014-11-17 18:13:51 -0800125
kelvin-onlabbbe46482015-01-16 10:44:28 -0800126 for j in range( 0, n ):
127 network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
128 routes.append( network )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800129 routesGen = routesGen + 1
pingping-lin8b306ac2014-11-17 18:13:51 -0800130
kelvin-onlabd3b64892015-01-20 13:26:24 -0800131 if routesGen == numRoutes:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800132 main.log.info( "Successfully generated " + str( numRoutes )
133 + " prefixes!" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800134 return routes
135 return main.FALSE
pingping-lin6f6332e2014-11-19 19:13:58 -0800136
kelvin-onlabbbe46482015-01-16 10:44:28 -0800137 # This method generates a multiple to single point intent(
138 # MultiPointToSinglePointIntent ) for a given route
pingping-lin4e7b0d32015-01-27 18:06:22 -0800139 def generateExpectedSingleRouteIntent( self, prefix, nextHop, nextHopMac,
140 sdnipData ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800141
pingping-linc1c696e2015-01-27 13:46:44 -0800142 ingresses = []
pingping-lin6f6332e2014-11-19 19:13:58 -0800143 egress = ""
kelvin-onlabd3b64892015-01-20 13:26:24 -0800144 for peer in sdnipData[ 'bgpPeers' ]:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800145 if peer[ 'ipAddress' ] == nextHop:
pingping-linc1c696e2015-01-27 13:46:44 -0800146 egress = "of:" + str(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800147 peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" \
148 + str( peer[ 'attachmentPort' ] )
pingping-linc1c696e2015-01-27 13:46:44 -0800149 for peer in sdnipData[ 'bgpPeers' ]:
150 if not peer[ 'ipAddress' ] == nextHop:
151 ingress = "of:" + str(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800152 peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" \
153 + str( peer[ 'attachmentPort' ] )
pingping-linc1c696e2015-01-27 13:46:44 -0800154 if not ingress == egress and ingress not in ingresses:
155 ingresses.append( ingress )
156 # ingresses.append( "of:" + str( peer[ 'attachmentDpid' ]
157 # ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort'
158 # ] ) )
pingping-lin6f6332e2014-11-19 19:13:58 -0800159
pingping-linc6b86fa2014-12-01 16:18:10 -0800160 selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800161 treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
pingping-lin6f6332e2014-11-19 19:13:58 -0800162
pingping-lin4e7b0d32015-01-27 18:06:22 -0800163 intent = egress + "/" + str( sorted( ingresses ) ) + "/" + \
164 selector + "/" + treatment
pingping-lin6f6332e2014-11-19 19:13:58 -0800165 return intent
166
pingping-lin4e7b0d32015-01-27 18:06:22 -0800167 def generateExpectedOnePeerRouteIntents( self, prefixes, nextHop,
168 nextHopMac, sdnipJsonFilePath ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800169 intents = []
kelvin-onlabd3b64892015-01-20 13:26:24 -0800170 sdnipJsonFile = open( sdnipJsonFilePath ).read()
pingping-lin6f6332e2014-11-19 19:13:58 -0800171
kelvin-onlabd3b64892015-01-20 13:26:24 -0800172 sdnipData = json.loads( sdnipJsonFile )
pingping-lin6f6332e2014-11-19 19:13:58 -0800173
174 for prefix in prefixes:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800175 intents.append(
kelvin-onlabd3b64892015-01-20 13:26:24 -0800176 self.generateExpectedSingleRouteIntent(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800177 prefix, nextHop, nextHopMac, sdnipData ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800178 return sorted( intents )
pingping-lin6f6332e2014-11-19 19:13:58 -0800179
180 # TODO
181 # This method generates all expected route intents for all BGP peers
kelvin-onlabd3b64892015-01-20 13:26:24 -0800182 def generateExpectedRouteIntents( self ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800183 intents = []
184 return intents
185
186 # This method extracts all actual routes from ONOS CLI
pingping-linb2a86582015-02-02 16:18:59 -0800187 def extractActualRoutesOneDotZero( self, getRoutesResult ):
kelvin-onlabd3b64892015-01-20 13:26:24 -0800188 routesJsonObj = json.loads( getRoutesResult )
pingping-lin6f6332e2014-11-19 19:13:58 -0800189
kelvin-onlabd3b64892015-01-20 13:26:24 -0800190 allRoutesActual = []
pingping-lin763ee042015-05-20 17:45:30 -0700191 for route in routesJsonObj['routes4']:
192 if 'prefix' in route:
193 if route[ 'prefix' ] == '172.16.10.0/24':
194 continue
195 allRoutesActual.append(
196 route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
pingping-lin6f6332e2014-11-19 19:13:58 -0800197
kelvin-onlabd3b64892015-01-20 13:26:24 -0800198 return sorted( allRoutesActual )
pingping-linb2a86582015-02-02 16:18:59 -0800199
200 def extractActualRoutesMaster( self, getRoutesResult ):
pingping-lina600d9b2015-01-30 13:57:26 -0800201 routesJsonObj = json.loads( getRoutesResult )
202
203 allRoutesActual = []
204 for route in routesJsonObj['routes4']:
205 if route[ 'prefix' ] == '172.16.10.0/24':
206 continue
207 allRoutesActual.append(
208 route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
209
210 return sorted( allRoutesActual )
pingping-lin6f6332e2014-11-19 19:13:58 -0800211
212 # This method extracts all actual route intents from ONOS CLI
kelvin-onlabd3b64892015-01-20 13:26:24 -0800213 def extractActualRouteIntents( self, getIntentsResult ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800214 intents = []
215 # TODO: delete the line below when change to Mininet demo script
kelvin-onlabd3b64892015-01-20 13:26:24 -0800216 # getIntentsResult=open( "../tests/SdnIpTest/intents.json" ).read()
217 intentsJsonObj = json.loads( getIntentsResult )
pingping-lin6f6332e2014-11-19 19:13:58 -0800218
kelvin-onlabd3b64892015-01-20 13:26:24 -0800219 for intent in intentsJsonObj:
pingping-linf30cf272015-05-29 15:54:07 -0700220 #if intent[ 'appId' ] != "org.onosproject.sdnip":
221 # continue
pingping-lin4e7b0d32015-01-27 18:06:22 -0800222 if intent[ 'type' ] == "MultiPointToSinglePointIntent" \
223 and intent[ 'state' ] == 'INSTALLED':
224 egress = str( intent[ 'egress' ][ 'device' ] ) + ":" \
225 + str( intent[ 'egress' ][ 'port' ] )
pingping-lin6f6332e2014-11-19 19:13:58 -0800226 ingress = []
kelvin-onlabbbe46482015-01-16 10:44:28 -0800227 for attachmentPoint in intent[ 'ingress' ]:
pingping-linc1c696e2015-01-27 13:46:44 -0800228 ingress.append(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800229 str( attachmentPoint[ 'device' ] ) + ":"
230 + str( attachmentPoint[ 'port' ] ) )
pingping-linc6b86fa2014-12-01 16:18:10 -0800231
kelvin-onlabbbe46482015-01-16 10:44:28 -0800232 selector = intent[ 'selector' ].replace(
233 "[", "" ).replace( "]", "" ).replace( " ", "" )
234 if str( selector ).startswith( "IPV4" ):
235 str1, str2 = str( selector ).split( "," )
pingping-linc6b86fa2014-12-01 16:18:10 -0800236 selector = str2 + "," + str1
237
pingping-lin4e7b0d32015-01-27 18:06:22 -0800238 intent = egress + "/" + str( sorted( ingress ) ) + "/" + \
239 selector + "/" + intent[ 'treatment' ]
kelvin-onlabbbe46482015-01-16 10:44:28 -0800240 intents.append( intent )
241 return sorted( intents )
pingping-lin6f6332e2014-11-19 19:13:58 -0800242
pingping-linf30cf272015-05-29 15:54:07 -0700243 # This method calculates the MultiPointToSinglePointIntent number installed
244 def extractActualRouteIntentNum( self, getIntentsResult ):
245 intentsJsonObj = json.loads( getIntentsResult )
246 num = 0
247 for intent in intentsJsonObj:
248 if intent[ 'type' ] == "MultiPointToSinglePointIntent" \
249 and intent[ 'state' ] == 'INSTALLED':
250 num = num + 1
251 return num
252
253 # This method calculates the PointToPointIntent number installed
254 def extractActualBgpIntentNum( self, getIntentsResult ):
255 intentsJsonObj = json.loads( getIntentsResult )
256 num = 0
257 for intent in intentsJsonObj:
258 if intent[ 'type' ] == "PointToPointIntent" \
259 and intent[ 'state' ] == 'INSTALLED':
260 num = num + 1
261 return num
262
pingping-lin6f6332e2014-11-19 19:13:58 -0800263 # This method extracts all actual BGP intents from ONOS CLI
kelvin-onlabd3b64892015-01-20 13:26:24 -0800264 def extractActualBgpIntents( self, getIntentsResult ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800265 intents = []
266 # TODO: delete the line below when change to Mininet demo script
kelvin-onlabd3b64892015-01-20 13:26:24 -0800267 # getIntentsResult=open( "../tests/SdnIpTest/intents.json" ).read()
268 intentsJsonObj = json.loads( getIntentsResult )
pingping-lin6f6332e2014-11-19 19:13:58 -0800269
kelvin-onlabd3b64892015-01-20 13:26:24 -0800270 for intent in intentsJsonObj:
pingping-linf30cf272015-05-29 15:54:07 -0700271 #if intent[ 'appId' ] != "org.onosproject.sdnip":
272 # continue
pingping-lin4e7b0d32015-01-27 18:06:22 -0800273 if intent[ 'type' ] == "PointToPointIntent" \
274 and "protocol=6" in str( intent[ 'selector' ] ):
275 ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" \
276 + str( intent[ 'ingress' ][ 'port' ] )
277 egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + \
278 str( intent[ 'egress' ][ 'port' ] )
279 selector = str( intent[ 'selector' ] ).replace( " ", "" )\
280 .replace( "[", "" ).replace( "]", "" ).split( "," )
281 intent = ingress + "/" + egress + "/" + \
282 str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800283 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800284
kelvin-onlabbbe46482015-01-16 10:44:28 -0800285 return sorted( intents )
pingping-lin6f6332e2014-11-19 19:13:58 -0800286
kelvin-onlabbbe46482015-01-16 10:44:28 -0800287 # This method generates a single point to single point intent(
288 # PointToPointIntent ) for BGP path
kelvin-onlabd3b64892015-01-20 13:26:24 -0800289 def generateExpectedBgpIntents( self, sdnipJsonFilePath ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800290 from operator import eq
291
kelvin-onlabd3b64892015-01-20 13:26:24 -0800292 sdnipJsonFile = open( sdnipJsonFilePath ).read()
293 sdnipData = json.loads( sdnipJsonFile )
pingping-lin6f6332e2014-11-19 19:13:58 -0800294
295 intents = []
pingping-linc6b86fa2014-12-01 16:18:10 -0800296 bgpPeerAttachmentPoint = ""
kelvin-onlabbbe46482015-01-16 10:44:28 -0800297 bgpSpeakerAttachmentPoint = "of:" + str(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800298 sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] )\
299 .replace( ":", "" ) + ":" \
300 + str( sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800301 for peer in sdnipData[ 'bgpPeers' ]:
pingping-lin4e7b0d32015-01-27 18:06:22 -0800302 bgpPeerAttachmentPoint = "of:" \
303 + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) \
304 + ":" + str( peer[ 'attachmentPort' ] )
pingping-lin6f6332e2014-11-19 19:13:58 -0800305 # find out the BGP speaker IP address for this BGP peer
pingping-linc6b86fa2014-12-01 16:18:10 -0800306 bgpSpeakerIpAddress = ""
pingping-lin4e7b0d32015-01-27 18:06:22 -0800307 for interfaceAddress in \
308 sdnipData[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
kelvin-onlabd3b64892015-01-20 13:26:24 -0800309 # if eq( interfaceAddress[ 'interfaceDpid' ],sdnipData[
kelvin-onlabbbe46482015-01-16 10:44:28 -0800310 # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
pingping-linc1c696e2015-01-27 13:46:44 -0800311 # interfaceAddress[ 'interfacePort' ], sdnipData[ 'bgpSpeakers'
312 # ][ 0 ][ 'attachmentPort' ] ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800313 if eq( interfaceAddress[ 'interfaceDpid' ],
314 peer[ 'attachmentDpid' ] ) \
315 and eq( interfaceAddress[ 'interfacePort' ],
316 peer[ 'attachmentPort' ] ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800317 bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
pingping-lin6f6332e2014-11-19 19:13:58 -0800318 break
319 else:
320 continue
321
kelvin-onlabbbe46482015-01-16 10:44:28 -0800322 # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
323 # direction
pingping-lin4e7b0d32015-01-27 18:06:22 -0800324 selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," \
325 + "IPV4_DST{ip=" + peer[ 'ipAddress' ] + "/32}," \
326 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
327 TCP_DST{tcpPort=179}"
328 selector = selectorStr.replace( " ", "" ).replace("[", "" )\
329 .replace( "]", "" ).split( "," )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800330 intent = bgpSpeakerAttachmentPoint + "/" + \
331 bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
332 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800333
pingping-lin4e7b0d32015-01-27 18:06:22 -0800334 selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," \
335 + "IPV4_DST{ip=" + peer[ 'ipAddress' ] + "/32}," \
336 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
337 TCP_SRC{tcpPort=179}"
338 selector = selectorStr.replace( " ", "" ).replace("[", "" )\
339 .replace( "]", "" ).split( "," )
340 intent = bgpSpeakerAttachmentPoint + "/" \
341 + bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800342 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800343
kelvin-onlabbbe46482015-01-16 10:44:28 -0800344 # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
345 # direction
pingping-lin4e7b0d32015-01-27 18:06:22 -0800346 selectorStr = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," \
347 + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," \
348 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
349 TCP_DST{tcpPort=179}"
350 selector = selectorStr.replace( " ", "" ).replace("[", "" )\
351 .replace( "]", "" ).split( "," )
352 intent = bgpPeerAttachmentPoint + "/" \
353 + bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800354 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800355
pingping-lin4e7b0d32015-01-27 18:06:22 -0800356 selectorStr = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," \
357 + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," \
358 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
359 TCP_SRC{tcpPort=179}"
360 selector = selectorStr.replace( " ", "" ).replace( "[", "" )\
361 .replace( "]", "" ).split( "," )
362 intent = bgpPeerAttachmentPoint + "/" \
363 + bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800364 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800365
kelvin-onlabbbe46482015-01-16 10:44:28 -0800366 return sorted( intents )
pingping-linc6b86fa2014-12-01 16:18:10 -0800367
kelvin-onlabd3b64892015-01-20 13:26:24 -0800368 def addRoutes( self, routes, routeRate ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800369 main.log.info( "I am in add_routes method!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800370
kelvin-onlabd3b64892015-01-20 13:26:24 -0800371 routesAdded = 0
pingping-lin8b306ac2014-11-17 18:13:51 -0800372 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800373 self.handle.sendline( "" )
374 # self.handle.expect( "config-router" )
375 self.handle.expect( "config-router", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700376 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800377 main.log.warn( "Probably not in config-router mode!" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800378 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800379 main.log.info( "Start to add routes" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800380
pingping-lin763ee042015-05-20 17:45:30 -0700381 chunk_size = 20
382
383 if len(routes) > chunk_size:
Jon Hall4ba53f02015-07-29 13:07:41 -0700384 num_iter = (int) (len(routes) / chunk_size)
pingping-lin763ee042015-05-20 17:45:30 -0700385 else:
386 num_iter = 1;
387
388 total = 0
389 for n in range( 0, num_iter + 1):
390 routeCmd = ""
391 if (len( routes ) - (n * chunk_size)) >= chunk_size:
392 m = (n + 1) * chunk_size
393 else:
394 m = len( routes )
395 for i in range( n * chunk_size, m ):
396 routeCmd = routeCmd + "network " + routes[ i ] + "\n"
397 total = total + 1
398
399 main.log.info(routeCmd)
pingping-lin8b306ac2014-11-17 18:13:51 -0800400 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800401 self.handle.sendline( routeCmd )
402 self.handle.expect( "bgpd", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700403 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800404 main.log.warn( "Failed to add route" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800405 self.disconnect()
Jon Hall4ba53f02015-07-29 13:07:41 -0700406
pingping-linc1c696e2015-01-27 13:46:44 -0800407 # waitTimer = 1.00 / routeRate
pingping-lin763ee042015-05-20 17:45:30 -0700408 main.log.info("Total routes so far " + ((str) (total)) + " wait for 0 sec")
409 #time.sleep( 1 )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800410 if routesAdded == len( routes ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800411 main.log.info( "Finished adding routes" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800412 return main.TRUE
413 return main.FALSE
pingping-linc6b86fa2014-12-01 16:18:10 -0800414
kelvin-onlabd3b64892015-01-20 13:26:24 -0800415 def deleteRoutes( self, routes, routeRate ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800416 main.log.info( "I am in delete_routes method!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800417
kelvin-onlabd3b64892015-01-20 13:26:24 -0800418 routesAdded = 0
pingping-linc6b86fa2014-12-01 16:18:10 -0800419 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800420 self.handle.sendline( "" )
421 # self.handle.expect( "config-router" )
422 self.handle.expect( "config-router", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700423 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800424 main.log.warn( "Probably not in config-router mode!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800425 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800426 main.log.info( "Start to delete routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800427
kelvin-onlabbbe46482015-01-16 10:44:28 -0800428 for i in range( 0, len( routes ) ):
429 routeCmd = "no network " + routes[ i ]
pingping-linc6b86fa2014-12-01 16:18:10 -0800430 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800431 self.handle.sendline( routeCmd )
432 self.handle.expect( "bgpd", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700433 except Exception:
pingping-lin4e7b0d32015-01-27 18:06:22 -0800434 main.log.warn( "Failed to delete route" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800435 self.disconnect()
pingping-linc1c696e2015-01-27 13:46:44 -0800436 # waitTimer = 1.00 / routeRate
437 # time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800438 if routesAdded == len( routes ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800439 main.log.info( "Finished deleting routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800440 return main.TRUE
441 return main.FALSE
442
pingping-linc1c696e2015-01-27 13:46:44 -0800443 def pingTest( self, ip_address, pingTestFile, pingTestResultFile ):
444 main.log.info( "Start the ping test on host:" + str( ip_address ) )
pingping-linc6b86fa2014-12-01 16:18:10 -0800445
kelvin-onlabbbe46482015-01-16 10:44:28 -0800446 self.name = self.options[ 'name' ]
447 self.handle = super( QuaggaCliDriver, self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -0800448 user_name=self.user_name, ip_address=ip_address,
kelvin-onlabbbe46482015-01-16 10:44:28 -0800449 port=self.port, pwd=self.pwd )
pingping-linc1c696e2015-01-27 13:46:44 -0800450 main.log.info( "connect parameters:" + str( self.user_name ) + ";"
pingping-lin4e7b0d32015-01-27 18:06:22 -0800451 + str( self.ip_address ) + ";" + str( self.port )
452 + ";" + str( self.pwd ) )
pingping-linc6b86fa2014-12-01 16:18:10 -0800453
454 if self.handle:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800455 # self.handle.expect( "" )
456 # self.handle.expect( "\$" )
pingping-linc1c696e2015-01-27 13:46:44 -0800457 main.log.info( "I in host " + str( ip_address ) )
458 main.log.info( pingTestFile + " > " + pingTestResultFile + " &" )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800459 self.handle.sendline(
kelvin-onlabd3b64892015-01-20 13:26:24 -0800460 pingTestFile +
kelvin-onlabbbe46482015-01-16 10:44:28 -0800461 " > " +
kelvin-onlabd3b64892015-01-20 13:26:24 -0800462 pingTestResultFile +
kelvin-onlabbbe46482015-01-16 10:44:28 -0800463 " &" )
464 self.handle.expect( "\$", timeout=60 )
pingping-linc6b86fa2014-12-01 16:18:10 -0800465 handle = self.handle.before
466
467 return handle
468 else:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800469 main.log.info( "NO HANDLE" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800470 return main.FALSE
471
pingping-lin763ee042015-05-20 17:45:30 -0700472
pingping-lin4e7b0d32015-01-27 18:06:22 -0800473 # Please use the generateRoutes plus addRoutes instead of this one!
kelvin-onlabd3b64892015-01-20 13:26:24 -0800474 def addRoute( self, net, numRoutes, routeRate ):
timlindbergef8d55d2013-09-27 12:50:13 -0700475 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800476 self.handle.sendline( "" )
477 self.handle.expect( "config-router" )
pingping-lin763ee042015-05-20 17:45:30 -0700478 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800479 main.log.warn( "Probably not in config-router mode!" )
timlindbergef8d55d2013-09-27 12:50:13 -0700480 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800481 main.log.info( "Adding Routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800482 j = 0
483 k = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700484 while numRoutes > 255:
485 numRoutes = numRoutes - 255
486 j = j + 1
487 k = numRoutes % 254
kelvin-onlabd3b64892015-01-20 13:26:24 -0800488 routesAdded = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700489 if numRoutes > 255:
490 numRoutes = 255
kelvin-onlabbbe46482015-01-16 10:44:28 -0800491 for m in range( 1, j + 1 ):
492 for n in range( 1, numRoutes + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800493 network = str( net ) + "." + str( m ) + "." + str( n ) \
494 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700495 routeCmd = "network " + network
496 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800497 self.handle.sendline( routeCmd )
498 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700499 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800500 main.log.warn( "failed to add route" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800501 self.disconnect()
502 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800503 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800504 routesAdded = routesAdded + 1
kelvin-onlabbbe46482015-01-16 10:44:28 -0800505 for d in range( j + 1, j + 2 ):
506 for e in range( 1, k + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800507 network = str( net ) + "." + str( d ) + "." + str( e ) \
508 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700509 routeCmd = "network " + network
510 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800511 self.handle.sendline( routeCmd )
512 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700513 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800514 main.log.warn( "failed to add route" )
pingping-lin763ee042015-05-20 17:45:30 -0700515 self.disconnect()
pingping-linc6b86fa2014-12-01 16:18:10 -0800516 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800517 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800518 routesAdded = routesAdded + 1
519 if routesAdded == numRoutes:
timlindbergef8d55d2013-09-27 12:50:13 -0700520 return main.TRUE
521 return main.FALSE
pingping-lin0904ad02015-01-30 15:18:14 -0800522
pingping-lin4e7b0d32015-01-27 18:06:22 -0800523 # Please use deleteRoutes method instead of this one!
kelvin-onlabd3b64892015-01-20 13:26:24 -0800524 def delRoute( self, net, numRoutes, routeRate ):
timlindbergef8d55d2013-09-27 12:50:13 -0700525 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800526 self.handle.sendline( "" )
527 self.handle.expect( "config-router" )
pingping-lin763ee042015-05-20 17:45:30 -0700528 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800529 main.log.warn( "Probably not in config-router mode!" )
timlindbergef8d55d2013-09-27 12:50:13 -0700530 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800531 main.log.info( "Deleting Routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800532 j = 0
533 k = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700534 while numRoutes > 255:
535 numRoutes = numRoutes - 255
536 j = j + 1
537 k = numRoutes % 254
kelvin-onlabd3b64892015-01-20 13:26:24 -0800538 routesDeleted = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700539 if numRoutes > 255:
540 numRoutes = 255
kelvin-onlabbbe46482015-01-16 10:44:28 -0800541 for m in range( 1, j + 1 ):
542 for n in range( 1, numRoutes + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800543 network = str( net ) + "." + str( m ) + "." + str( n ) \
544 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700545 routeCmd = "no network " + network
546 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800547 self.handle.sendline( routeCmd )
548 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700549 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800550 main.log.warn( "Failed to delete route" )
timlindbergef8d55d2013-09-27 12:50:13 -0700551 self.disconnect()
pingping-linc6b86fa2014-12-01 16:18:10 -0800552 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800553 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800554 routesDeleted = routesDeleted + 1
kelvin-onlabbbe46482015-01-16 10:44:28 -0800555 for d in range( j + 1, j + 2 ):
556 for e in range( 1, k + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800557 network = str( net ) + "." + str( d ) + "." + str( e ) \
558 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700559 routeCmd = "no network " + network
560 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800561 self.handle.sendline( routeCmd )
562 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700563 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800564 main.log.warn( "Failed to delete route" )
timlindbergef8d55d2013-09-27 12:50:13 -0700565 self.disconnect()
pingping-linc6b86fa2014-12-01 16:18:10 -0800566 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800567 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800568 routesDeleted = routesDeleted + 1
569 if routesDeleted == numRoutes:
timlindbergef8d55d2013-09-27 12:50:13 -0700570 return main.TRUE
571 return main.FALSE
pingping-linc6b86fa2014-12-01 16:18:10 -0800572
kelvin-onlabd3b64892015-01-20 13:26:24 -0800573 def checkRoutes( self, brand, ip, user, pw ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800574 def pronto( ip, user, passwd ):
timlindbergef8d55d2013-09-27 12:50:13 -0700575 print "Connecting to Pronto switch"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800576 child = pexpect.spawn( "telnet " + ip )
577 i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700578 if i == 0:
pingping-linc1c696e2015-01-27 13:46:44 -0800579 print "user_name and password required. Passing login info."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800580 child.sendline( user )
581 child.expect( "Password:" )
582 child.sendline( passwd )
583 child.expect( "CLI#" )
timlindbergef8d55d2013-09-27 12:50:13 -0700584 print "Logged in, getting flowtable."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800585 child.sendline( "flowtable brief" )
586 for t in range( 9 ):
timlindbergef8d55d2013-09-27 12:50:13 -0700587 t2 = 9 - t
kelvin-onlabbbe46482015-01-16 10:44:28 -0800588 print "\r" + str( t2 )
589 sys.stdout.write( "\033[F" )
590 time.sleep( 1 )
timlindbergef8d55d2013-09-27 12:50:13 -0700591 print "Scanning flowtable"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800592 child.expect( "Flow table show" )
timlindbergef8d55d2013-09-27 12:50:13 -0700593 count = 0
kelvin-onlabbbe46482015-01-16 10:44:28 -0800594 while True:
pingping-lin0904ad02015-01-30 15:18:14 -0800595 i = child.expect( [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
pingping-lin4e7b0d32015-01-27 18:06:22 -0800596 'CLI#', pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700597 if i == 0:
598 count = count + 1
599 elif i == 1:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800600 print "Pronto flows: " + str( count ) + "\nDone\n"
timlindbergef8d55d2013-09-27 12:50:13 -0700601 break
602 else:
603 break
kelvin-onlabbbe46482015-01-16 10:44:28 -0800604
605 def cisco( ip, user, passwd ):
timlindbergef8d55d2013-09-27 12:50:13 -0700606 print "Establishing Cisco switch connection"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800607 child = pexpect.spawn( "ssh " + user + "@" + ip )
608 i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700609 if i == 0:
610 print "Password required. Passing now."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800611 child.sendline( passwd )
612 child.expect( "#" )
timlindbergef8d55d2013-09-27 12:50:13 -0700613 print "Logged in. Retrieving flow table then counting flows."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800614 child.sendline( "show openflow switch all flows all" )
615 child.expect( "Logical Openflow Switch" )
timlindbergef8d55d2013-09-27 12:50:13 -0700616 print "Flow table retrieved. Counting flows"
617 count = 0
kelvin-onlabbbe46482015-01-16 10:44:28 -0800618 while True:
619 i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700620 if i == 0:
621 count = count + 1
622 elif i == 1:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800623 print "Cisco flows: " + str( count ) + "\nDone\n"
timlindbergef8d55d2013-09-27 12:50:13 -0700624 break
625 else:
626 break
627 if brand == "pronto" or brand == "PRONTO":
kelvin-onlabbbe46482015-01-16 10:44:28 -0800628 pronto( ip, user, passwd )
pingping-linc6b86fa2014-12-01 16:18:10 -0800629 # elif brand == "cisco" or brand == "CISCO":
kelvin-onlabbbe46482015-01-16 10:44:28 -0800630 # cisco( ip,user,passwd )
631
pingping-lin763ee042015-05-20 17:45:30 -0700632 def disable_bgp_peer( self, peer, peer_as ):
633 main.log.info( "I am in disconnect_peer_session method!" )
634
635 try:
636 self.handle.sendline( "" )
637 # self.handle.expect( "config-router" )
638 self.handle.expect( "config-router", timeout=5 )
639 except Exception:
640 main.log.warn( "Probably not in config-router mode!" )
641 self.disconnect()
642 main.log.info( "Start to disable peer" )
643
644 cmd = "no neighbor " + peer + " remote-as " + peer_as
645 try:
646 self.handle.sendline( cmd )
647 self.handle.expect( "bgpd", timeout=5 )
648 except Exception:
649 main.log.warn( "Failed to disable peer" )
650 self.disconnect()
651
652 def enable_bgp_peer( self, peer, peer_as ):
653 main.log.info( "I am in enable_bgp_peer method!" )
654
655 try:
656 self.handle.sendline( "" )
657 # self.handle.expect( "config-router" )
658 self.handle.expect( "config-router", timeout=5 )
659 except Exception:
660 main.log.warn( "Probably not in config-router mode!" )
661 self.disconnect()
662 main.log.info( "Start to disable peer" )
663
664 cmd = "neighbor " + peer + " remote-as " + peer_as
665 try:
666 self.handle.sendline( cmd )
667 self.handle.expect( "bgpd", timeout=5 )
668 except Exception:
669 main.log.warn( "Failed to enable peer" )
670 self.disconnect()
671
kelvin-onlabbbe46482015-01-16 10:44:28 -0800672 def disconnect( self ):
673 """
674 Called when Test is complete to disconnect the Quagga handle.
675 """
timlindbergef8d55d2013-09-27 12:50:13 -0700676 response = ''
677 try:
678 self.handle.close()
pingping-lin763ee042015-05-20 17:45:30 -0700679 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800680 main.log.error( "Connection failed to the host" )
timlindbergef8d55d2013-09-27 12:50:13 -0700681 response = main.FALSE
682 return response
pingping-linc1c696e2015-01-27 13:46:44 -0800683