Skip to content

Commit 5e427bd

Browse files
committed
CLOUDSTACK-2536: fix the regression introduced by 4c81ea6
1 parent 17a6759 commit 5e427bd

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

‎engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ public boolean deleteSnapshot(Long snapshotId) {
189189
if (result) {
190190
//snapshot is deleted on backup storage, need to delete it on primary storage
191191
SnapshotDataStoreVO snapshotOnPrimary = snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Primary);
192-
snapshotOnPrimary.setState(State.Destroyed);
193-
snapshotStoreDao.update(snapshotOnPrimary.getId(), snapshotOnPrimary);
192+
if (snapshotOnPrimary != null) {
193+
snapshotOnPrimary.setState(State.Destroyed);
194+
snapshotStoreDao.update(snapshotOnPrimary.getId(), snapshotOnPrimary);
195+
}
194196
}
195197
} catch (Exception e) {
196198
s_logger.debug("Failed to delete snapshot: ", e);

‎server/src/com/cloud/api/ApiDBUtils.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,13 @@ public static ClusterVO findClusterById(long clusterId) {
783783
return _clusterDao.findById(clusterId);
784784
}
785785

786-
public static ClusterDetailsVO findClusterDetails(long clusterId, String name){
787-
return _clusterDetailsDao.findDetail(clusterId,name);
786+
public static String findClusterDetails(long clusterId, String name){
787+
ClusterDetailsVO detailsVO = _clusterDetailsDao.findDetail(clusterId,name);
788+
if (detailsVO != null) {
789+
return detailsVO.getValue();
790+
}
791+
792+
return null;
788793
}
789794

790795
public static DiskOfferingVO findDiskOfferingById(Long diskOfferingId) {

‎server/src/com/cloud/api/ApiResponseHelper.java‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,11 +979,12 @@ public ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapaci
979979
clusterResponse.setClusterType(cluster.getClusterType().toString());
980980
clusterResponse.setAllocationState(cluster.getAllocationState().toString());
981981
clusterResponse.setManagedState(cluster.getManagedState().toString());
982-
String cpuOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio").getValue();
983-
String memoryOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio").getValue();
982+
String cpuOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio");
983+
String memoryOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio");
984984
clusterResponse.setCpuOvercommitRatio(cpuOvercommitRatio);
985985
clusterResponse.setMemoryOvercommitRatio(memoryOvercommitRatio);
986986

987+
987988
if (showCapacities != null && showCapacities) {
988989
List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId());
989990
Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
@@ -994,9 +995,13 @@ public ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapaci
994995
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
995996

996997
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
997-
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(cpuOvercommitRatio))));
998+
if (cpuOvercommitRatio != null) {
999+
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(cpuOvercommitRatio))));
1000+
}
9981001
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_MEMORY) {
999-
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(memoryOvercommitRatio))));
1002+
if (memoryOvercommitRatio != null) {
1003+
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(memoryOvercommitRatio))));
1004+
}
10001005
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
10011006
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, null, cluster.getId());
10021007
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());

‎server/src/com/cloud/resource/ResourceManagerImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
479479
result.add(cluster);
480480

481481
if (clusterType == Cluster.ClusterType.CloudManaged) {
482+
Map<String, String> details = new HashMap<String, String>();
483+
details.put("cpuOvercommitRatio", _configDao.getValue(Config.CPUOverprovisioningFactor.key()));
484+
details.put("memoryOvercommitRatio", _configDao.getValue(Config.MemOverprovisioningFactor.key()));
485+
_clusterDetailsDao.persist(cluster.getId(), details);
482486
return result;
483487
}
484488

0 commit comments

Comments
 (0)