2626
2727import javax .naming .ConfigurationException ;
2828
29+ import com .google .common .base .Strings ;
2930import org .apache .log4j .Logger ;
3031import org .libvirt .LibvirtException ;
3132
@@ -275,7 +276,7 @@ private void createControlNetwork() throws LibvirtException {
275276 createControlNetwork (_bridges .get ("linklocal" ));
276277 }
277278
278- private void deleteExitingLinkLocalRouteTable (String linkLocalBr ) {
279+ private void deleteExistingLinkLocalRouteTable (String linkLocalBr ) {
279280 Script command = new Script ("/bin/bash" , _timeout );
280281 command .add ("-c" );
281282 command .add ("ip route | grep " + NetUtils .getLinkLocalCIDR ());
@@ -286,7 +287,11 @@ private void deleteExitingLinkLocalRouteTable(String linkLocalBr) {
286287 String [] lines = parser .getLines ().split ("\\ n" );
287288 for (String line : lines ) {
288289 String [] tokens = line .split (" " );
289- if (!tokens [2 ].equalsIgnoreCase (linkLocalBr )) {
290+ if (tokens != null && tokens .length < 2 ) {
291+ continue ;
292+ }
293+ final String device = tokens [2 ];
294+ if (!Strings .isNullOrEmpty (device ) && !device .equalsIgnoreCase (linkLocalBr )) {
290295 Script .runSimpleBashScript ("ip route del " + NetUtils .getLinkLocalCIDR () + " dev " + tokens [2 ]);
291296 } else {
292297 foundLinkLocalBr = true ;
@@ -300,7 +305,7 @@ private void deleteExitingLinkLocalRouteTable(String linkLocalBr) {
300305 }
301306
302307 private void createControlNetwork (String privBrName ) {
303- deleteExitingLinkLocalRouteTable (privBrName );
308+ deleteExistingLinkLocalRouteTable (privBrName );
304309 if (!isBridgeExists (privBrName )) {
305310 Script .runSimpleBashScript ("brctl addbr " + privBrName + "; ip link set " + privBrName + " up; ip address add 169.254.0.1/16 dev " + privBrName , _timeout );
306311 }
0 commit comments