use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class AddVmCommand method addVmWatchdog.
private void addVmWatchdog() {
VmWatchdog vmWatchdog = getParameters().getWatchdog();
if (vmWatchdog != null) {
ActionType actionType = getVmDeviceUtils().hasWatchdog(getVmTemplateId()) ? ActionType.UpdateWatchdog : ActionType.AddWatchdog;
runInternalAction(actionType, buildWatchdogParameters(vmWatchdog), cloneContextAndDetachFromParent());
}
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class ImportHostedEngineStorageDomainCommand method executeCommand.
@Override
protected void executeCommand() {
StorageDomainManagementParameter addSdParams = new StorageDomainManagementParameter(heStorageDomain.getStorageStaticData());
addSdParams.setVdsId(getParameters().getVdsId());
addSdParams.setStoragePoolId(getVds().getStoragePoolId());
ActionType actionType = null;
switch(heStorageDomain.getStorageType()) {
case NFS:
case GLUSTERFS:
actionType = ActionType.AddExistingFileStorageDomain;
addStorageServerConnection();
break;
case ISCSI:
discoverBlockConnectionDetails();
case FCP:
actionType = ActionType.AddExistingBlockStorageDomain;
removeHostedEngineLunDisk();
break;
}
if (getSucceeded()) {
setSucceeded(backend.runInternalAction(actionType, addSdParams, getContext()).getSucceeded());
}
if (getSucceeded()) {
AttachStorageDomainToPoolParameters attachSdParams = new AttachStorageDomainToPoolParameters(addSdParams.getStorageDomainId(), addSdParams.getStoragePoolId());
setSucceeded(backend.runInternalAction(ActionType.AttachStorageDomainToPool, attachSdParams, getContext()).getSucceeded());
}
setActionReturnValue(heStorageDomain);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class DiskOperationsValidatorTest method testDisallowedOperations.
@Test
public void testDisallowedOperations() {
Disk disk = new DiskImage();
for (Map.Entry<ActionType, List<DiskContentType>> entry : DiskOperationsValidator.allowedCommandsOnTypes.entrySet()) {
EnumSet<DiskContentType> allowedTypes = EnumSet.copyOf(entry.getValue());
EnumSet<DiskContentType> disallowedTypes = EnumSet.complementOf(allowedTypes);
if (disallowedTypes.isEmpty()) {
continue;
}
disk.setContentType(disallowedTypes.iterator().next());
DiskOperationsValidator validator = new DiskOperationsValidator(disk);
assertThat(validator.isOperationAllowedOnDisk(entry.getKey()), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_CONTENT_TYPE_NOT_SUPPORTED_FOR_OPERATION, String.format("$diskContentType %s", disk.getContentType())));
}
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class DiskOperationsValidatorTest method testAllowedOperations.
@Test
public void testAllowedOperations() {
Disk disk = new DiskImage();
for (Map.Entry<ActionType, List<DiskContentType>> entry : DiskOperationsValidator.allowedCommandsOnTypes.entrySet()) {
disk.setContentType(entry.getValue().get(0));
DiskOperationsValidator validator = new DiskOperationsValidator(disk);
assertThat(validator.isOperationAllowedOnDisk(entry.getKey()), isValid());
}
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class Frontend method runAction.
/**
* Run an action of the specified action type using the passed in parameters, also pass in a state object.
* @param actionType The action type of the action to perform.
* @param parameters The parameters of the action.
* @param callback The callback to call when the action is completed.
* @param state The state object.
* @param showErrorDialog Whether to show a pop-up dialog with the error or not.
*/
public void runAction(final ActionType actionType, final ActionParametersBase parameters, final IFrontendActionAsyncCallback callback, final Object state, final boolean showErrorDialog) {
VdcOperation<ActionType, ActionParametersBase> operation = new VdcOperation<>(actionType, parameters, new VdcOperationCallback<VdcOperation<ActionType, ActionParametersBase>, ActionReturnValue>() {
@Override
public void onSuccess(final VdcOperation<ActionType, ActionParametersBase> operation, final ActionReturnValue result) {
// $NON-NLS-1$
logger.finer("Frontend: sucessfully executed runAction, determining result!");
handleActionResult(actionType, parameters, result, callback != null ? callback : NULLABLE_ASYNC_CALLBACK, state, showErrorDialog);
fireAsyncActionSucceededEvent(state);
}
@Override
public void onFailure(final VdcOperation<ActionType, ActionParametersBase> operation, final Throwable caught) {
if (ignoreFailure(caught)) {
return;
}
// $NON-NLS-1$
logger.log(Level.SEVERE, "Failed to execute runAction: " + caught, caught);
failureEventHandler(caught);
FrontendActionAsyncResult f = new FrontendActionAsyncResult(actionType, parameters, null, state);
if (callback != null) {
callback.executed(f);
}
fireAsyncActionFailedEvent(state);
}
});
fireAsyncOperationStartedEvent(state);
getOperationManager().addOperation(operation);
}
Aggregations