use of org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters in project ovirt-engine by oVirt.
the class BackendStorageDomainTemplatesResource method getEntitiesFromExportDomain.
@SuppressWarnings("unchecked")
@Override
protected Collection<VmTemplate> getEntitiesFromExportDomain() {
GetAllFromExportDomainQueryParameters params = new GetAllFromExportDomainQueryParameters(getDataCenterId(storageDomainId), storageDomainId);
Map<VmTemplate, List<DiskImage>> ret = getEntity(HashMap.class, QueryType.GetTemplatesFromExportDomain, params, "Templates under storage domain id : " + storageDomainId.toString());
return ret.keySet();
}
use of org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters in project ovirt-engine by oVirt.
the class ExportVmCommand method checkTemplateInStorageDomain.
public static boolean checkTemplateInStorageDomain(Guid storagePoolId, Guid storageDomainId, final Guid tmplId, EngineContext engineContext) {
GetAllFromExportDomainQueryParameters tempVar = new GetAllFromExportDomainQueryParameters(storagePoolId, storageDomainId);
QueryReturnValue qretVal = Backend.getInstance().runInternalQuery(QueryType.GetTemplatesFromExportDomain, tempVar, engineContext);
if (qretVal.getSucceeded()) {
if (!VmTemplateHandler.BLANK_VM_TEMPLATE_ID.equals(tmplId)) {
Map<VmTemplate, List<DiskImage>> templates = qretVal.getReturnValue();
return templates.keySet().stream().anyMatch(vmTemplate -> vmTemplate.getId().equals(tmplId));
} else {
return true;
}
}
return false;
}
use of org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters in project ovirt-engine by oVirt.
the class ExportVmCommand method checkVmInStorageDomain.
/**
* Check that vm is in export domain
*/
protected boolean checkVmInStorageDomain() {
GetAllFromExportDomainQueryParameters tempVar = new GetAllFromExportDomainQueryParameters(getVm().getStoragePoolId(), getParameters().getStorageDomainId());
QueryReturnValue qretVal = runInternalQuery(QueryType.GetVmsFromExportDomain, tempVar);
if (qretVal.getSucceeded()) {
List<VM> vms = qretVal.getReturnValue();
for (VM vm : vms) {
if (vm.getId().equals(getVm().getId())) {
if (!getParameters().getForceOverride()) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_GUID_ALREADY_EXIST);
}
} else if (vm.getName().equals(getVm().getName())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_NAME_ALREADY_USED);
}
}
}
return true;
}
use of org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters in project ovirt-engine by oVirt.
the class RemoveVmTemplateFromImportExportCommand method getVmTemplate.
/*
* get template from export domain
*/
@Override
public VmTemplate getVmTemplate() {
if (exportTemplate == null) {
GetAllFromExportDomainQueryParameters tempVar = new GetAllFromExportDomainQueryParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId());
QueryReturnValue qretVal = runInternalQuery(QueryType.GetTemplatesFromExportDomain, tempVar);
if (qretVal.getSucceeded()) {
templatesFromExport = qretVal.getReturnValue();
exportTemplate = templatesFromExport.keySet().stream().filter(t -> t.getId().equals(getParameters().getVmTemplateId())).findFirst().orElse(null);
setVmTemplate(exportTemplate);
}
}
return exportTemplate;
}
use of org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters in project ovirt-engine by oVirt.
the class ImportVmCommand method isTemplateExistsOnExportDomain.
private boolean isTemplateExistsOnExportDomain() {
if (VmTemplateHandler.BLANK_VM_TEMPLATE_ID.equals(getParameters().getVm().getVmtGuid())) {
return true;
}
QueryReturnValue qRetVal = runInternalQuery(QueryType.GetTemplatesFromExportDomain, new GetAllFromExportDomainQueryParameters(getParameters().getStoragePoolId(), getParameters().getSourceDomainId()));
if (!qRetVal.getSucceeded()) {
return false;
}
Map<VmTemplate, ?> templates = qRetVal.getReturnValue();
return templates.keySet().stream().anyMatch(t -> getParameters().getVm().getVmtGuid().equals(t.getId()));
}
Aggregations