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);
}
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);
}
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;
}
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);
}
Aggregations