Search in sources :

Example 11 with ErrataData

use of org.ovirt.engine.core.common.businessentities.ErrataData in project ovirt-engine by oVirt.

the class BackendHostKatelloErrataResource method list.

@Override
public KatelloErrata list() {
    ErrataData errataData = null;
    try {
        QueryReturnValue returnValue = runQuery(QueryType.GetErrataForHost, new GetErrataCountsParameters(asGuid(hostId)));
        if (!returnValue.getSucceeded()) {
            backendFailure(returnValue.getExceptionString());
        }
        errataData = returnValue.getReturnValue();
    } catch (Exception e) {
        handleError(e, false);
    }
    if (errataData == null) {
        return new KatelloErrata();
    }
    return mapCollection(errataData.getErrata());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ErrataData(org.ovirt.engine.core.common.businessentities.ErrataData) GetErrataCountsParameters(org.ovirt.engine.core.common.queries.GetErrataCountsParameters) KatelloErrata(org.ovirt.engine.api.model.KatelloErrata)

Example 12 with ErrataData

use of org.ovirt.engine.core.common.businessentities.ErrataData in project ovirt-engine by oVirt.

the class GetErrataCountsForHostQueryTest method setupToReportErrata.

@SuppressWarnings("unchecked")
private void setupToReportErrata(List<Erratum> errata) {
    when(host.getHostProviderId()).thenReturn(mock(Guid.class));
    when(vdsStaticDao.get(any())).thenReturn(host);
    when(providerDao.get(any())).thenReturn(mock(Provider.class));
    doReturn(providerProxy).when(getQuery()).getHostProviderProxy(any());
    ErrataData errataData = mock(ErrataData.class);
    ErrataCounts errataCounts = mock(ErrataCounts.class);
    when(errataData.getErrataCounts()).thenReturn(errataCounts);
    Stream.of(ErrataType.values()).forEach(type -> when(errataCounts.getCountByType(type)).thenReturn((int) errata.stream().filter(erratum -> erratum.getType() == type).count()));
    doReturn(errataData).when(providerProxy).getErrataForHost(any(), any());
}
Also used : ErrataData(org.ovirt.engine.core.common.businessentities.ErrataData) ErrataCounts(org.ovirt.engine.core.common.businessentities.ErrataCounts) Guid(org.ovirt.engine.core.compat.Guid) Provider(org.ovirt.engine.core.common.businessentities.Provider)

Example 13 with ErrataData

use of org.ovirt.engine.core.common.businessentities.ErrataData in project ovirt-engine by oVirt.

the class GetErrataForHostQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VdsStatic host = hostStaticDao.get(getParameters().getId());
    if (host == null || host.getHostProviderId() == null) {
        getQueryReturnValue().setReturnValue(ErrataData.emptyData());
        return;
    }
    Provider<?> provider = providerDao.get(host.getHostProviderId());
    if (provider != null) {
        HostProviderProxy proxy = providerProxyFactory.create(provider);
        ErrataData errataForHost = proxy.getErrataForHost(host.getHostName(), getParameters().getErrataFilter());
        getQueryReturnValue().setReturnValue(errataForHost);
    } else {
        getQueryReturnValue().setReturnValue(ErrataData.emptyData());
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) ErrataData(org.ovirt.engine.core.common.businessentities.ErrataData) HostProviderProxy(org.ovirt.engine.core.bll.host.provider.HostProviderProxy)

Example 14 with ErrataData

use of org.ovirt.engine.core.common.businessentities.ErrataData in project ovirt-engine by oVirt.

the class GetErrataForVmQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VM vm = vmDao.get(getParameters().getId());
    if (vm == null || vm.getDynamicData().getVmHost() == null) {
        getQueryReturnValue().setReturnValue(ErrataData.emptyData());
        return;
    }
    Provider<?> provider = providerDao.get(vm.getProviderId());
    if (provider != null) {
        HostProviderProxy proxy = providerProxyFactory.create(provider);
        ErrataData errataForVm = proxy.getErrataForHost(vm.getDynamicData().getVmHost(), getParameters().getErrataFilter());
        getQueryReturnValue().setReturnValue(errataForVm);
    } else {
        getQueryReturnValue().setReturnValue(ErrataData.emptyData());
    }
}
Also used : ErrataData(org.ovirt.engine.core.common.businessentities.ErrataData) VM(org.ovirt.engine.core.common.businessentities.VM) HostProviderProxy(org.ovirt.engine.core.bll.host.provider.HostProviderProxy)

Aggregations

ErrataData (org.ovirt.engine.core.common.businessentities.ErrataData)14 HostProviderProxy (org.ovirt.engine.core.bll.host.provider.HostProviderProxy)5 GetErrataCountsParameters (org.ovirt.engine.core.common.queries.GetErrataCountsParameters)4 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)4 KatelloErrata (org.ovirt.engine.api.model.KatelloErrata)3 VM (org.ovirt.engine.core.common.businessentities.VM)2 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)2 IOException (java.io.IOException)1 ErrataCounts (org.ovirt.engine.core.common.businessentities.ErrataCounts)1 Provider (org.ovirt.engine.core.common.businessentities.Provider)1 Guid (org.ovirt.engine.core.compat.Guid)1