You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/12/05 17:46:11 UTC

[GitHub] wido commented on a change in pull request #3080: kvm: Use 'ip route show default 0.0.0.0/0' to find the default gateway

wido commented on a change in pull request #3080: kvm: Use 'ip route show default 0.0.0.0/0' to find the default gateway
URL: https://github.com/apache/cloudstack/pull/3080#discussion_r239169097
 
 

 ##########
 File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 ##########
 @@ -1015,21 +1015,21 @@ public boolean configure(final String name, final Map<String, Object> params) th
         */
 
         if (_pifs.get("private") == null) {
-            s_logger.debug("Failed to get private nic name");
+            s_logger.error("Failed to get private nic name");
             throw new ConfigurationException("Failed to get private nic name");
         }
 
         if (_pifs.get("public") == null) {
-            s_logger.debug("Failed to get public nic name");
+            s_logger.error("Failed to get public nic name");
             throw new ConfigurationException("Failed to get public nic name");
         }
         s_logger.debug("Found pif: " + _pifs.get("private") + " on " + _privBridgeName + ", pif: " + _pifs.get("public") + " on " + _publicBridgeName);
 
         _canBridgeFirewall = canBridgeFirewall(_pifs.get("public"));
 
-        _localGateway = Script.runSimpleBashScript("ip route |grep default|awk '{print $3}'");
+        _localGateway = Script.runSimpleBashScript("ip route show default 0.0.0.0/0|head -1|awk '{print $3}'");
 
 Review comment:
   That still prints additional lines, for example:
   
   <pre>
   wido@n01:~$ ip route show default 0.0.0.0/0|wc -l
   1
   wido@n01:~$ ip route show default|wc -l
   22
   wido@n01:~$
   </pre>
   
   We only want to know the route for *0.0.0.0/0* and not other more specific routes set in the routing table.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services