Search in sources :

Example 6 with GetVmTemplateParameters

use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.

the class GetInstanceTypeQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    InstanceType instance;
    GetVmTemplateParameters params = getParameters();
    if (params.getName() != null) {
        instance = vmTemplateDao.getInstanceTypeByName(params.getName(), getUserID(), getParameters().isFiltered());
    } else {
        instance = vmTemplateDao.getInstanceType(getParameters().getId(), getUserID(), getParameters().isFiltered());
    }
    getQueryReturnValue().setReturnValue(instance);
}
Also used : GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

Example 7 with GetVmTemplateParameters

use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.

the class GetVmDataByPoolIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VM vm = vmPoolDao.getVmDataFromPoolByPoolGuid(getParameters().getId(), getUserID(), getParameters().isFiltered());
    if (vm != null) {
        boolean isLatestLoad = vm.isUseLatestVersion();
        boolean loadTemplateData = false;
        Guid vmtGuid = vm.getVmtGuid();
        if (vm.isNextRunConfigurationExists()) {
            QueryReturnValue nextRunRet = backend.runInternalQuery(QueryType.GetVmNextRunConfiguration, new IdQueryParameters(vm.getId()));
            if (nextRunRet != null) {
                VM nextRunVm = nextRunRet.getReturnValue();
                if (nextRunVm != null) {
                    // template version was changed -> load data from template
                    isLatestLoad = nextRunVm.isUseLatestVersion();
                    vmtGuid = nextRunVm.getVmtGuid();
                    loadTemplateData = true;
                }
            }
        }
        VmTemplate templateData = null;
        if (isLatestLoad) {
            QueryReturnValue latestRet = backend.runInternalQuery(QueryType.GetLatestTemplateInChain, new IdQueryParameters(vmtGuid));
            if (latestRet != null) {
                templateData = latestRet.getReturnValue();
            }
        } else if (loadTemplateData) {
            QueryReturnValue templateRet = backend.runInternalQuery(QueryType.GetVmTemplate, new GetVmTemplateParameters(vmtGuid));
            if (templateRet != null) {
                templateData = templateRet.getReturnValue();
            }
        }
        if (templateData != null) {
            VmStatic temp = vm.getStaticData();
            temp.setVmtGuid(vmtGuid);
            temp.setUseLatestVersion(isLatestLoad);
            VmHandler.copyData(templateData, temp);
            vm.setStaticData(temp);
        }
        vmHandler.updateDisksFromDb(vm);
        vmHandler.updateVmInitFromDB(vm.getStaticData(), true);
    }
    getQueryReturnValue().setReturnValue(vm);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with GetVmTemplateParameters

use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.

the class GetVmTemplateQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VmTemplate vmt;
    GetVmTemplateParameters params = getParameters();
    if (params.getName() != null) {
        // If no DC info available, the query will return the first
        Guid storagePoolId = getStoragePoolId();
        // Template with the given name found.
        vmt = vmTemplateDao.getByName(params.getName(), storagePoolId, getUserID(), params.isFiltered());
    } else {
        vmt = vmTemplateDao.get(getParameters().getId(), getUserID(), getParameters().isFiltered());
    }
    if (vmt != null) {
        vmTemplateHandler.updateDisksFromDb(vmt);
        vmHandler.updateVmInitFromDB(vmt, true);
    }
    getQueryReturnValue().setReturnValue(vmt);
}
Also used : GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Guid(org.ovirt.engine.core.compat.Guid)

Example 9 with GetVmTemplateParameters

use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.

the class GetVmTemplateQuery method getStoragePoolId.

// Get the datacenter ID.
private Guid getStoragePoolId() {
    Guid result = null;
    GetVmTemplateParameters params = getParameters();
    if (params.getDataCenterId() != null) {
        result = params.getDataCenterId();
    } else if (params.getClusterId() != null) {
        Cluster cluster = clusterDao.get(params.getClusterId());
        if (cluster != null) {
            result = cluster.getStoragePoolId();
        }
    }
    return result;
}
Also used : GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid)

Example 10 with GetVmTemplateParameters

use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.

the class BackendInstanceTypeResource method get.

@Override
public InstanceType get() {
    InstanceType instanceType = performGet(QueryType.GetInstanceType, new GetVmTemplateParameters(guid));
    DisplayHelper.adjustDisplayData(this, instanceType);
    return instanceType;
}
Also used : GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) InstanceType(org.ovirt.engine.api.model.InstanceType)

Aggregations

GetVmTemplateParameters (org.ovirt.engine.core.common.queries.GetVmTemplateParameters)10 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 Guid (org.ovirt.engine.core.compat.Guid)3 InstanceType (org.ovirt.engine.api.model.InstanceType)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1