Skip to content

Commit ebd0b7e

Browse files
committed
CLOUDSTACK-9539: Refactor based on reviews
1 parent abad39e commit ebd0b7e

File tree

7 files changed

+11
-22
lines changed

7 files changed

+11
-22
lines changed

api/src/com/cloud/vm/snapshot/VMSnapshot.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,6 @@ enum Event {
102102

103103
@Override
104104
public long getAccountId();
105+
106+
public long getServiceOfferingId();
105107
}

core/src/com/cloud/agent/api/VMSnapshotTO.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class VMSnapshotTO {
3535
private VMSnapshotTO parent;
3636
private List<VolumeObjectTO> volumes;
3737
private boolean quiescevm;
38-
private Long serviceOfferingId;
3938

4039
public Long getId() {
4140
return id;
@@ -45,7 +44,7 @@ public void setId(Long id) {
4544
this.id = id;
4645
}
4746

48-
public VMSnapshotTO(Long id, String snapshotName, VMSnapshot.Type type, Long createTime, String description, Boolean current, VMSnapshotTO parent, boolean quiescevm, Long serviceOfferingId) {
47+
public VMSnapshotTO(Long id, String snapshotName, VMSnapshot.Type type, Long createTime, String description, Boolean current, VMSnapshotTO parent, boolean quiescevm) {
4948
super();
5049
this.id = id;
5150
this.snapshotName = snapshotName;
@@ -55,7 +54,6 @@ public VMSnapshotTO(Long id, String snapshotName, VMSnapshot.Type type, Long cre
5554
this.description = description;
5655
this.parent = parent;
5756
this.quiescevm = quiescevm;
58-
this.serviceOfferingId = serviceOfferingId;
5957
}
6058

6159
public VMSnapshotTO() {
@@ -126,11 +124,4 @@ public void setQuiescevm(boolean quiescevm) {
126124
this.quiescevm = quiescevm;
127125
}
128126

129-
public Long getServiceOfferingId() {
130-
return serviceOfferingId;
131-
}
132-
133-
public void setServiceOfferingId(Long serviceOfferingId) {
134-
this.serviceOfferingId = serviceOfferingId;
135-
}
136127
}

engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ public Class<?> getEntityType() {
253253
return VMSnapshot.class;
254254
}
255255

256+
@Override
256257
public long getServiceOfferingId() {
257258
return serviceOfferingId;
258259
}

engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
128128
if (options != null)
129129
quiescevm = options.needQuiesceVM();
130130
VMSnapshotTO target =
131-
new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(), null, vmSnapshot.getDescription(), false, current, quiescevm, userVm.getServiceOfferingId());
131+
new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(), null, vmSnapshot.getDescription(), false, current, quiescevm);
132132
if (current == null)
133133
vmSnapshotVO.setParent(null);
134134
else
@@ -199,7 +199,7 @@ public boolean deleteVMSnapshot(VMSnapshot vmSnapshot) {
199199
VMSnapshotTO parent = vmSnapshotHelper.getSnapshotWithParents(vmSnapshotVO).getParent();
200200
VMSnapshotTO vmSnapshotTO =
201201
new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(), vmSnapshot.getCreated().getTime(), vmSnapshot.getDescription(),
202-
vmSnapshot.getCurrent(), parent, true, vmSnapshotVO.getServiceOfferingId());
202+
vmSnapshot.getCurrent(), parent, true);
203203
GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId());
204204
DeleteVMSnapshotCommand deleteSnapshotCommand = new DeleteVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
205205

@@ -347,7 +347,7 @@ public boolean revertVMSnapshot(VMSnapshot vmSnapshot) {
347347

348348
VMSnapshotTO vmSnapshotTO =
349349
new VMSnapshotTO(snapshot.getId(), snapshot.getName(), snapshot.getType(), snapshot.getCreated().getTime(), snapshot.getDescription(),
350-
snapshot.getCurrent(), parent, true, snapshot.getServiceOfferingId());
350+
snapshot.getCurrent(), parent, true);
351351
Long hostId = vmSnapshotHelper.pickRunningHost(vmSnapshot.getVmId());
352352
GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId());
353353
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, userVm.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());

engine/storage/src/org/apache/cloudstack/storage/helper/HypervisorHelperImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public VMSnapshotTO quiesceVm(VirtualMachine virtualMachine) {
120120
int wait = NumbersUtil.parseInt(value, 1800);
121121
Long hostId = vmSnapshotHelper.pickRunningHost(virtualMachine.getId());
122122
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(1L, UUID.randomUUID().toString(), VMSnapshot.Type.Disk, null, null, false,
123-
null, true, virtualMachine.getServiceOfferingId());
123+
null, true);
124124
GuestOSVO guestOS = guestOSDao.findById(virtualMachine.getGuestOSId());
125125
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(virtualMachine.getId());
126126
CreateVMSnapshotCommand ccmd =

engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public List<VolumeObjectTO> getVolumeTOList(Long vmId) {
122122
}
123123

124124
private VMSnapshotTO convert2VMSnapshotTO(VMSnapshotVO vo) {
125-
return new VMSnapshotTO(vo.getId(), vo.getName(), vo.getType(), vo.getCreated().getTime(), vo.getDescription(), vo.getCurrent(), null, true, vo.getServiceOfferingId());
125+
return new VMSnapshotTO(vo.getId(), vo.getName(), vo.getType(), vo.getCreated().getTime(), vo.getDescription(), vo.getCurrent(), null, true);
126126
}
127127

128128
@Override

server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,7 @@ public UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientCapacityExc
615615
VmWorkJobVO placeHolder = null;
616616
placeHolder = createPlaceHolderWork(vmSnapshotVo.getVmId());
617617
try {
618-
UserVm revertedVM = orchestrateRevertToVMSnapshot(vmSnapshotId);
619-
620-
updateUserVmServiceOffering(revertedVM, vmSnapshotVo);
621-
622-
return revertedVM;
618+
return orchestrateRevertToVMSnapshot(vmSnapshotId);
623619
} finally {
624620
_workJobDao.expunge(placeHolder.getId());
625621
}
@@ -648,8 +644,6 @@ else if (jobResult instanceof Throwable)
648644
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
649645
}
650646

651-
updateUserVmServiceOffering(userVm, vmSnapshotVo);
652-
653647
return userVm;
654648
}
655649
}
@@ -766,6 +760,7 @@ private UserVm orchestrateRevertToVMSnapshot(Long vmSnapshotId) throws Insuffici
766760
try {
767761
VMSnapshotStrategy strategy = findVMSnapshotStrategy(vmSnapshotVo);
768762
strategy.revertVMSnapshot(vmSnapshotVo);
763+
updateUserVmServiceOffering(userVm, vmSnapshotVo);
769764
return userVm;
770765
} catch (Exception e) {
771766
s_logger.debug("Failed to revert vmsnapshot: " + vmSnapshotId, e);

0 commit comments

Comments
 (0)