Search in sources :

Example 11 with ActionType

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());
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 12 with ActionType

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);
}
Also used : AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter)

Example 13 with ActionType

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())));
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) DiskContentType(org.ovirt.engine.core.common.businessentities.storage.DiskContentType) List(java.util.List) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Map(java.util.Map) Test(org.junit.Test)

Example 14 with ActionType

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());
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) List(java.util.List) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Map(java.util.Map) Test(org.junit.Test)

Example 15 with ActionType

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);
}
Also used : FrontendActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult) ActionType(org.ovirt.engine.core.common.action.ActionType) VdcOperation(org.ovirt.engine.ui.frontend.communication.VdcOperation) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ActionType (org.ovirt.engine.core.common.action.ActionType)58 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)37 ArrayList (java.util.ArrayList)31 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)24 Test (org.junit.Test)23 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)16 Guid (org.ovirt.engine.core.compat.Guid)15 List (java.util.List)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)11 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)10 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)10 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)9 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)9 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)9 Arrays (java.util.Arrays)7 HashSet (java.util.HashSet)7 Set (java.util.Set)7