Skip to content

Commit 81e945c

Browse files
sureshanapartiLocharla, Sandeep
authored andcommitted
Update physical size for the snapshots of the volumes on ceph primary storage (apache#12465)
1 parent 077c70f commit 81e945c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

core/src/main/java/org/apache/cloudstack/storage/to/SnapshotObjectTO.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ public class SnapshotObjectTO extends DownloadableObjectTO implements DataTO {
4848
private Long physicalSize = (long) 0;
4949
private long accountId;
5050

51-
5251
public SnapshotObjectTO() {
53-
5452
}
5553

5654
@Override

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,16 @@ public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answe
398398
if (answer instanceof CreateObjectAnswer) {
399399
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CreateObjectAnswer)answer).getData();
400400
snapshotStore.setInstallPath(snapshotTO.getPath());
401+
if (snapshotTO.getPhysicalSize() != null && snapshotTO.getPhysicalSize() > 0L) {
402+
snapshotStore.setPhysicalSize(snapshotTO.getPhysicalSize());
403+
}
401404
snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
402405
} else if (answer instanceof CopyCmdAnswer) {
403406
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CopyCmdAnswer)answer).getNewData();
404407
snapshotStore.setInstallPath(snapshotTO.getPath());
405408
if (snapshotTO.getPhysicalSize() != null) {
406409
// For S3 delta snapshot, physical size is currently not set
407-
snapshotStore.setPhysicalSize(snapshotTO.getPhysicalSize());
410+
snapshotStore.setPhysicalSize(snapshotTO.getPhysicalSize());
408411
}
409412
if (snapshotTO.getParentSnapshotPath() == null) {
410413
snapshotStore.setParentSnapshotId(0L);

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ protected static boolean isInterface(final String fname) {
19711971
for (final String ifNamePattern : ifNamePatterns) {
19721972
commonPattern.append("|(").append(ifNamePattern).append(".*)");
19731973
}
1974-
if(fname.matches(commonPattern.toString())) {
1974+
if (fname.matches(commonPattern.toString())) {
19751975
return true;
19761976
}
19771977
return false;
@@ -2498,11 +2498,10 @@ private String getBroadcastUriFromBridge(final String brName) {
24982498
final Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)(\\D*)(\\d*)");
24992499
final Matcher matcher = pattern.matcher(pif);
25002500
LOGGER.debug("getting broadcast uri for pif " + pif + " and bridge " + brName);
2501-
if(matcher.find()) {
2501+
if (matcher.find()) {
25022502
if (brName.startsWith("brvx")){
25032503
return BroadcastDomainType.Vxlan.toUri(matcher.group(2)).toString();
2504-
}
2505-
else{
2504+
} else {
25062505
if (!matcher.group(6).isEmpty()) {
25072506
return BroadcastDomainType.Vlan.toUri(matcher.group(6)).toString();
25082507
} else if (!matcher.group(4).isEmpty()) {
@@ -3742,7 +3741,7 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
37423741
} else if (volume.getType() == Volume.Type.DATADISK) {
37433742
final KVMPhysicalDisk physicalDisk = storagePoolManager.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath());
37443743
final KVMStoragePool pool = physicalDisk.getPool();
3745-
if(StoragePoolType.RBD.equals(pool.getType())) {
3744+
if (StoragePoolType.RBD.equals(pool.getType())) {
37463745
final int devId = volume.getDiskSeq().intValue();
37473746
final String device = mapRbdDevice(physicalDisk);
37483747
if (device != null) {
@@ -5200,7 +5199,7 @@ protected long getMemoryFreeInKBs(Domain dm) throws LibvirtException {
52005199
}
52015200

52025201
for (int i = 0; i < memoryStats.length; i++) {
5203-
if(memoryStats[i].getTag() == UNUSEDMEMORY) {
5202+
if (memoryStats[i].getTag() == UNUSEDMEMORY) {
52045203
freeMemory = memoryStats[i].getValue();
52055204
break;
52065205
}
@@ -5772,12 +5771,12 @@ public HypervisorType getHypervisorType(){
57725771
return hypervisorType;
57735772
}
57745773

5775-
public String mapRbdDevice(final KVMPhysicalDisk disk){
5774+
public String mapRbdDevice(final KVMPhysicalDisk disk) {
57765775
final KVMStoragePool pool = disk.getPool();
57775776
//Check if rbd image is already mapped
57785777
final String[] splitPoolImage = disk.getPath().split("/");
57795778
String device = Script.runSimpleBashScript("rbd showmapped | grep \""+splitPoolImage[0]+"[ ]*"+splitPoolImage[1]+"\" | grep -o \"[^ ]*[ ]*$\"");
5780-
if(device == null) {
5779+
if (device == null) {
57815780
//If not mapped, map and return mapped device
57825781
Script.runSimpleBashScript("rbd map " + disk.getPath() + " --id " + pool.getAuthUserName());
57835782
device = Script.runSimpleBashScript("rbd showmapped | grep \""+splitPoolImage[0]+"[ ]*"+splitPoolImage[1]+"\" | grep -o \"[^ ]*[ ]*$\"");

0 commit comments

Comments
 (0)