Skip to content

Commit e78b5cc

Browse files
committed
Merge remote-tracking branch 'apache/4.20'
2 parents 4884f52 + 98b9af2 commit e78b5cc

File tree

16 files changed

+205
-94
lines changed

16 files changed

+205
-94
lines changed

api/src/main/java/com/cloud/vm/UserVmService.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,31 @@ UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException
507507

508508
void collectVmNetworkStatistics (UserVm userVm);
509509

510-
UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceName, final String displayName, final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
510+
/**
511+
* Import VM into CloudStack
512+
* @param zone importing zone
513+
* @param host importing host
514+
* @param template template for the imported VM
515+
* @param instanceNameInternal set to null to CloudStack to autogenerate from the next available VM ID on database
516+
* @param displayName display name for the imported VM
517+
* @param owner owner of the imported VM
518+
* @param userData user data for the imported VM
519+
* @param caller caller account
520+
* @param isDisplayVm true to display the imported VM
521+
* @param keyboard keyboard distribution for the imported VM
522+
* @param accountId account ID
523+
* @param userId user ID
524+
* @param serviceOffering service offering for the imported VM
525+
* @param sshPublicKey ssh key for the imported VM
526+
* @param hostName the name for the imported VM
527+
* @param hypervisorType hypervisor type for the imported VM
528+
* @param customParameters details for the imported VM
529+
* @param powerState power state of the imported VM
530+
* @param networkNicMap network to nic mapping
531+
* @return the imported VM
532+
* @throws InsufficientCapacityException in case of errors
533+
*/
534+
UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceNameInternal, final String displayName, final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
511535
final long accountId, final long userId, final ServiceOffering serviceOffering, final String sshPublicKey,
512536
final String hostName, final HypervisorType hypervisorType, final Map<String, String> customParameters,
513537
final VirtualMachine.PowerState powerState, final LinkedHashMap<String, List<NicProfile>> networkNicMap) throws InsufficientCapacityException;

api/src/main/java/com/cloud/vm/snapshot/VMSnapshotService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.List;
2121

22+
import com.cloud.utils.fsm.NoTransitionException;
2223
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
2324

2425
import com.cloud.exception.ConcurrentOperationException;
@@ -53,4 +54,6 @@ UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientServerCapacityExce
5354
* @param id vm id
5455
*/
5556
boolean deleteVMSnapshotsFromDB(Long vmId, boolean unmanage);
57+
58+
void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException;
5659
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.List;
2222

2323
import com.cloud.storage.DataStoreRole;
24+
import com.cloud.utils.fsm.NoTransitionException;
2425

