mirror of https://github.com/apache/cloudstack.git
VPC: CS-15950 - throw networkConflictException when try to create network rule for the ip address that is already in use for another service
Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java server/src/com/cloud/network/rules/RulesManagerImpl.java
This commit is contained in:
parent
327b4833ce
commit
d93c5d0531
|
|
@ -846,7 +846,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean canIpUsedForService(PublicIp publicIp, Service service) {
|
||||
public boolean canIpUsedForService(PublicIp publicIp, Service service, Long networkId) {
|
||||
List<PublicIp> ipList = new ArrayList<PublicIp>();
|
||||
ipList.add(publicIp);
|
||||
Map<PublicIp, Set<Service>> ipToServices = getIpToServices(ipList, false, true);
|
||||
|
|
@ -854,9 +854,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (services == null || services.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (networkId == null) {
|
||||
networkId = publicIp.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
// We only support one provider for one service now
|
||||
Map<Service, Set<Provider>> serviceToProviders = getServiceProvidersMap(publicIp.getAssociatedWithNetworkId());
|
||||
Set<Provider> oldProviders = serviceToProviders.get((Service) services.toArray()[0]);
|
||||
Map<Service, Set<Provider>> serviceToProviders = getServiceProvidersMap(networkId);
|
||||
Set<Provider> oldProviders = serviceToProviders.get(services.toArray()[0]);
|
||||
Provider oldProvider = (Provider) oldProviders.toArray()[0];
|
||||
// Since IP already has service to bind with, the oldProvider can't be null
|
||||
Set<Provider> newProviders = serviceToProviders.get(service);
|
||||
|
|
@ -6890,7 +6895,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return true;
|
||||
}
|
||||
PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()), NetUtils.createSequenceBasedMacAddress(userIp.getMacAddress()));
|
||||
if (!canIpUsedForService(publicIp, service)) {
|
||||
if (!canIpUsedForService(publicIp, service, networkId)) {
|
||||
return false;
|
||||
}
|
||||
if (!offering.isConserveMode()) {
|
||||
|
|
|
|||
|
|
@ -190,8 +190,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
//set networkId just for verification purposes
|
||||
ipAddress.setAssociatedWithNetworkId(networkId);
|
||||
_networkMgr.checkIpForService(ipAddress, Service.PortForwarding, networkId);
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
|
||||
|
|
|
|||
Loading…
Reference in New Issue