diff --git a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java index f5263e21045..7dc2a50382b 100644 --- a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.capacity.CapacityVO; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; @@ -353,12 +354,16 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla return; } + String configurationName = ClusterCPUCapacityDisableThreshold.key(); + float configurationValue = ClusterCPUCapacityDisableThreshold.value(); if (capacity == Capacity.CAPACITY_TYPE_CPU) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested); } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested); + configurationName = ClusterMemoryCapacityDisableThreshold.key(); + configurationValue = ClusterMemoryCapacityDisableThreshold.value(); } if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) { @@ -367,8 +372,11 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla // Remove clusters crossing disabled threshold clusterListForVmAllocation.removeAll(clustersCrossingThreshold); - s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" + - " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters"); + String warnMessageForClusterReachedCapacityThreshold = String.format( + "Cannot allocate cluster list %s for VM creation since their allocated percentage crosses the disable capacity threshold defined at each cluster at" + + " Global Settings Configuration [name: %s, value: %s] for capacity Type : %s, skipping these clusters", clustersCrossingThreshold.toString(), + configurationName, String.valueOf(configurationValue), CapacityVO.getCapacityName(capacity)); + s_logger.warn(warnMessageForClusterReachedCapacityThreshold); } } diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java index 08ae0ad13f4..2b79ff00be0 100644 --- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java +++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java @@ -1146,7 +1146,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe final SearchBuilder sb = _clusterDao.createSearchBuilder(); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); - sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); + sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ); sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ); @@ -1159,7 +1159,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } if (name != null) { - sc.setParameters("name", "%" + name + "%"); + sc.setParameters("name", name); } if (podId != null) { diff --git a/server/src/main/java/com/cloud/vm/UserVmManager.java b/server/src/main/java/com/cloud/vm/UserVmManager.java index 8d4cf453a56..cde2d04970d 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManager.java +++ b/server/src/main/java/com/cloud/vm/UserVmManager.java @@ -110,6 +110,9 @@ public interface UserVmManager extends UserVmService { Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map additionalParams, String deploymentPlannerToUse) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException; + Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map additionalParams, String deploymentPlannerToUse, boolean isExplicitHost) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException; + boolean upgradeVirtualMachine(Long id, Long serviceOfferingId, Map customParameters) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 07d1f2b80a9..83caf07cccc 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -1081,7 +1081,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir params = new HashMap(); params.put(VirtualMachineProfile.Param.BootIntoSetup, Boolean.TRUE); } - return startVirtualMachine(vmId, null, null, hostId, params, null).first(); + return startVirtualMachine(vmId, null, null, hostId, params, null, false).first(); } } catch (ResourceUnavailableException e) { throw new CloudRuntimeException("Unable to reboot the VM: " + vmId, e); @@ -5068,6 +5068,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir public Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map additionalParams, String deploymentPlannerToUse) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { + return startVirtualMachine(vmId, podId, clusterId, hostId, additionalParams, deploymentPlannerToUse, true); + } + + @Override + public Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, + Map additionalParams, String deploymentPlannerToUse, boolean isExplicitHost) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { // Input validation final Account callerAccount = CallContext.current().getCallingAccount(); UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId()); @@ -5123,7 +5130,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir boolean isRootAdmin = _accountService.isRootAdmin(callerAccount.getId()); Pod destinationPod = getDestinationPod(podId, isRootAdmin); Cluster destinationCluster = getDestinationCluster(clusterId, isRootAdmin); - Host destinationHost = getDestinationHost(hostId, isRootAdmin); + Host destinationHost = getDestinationHost(hostId, isRootAdmin, isExplicitHost); DataCenterDeployment plan = null; boolean deployOnGivenHost = false; if (destinationHost != null) { @@ -5276,10 +5283,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir return destinationCluster; } - private Host getDestinationHost(Long hostId, boolean isRootAdmin) { + private Host getDestinationHost(Long hostId, boolean isRootAdmin, boolean isExplicitHost) { Host destinationHost = null; if (hostId != null) { - if (!isRootAdmin) { + if (isExplicitHost && !isRootAdmin) { throw new PermissionDeniedException( "Parameter " + ApiConstants.HOST_ID + " can only be specified by a Root Admin, permission denied"); } @@ -5622,7 +5629,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir boolean isRootAdmin = _accountService.isRootAdmin(callerId); Long hostId = cmd.getHostId(); - getDestinationHost(hostId, isRootAdmin); + getDestinationHost(hostId, isRootAdmin, true); String ipAddress = cmd.getIpAddress(); String ip6Address = cmd.getIp6Address();