Search in sources :

Example 1 with MoveOrCopyParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyParameters in project ovirt-engine by oVirt.

the class VmListModel method onExportNoTemplates.

private void onExportNoTemplates() {
    ExportVmModel model = (ExportVmModel) getWindow();
    Guid storageDomainId = model.getStorage().getSelectedItem().getId();
    if (model.getProgress() != null) {
        return;
    }
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VM a = (VM) item;
        MoveOrCopyParameters parameters = new MoveOrCopyParameters(a.getId(), storageDomainId);
        parameters.setForceOverride(model.getForceOverride().getEntity());
        parameters.setCopyCollapse(model.getCollapseSnapshots().getEntity());
        parameters.setTemplateMustExists(false);
        list.add(parameters);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ExportVm, list, result -> {
        ExportVmModel localModel = (ExportVmModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 2 with MoveOrCopyParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyParameters in project ovirt-engine by oVirt.

the class JsonImmutableSerializeDeserializeTest method serializeCollectionsSingletonMap.

@Test
public void serializeCollectionsSingletonMap() {
    MoveOrCopyParameters params = new MoveOrCopyParameters(Guid.newGuid(), Guid.newGuid());
    params.setImageToDestinationDomainMap(Collections.singletonMap(Guid.createGuidFromString("9edb6526-7ab5-11e6-b829-54ee755c6cc7"), Guid.createGuidFromString("c097a788-7ab5-11e6-849b-54ee755c6cc7")));
    JsonObjectSerializer serializer = new JsonObjectSerializer();
    String json = serializer.serialize(params);
    assertTrue(json.length() > 0);
    MoveOrCopyParameters deserializedParams = new JsonObjectDeserializer().deserialize(json, MoveOrCopyParameters.class);
    assertEquals(params.getContainerId(), deserializedParams.getContainerId());
    assertEquals(params.getExecutionReason(), deserializedParams.getExecutionReason());
}
Also used : MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Test(org.junit.Test)

Example 3 with MoveOrCopyParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyParameters in project ovirt-engine by oVirt.

the class BackendTemplateResource method export.

@Override
public Response export(Action action) {
    validateParameters(action, "storageDomain.id|name");
    MoveOrCopyParameters params = new MoveOrCopyParameters(guid, getStorageDomainId(action));
    if (action.isSetExclusive() && action.isExclusive()) {
        params.setForceOverride(true);
    }
    return doAction(ActionType.ExportVmTemplate, params, action, PollingType.JOB);
}
Also used : MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters)

Example 4 with MoveOrCopyParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyParameters in project ovirt-engine by oVirt.

the class TemplateListModel method doExport.

private void doExport() {
    ExportVmModel model = (ExportVmModel) getWindow();
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VmTemplate a = (VmTemplate) item;
        if (a.getId().equals(Guid.Empty)) {
            continue;
        }
        MoveOrCopyParameters tempVar = new MoveOrCopyParameters(a.getId(), model.getStorage().getSelectedItem().getId());
        tempVar.setForceOverride(model.getForceOverride().getEntity());
        list.add(tempVar);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ExportVmTemplate, list, result -> {
        ExportVmModel localModel = (ExportVmModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 5 with MoveOrCopyParameters

use of org.ovirt.engine.core.common.action.MoveOrCopyParameters in project ovirt-engine by oVirt.

the class VmListModel method postExportGetMissingTemplates.

private void postExportGetMissingTemplates(ArrayList<String> missingTemplatesFromVms) {
    ExportVmModel model = (ExportVmModel) getWindow();
    Guid storageDomainId = model.getStorage().getSelectedItem().getId();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    model.stopProgress();
    for (Object a : getSelectedItems()) {
        VM vm = (VM) a;
        MoveOrCopyParameters parameter = new MoveOrCopyParameters(vm.getId(), storageDomainId);
        parameter.setForceOverride(model.getForceOverride().getEntity());
        parameter.setCopyCollapse(model.getCollapseSnapshots().getEntity());
        parameter.setTemplateMustExists(true);
        parameters.add(parameter);
    }
    if (!model.getCollapseSnapshots().getEntity()) {
        if (missingTemplatesFromVms == null || missingTemplatesFromVms.size() > 0) {
            ConfirmationModel confirmModel = new ConfirmationModel();
            setConfirmWindow(confirmModel);
            confirmModel.setTitle(ConstantsManager.getInstance().getConstants().templatesNotFoundOnExportDomainTitle());
            confirmModel.setHelpTag(HelpTag.template_not_found_on_export_domain);
            // $NON-NLS-1$
            confirmModel.setHashName("template_not_found_on_export_domain");
            confirmModel.setMessage(missingTemplatesFromVms == null ? ConstantsManager.getInstance().getConstants().couldNotReadTemplatesFromExportDomainMsg() : ConstantsManager.getInstance().getConstants().theFollowingTemplatesAreMissingOnTargetExportDomainMsg());
            confirmModel.setItems(missingTemplatesFromVms);
            // $NON-NLS-1$
            UICommand tempVar = UICommand.createDefaultOkUiCommand("OnExportNoTemplates", this);
            confirmModel.getCommands().add(tempVar);
            // $NON-NLS-1$
            UICommand tempVar2 = UICommand.createCancelUiCommand("CancelConfirmation", this);
            confirmModel.getCommands().add(tempVar2);
        } else {
            if (model.getProgress() != null) {
                return;
            }
            model.startProgress();
            Frontend.getInstance().runMultipleAction(ActionType.ExportVm, parameters, result -> {
                ExportVmModel localModel = (ExportVmModel) result.getState();
                localModel.stopProgress();
                cancel();
            }, model);
        }
    } else {
        if (model.getProgress() != null) {
            return;
        }
        for (ActionParametersBase item : parameters) {
            MoveOrCopyParameters parameter = (MoveOrCopyParameters) item;
            parameter.setTemplateMustExists(false);
        }
        model.startProgress();
        Frontend.getInstance().runMultipleAction(ActionType.ExportVm, parameters, result -> {
            ExportVmModel localModel = (ExportVmModel) result.getState();
            localModel.stopProgress();
            cancel();
        }, model);
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Guid(org.ovirt.engine.core.compat.Guid) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

MoveOrCopyParameters (org.ovirt.engine.core.common.action.MoveOrCopyParameters)5 ArrayList (java.util.ArrayList)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 VM (org.ovirt.engine.core.common.businessentities.VM)2 Guid (org.ovirt.engine.core.compat.Guid)2 Test (org.junit.Test)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1 ExportVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel)1