use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class VmSnapshotListModel method onCloneVM.
private void onCloneVM() {
UnitVmModel model = (UnitVmModel) getWindow();
CloneVmFromSnapshotModelBehavior behavior = (CloneVmFromSnapshotModelBehavior) model.getBehavior();
Snapshot snapshot = getSelectedItem();
if (snapshot == null) {
cancel();
return;
}
if (!model.validate()) {
return;
}
VM vm = behavior.getVm();
// Save changes.
buildVmOnClone(model, vm);
vm.setUseHostCpuFlags(model.getHostCpu().getEntity());
vm.setDiskMap(behavior.getVm().getDiskMap());
HashMap<Guid, DiskImage> imageToDestinationDomainMap = model.getDisksAllocationModel().getImageToDestinationDomainMap();
AddVmFromSnapshotParameters parameters = new AddVmFromSnapshotParameters(vm.getStaticData(), snapshot.getId());
parameters.setDiskInfoDestinationMap(imageToDestinationDomainMap);
parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
parameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
parameters.setVmId(new Guid(model.getVmId().getEntity()));
}
model.startProgress();
Frontend.getInstance().runAction(ActionType.AddVmFromSnapshot, parameters, result -> {
VmSnapshotListModel vmSnapshotListModel = (VmSnapshotListModel) result.getState();
vmSnapshotListModel.getWindow().stopProgress();
ActionReturnValue returnValueBase = result.getReturnValue();
if (returnValueBase != null && returnValueBase.getSucceeded()) {
vmSnapshotListModel.cancel();
vmSnapshotListModel.updateActionAvailability();
}
}, this);
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class UiVdcActionTest method executeCallbacks.
@Override
protected void executeCallbacks(boolean success, ActionFlowState flowState, List<IFrontendActionAsyncCallback> callbacks) {
Collections.shuffle(callbacks);
for (IFrontendActionAsyncCallback callback : callbacks) {
assertNotAllDone(flowState);
ActionReturnValue result = new ActionReturnValue();
result.setValid(true);
result.setSucceeded(success);
callback.executed(new FrontendActionAsyncResult(ACTION_TYPE, null, result));
}
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class AddVmCommand method addVmCinderDisks.
protected void addVmCinderDisks(Collection<DiskImage> templateDisks) {
List<CinderDisk> cinderDisks = DisksFilter.filterCinderDisks(templateDisks);
if (cinderDisks.isEmpty()) {
return;
}
Map<Guid, Guid> diskImageMap = new HashMap<>();
for (CinderDisk cinderDisk : cinderDisks) {
ImagesContainterParametersBase params = buildCloneCinderDiskCommandParameters(cinderDisk);
ActionReturnValue actionReturnValue = runInternalAction(ActionType.CloneSingleCinderDisk, params, cloneContext().withoutExecutionContext().withoutLock());
if (!actionReturnValue.getSucceeded()) {
log.error("Error cloning Cinder disk '{}': {}", cinderDisk.getDiskAlias());
getReturnValue().setFault(actionReturnValue.getFault());
return;
}
Guid imageId = actionReturnValue.getActionReturnValue();
diskImageMap.put(cinderDisk.getId(), imageId);
}
srcDiskIdToTargetDiskIdMapping.putAll(diskImageMap);
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class AddVmCommand method addVmImages.
protected boolean addVmImages() {
if (!vmDisksSource.getDiskTemplateMap().isEmpty()) {
if (getVm().getStatus() != VMStatus.Down) {
log.error("Cannot add images. VM is not Down");
throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
}
lockVM();
Collection<DiskImage> templateDisks = getImagesToCheckDestinationStorageDomains();
List<DiskImage> diskImages = DisksFilter.filterImageDisks(templateDisks, ONLY_NOT_SHAREABLE, ONLY_ACTIVE);
for (DiskImage image : diskImages) {
ActionReturnValue result = runInternalActionWithTasksContext(getDiskCreationCommandType(), buildDiskCreationParameters(image));
// if couldn't create snapshot then stop the transaction and the command
if (!result.getSucceeded()) {
throw new EngineException(result.getFault().getError());
} else {
getTaskIdList().addAll(result.getInternalVdsmTaskIdList());
DiskImage newImage = result.getActionReturnValue();
srcDiskIdToTargetDiskIdMapping.put(image.getId(), newImage.getId());
}
}
// Clone volumes for Cinder disk templates
addVmCinderDisks(templateDisks);
}
return true;
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderCommand method createDisk.
protected Guid createDisk(DiskImage image) {
ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.AddDisk, buildAddDiskParameters(image));
if (!actionReturnValue.getSucceeded()) {
throw new EngineException(actionReturnValue.getFault().getError(), "Failed to create disk!");
}
getTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
return actionReturnValue.getActionReturnValue();
}
Aggregations