CLOUDSTACK-2536: fix the regression introduced by 4c81ea69c4e8326cc81a0e2607f6a6d99645ce5f

This commit is contained in:
Edison Su 2013-07-25 16:34:19 -07:00
parent 17a675942c
commit 5e427bd2f6
4 changed files with 24 additions and 8 deletions

View File

@ -189,8 +189,10 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
if (result) {
//snapshot is deleted on backup storage, need to delete it on primary storage
SnapshotDataStoreVO snapshotOnPrimary = snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Primary);
snapshotOnPrimary.setState(State.Destroyed);
snapshotStoreDao.update(snapshotOnPrimary.getId(), snapshotOnPrimary);
if (snapshotOnPrimary != null) {
snapshotOnPrimary.setState(State.Destroyed);
snapshotStoreDao.update(snapshotOnPrimary.getId(), snapshotOnPrimary);
}
}
} catch (Exception e) {
s_logger.debug("Failed to delete snapshot: ", e);

View File

@ -783,8 +783,13 @@ public class ApiDBUtils {
return _clusterDao.findById(clusterId);
}
public static ClusterDetailsVO findClusterDetails(long clusterId, String name){
return _clusterDetailsDao.findDetail(clusterId,name);
public static String findClusterDetails(long clusterId, String name){
ClusterDetailsVO detailsVO = _clusterDetailsDao.findDetail(clusterId,name);
if (detailsVO != null) {
return detailsVO.getValue();
}
return null;
}
public static DiskOfferingVO findDiskOfferingById(Long diskOfferingId) {

View File

@ -979,11 +979,12 @@ public class ApiResponseHelper implements ResponseGenerator {
clusterResponse.setClusterType(cluster.getClusterType().toString());
clusterResponse.setAllocationState(cluster.getAllocationState().toString());
clusterResponse.setManagedState(cluster.getManagedState().toString());
String cpuOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio").getValue();
String memoryOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio").getValue();
String cpuOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio");
String memoryOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio");
clusterResponse.setCpuOvercommitRatio(cpuOvercommitRatio);
clusterResponse.setMemoryOvercommitRatio(memoryOvercommitRatio);
if (showCapacities != null && showCapacities) {
List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId());
Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
@ -994,9 +995,13 @@ public class ApiResponseHelper implements ResponseGenerator {
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(cpuOvercommitRatio))));
if (cpuOvercommitRatio != null) {
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(cpuOvercommitRatio))));
}
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_MEMORY) {
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(memoryOvercommitRatio))));
if (memoryOvercommitRatio != null) {
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(memoryOvercommitRatio))));
}
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, null, cluster.getId());
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());

View File

@ -479,6 +479,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
result.add(cluster);
if (clusterType == Cluster.ClusterType.CloudManaged) {
Map<String, String> details = new HashMap<String, String>();
details.put("cpuOvercommitRatio", _configDao.getValue(Config.CPUOverprovisioningFactor.key()));
details.put("memoryOvercommitRatio", _configDao.getValue(Config.MemOverprovisioningFactor.key()));
_clusterDetailsDao.persist(cluster.getId(), details);
return result;
}