mirror of https://github.com/apache/cloudstack.git
kvm: Use 'ip route show default 0.0.0.0/0' to find the default gateway (#3080)
If a host has many routes this can be a magnitude faster then printing all the routes and grepping for the default. In some situations the host might have a large amount of routes due to dynamic routing being used like OSPF or BGP. In addition fix a couple of loglines which were throwing messages on DEBUG while WARN and ERROR should be used there. Signed-off-by: Wido den Hollander <wido@widodh.nl>
This commit is contained in:
parent
52f68a273a
commit
d96bc05d10
|
|
@ -1015,21 +1015,21 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
*/
|
||||
|
||||
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}'");
|
||||
if (_localGateway == null) {
|
||||
s_logger.debug("Failed to found the local gateway");
|
||||
s_logger.warn("No default IPv4 gateway found");
|
||||
}
|
||||
|
||||
_mountPoint = (String)params.get("mount.path");
|
||||
|
|
|
|||
Loading…
Reference in New Issue