2526
public interface SnapshotDataFactory {
2627
SnapshotInfo getSnapshot(long snapshotId, DataStore store);
@@ -42,4 +43,6 @@ public interface SnapshotDataFactory {
4243
List<SnapshotInfo> listSnapshotOnCache(long snapshotId);
4344

4445
SnapshotInfo getReadySnapshotOnCache(long snapshotId);
46+
47+
void updateOperationFailed(long snapshotId) throws NoTransitionException;
4548
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotStrategy.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

21+
import com.cloud.utils.fsm.NoTransitionException;
2122
import com.cloud.vm.snapshot.VMSnapshot;
2223

2324
public interface VMSnapshotStrategy {
@@ -44,4 +45,6 @@ public interface VMSnapshotStrategy {
4445
* @return true if vm snapshot removed from DB, false if not.
4546
*/
4647
boolean deleteVMSnapshotFromDB(VMSnapshot vmSnapshot, boolean unmanage);
48+
49+
void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException;
4750
}

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public interface StorageManager extends StorageService {
182182
ConfigKey<Boolean> MountDisabledStoragePool = new ConfigKey<>(Boolean.class,
183183
"mount.disabled.storage.pool",
184184
"Storage",
185-
"false",
185+
Boolean.TRUE.toString(),
186186
"Mount all zone-wide or cluster-wide disabled storage pools after node reboot",
187187
true,
188188
ConfigKey.Scope.Cluster,

engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager {
5454
boolean hasActiveVMSnapshotTasks(Long vmId);
5555

5656
RestoreVMSnapshotCommand createRestoreCommand(UserVmVO userVm, List<VMSnapshotVO> vmSnapshotVOs);
57-
5857
}

engine/schema/src/main/java/com/cloud/vm/snapshot/dao/VMSnapshotDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public interface VMSnapshotDao extends GenericDao<VMSnapshotVO, Long>, StateDao<
4242
VMSnapshotVO findByName(Long vmId, String name);
4343

4444
List<VMSnapshotVO> listByAccountId(Long accountId);
45+
4546
List<VMSnapshotVO> searchByVms(List<Long> vmIds);
47+
4648
List<VMSnapshotVO> searchRemovedByVms(List<Long> vmIds, Long batchSize);
4749
}

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@
2323

2424
import javax.inject.Inject;
2525

26+
import com.cloud.storage.Snapshot;
27+
import com.cloud.storage.Volume;
28+
import com.cloud.utils.fsm.NoTransitionException;
2629
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2730
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2831
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
32+
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
2933
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
3034
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
35+
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
3136
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
3237
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
3338
import org.apache.commons.collections.CollectionUtils;
@@ -73,7 +78,7 @@ public List<SnapshotInfo> getSnapshotsForVolumeAndStoreRole(long volumeId, DataS
7378
for (SnapshotDataStoreVO snapshotDataStoreVO : allSnapshotsFromVolumeAndDataStore) {
7479
DataStore store = storeMgr.getDataStore(snapshotDataStoreVO.getDataStoreId(), role);
7580
SnapshotVO snapshot = snapshotDao.findById(snapshotDataStoreVO.getSnapshotId());
76-
if (snapshot == null){ //snapshot may have been removed;
81+
if (snapshot == null) { //snapshot may have been removed;
7782
continue;
7883
}
7984
SnapshotObject info = SnapshotObject.getSnapshotObject(snapshot, store);
@@ -107,8 +112,6 @@ public List<SnapshotInfo> getSnapshots(long snapshotId, Long zoneId) {
107112
return infos;
108113
}
109114

110-
111-
112115
@Override
113116
public SnapshotInfo getSnapshot(long snapshotId, long storeId, DataStoreRole role) {
114117
SnapshotVO snapshot = snapshotDao.findById(snapshotId);
@@ -202,4 +205,17 @@ public List<SnapshotInfo> listSnapshotOnCache(long snapshotId) {
202205
return snapObjs;
203206
}
204207

208+
@Override
209+
public void updateOperationFailed(long snapshotId) throws NoTransitionException {
210+
List<SnapshotDataStoreVO> snapshotStoreRefs = snapshotStoreDao.findBySnapshotId(snapshotId);
211+
for (SnapshotDataStoreVO snapshotStoreRef : snapshotStoreRefs) {
212+
SnapshotInfo snapshotInfo = getSnapshot(snapshotStoreRef.getSnapshotId(), snapshotStoreRef.getDataStoreId(), snapshotStoreRef.getRole());
213+
if (snapshotInfo != null) {
214+
VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
215+
volumeInfo.stateTransit(Volume.Event.OperationFailed);
216+
((SnapshotObject)snapshotInfo).processEvent(Snapshot.Event.OperationFailed);
217+
snapshotInfo.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
218+
}
219+
}
220+
}
205221
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,4 +514,14 @@ private boolean vmHasKvmDiskOnlySnapshot(UserVm vm) {
514514

515515
return false;
516516
}
517+
518+
@Override
519+
public void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException {
520+
try {
521+
vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed);
522+
} catch (NoTransitionException e) {
523+
logger.debug("Failed to change vm snapshot state with event OperationFailed");
524+
throw e;
525+
}
526+
}
517527
}

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,16 @@ public boolean deleteVMSnapshotFromDB(VMSnapshot vmSnapshot, boolean unmanage) {
488488
return vmSnapshotDao.remove(vmSnapshot.getId());
489489
}
490490

491+
@Override
492+
public void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException {
493+
try {
494+
vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed);
495+
} catch (NoTransitionException e) {
496+
logger.debug("Failed to change vm snapshot state with event OperationFailed");
497+
throw e;
498+
}
499+
}
500+
491501
private void publishUsageEvent(String type, VMSnapshot vmSnapshot, UserVm userVm, VolumeObjectTO volumeTo) {
492502
VolumeVO volume = volumeDao.findById(volumeTo.getId());
493503
Long diskOfferingId = volume.getDiskOfferingId();

0 commit comments

Comments
 (0)