Search in sources :

Example 1 with ImportRepoImageParameters

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

the class BackendOpenStackImageResource method doImport.

@Override
public Response doImport(Action action) {
    validateParameters(action, "storageDomain.id|name");
    Guid storageDomainId = BackendOpenStackStorageProviderHelper.getStorageDomainId(this, providerId);
    ImportRepoImageParameters parameters = new ImportRepoImageParameters();
    parameters.setSourceRepoImageId(id);
    parameters.setSourceStorageDomainId(storageDomainId);
    parameters.setStoragePoolId(getDataCenterId(getStorageDomainId(action)));
    parameters.setStorageDomainId(getStorageDomainId(action));
    if (action.isSetImportAsTemplate()) {
        if (action.isImportAsTemplate()) {
            validateParameters(action, "cluster.id|name");
            parameters.setClusterId(getClusterId(action));
            if (action.isSetTemplate() && action.getTemplate().isSetName()) {
                parameters.setTemplateName(action.getTemplate().getName());
            }
        }
        parameters.setImportAsTemplate(action.isImportAsTemplate());
    }
    if (action.isSetDisk()) {
        if (action.getDisk().isSetName()) {
            parameters.setDiskAlias(action.getDisk().getName());
        }
        if (action.getDisk().isSetAlias()) {
            parameters.setDiskAlias(action.getDisk().getAlias());
        }
    }
    EntityResolver resolver = new SimpleIdResolver(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class, QueryType.GetDiskByDiskId, IdQueryParameters.class);
    return doAction(ActionType.ImportRepoImage, parameters, action, resolver);
}
Also used : ImportRepoImageParameters(org.ovirt.engine.core.common.action.ImportRepoImageParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with ImportRepoImageParameters

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

the class BackendStorageDomainImageResource method doImport.

@Override
public Response doImport(Action action) {
    validateParameters(action, "storageDomain.id|name");
    ImportRepoImageParameters importParameters = new ImportRepoImageParameters();
    importParameters.setSourceRepoImageId(id);
    importParameters.setSourceStorageDomainId(getStorageDomainId());
    importParameters.setStoragePoolId(getDataCenterId(getStorageDomainId(action)));
    importParameters.setStorageDomainId(getStorageDomainId(action));
    if (action.isSetImportAsTemplate()) {
        if (action.isImportAsTemplate()) {
            validateParameters(action, "cluster.id|name");
            importParameters.setClusterId(getClusterId(action));
            if (action.isSetTemplate() && action.getTemplate().isSetName()) {
                importParameters.setTemplateName(action.getTemplate().getName());
            }
        }
        importParameters.setImportAsTemplate(action.isImportAsTemplate());
    }
    if (action.isSetDisk()) {
        if (action.getDisk().isSetName()) {
            importParameters.setDiskAlias(action.getDisk().getName());
        }
        if (action.getDisk().isSetAlias()) {
            importParameters.setDiskAlias(action.getDisk().getAlias());
        }
    }
    EntityResolver resolver = new SimpleIdResolver(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class, QueryType.GetDiskByDiskId, IdQueryParameters.class);
    return doAction(ActionType.ImportRepoImage, importParameters, action, resolver);
}
Also used : ImportRepoImageParameters(org.ovirt.engine.core.common.action.ImportRepoImageParameters)

Example 3 with ImportRepoImageParameters

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

the class ImportRepoImageCommandTest method createParameters.

private ImportRepoImageParameters createParameters() {
    ImportRepoImageParameters p = new ImportRepoImageParameters();
    p.setSourceRepoImageId(repoImageId);
    p.setSourceStorageDomainId(repoStorageDomainId);
    p.setStoragePoolId(storagePoolId);
    p.setStorageDomainId(storageDomainId);
    return p;
}
Also used : ImportRepoImageParameters(org.ovirt.engine.core.common.action.ImportRepoImageParameters)

Example 4 with ImportRepoImageParameters

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

the class ImportRepoImageModel method executeCommand.

@Override
public void executeCommand(UICommand command) {
    if (!validate()) {
        return;
    }
    super.executeCommand(command);
    startProgress();
    ArrayList<ActionParametersBase> actionParameters = new ArrayList<>();
    final StringBuilder imageNames = new StringBuilder();
    for (EntityModel entity : getEntities()) {
        RepoImage repoImage = (RepoImage) entity.getEntity();
        // $NON-NLS-1$
        imageNames.append("\n -");
        imageNames.append(repoImage.getRepoImageName());
        ImportRepoImageParameters importParameters = new ImportRepoImageParameters();
        // source
        importParameters.setSourceRepoImageId(repoImage.getRepoImageId());
        importParameters.setSourceStorageDomainId(sourceStorageDomain.getId());
        // destination
        importParameters.setDiskAlias(((RepoImageModel) entity).getDiskImageAlias());
        importParameters.setStoragePoolId(getDataCenter().getSelectedItem().getId());
        importParameters.setStorageDomainId(getStorageDomain().getSelectedItem().getId());
        importParameters.setClusterId(getStorageDomain().getSelectedItem().getId());
        Quota selectedQuota = getQuota().getSelectedItem();
        if (selectedQuota != null) {
            importParameters.setQuotaId(selectedQuota.getId());
        }
        Boolean importAsTemplate = getImportAsTemplate().getEntity();
        importParameters.setImportAsTemplate(importAsTemplate);
        if (importAsTemplate) {
            importParameters.setClusterId(getCluster().getSelectedItem().getId());
            String templateName = getTemplateName().getEntity();
            if (StringHelper.isNotNullOrEmpty(templateName)) {
                importParameters.setTemplateName(templateName);
            }
        }
        actionParameters.add(importParameters);
    }
    Frontend.getInstance().runMultipleAction(ActionType.ImportRepoImage, actionParameters, result -> {
        ImportExportRepoImageBaseModel model = (ImportExportRepoImageBaseModel) result.getState();
        model.stopProgress();
        model.cancel();
        ConfirmationModel confirmModel = new ConfirmationModel();
        storageIsoListModel.setConfirmWindow(confirmModel);
        confirmModel.setTitle(ConstantsManager.getInstance().getConstants().importImagesTitle());
        confirmModel.setHelpTag(HelpTag.import_images);
        // $NON-NLS-1$
        confirmModel.setHashName("import_images");
        confirmModel.setMessage(ConstantsManager.getInstance().getMessages().importProcessHasBegunForImages(imageNames.toString()));
        confirmModel.getCommands().add(// $NON-NLS-1$
        new UICommand("CancelConfirm", storageIsoListModel).setTitle(ConstantsManager.getInstance().getConstants().close()).setIsDefault(true).setIsCancel(true));
    }, this);
}
Also used : ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ImportRepoImageParameters(org.ovirt.engine.core.common.action.ImportRepoImageParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Quota(org.ovirt.engine.core.common.businessentities.Quota) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

ImportRepoImageParameters (org.ovirt.engine.core.common.action.ImportRepoImageParameters)4 ArrayList (java.util.ArrayList)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 Quota (org.ovirt.engine.core.common.businessentities.Quota)1 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)1 Guid (org.ovirt.engine.core.compat.Guid)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1