diff --git a/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java b/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java index 5cab7bcf19c..981e652fb8f 100644 --- a/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java +++ b/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java @@ -316,9 +316,6 @@ public class MetricsServiceImpl extends ComponentLifecycleBase implements Metric final Float cpuDisableThreshold = DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.valueIn(clusterId); final Float memoryDisableThreshold = DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.valueIn(clusterId); - final Double cpuOvercommitRatio = findRatioValue(ApiDBUtils.findClusterDetails(clusterId, "cpuOvercommitRatio")); - final Double memoryOvercommitRatio = findRatioValue(ApiDBUtils.findClusterDetails(clusterId, "memoryOvercommitRatio")); - // CPU and memory capacities final CapacityDaoImpl.SummedCapacity cpuCapacity = getCapacity((int) Capacity.CAPACITY_TYPE_CPU, null, clusterId); final CapacityDaoImpl.SummedCapacity memoryCapacity = getCapacity((int) Capacity.CAPACITY_TYPE_MEMORY, null, clusterId); @@ -351,13 +348,13 @@ public class MetricsServiceImpl extends ComponentLifecycleBase implements Metric // CPU thresholds metricsResponse.setCpuUsageThreshold(metrics.getCpuUsedPercentage(), metrics.getTotalHosts(), cpuThreshold); metricsResponse.setCpuUsageDisableThreshold(metrics.getCpuUsedPercentage(), metrics.getTotalHosts(), cpuDisableThreshold); - metricsResponse.setCpuAllocatedThreshold(metrics.getCpuAllocated(), metrics.getTotalCpu(), cpuOvercommitRatio, cpuThreshold); - metricsResponse.setCpuAllocatedDisableThreshold(metrics.getCpuAllocated(), metrics.getTotalCpu(), cpuOvercommitRatio, cpuDisableThreshold); + metricsResponse.setCpuAllocatedThreshold(metrics.getCpuAllocated(), metrics.getTotalCpu(), cpuThreshold); + metricsResponse.setCpuAllocatedDisableThreshold(metrics.getCpuAllocated(), metrics.getTotalCpu(), cpuDisableThreshold); // Memory thresholds metricsResponse.setMemoryUsageThreshold(metrics.getMemoryUsed(), metrics.getTotalMemory(), memoryThreshold); metricsResponse.setMemoryUsageDisableThreshold(metrics.getMemoryUsed(), metrics.getTotalMemory(), memoryDisableThreshold); - metricsResponse.setMemoryAllocatedThreshold(metrics.getMemoryAllocated(), metrics.getTotalMemory(), memoryOvercommitRatio, memoryThreshold); - metricsResponse.setMemoryAllocatedDisableThreshold(metrics.getMemoryAllocated(), metrics.getTotalMemory(), memoryOvercommitRatio, memoryDisableThreshold); + metricsResponse.setMemoryAllocatedThreshold(metrics.getMemoryAllocated(), metrics.getTotalMemory(), memoryThreshold); + metricsResponse.setMemoryAllocatedDisableThreshold(metrics.getMemoryAllocated(), metrics.getTotalMemory(), memoryDisableThreshold); metricsResponses.add(metricsResponse); } diff --git a/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java index d93884532a9..a12ecd3b4f4 100644 --- a/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java +++ b/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java @@ -172,15 +172,15 @@ public class ClusterMetricsResponse extends ClusterResponse { } } - public void setCpuAllocatedThreshold(final Long cpuAllocated, final Long cpuUsed, final Double overCommitRatio, final Double threshold) { - if (cpuAllocated != null && cpuUsed != null && overCommitRatio != null && threshold != null && cpuUsed != 0) { - this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated * overCommitRatio / cpuUsed) > threshold; + public void setCpuAllocatedThreshold(final Long cpuAllocated, final Long cpuTotal, final Double threshold) { + if (cpuAllocated != null && cpuTotal != null && threshold != null && cpuTotal != 0) { + this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated / cpuTotal) > threshold; } } - public void setCpuAllocatedDisableThreshold(final Long cpuAllocated, final Long cpuUsed, final Double overCommitRatio, final Float threshold) { - if (cpuAllocated != null && cpuUsed != null && overCommitRatio != null && threshold != null && cpuUsed != 0) { - this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated * overCommitRatio / cpuUsed) > threshold; + public void setCpuAllocatedDisableThreshold(final Long cpuAllocated, final Long cpuTotal, final Float threshold) { + if (cpuAllocated != null && cpuTotal != null && threshold != null && cpuTotal != 0) { + this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated / cpuTotal) > threshold; } } @@ -197,15 +197,15 @@ public class ClusterMetricsResponse extends ClusterResponse { } - public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Double threshold) { - if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null && memTotal != 0) { - this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated * overCommitRatio / memTotal) > threshold; + public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double threshold) { + if (memAllocated != null && memTotal != null && threshold != null && memTotal != 0) { + this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated / memTotal) > threshold; } } - public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Float threshold) { - if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null && memTotal != 0) { - this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated * overCommitRatio / memTotal) > threshold; + public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Float threshold) { + if (memAllocated != null && memTotal != null && threshold != null && memTotal != 0) { + this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated / memTotal) > threshold; } } } diff --git a/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java index cdc9d16d845..72e9f92f803 100644 --- a/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java +++ b/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java @@ -167,13 +167,13 @@ public class HostMetricsResponse extends HostResponse { public void setCpuAllocatedThreshold(final String cpuAllocated, final Double overCommitRatio, final Double threshold) { if (cpuAllocated != null && overCommitRatio != null && threshold != null) { - this.cpuAllocatedThresholdExceeded = (Double.valueOf(cpuAllocated.replace("%", "")) * overCommitRatio) > (100.0 * threshold); + this.cpuAllocatedThresholdExceeded = Double.valueOf(cpuAllocated.replace("%", "")) > (100.0 * threshold * overCommitRatio); } } public void setCpuAllocatedDisableThreshold(final String cpuAllocated, final Double overCommitRatio, final Float threshold) { if (cpuAllocated != null && overCommitRatio != null && threshold != null) { - this.cpuAllocatedDisableThresholdExceeded = (Double.valueOf(cpuAllocated.replace("%", "")) * overCommitRatio) > (100.0 * threshold); + this.cpuAllocatedDisableThresholdExceeded = Double.valueOf(cpuAllocated.replace("%", "")) > (100.0 * threshold * overCommitRatio); } } @@ -191,13 +191,13 @@ public class HostMetricsResponse extends HostResponse { public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Double threshold) { if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null) { - this.memoryAllocatedThresholdExceeded = (memAllocated * overCommitRatio) > (memTotal * threshold); + this.memoryAllocatedThresholdExceeded = memAllocated > (memTotal * threshold * overCommitRatio); } } public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Float threshold) { if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null) { - this.memoryAllocatedDisableThresholdExceeded = (memAllocated * overCommitRatio) > (memTotal * threshold); + this.memoryAllocatedDisableThresholdExceeded = memAllocated > (memTotal * threshold * overCommitRatio); } } diff --git a/server/src/org/apache/cloudstack/acl/RoleManagerImpl.java b/server/src/org/apache/cloudstack/acl/RoleManagerImpl.java index 7363b13b35a..27cb3d0238a 100644 --- a/server/src/org/apache/cloudstack/acl/RoleManagerImpl.java +++ b/server/src/org/apache/cloudstack/acl/RoleManagerImpl.java @@ -50,6 +50,7 @@ import javax.inject.Inject; import java.io.File; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; @Local(value = {RoleService.class}) @@ -172,7 +173,12 @@ public class RoleManagerImpl extends ManagerBase implements RoleService, Configu rolePermissionsDao.remove(rolePermission.getId()); } } - return roleDao.remove(role.getId()); + if (roleDao.remove(role.getId())) { + RoleVO roleVO = roleDao.findByIdIncludingRemoved(role.getId()); + roleVO.setName(role.getName() + "-deleted-" + new Date()); + return roleDao.update(role.getId(), roleVO); + } + return false; } }); }