CLOUDSTACK-7121: agent: Make IPv4/IPv6 preference configurable

This allows us to have the Agent connect to the Management Server
over IPv6 if that is listening on :::8250

With this patch it is possible to deploy a IPv6-only KVM Agent where
IPv4 traffic is still forwarded over the bridges, but the KVM Agent
itself does not have IPv4 connectivity.
This commit is contained in:
Wido den Hollander 2014-07-15 09:05:04 +02:00
parent 7542ffc482
commit 5091d0f5c5
1 changed files with 17 additions and 1 deletions

View File

@ -413,7 +413,23 @@ public class AgentShell implements IAgentShell, Daemon {
/* By default we only search for log4j.xml */
LogUtils.initLog4j("log4j-cloud.xml");
System.setProperty("java.net.preferIPv4Stack", "true");
/*
By default we disable IPv6 for now to maintain backwards
compatibility. At a later point in time we can change this
behavior to prefer IPv6 over IPv4.
*/
boolean ipv6disabled = true;
String ipv6 = getProperty(null, "ipv6disabled");
if (ipv6 != null) {
ipv6disabled = Boolean.parseBoolean(ipv6);
}
if (ipv6disabled) {
s_logger.debug("Preferring IPv4 address family for agent connection");
System.setProperty("java.net.preferIPv4Stack", "true");
} else {
s_logger.debug("Preferring IPv6 address family for agent connection");
}
String instance = getProperty(null, "instance");
if (instance == null) {