DaanHoogland commented on code in PR #8488:
URL: https://github.com/apache/cloudstack/pull/8488#discussion_r1447256623
##########
server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java:
##########
@@ -695,9 +695,16 @@ private void checkUnmanagedNicIpAndNetworkForImport(String
instanceName, Unmanag
}
// If network is non L2, IP v4 is assigned and not set to auto-assign,
check it is available for network
if (!network.getGuestType().equals(Network.GuestType.L2) &&
ipAddresses != null && StringUtils.isNotEmpty(ipAddresses.getIp4Address()) &&
!ipAddresses.getIp4Address().equals("auto")) {
- Set<Long> ips = networkModel.getAvailableIps(network,
ipAddresses.getIp4Address());
- if (CollectionUtils.isEmpty(ips) ||
!ips.contains(NetUtils.ip2Long(ipAddresses.getIp4Address()))) {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
String.format("IP address %s for NIC(ID: %s) is not available in network(ID:
%s)", ipAddresses.getIp4Address(), nic.getNicId(), network.getUuid()));
+ List<String> usedIps = networkModel.getUsedIpsInNetwork(network);
+ if (LOGGER.isDebugEnabled() && usedIps != null) {
+ String s = usedIps.stream().collect(Collectors.joining(", "));
+ LOGGER.debug(String.format("available IPs for network(ID: %s)
are [%s]",network.getUuid(), s));
+ }
+ for (String usedIp : usedIps) {
+ // only half witted support for ipv6 here :(
+ if (usedIp.equals(ipAddresses.getIp4Address()) ||
usedIp.equals(ipAddresses.getIp6Address())) {
Review Comment:
good point, maybe add a cidr check as well. The issue was that the network
did not have a cidr though. Not sure how to handle that except for just
accepting the ip.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]