Search in sources :

Example 6 with GetAllFromExportDomainQueryParameters

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();
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Example 7 with GetAllFromExportDomainQueryParameters

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;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) List(java.util.List) ArrayList(java.util.ArrayList) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Example 8 with GetAllFromExportDomainQueryParameters

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;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Example 9 with GetAllFromExportDomainQueryParameters

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;
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) LockProperties(org.ovirt.engine.core.common.action.LockProperties) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmTemplateDao(org.ovirt.engine.core.dao.VmTemplateDao) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) RemoveVMVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.RemoveVMVDSCommandParameters) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) Map(java.util.Map) VmTemplateImportExportParameters(org.ovirt.engine.core.common.action.VmTemplateImportExportParameters) RemoveAllVmImagesParameters(org.ovirt.engine.core.common.action.RemoveAllVmImagesParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) List(java.util.List) RemoveVmTemplateCommand(org.ovirt.engine.core.bll.RemoveVmTemplateCommand) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Example 10 with GetAllFromExportDomainQueryParameters

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()));
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)

Aggregations

GetAllFromExportDomainQueryParameters (org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters)11 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)6 Guid (org.ovirt.engine.core.compat.Guid)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 Inject (com.google.inject.Inject)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)2