mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
1fa4f10a9e
@ -359,7 +359,7 @@ public final class RootCAProvider extends AdapterBase implements CAProvider, Con
|
||||
return true;
|
||||
}
|
||||
final Certificate serverCertificate = issueCertificate(Collections.singletonList(NetUtils.getHostName()),
|
||||
Collections.singletonList(NetUtils.getDefaultHostIp()), getCaValidityDays());
|
||||
NetUtils.getAllDefaultNicIps(), getCaValidityDays());
|
||||
if (serverCertificate == null || serverCertificate.getPrivateKey() == null) {
|
||||
throw new CloudRuntimeException("Failed to generate management server certificate and load management server keystore");
|
||||
}
|
||||
|
||||
@ -225,6 +225,27 @@ public class NetUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getAllDefaultNicIps() {
|
||||
final List<String> addrs = new ArrayList<>();
|
||||
final String pubNic = getDefaultEthDevice();
|
||||
|
||||
if (pubNic == null) {
|
||||
return addrs;
|
||||
}
|
||||
|
||||
NetworkInterface nic = null;
|
||||
try {
|
||||
nic = NetworkInterface.getByName(pubNic);
|
||||
} catch (final SocketException e) {
|
||||
return addrs;
|
||||
}
|
||||
|
||||
for (InterfaceAddress address : nic.getInterfaceAddresses()) {
|
||||
addrs.add(address.getAddress().getHostAddress().split("%")[0]);
|
||||
}
|
||||
return addrs;
|
||||
}
|
||||
|
||||
public static String getDefaultEthDevice() {
|
||||
if (SystemUtils.IS_OS_MAC) {
|
||||
final String defDev = Script.runSimpleBashScript("/sbin/route -n get default 2> /dev/null | grep interface | awk '{print $2}'");
|
||||
|
||||
@ -694,4 +694,9 @@ public class NetUtilsTest {
|
||||
public void testIsIpv4ExpectException2() {
|
||||
NetUtils.isIpv4("2001:db8:300::/64");
|
||||
}
|
||||
|
||||
public void testAllIpsOfDefaultNic() {
|
||||
final String defaultHostIp = NetUtils.getDefaultHostIp();
|
||||
assertTrue(NetUtils.getAllDefaultNicIps().stream().anyMatch(defaultHostIp::contains));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user