Committed by
Brian O'Connor
Use netstat for waitListening; client -h h1 "apps -a"
And fix do_log() Change-Id: I04402fda9c409fa4cb41ae20cf1c551369b7669d
Showing
1 changed file
with
15 additions
and
26 deletions
... | @@ -149,34 +149,22 @@ def unpackONOS( destDir='/tmp', run=quietRun ): | ... | @@ -149,34 +149,22 @@ def unpackONOS( destDir='/tmp', run=quietRun ): |
149 | return onosDir | 149 | return onosDir |
150 | 150 | ||
151 | 151 | ||
152 | -def waitListening( client=None, server='127.0.0.1', port=80, timeout=None, | 152 | +def waitListening( server, port=80, callback=None, sleepSecs=.5, |
153 | - callback=None, sleepSecs=.5 ): | 153 | + proc='java' ): |
154 | - "Modified mininet.util.waitListening with callback, sleepSecs" | 154 | + "Simplified netstat version of waitListening" |
155 | - runCmd = ( client.cmd if client else | 155 | + while True: |
156 | - partial( quietRun, shell=True ) ) | 156 | + lines = server.cmd( 'netstat -natp' ).strip().split( '\n' ) |
157 | - if not runCmd( 'which telnet' ): | 157 | + entries = [ line.split() for line in lines ] |
158 | - raise Exception('Could not find telnet' ) | 158 | + portstr = ':%s' % port |
159 | - # pylint: disable=maybe-no-member | 159 | + listening = [ entry for entry in entries |
160 | - serverIP = server if isinstance( server, basestring ) else server.IP() | 160 | + if len( entry ) > 6 and portstr in entry[ 3 ] |
161 | - cmd = ( 'echo A | telnet -e A %s %s' % ( serverIP, port ) ) | 161 | + and proc in entry[ 6 ] ] |
162 | - elapsed = 0 | 162 | + if listening: |
163 | - result = runCmd( cmd ) | 163 | + break |
164 | - while 'Connected' not in result: | ||
165 | - if 'No route' in result: | ||
166 | - rtable = runCmd( 'route' ) | ||
167 | - error( 'no route to %s:\n%s' % ( server, rtable ) ) | ||
168 | - return False | ||
169 | - if timeout and elapsed >= timeout: | ||
170 | - error( 'could not connect to %s on port %d\n' % ( server, port ) ) | ||
171 | - return False | ||
172 | - debug( 'waiting for', server, 'to listen on port', port, '\n' ) | ||
173 | info( '.' ) | 164 | info( '.' ) |
174 | if callback: | 165 | if callback: |
175 | callback() | 166 | callback() |
176 | time.sleep( sleepSecs ) | 167 | time.sleep( sleepSecs ) |
177 | - elapsed += sleepSecs | ||
178 | - result = runCmd( cmd ) | ||
179 | - return True | ||
180 | 168 | ||
181 | 169 | ||
182 | ### Mininet classes | 170 | ### Mininet classes |
... | @@ -338,7 +326,7 @@ class ONOSNode( Controller ): | ... | @@ -338,7 +326,7 @@ class ONOSNode( Controller ): |
338 | callback=self.sanityCheck ) | 326 | callback=self.sanityCheck ) |
339 | info( ' client' ) | 327 | info( ' client' ) |
340 | while True: | 328 | while True: |
341 | - result = quietRun( 'echo apps -a | %s -h %s' % | 329 | + result = quietRun( '%s -h %s "apps -a"' % |
342 | ( self.client, self.IP() ), shell=True ) | 330 | ( self.client, self.IP() ), shell=True ) |
343 | if 'openflow' in result: | 331 | if 'openflow' in result: |
344 | break | 332 | break |
... | @@ -528,7 +516,8 @@ class ONOSCLI( OldCLI ): | ... | @@ -528,7 +516,8 @@ class ONOSCLI( OldCLI ): |
528 | 516 | ||
529 | def do_log( self, line ): | 517 | def do_log( self, line ): |
530 | "Run tail -f /tmp/onos1/log; press control-C to stop" | 518 | "Run tail -f /tmp/onos1/log; press control-C to stop" |
531 | - self.default( self.onos1().name, 'tail -f /tmp/%s/log' % self.onos1() ) | 519 | + self.default( '%s tail -f /tmp/%s/log' % |
520 | + ( self.onos1(), self.onos1() ) ) | ||
532 | 521 | ||
533 | def do_status( self, line ): | 522 | def do_status( self, line ): |
534 | "Return status of ONOS cluster(s)" | 523 | "Return status of ONOS cluster(s)" | ... | ... |
-
Please register or login to post a comment