blob: 7e3df2b5403b3e04862fe658ae8eee13f351ebfa [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
kelvin-onlabbbe46482015-01-16 10:44:28 -08007sys.path.append( "../" )
timlindbergef8d55d2013-09-27 12:50:13 -07008from drivers.common.clidriver import CLI
9
timlindbergef8d55d2013-09-27 12:50:13 -070010
kelvin-onlabbbe46482015-01-16 10:44:28 -080011class QuaggaCliDriver( CLI ):
12
13 def __init__( self ):
14 super( CLI, self ).__init__()
timlindbergef8d55d2013-09-27 12:50:13 -070015
pingping-linc6b86fa2014-12-01 16:18:10 -080016 # TODO: simplify this method
kelvin-onlabbbe46482015-01-16 10:44:28 -080017 def connect( self, **connectargs ):
timlindbergef8d55d2013-09-27 12:50:13 -070018 for key in connectargs:
kelvin-onlabbbe46482015-01-16 10:44:28 -080019 vars( self )[ key ] = connectargs[ key ]
pingping-lin763ee042015-05-20 17:45:30 -070020 self.name = self.options[ 'name' ]
21 self.handle = super( QuaggaCliDriver, self ).connect(
22 user_name=self.user_name,
23 ip_address="127.0.0.1",
24 port=self.port,
25 pwd=self.pwd )
26 if self.handle:
27 return self.handle
28 else:
29 main.log.info( "NO HANDLE" )
30 return main.FALSE
31
pingping-linc6b86fa2014-12-01 16:18:10 -080032
pingping-lin763ee042015-05-20 17:45:30 -070033 def connectQuagga( self ):
kelvin-onlabbbe46482015-01-16 10:44:28 -080034 self.name = self.options[ 'name' ]
35 # self.handle = super( QuaggaCliDriver,self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -080036 # user_name=self.user_name, ip_address=self.ip_address,port=self.port,
kelvin-onlabbbe46482015-01-16 10:44:28 -080037 # pwd=self.pwd )
pingping-lin4e7b0d32015-01-27 18:06:22 -080038 self.handle = super( QuaggaCliDriver, self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -080039 user_name=self.user_name,
40 ip_address="1.1.1.1",
41 port=self.port,
42 pwd=self.pwd )
pingping-lina600d9b2015-01-30 13:57:26 -080043 #main.log.info( "connect parameters:" + str( self.user_name ) + ";"
44 # + str( self.ip_address ) + ";" + str( self.port )
45 # + ";" + str(self.pwd ) )
timlindbergef8d55d2013-09-27 12:50:13 -070046
pingping-linc6b86fa2014-12-01 16:18:10 -080047 if self.handle:
kelvin-onlabbbe46482015-01-16 10:44:28 -080048 # self.handle.expect( "",timeout=10 )
49 # self.handle.expect( "\$",timeout=10 )
50 self.handle.sendline( "telnet localhost 2605" )
51 # self.handle.expect( "Password:", timeout=5 )
52 self.handle.expect( "Password:" )
53 self.handle.sendline( "hello" )
54 # self.handle.expect( "bgpd", timeout=5 )
55 self.handle.expect( "bgpd" )
56 self.handle.sendline( "enable" )
57 # self.handle.expect( "bgpd#", timeout=5 )
58 self.handle.expect( "bgpd#" )
timlindbergef8d55d2013-09-27 12:50:13 -070059 return self.handle
kelvin-onlabbbe46482015-01-16 10:44:28 -080060 else:
61 main.log.info( "NO HANDLE" )
timlindbergef8d55d2013-09-27 12:50:13 -070062 return main.FALSE
63
pingping-linc1c696e2015-01-27 13:46:44 -080064 def loginQuagga( self, ip_address ):
kelvin-onlabbbe46482015-01-16 10:44:28 -080065 self.name = self.options[ 'name' ]
66 self.handle = super( QuaggaCliDriver, self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -080067 user_name=self.user_name, ip_address=ip_address,
kelvin-onlabbbe46482015-01-16 10:44:28 -080068 port=self.port, pwd=self.pwd )
pingping-linc1c696e2015-01-27 13:46:44 -080069 main.log.info( "connect parameters:" + str( self.user_name ) + ";"
pingping-lin4e7b0d32015-01-27 18:06:22 -080070 + str( self.ip_address ) + ";" + str( self.port )
71 + ";" + str( self.pwd ) )
pingping-lin8b306ac2014-11-17 18:13:51 -080072
73 if self.handle:
kelvin-onlabbbe46482015-01-16 10:44:28 -080074 # self.handle.expect( "" )
75 # self.handle.expect( "\$" )
76 self.handle.sendline( "telnet localhost 2605" )
77 # self.handle.expect( "Password:", timeout=5 )
78 self.handle.expect( "Password:" )
79 self.handle.sendline( "hello" )
80 # self.handle.expect( "bgpd", timeout=5 )
81 self.handle.expect( "bgpd" )
82 self.handle.sendline( "enable" )
83 # self.handle.expect( "bgpd#", timeout=5 )
84 self.handle.expect( "bgpd#" )
pingping-linc1c696e2015-01-27 13:46:44 -080085 main.log.info( "I am in quagga on host " + str( ip_address ) )
pingping-lin8b306ac2014-11-17 18:13:51 -080086
87 return self.handle
88 else:
kelvin-onlabbbe46482015-01-16 10:44:28 -080089 main.log.info( "NO HANDLE" )
pingping-lin8b306ac2014-11-17 18:13:51 -080090 return main.FALSE
91
kelvin-onlabd3b64892015-01-20 13:26:24 -080092 def enterConfig( self, asn ):
kelvin-onlabbbe46482015-01-16 10:44:28 -080093 main.log.info( "I am in enter_config method!" )
timlindbergef8d55d2013-09-27 12:50:13 -070094 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -080095 self.handle.sendline( "" )
96 self.handle.expect( "bgpd#" )
pingping-lin763ee042015-05-20 17:45:30 -070097 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -080098 main.log.warn( "Probably not currently in enable mode!" )
timlindbergef8d55d2013-09-27 12:50:13 -070099 self.disconnect()
100 return main.FALSE
kelvin-onlabbbe46482015-01-16 10:44:28 -0800101 self.handle.sendline( "configure terminal" )
102 self.handle.expect( "config", timeout=5 )
103 routerAS = "router bgp " + str( asn )
timlindbergef8d55d2013-09-27 12:50:13 -0700104 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800105 self.handle.sendline( routerAS )
106 self.handle.expect( "config-router", timeout=5 )
timlindbergef8d55d2013-09-27 12:50:13 -0700107 return main.TRUE
pingping-lin763ee042015-05-20 17:45:30 -0700108 except Exception:
timlindbergef8d55d2013-09-27 12:50:13 -0700109 return main.FALSE
pingping-lin8b306ac2014-11-17 18:13:51 -0800110
kelvin-onlabd3b64892015-01-20 13:26:24 -0800111 def generatePrefixes( self, net, numRoutes ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800112 main.log.info( "I am in generate_prefixes method!" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800113
pingping-lin4e7b0d32015-01-27 18:06:22 -0800114 # each IP prefix is composed by "net" + "." + m + "." + n + "." + x
pingping-lin8b306ac2014-11-17 18:13:51 -0800115 # the length of each IP prefix is 24
116 routes = []
kelvin-onlabd3b64892015-01-20 13:26:24 -0800117 routesGen = 0
pingping-lin8b306ac2014-11-17 18:13:51 -0800118 m = numRoutes / 256
119 n = numRoutes % 256
120
kelvin-onlabbbe46482015-01-16 10:44:28 -0800121 for i in range( 0, m ):
122 for j in range( 0, 256 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800123 network = str( net ) + "." + str( i ) + "." + str( j ) \
124 + ".0/24"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800125 routes.append( network )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800126 routesGen = routesGen + 1
pingping-lin8b306ac2014-11-17 18:13:51 -0800127
kelvin-onlabbbe46482015-01-16 10:44:28 -0800128 for j in range( 0, n ):
129 network = str( net ) + "." + str( m ) + "." + str( j ) + ".0/24"
130 routes.append( network )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800131 routesGen = routesGen + 1
pingping-lin8b306ac2014-11-17 18:13:51 -0800132
kelvin-onlabd3b64892015-01-20 13:26:24 -0800133 if routesGen == numRoutes:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800134 main.log.info( "Successfully generated " + str( numRoutes )
135 + " prefixes!" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800136 return routes
137 return main.FALSE
pingping-lin6f6332e2014-11-19 19:13:58 -0800138
kelvin-onlabbbe46482015-01-16 10:44:28 -0800139 # This method generates a multiple to single point intent(
140 # MultiPointToSinglePointIntent ) for a given route
pingping-lin4e7b0d32015-01-27 18:06:22 -0800141 def generateExpectedSingleRouteIntent( self, prefix, nextHop, nextHopMac,
142 sdnipData ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800143
pingping-linc1c696e2015-01-27 13:46:44 -0800144 ingresses = []
pingping-lin6f6332e2014-11-19 19:13:58 -0800145 egress = ""
kelvin-onlabd3b64892015-01-20 13:26:24 -0800146 for peer in sdnipData[ 'bgpPeers' ]:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800147 if peer[ 'ipAddress' ] == nextHop:
pingping-linc1c696e2015-01-27 13:46:44 -0800148 egress = "of:" + str(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800149 peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" \
150 + str( peer[ 'attachmentPort' ] )
pingping-linc1c696e2015-01-27 13:46:44 -0800151 for peer in sdnipData[ 'bgpPeers' ]:
152 if not peer[ 'ipAddress' ] == nextHop:
153 ingress = "of:" + str(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800154 peer[ 'attachmentDpid' ] ).replace( ":", "" ) + ":" \
155 + str( peer[ 'attachmentPort' ] )
pingping-linc1c696e2015-01-27 13:46:44 -0800156 if not ingress == egress and ingress not in ingresses:
157 ingresses.append( ingress )
158 # ingresses.append( "of:" + str( peer[ 'attachmentDpid' ]
159 # ).replace( ":", "" ) + ":" + str( peer[ 'attachmentPort'
160 # ] ) )
pingping-lin6f6332e2014-11-19 19:13:58 -0800161
pingping-linc6b86fa2014-12-01 16:18:10 -0800162 selector = "ETH_TYPE{ethType=800},IPV4_DST{ip=" + prefix + "}"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800163 treatment = "[ETH_DST{mac=" + str( nextHopMac ) + "}]"
pingping-lin6f6332e2014-11-19 19:13:58 -0800164
pingping-lin4e7b0d32015-01-27 18:06:22 -0800165 intent = egress + "/" + str( sorted( ingresses ) ) + "/" + \
166 selector + "/" + treatment
pingping-lin6f6332e2014-11-19 19:13:58 -0800167 return intent
168
pingping-lin4e7b0d32015-01-27 18:06:22 -0800169 def generateExpectedOnePeerRouteIntents( self, prefixes, nextHop,
170 nextHopMac, sdnipJsonFilePath ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800171 intents = []
kelvin-onlabd3b64892015-01-20 13:26:24 -0800172 sdnipJsonFile = open( sdnipJsonFilePath ).read()
pingping-lin6f6332e2014-11-19 19:13:58 -0800173
kelvin-onlabd3b64892015-01-20 13:26:24 -0800174 sdnipData = json.loads( sdnipJsonFile )
pingping-lin6f6332e2014-11-19 19:13:58 -0800175
176 for prefix in prefixes:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800177 intents.append(
kelvin-onlabd3b64892015-01-20 13:26:24 -0800178 self.generateExpectedSingleRouteIntent(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800179 prefix, nextHop, nextHopMac, sdnipData ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800180 return sorted( intents )
pingping-lin6f6332e2014-11-19 19:13:58 -0800181
182 # TODO
183 # This method generates all expected route intents for all BGP peers
kelvin-onlabd3b64892015-01-20 13:26:24 -0800184 def generateExpectedRouteIntents( self ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800185 intents = []
186 return intents
187
188 # This method extracts all actual routes from ONOS CLI
pingping-linb2a86582015-02-02 16:18:59 -0800189 def extractActualRoutesOneDotZero( self, getRoutesResult ):
kelvin-onlabd3b64892015-01-20 13:26:24 -0800190 routesJsonObj = json.loads( getRoutesResult )
pingping-lin6f6332e2014-11-19 19:13:58 -0800191
kelvin-onlabd3b64892015-01-20 13:26:24 -0800192 allRoutesActual = []
pingping-lin763ee042015-05-20 17:45:30 -0700193 for route in routesJsonObj['routes4']:
194 if 'prefix' in route:
195 if route[ 'prefix' ] == '172.16.10.0/24':
196 continue
197 allRoutesActual.append(
198 route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
pingping-lin6f6332e2014-11-19 19:13:58 -0800199
kelvin-onlabd3b64892015-01-20 13:26:24 -0800200 return sorted( allRoutesActual )
pingping-linb2a86582015-02-02 16:18:59 -0800201
202 def extractActualRoutesMaster( self, getRoutesResult ):
pingping-lina600d9b2015-01-30 13:57:26 -0800203 routesJsonObj = json.loads( getRoutesResult )
204
205 allRoutesActual = []
206 for route in routesJsonObj['routes4']:
207 if route[ 'prefix' ] == '172.16.10.0/24':
208 continue
209 allRoutesActual.append(
210 route[ 'prefix' ] + "/" + route[ 'nextHop' ] )
211
212 return sorted( allRoutesActual )
pingping-lin6f6332e2014-11-19 19:13:58 -0800213
214 # This method extracts all actual route intents from ONOS CLI
kelvin-onlabd3b64892015-01-20 13:26:24 -0800215 def extractActualRouteIntents( self, getIntentsResult ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800216 intents = []
217 # TODO: delete the line below when change to Mininet demo script
kelvin-onlabd3b64892015-01-20 13:26:24 -0800218 # getIntentsResult=open( "../tests/SdnIpTest/intents.json" ).read()
219 intentsJsonObj = json.loads( getIntentsResult )
pingping-lin6f6332e2014-11-19 19:13:58 -0800220
kelvin-onlabd3b64892015-01-20 13:26:24 -0800221 for intent in intentsJsonObj:
pingping-linf30cf272015-05-29 15:54:07 -0700222 #if intent[ 'appId' ] != "org.onosproject.sdnip":
223 # continue
pingping-lin4e7b0d32015-01-27 18:06:22 -0800224 if intent[ 'type' ] == "MultiPointToSinglePointIntent" \
225 and intent[ 'state' ] == 'INSTALLED':
226 egress = str( intent[ 'egress' ][ 'device' ] ) + ":" \
227 + str( intent[ 'egress' ][ 'port' ] )
pingping-lin6f6332e2014-11-19 19:13:58 -0800228 ingress = []
kelvin-onlabbbe46482015-01-16 10:44:28 -0800229 for attachmentPoint in intent[ 'ingress' ]:
pingping-linc1c696e2015-01-27 13:46:44 -0800230 ingress.append(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800231 str( attachmentPoint[ 'device' ] ) + ":"
232 + str( attachmentPoint[ 'port' ] ) )
pingping-linc6b86fa2014-12-01 16:18:10 -0800233
kelvin-onlabbbe46482015-01-16 10:44:28 -0800234 selector = intent[ 'selector' ].replace(
235 "[", "" ).replace( "]", "" ).replace( " ", "" )
236 if str( selector ).startswith( "IPV4" ):
237 str1, str2 = str( selector ).split( "," )
pingping-linc6b86fa2014-12-01 16:18:10 -0800238 selector = str2 + "," + str1
239
pingping-lin4e7b0d32015-01-27 18:06:22 -0800240 intent = egress + "/" + str( sorted( ingress ) ) + "/" + \
241 selector + "/" + intent[ 'treatment' ]
kelvin-onlabbbe46482015-01-16 10:44:28 -0800242 intents.append( intent )
243 return sorted( intents )
pingping-lin6f6332e2014-11-19 19:13:58 -0800244
pingping-linf30cf272015-05-29 15:54:07 -0700245 # This method calculates the MultiPointToSinglePointIntent number installed
246 def extractActualRouteIntentNum( self, getIntentsResult ):
247 intentsJsonObj = json.loads( getIntentsResult )
248 num = 0
249 for intent in intentsJsonObj:
250 if intent[ 'type' ] == "MultiPointToSinglePointIntent" \
251 and intent[ 'state' ] == 'INSTALLED':
252 num = num + 1
253 return num
254
255 # This method calculates the PointToPointIntent number installed
256 def extractActualBgpIntentNum( self, getIntentsResult ):
257 intentsJsonObj = json.loads( getIntentsResult )
258 num = 0
259 for intent in intentsJsonObj:
260 if intent[ 'type' ] == "PointToPointIntent" \
261 and intent[ 'state' ] == 'INSTALLED':
262 num = num + 1
263 return num
264
pingping-lin6f6332e2014-11-19 19:13:58 -0800265 # This method extracts all actual BGP intents from ONOS CLI
kelvin-onlabd3b64892015-01-20 13:26:24 -0800266 def extractActualBgpIntents( self, getIntentsResult ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800267 intents = []
268 # TODO: delete the line below when change to Mininet demo script
kelvin-onlabd3b64892015-01-20 13:26:24 -0800269 # getIntentsResult=open( "../tests/SdnIpTest/intents.json" ).read()
270 intentsJsonObj = json.loads( getIntentsResult )
pingping-lin6f6332e2014-11-19 19:13:58 -0800271
kelvin-onlabd3b64892015-01-20 13:26:24 -0800272 for intent in intentsJsonObj:
pingping-linf30cf272015-05-29 15:54:07 -0700273 #if intent[ 'appId' ] != "org.onosproject.sdnip":
274 # continue
pingping-lin4e7b0d32015-01-27 18:06:22 -0800275 if intent[ 'type' ] == "PointToPointIntent" \
276 and "protocol=6" in str( intent[ 'selector' ] ):
277 ingress = str( intent[ 'ingress' ][ 'device' ] ) + ":" \
278 + str( intent[ 'ingress' ][ 'port' ] )
279 egress = str( intent[ 'egress' ][ 'device' ] ) + ":" + \
280 str( intent[ 'egress' ][ 'port' ] )
281 selector = str( intent[ 'selector' ] ).replace( " ", "" )\
282 .replace( "[", "" ).replace( "]", "" ).split( "," )
283 intent = ingress + "/" + egress + "/" + \
284 str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800285 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800286
kelvin-onlabbbe46482015-01-16 10:44:28 -0800287 return sorted( intents )
pingping-lin6f6332e2014-11-19 19:13:58 -0800288
kelvin-onlabbbe46482015-01-16 10:44:28 -0800289 # This method generates a single point to single point intent(
290 # PointToPointIntent ) for BGP path
kelvin-onlabd3b64892015-01-20 13:26:24 -0800291 def generateExpectedBgpIntents( self, sdnipJsonFilePath ):
pingping-lin6f6332e2014-11-19 19:13:58 -0800292 from operator import eq
293
kelvin-onlabd3b64892015-01-20 13:26:24 -0800294 sdnipJsonFile = open( sdnipJsonFilePath ).read()
295 sdnipData = json.loads( sdnipJsonFile )
pingping-lin6f6332e2014-11-19 19:13:58 -0800296
297 intents = []
pingping-linc6b86fa2014-12-01 16:18:10 -0800298 bgpPeerAttachmentPoint = ""
kelvin-onlabbbe46482015-01-16 10:44:28 -0800299 bgpSpeakerAttachmentPoint = "of:" + str(
pingping-lin4e7b0d32015-01-27 18:06:22 -0800300 sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] )\
301 .replace( ":", "" ) + ":" \
302 + str( sdnipData[ 'bgpSpeakers' ][ 0 ][ 'attachmentPort' ] )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800303 for peer in sdnipData[ 'bgpPeers' ]:
pingping-lin4e7b0d32015-01-27 18:06:22 -0800304 bgpPeerAttachmentPoint = "of:" \
305 + str( peer[ 'attachmentDpid' ] ).replace( ":", "" ) \
306 + ":" + str( peer[ 'attachmentPort' ] )
pingping-lin6f6332e2014-11-19 19:13:58 -0800307 # find out the BGP speaker IP address for this BGP peer
pingping-linc6b86fa2014-12-01 16:18:10 -0800308 bgpSpeakerIpAddress = ""
pingping-lin4e7b0d32015-01-27 18:06:22 -0800309 for interfaceAddress in \
310 sdnipData[ 'bgpSpeakers' ][ 0 ][ 'interfaceAddresses' ]:
kelvin-onlabd3b64892015-01-20 13:26:24 -0800311 # if eq( interfaceAddress[ 'interfaceDpid' ],sdnipData[
kelvin-onlabbbe46482015-01-16 10:44:28 -0800312 # 'bgpSpeakers' ][ 0 ][ 'attachmentDpid' ] ) and eq(
pingping-linc1c696e2015-01-27 13:46:44 -0800313 # interfaceAddress[ 'interfacePort' ], sdnipData[ 'bgpSpeakers'
314 # ][ 0 ][ 'attachmentPort' ] ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800315 if eq( interfaceAddress[ 'interfaceDpid' ],
316 peer[ 'attachmentDpid' ] ) \
317 and eq( interfaceAddress[ 'interfacePort' ],
318 peer[ 'attachmentPort' ] ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800319 bgpSpeakerIpAddress = interfaceAddress[ 'ipAddress' ]
pingping-lin6f6332e2014-11-19 19:13:58 -0800320 break
321 else:
322 continue
323
kelvin-onlabbbe46482015-01-16 10:44:28 -0800324 # from bgpSpeakerAttachmentPoint to bgpPeerAttachmentPoint
325 # direction
pingping-lin4e7b0d32015-01-27 18:06:22 -0800326 selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," \
327 + "IPV4_DST{ip=" + peer[ 'ipAddress' ] + "/32}," \
328 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
329 TCP_DST{tcpPort=179}"
330 selector = selectorStr.replace( " ", "" ).replace("[", "" )\
331 .replace( "]", "" ).split( "," )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800332 intent = bgpSpeakerAttachmentPoint + "/" + \
333 bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
334 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800335
pingping-lin4e7b0d32015-01-27 18:06:22 -0800336 selectorStr = "IPV4_SRC{ip=" + bgpSpeakerIpAddress + "/32}," \
337 + "IPV4_DST{ip=" + peer[ 'ipAddress' ] + "/32}," \
338 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
339 TCP_SRC{tcpPort=179}"
340 selector = selectorStr.replace( " ", "" ).replace("[", "" )\
341 .replace( "]", "" ).split( "," )
342 intent = bgpSpeakerAttachmentPoint + "/" \
343 + bgpPeerAttachmentPoint + "/" + str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800344 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800345
kelvin-onlabbbe46482015-01-16 10:44:28 -0800346 # from bgpPeerAttachmentPoint to bgpSpeakerAttachmentPoint
347 # direction
pingping-lin4e7b0d32015-01-27 18:06:22 -0800348 selectorStr = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," \
349 + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," \
350 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
351 TCP_DST{tcpPort=179}"
352 selector = selectorStr.replace( " ", "" ).replace("[", "" )\
353 .replace( "]", "" ).split( "," )
354 intent = bgpPeerAttachmentPoint + "/" \
355 + bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800356 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800357
pingping-lin4e7b0d32015-01-27 18:06:22 -0800358 selectorStr = "IPV4_SRC{ip=" + peer[ 'ipAddress' ] + "/32}," \
359 + "IPV4_DST{ip=" + bgpSpeakerIpAddress + "/32}," \
360 + "IP_PROTO{protocol=6}, ETH_TYPE{ethType=800}, \
361 TCP_SRC{tcpPort=179}"
362 selector = selectorStr.replace( " ", "" ).replace( "[", "" )\
363 .replace( "]", "" ).split( "," )
364 intent = bgpPeerAttachmentPoint + "/" \
365 + bgpSpeakerAttachmentPoint + "/" + str( sorted( selector ) )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800366 intents.append( intent )
pingping-lin6f6332e2014-11-19 19:13:58 -0800367
kelvin-onlabbbe46482015-01-16 10:44:28 -0800368 return sorted( intents )
pingping-linc6b86fa2014-12-01 16:18:10 -0800369
kelvin-onlabd3b64892015-01-20 13:26:24 -0800370 def addRoutes( self, routes, routeRate ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800371 main.log.info( "I am in add_routes method!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800372
kelvin-onlabd3b64892015-01-20 13:26:24 -0800373 routesAdded = 0
pingping-lin8b306ac2014-11-17 18:13:51 -0800374 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800375 self.handle.sendline( "" )
376 # self.handle.expect( "config-router" )
377 self.handle.expect( "config-router", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700378 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800379 main.log.warn( "Probably not in config-router mode!" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800380 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800381 main.log.info( "Start to add routes" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800382
pingping-lin763ee042015-05-20 17:45:30 -0700383 chunk_size = 20
384
385 if len(routes) > chunk_size:
386 num_iter = (int) (len(routes) / chunk_size)
387 else:
388 num_iter = 1;
389
390 total = 0
391 for n in range( 0, num_iter + 1):
392 routeCmd = ""
393 if (len( routes ) - (n * chunk_size)) >= chunk_size:
394 m = (n + 1) * chunk_size
395 else:
396 m = len( routes )
397 for i in range( n * chunk_size, m ):
398 routeCmd = routeCmd + "network " + routes[ i ] + "\n"
399 total = total + 1
400
401 main.log.info(routeCmd)
pingping-lin8b306ac2014-11-17 18:13:51 -0800402 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800403 self.handle.sendline( routeCmd )
404 self.handle.expect( "bgpd", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700405 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800406 main.log.warn( "Failed to add route" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800407 self.disconnect()
pingping-lin763ee042015-05-20 17:45:30 -0700408
pingping-linc1c696e2015-01-27 13:46:44 -0800409 # waitTimer = 1.00 / routeRate
pingping-lin763ee042015-05-20 17:45:30 -0700410 main.log.info("Total routes so far " + ((str) (total)) + " wait for 0 sec")
411 #time.sleep( 1 )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800412 if routesAdded == len( routes ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800413 main.log.info( "Finished adding routes" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800414 return main.TRUE
415 return main.FALSE
pingping-linc6b86fa2014-12-01 16:18:10 -0800416
kelvin-onlabd3b64892015-01-20 13:26:24 -0800417 def deleteRoutes( self, routes, routeRate ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800418 main.log.info( "I am in delete_routes method!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800419
kelvin-onlabd3b64892015-01-20 13:26:24 -0800420 routesAdded = 0
pingping-linc6b86fa2014-12-01 16:18:10 -0800421 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800422 self.handle.sendline( "" )
423 # self.handle.expect( "config-router" )
424 self.handle.expect( "config-router", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700425 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800426 main.log.warn( "Probably not in config-router mode!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800427 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800428 main.log.info( "Start to delete routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800429
kelvin-onlabbbe46482015-01-16 10:44:28 -0800430 for i in range( 0, len( routes ) ):
431 routeCmd = "no network " + routes[ i ]
pingping-linc6b86fa2014-12-01 16:18:10 -0800432 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800433 self.handle.sendline( routeCmd )
434 self.handle.expect( "bgpd", timeout=5 )
pingping-lin763ee042015-05-20 17:45:30 -0700435 except Exception:
pingping-lin4e7b0d32015-01-27 18:06:22 -0800436 main.log.warn( "Failed to delete route" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800437 self.disconnect()
pingping-linc1c696e2015-01-27 13:46:44 -0800438 # waitTimer = 1.00 / routeRate
439 # time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800440 if routesAdded == len( routes ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800441 main.log.info( "Finished deleting routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800442 return main.TRUE
443 return main.FALSE
444
pingping-linc1c696e2015-01-27 13:46:44 -0800445 def pingTest( self, ip_address, pingTestFile, pingTestResultFile ):
446 main.log.info( "Start the ping test on host:" + str( ip_address ) )
pingping-linc6b86fa2014-12-01 16:18:10 -0800447
kelvin-onlabbbe46482015-01-16 10:44:28 -0800448 self.name = self.options[ 'name' ]
449 self.handle = super( QuaggaCliDriver, self ).connect(
pingping-linc1c696e2015-01-27 13:46:44 -0800450 user_name=self.user_name, ip_address=ip_address,
kelvin-onlabbbe46482015-01-16 10:44:28 -0800451 port=self.port, pwd=self.pwd )
pingping-linc1c696e2015-01-27 13:46:44 -0800452 main.log.info( "connect parameters:" + str( self.user_name ) + ";"
pingping-lin4e7b0d32015-01-27 18:06:22 -0800453 + str( self.ip_address ) + ";" + str( self.port )
454 + ";" + str( self.pwd ) )
pingping-linc6b86fa2014-12-01 16:18:10 -0800455
456 if self.handle:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800457 # self.handle.expect( "" )
458 # self.handle.expect( "\$" )
pingping-linc1c696e2015-01-27 13:46:44 -0800459 main.log.info( "I in host " + str( ip_address ) )
460 main.log.info( pingTestFile + " > " + pingTestResultFile + " &" )
kelvin-onlabbbe46482015-01-16 10:44:28 -0800461 self.handle.sendline(
kelvin-onlabd3b64892015-01-20 13:26:24 -0800462 pingTestFile +
kelvin-onlabbbe46482015-01-16 10:44:28 -0800463 " > " +
kelvin-onlabd3b64892015-01-20 13:26:24 -0800464 pingTestResultFile +
kelvin-onlabbbe46482015-01-16 10:44:28 -0800465 " &" )
466 self.handle.expect( "\$", timeout=60 )
pingping-linc6b86fa2014-12-01 16:18:10 -0800467 handle = self.handle.before
468
469 return handle
470 else:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800471 main.log.info( "NO HANDLE" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800472 return main.FALSE
473
pingping-lin763ee042015-05-20 17:45:30 -0700474
pingping-lin4e7b0d32015-01-27 18:06:22 -0800475 # Please use the generateRoutes plus addRoutes instead of this one!
kelvin-onlabd3b64892015-01-20 13:26:24 -0800476 def addRoute( self, net, numRoutes, routeRate ):
timlindbergef8d55d2013-09-27 12:50:13 -0700477 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800478 self.handle.sendline( "" )
479 self.handle.expect( "config-router" )
pingping-lin763ee042015-05-20 17:45:30 -0700480 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800481 main.log.warn( "Probably not in config-router mode!" )
timlindbergef8d55d2013-09-27 12:50:13 -0700482 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800483 main.log.info( "Adding Routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800484 j = 0
485 k = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700486 while numRoutes > 255:
487 numRoutes = numRoutes - 255
488 j = j + 1
489 k = numRoutes % 254
kelvin-onlabd3b64892015-01-20 13:26:24 -0800490 routesAdded = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700491 if numRoutes > 255:
492 numRoutes = 255
kelvin-onlabbbe46482015-01-16 10:44:28 -0800493 for m in range( 1, j + 1 ):
494 for n in range( 1, numRoutes + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800495 network = str( net ) + "." + str( m ) + "." + str( n ) \
496 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700497 routeCmd = "network " + network
498 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800499 self.handle.sendline( routeCmd )
500 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700501 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800502 main.log.warn( "failed to add route" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800503 self.disconnect()
504 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800505 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800506 routesAdded = routesAdded + 1
kelvin-onlabbbe46482015-01-16 10:44:28 -0800507 for d in range( j + 1, j + 2 ):
508 for e in range( 1, k + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800509 network = str( net ) + "." + str( d ) + "." + str( e ) \
510 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700511 routeCmd = "network " + network
512 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800513 self.handle.sendline( routeCmd )
514 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700515 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800516 main.log.warn( "failed to add route" )
pingping-lin763ee042015-05-20 17:45:30 -0700517 self.disconnect()
pingping-linc6b86fa2014-12-01 16:18:10 -0800518 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800519 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800520 routesAdded = routesAdded + 1
521 if routesAdded == numRoutes:
timlindbergef8d55d2013-09-27 12:50:13 -0700522 return main.TRUE
523 return main.FALSE
pingping-lin0904ad02015-01-30 15:18:14 -0800524
pingping-lin4e7b0d32015-01-27 18:06:22 -0800525 # Please use deleteRoutes method instead of this one!
kelvin-onlabd3b64892015-01-20 13:26:24 -0800526 def delRoute( self, net, numRoutes, routeRate ):
timlindbergef8d55d2013-09-27 12:50:13 -0700527 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800528 self.handle.sendline( "" )
529 self.handle.expect( "config-router" )
pingping-lin763ee042015-05-20 17:45:30 -0700530 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800531 main.log.warn( "Probably not in config-router mode!" )
timlindbergef8d55d2013-09-27 12:50:13 -0700532 self.disconnect()
kelvin-onlabbbe46482015-01-16 10:44:28 -0800533 main.log.info( "Deleting Routes" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800534 j = 0
535 k = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700536 while numRoutes > 255:
537 numRoutes = numRoutes - 255
538 j = j + 1
539 k = numRoutes % 254
kelvin-onlabd3b64892015-01-20 13:26:24 -0800540 routesDeleted = 0
timlindbergef8d55d2013-09-27 12:50:13 -0700541 if numRoutes > 255:
542 numRoutes = 255
kelvin-onlabbbe46482015-01-16 10:44:28 -0800543 for m in range( 1, j + 1 ):
544 for n in range( 1, numRoutes + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800545 network = str( net ) + "." + str( m ) + "." + str( n ) \
546 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700547 routeCmd = "no network " + network
548 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800549 self.handle.sendline( routeCmd )
550 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700551 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800552 main.log.warn( "Failed to delete route" )
timlindbergef8d55d2013-09-27 12:50:13 -0700553 self.disconnect()
pingping-linc6b86fa2014-12-01 16:18:10 -0800554 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800555 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800556 routesDeleted = routesDeleted + 1
kelvin-onlabbbe46482015-01-16 10:44:28 -0800557 for d in range( j + 1, j + 2 ):
558 for e in range( 1, k + 1 ):
pingping-lin4e7b0d32015-01-27 18:06:22 -0800559 network = str( net ) + "." + str( d ) + "." + str( e ) \
560 + ".0/24"
timlindbergef8d55d2013-09-27 12:50:13 -0700561 routeCmd = "no network " + network
562 try:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800563 self.handle.sendline( routeCmd )
564 self.handle.expect( "bgpd" )
pingping-lin763ee042015-05-20 17:45:30 -0700565 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800566 main.log.warn( "Failed to delete route" )
timlindbergef8d55d2013-09-27 12:50:13 -0700567 self.disconnect()
pingping-linc6b86fa2014-12-01 16:18:10 -0800568 waitTimer = 1.00 / routeRate
kelvin-onlabbbe46482015-01-16 10:44:28 -0800569 time.sleep( waitTimer )
kelvin-onlabd3b64892015-01-20 13:26:24 -0800570 routesDeleted = routesDeleted + 1
571 if routesDeleted == numRoutes:
timlindbergef8d55d2013-09-27 12:50:13 -0700572 return main.TRUE
573 return main.FALSE
pingping-linc6b86fa2014-12-01 16:18:10 -0800574
kelvin-onlabd3b64892015-01-20 13:26:24 -0800575 def checkRoutes( self, brand, ip, user, pw ):
kelvin-onlabbbe46482015-01-16 10:44:28 -0800576 def pronto( ip, user, passwd ):
timlindbergef8d55d2013-09-27 12:50:13 -0700577 print "Connecting to Pronto switch"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800578 child = pexpect.spawn( "telnet " + ip )
579 i = child.expect( [ "login:", "CLI#", pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700580 if i == 0:
pingping-linc1c696e2015-01-27 13:46:44 -0800581 print "user_name and password required. Passing login info."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800582 child.sendline( user )
583 child.expect( "Password:" )
584 child.sendline( passwd )
585 child.expect( "CLI#" )
timlindbergef8d55d2013-09-27 12:50:13 -0700586 print "Logged in, getting flowtable."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800587 child.sendline( "flowtable brief" )
588 for t in range( 9 ):
timlindbergef8d55d2013-09-27 12:50:13 -0700589 t2 = 9 - t
kelvin-onlabbbe46482015-01-16 10:44:28 -0800590 print "\r" + str( t2 )
591 sys.stdout.write( "\033[F" )
592 time.sleep( 1 )
timlindbergef8d55d2013-09-27 12:50:13 -0700593 print "Scanning flowtable"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800594 child.expect( "Flow table show" )
timlindbergef8d55d2013-09-27 12:50:13 -0700595 count = 0
kelvin-onlabbbe46482015-01-16 10:44:28 -0800596 while True:
pingping-lin0904ad02015-01-30 15:18:14 -0800597 i = child.expect( [ '17\d\.\d{1,3}\.\d{1,3}\.\d{1,3}',
pingping-lin4e7b0d32015-01-27 18:06:22 -0800598 'CLI#', pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700599 if i == 0:
600 count = count + 1
601 elif i == 1:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800602 print "Pronto flows: " + str( count ) + "\nDone\n"
timlindbergef8d55d2013-09-27 12:50:13 -0700603 break
604 else:
605 break
kelvin-onlabbbe46482015-01-16 10:44:28 -0800606
607 def cisco( ip, user, passwd ):
timlindbergef8d55d2013-09-27 12:50:13 -0700608 print "Establishing Cisco switch connection"
kelvin-onlabbbe46482015-01-16 10:44:28 -0800609 child = pexpect.spawn( "ssh " + user + "@" + ip )
610 i = child.expect( [ "Password:", "CLI#", pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700611 if i == 0:
612 print "Password required. Passing now."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800613 child.sendline( passwd )
614 child.expect( "#" )
timlindbergef8d55d2013-09-27 12:50:13 -0700615 print "Logged in. Retrieving flow table then counting flows."
kelvin-onlabbbe46482015-01-16 10:44:28 -0800616 child.sendline( "show openflow switch all flows all" )
617 child.expect( "Logical Openflow Switch" )
timlindbergef8d55d2013-09-27 12:50:13 -0700618 print "Flow table retrieved. Counting flows"
619 count = 0
kelvin-onlabbbe46482015-01-16 10:44:28 -0800620 while True:
621 i = child.expect( [ "nw_src=17", "#", pexpect.TIMEOUT ] )
timlindbergef8d55d2013-09-27 12:50:13 -0700622 if i == 0:
623 count = count + 1
624 elif i == 1:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800625 print "Cisco flows: " + str( count ) + "\nDone\n"
timlindbergef8d55d2013-09-27 12:50:13 -0700626 break
627 else:
628 break
629 if brand == "pronto" or brand == "PRONTO":
kelvin-onlabbbe46482015-01-16 10:44:28 -0800630 pronto( ip, user, passwd )
pingping-linc6b86fa2014-12-01 16:18:10 -0800631 # elif brand == "cisco" or brand == "CISCO":
kelvin-onlabbbe46482015-01-16 10:44:28 -0800632 # cisco( ip,user,passwd )
633
pingping-lin763ee042015-05-20 17:45:30 -0700634 def disable_bgp_peer( self, peer, peer_as ):
635 main.log.info( "I am in disconnect_peer_session method!" )
636
637 try:
638 self.handle.sendline( "" )
639 # self.handle.expect( "config-router" )
640 self.handle.expect( "config-router", timeout=5 )
641 except Exception:
642 main.log.warn( "Probably not in config-router mode!" )
643 self.disconnect()
644 main.log.info( "Start to disable peer" )
645
646 cmd = "no neighbor " + peer + " remote-as " + peer_as
647 try:
648 self.handle.sendline( cmd )
649 self.handle.expect( "bgpd", timeout=5 )
650 except Exception:
651 main.log.warn( "Failed to disable peer" )
652 self.disconnect()
653
654 def enable_bgp_peer( self, peer, peer_as ):
655 main.log.info( "I am in enable_bgp_peer method!" )
656
657 try:
658 self.handle.sendline( "" )
659 # self.handle.expect( "config-router" )
660 self.handle.expect( "config-router", timeout=5 )
661 except Exception:
662 main.log.warn( "Probably not in config-router mode!" )
663 self.disconnect()
664 main.log.info( "Start to disable peer" )
665
666 cmd = "neighbor " + peer + " remote-as " + peer_as
667 try:
668 self.handle.sendline( cmd )
669 self.handle.expect( "bgpd", timeout=5 )
670 except Exception:
671 main.log.warn( "Failed to enable peer" )
672 self.disconnect()
673
kelvin-onlabbbe46482015-01-16 10:44:28 -0800674 def disconnect( self ):
675 """
676 Called when Test is complete to disconnect the Quagga handle.
677 """
timlindbergef8d55d2013-09-27 12:50:13 -0700678 response = ''
679 try:
680 self.handle.close()
pingping-lin763ee042015-05-20 17:45:30 -0700681 except Exception:
kelvin-onlabbbe46482015-01-16 10:44:28 -0800682 main.log.error( "Connection failed to the host" )
timlindbergef8d55d2013-09-27 12:50:13 -0700683 response = main.FALSE
684 return response
pingping-linc1c696e2015-01-27 13:46:44 -0800685