Committed by
Brian O'Connor
add arp cmd; always return lists from checkLog
The arp CLI command sends gratuitous ARPs from all hosts - this makes it easier for ONOS to discover hosts. Previously checkLog returned None, None if the log file didn't exist; now we return an empty list, to avoid breaking when we take the len() of errors or warnings (which was happening before) and to avoid having to check for None, None, which didn't seem to add a lot of value to justify its complexity. Change-Id: I84847fcf70525c82ac037d8a84cf40d21ab2a106
Showing
1 changed file
with
27 additions
and
1 deletions
... | @@ -281,7 +281,7 @@ class ONOSNode( Controller ): | ... | @@ -281,7 +281,7 @@ class ONOSNode( Controller ): |
281 | def checkLog( self ): | 281 | def checkLog( self ): |
282 | "Return log file errors and warnings" | 282 | "Return log file errors and warnings" |
283 | log = join( self.dir, 'log' ) | 283 | log = join( self.dir, 'log' ) |
284 | - errors, warnings = None, None | 284 | + errors, warnings = [], [] |
285 | if isfile( log ): | 285 | if isfile( log ): |
286 | lines = open( log ).read().split( '\n' ) | 286 | lines = open( log ).read().split( '\n' ) |
287 | errors = [ line for line in lines if 'ERROR' in line ] | 287 | errors = [ line for line in lines if 'ERROR' in line ] |
... | @@ -547,6 +547,32 @@ class ONOSCLI( OldCLI ): | ... | @@ -547,6 +547,32 @@ class ONOSCLI( OldCLI ): |
547 | status = status if status else 'OK' | 547 | status = status if status else 'OK' |
548 | info( node, '\t', running, '\t', status, '\n' ) | 548 | info( node, '\t', running, '\t', status, '\n' ) |
549 | 549 | ||
550 | + def do_arp( self, line ): | ||
551 | + "Send gratuitous arps from all data network hosts" | ||
552 | + startTime = time.time() | ||
553 | + try: | ||
554 | + count = int( line ) | ||
555 | + except: | ||
556 | + count = 1 | ||
557 | + # Technically this check should be on the host | ||
558 | + if '-U' not in quietRun( 'arping -h' ): | ||
559 | + warn( 'Please install iputils-arping' ) | ||
560 | + return | ||
561 | + # This is much faster if we do it in parallel | ||
562 | + for host in self.mn.net.hosts: | ||
563 | + intf = host.defaultIntf() | ||
564 | + # -b: keep using broadcasts; -f: quit after 1 reply | ||
565 | + # -U: gratuitous ARP update | ||
566 | + host.sendCmd( 'arping -bf -c', count, '-U -I', | ||
567 | + intf.name, intf.IP() ) | ||
568 | + for host in self.mn.net.hosts: | ||
569 | + # We could check the output here if desired | ||
570 | + host.waitOutput() | ||
571 | + info( '.' ) | ||
572 | + info( '\n' ) | ||
573 | + elapsed = time.time() - startTime | ||
574 | + debug( 'Completed in %.2f seconds\n' % elapsed ) | ||
575 | + | ||
550 | 576 | ||
551 | # For interactive use, exit on error | 577 | # For interactive use, exit on error |
552 | exitOnError = dict( nodeOpts={ 'alertAction': 'exit' } ) | 578 | exitOnError = dict( nodeOpts={ 'alertAction': 'exit' } ) | ... | ... |
-
Please register or login to post a comment