Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion engine/schema/src/main/java/com/cloud/dc/DataCenterVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -476,5 +476,4 @@ public PartitionType partitionType() {
public String toString() {
return String.format("Zone {\"id\": \"%s\", \"name\": \"%s\", \"uuid\": \"%s\"}", id, name, uuid);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public void deleteByOfferingId(long networkOfferingId) {
@Override
public List<String> listProvidersForServiceForNetworkOffering(long networkOfferingId, Service service) {
SearchCriteria<String> sc = ProvidersSearch.create();
;

sc.setParameters("networkOfferingId", networkOfferingId);
sc.setParameters("service", service.getName());
Expand All @@ -140,21 +139,16 @@ public List<String> listProvidersForServiceForNetworkOffering(long networkOfferi
@Override
public boolean isProviderForNetworkOffering(long networkOfferingId, Provider provider) {
SearchCriteria<NetworkOfferingServiceMapVO> sc = AllFieldsSearch.create();
;

sc.setParameters("networkOfferingId", networkOfferingId);
sc.setParameters("provider", provider.getName());

if (findOneBy(sc) != null) {
return true;
}
return false;
return findOneBy(sc) != null;
}

@Override
public List<String> listServicesForNetworkOffering(long networkOfferingId) {
SearchCriteria<String> sc = ServicesSearch.create();
;
sc.setParameters("networkOfferingId", networkOfferingId);
return customSearch(sc, null);
}
Expand Down
24 changes: 14 additions & 10 deletions server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,11 @@ public List<IPAddressVO> doInTransaction(TransactionStatus status) throws Insuff
}

if (vlanUse == VlanType.VirtualNetwork) {
if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) {
if (!dedicatedVlanDbIds.isEmpty()) {
fetchFromDedicatedRange = true;
sc.setParameters("vlanId", dedicatedVlanDbIds.toArray());
errorMessage.append(", vlanId id=" + Arrays.toString(dedicatedVlanDbIds.toArray()));
} else if (nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
} else if (!nonDedicatedVlanDbIds.isEmpty()) {
sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
errorMessage.append(", vlanId id=" + Arrays.toString(nonDedicatedVlanDbIds.toArray()));
} else {
Expand Down Expand Up @@ -898,7 +898,7 @@ public List<IPAddressVO> doInTransaction(TransactionStatus status) throws Insuff
if ((!lockOneRow || (lockOneRow && addrs.size() == 0)) && fetchFromDedicatedRange && vlanUse == VlanType.VirtualNetwork) {
// Verify if account is allowed to acquire IPs from the system
boolean useSystemIps = UseSystemPublicIps.valueIn(owner.getId());
if (useSystemIps && nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
if (useSystemIps && !nonDedicatedVlanDbIds.isEmpty()) {
fetchFromDedicatedRange = false;
sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
errorMessage.append(", vlanId id=" + Arrays.toString(nonDedicatedVlanDbIds.toArray()));
Expand Down Expand Up @@ -1124,15 +1124,19 @@ public boolean applyIpAssociations(Network network, boolean postApplyRules, bool
return success;
}

private String generateErrorMessageForOperationOnDisabledZone(String operation, DataCenter zone) {
return String.format("Cannot %s, %s is currently disabled.", operation, zone);
}

@DB
@Override
public AcquirePodIpCmdResponse allocatePodIp(String zoneId, String podId) throws ConcurrentOperationException, ResourceAllocationException {

DataCenter zone = _entityMgr.findByUuid(DataCenter.class, zoneId);
Account caller = CallContext.current().getCallingAccount();
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getId())) {
ResourceAllocationException ex = new ResourceAllocationException("Cannot perform this operation, " + "Zone is currently disabled" + "zoneId=" + zone.getUuid(),
ResourceType.network);
ResourceAllocationException ex = new ResourceAllocationException(
generateErrorMessageForOperationOnDisabledZone("allocate Pod IP addresses", zone), ResourceType.network);
throw ex;
}

Expand All @@ -1142,7 +1146,7 @@ public AcquirePodIpCmdResponse allocatePodIp(String zoneId, String podId) throws
HostPodVO podvo = null;
podvo = _hpDao.findByUuid(podId);
if (podvo == null)
throw new ResourceAllocationException("No sush pod exists", ResourceType.network);
throw new ResourceAllocationException("No such pod exists", ResourceType.network);

vo = _privateIPAddressDao.takeIpAddress(zone.getId(), podvo.getId(), 0, caller.getId() + "", false);
if(vo == null)
Expand Down Expand Up @@ -1181,7 +1185,7 @@ public void releasePodIp(Long id) throws CloudRuntimeException {
DataCenter zone = _entityMgr.findById(DataCenter.class, ipVO.getDataCenterId());
Account caller = CallContext.current().getCallingAccount();
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getId())) {
throw new CloudRuntimeException("Cannot perform this operation, " + "Zone is currently disabled" + "zoneId=" + ipVO.getDataCenterId());
throw new CloudRuntimeException(generateErrorMessageForOperationOnDisabledZone("release Pod IP", zone));
}
try {
_privateIPAddressDao.releasePodIpAddress(id);
Expand All @@ -1201,7 +1205,7 @@ public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Accou

if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getId())) {
// zone is of type DataCenter. See DataCenterVO.java.
PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, " + "Zone is currently disabled");
PermissionDeniedException ex = new PermissionDeniedException(generateErrorMessageForOperationOnDisabledZone("allocate IP addresses", zone));
ex.addProxyObject(zone.getUuid(), "zoneId");
throw ex;
}
Expand Down Expand Up @@ -1385,7 +1389,7 @@ public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean
}

if (ipToAssoc.getAssociatedWithNetworkId() != null) {
s_logger.debug("IP " + ipToAssoc + " is already assocaited with network id" + networkId);
s_logger.debug("IP " + ipToAssoc + " is already associated with network id" + networkId);
return ipToAssoc;
}

Expand Down Expand Up @@ -1463,7 +1467,7 @@ public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean
s_logger.warn("Failed to associate ip address, so releasing ip from the database " + ip);
_ipAddressDao.markAsUnavailable(ip.getId());
if (!applyIpAssociations(network, true)) {
// if fail to apply ip assciations again, unassign ip address without updating resource
// if fail to apply ip associations again, unassign ip address without updating resource
// count and generating usage event as there is no need to keep it in the db
_ipAddressDao.unassignIpAddress(ip.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ public boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, L
if (!checkedProvider.contains(providerName)) {
result = result && isProviderEnabledInPhysicalNetwork(physicalNtwkId, providerName);
}
checkedProvider.add(providerName);
}
}

Expand Down