Search in sources :

Example 1 with ErrataData

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

the class BackendEngineKatelloErrataResource method list.

@Override
public KatelloErrata list() {
    ErrataData errataData = null;
    try {
        QueryReturnValue returnValue = runQuery(QueryType.GetErrataForEngine, new GetErrataCountsParameters());
        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 2 with ErrataData

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

the class BackendVmKatelloErrataResource method list.

@Override
public KatelloErrata list() {
    ErrataData errataData = null;
    try {
        QueryReturnValue returnValue = runQuery(QueryType.GetErrataForVm, new GetErrataCountsParameters(asGuid(vmId)));
        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 3 with ErrataData

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

the class GetErrataCountsForHostQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VdsStatic host = vdsStaticDao.get(getParameters().getId());
    if (host == null) {
        failWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NOT_EXIST);
        return;
    }
    Provider<?> provider = getHostProvider(host);
    if (provider == null) {
        failWith(EngineMessage.NO_FOREMAN_PROVIDER_FOR_HOST);
        return;
    }
    HostProviderProxy proxy = getHostProviderProxy(provider);
    ErrataData errataForHost = proxy.getErrataForHost(host.getHostName(), getParameters().getErrataFilter());
    setReturnValue(errataForHost.getErrataCounts());
}
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 4 with ErrataData

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

the class GetErrataCountsForVmQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VM vm = vmDao.get(getParameters().getId());
    if (vm == null) {
        failWith(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_EXIST);
        return;
    }
    Provider<?> provider = getHostProvider(vm);
    if (provider == null) {
        failWith(EngineMessage.NO_FOREMAN_PROVIDER_FOR_VM);
        return;
    }
    HostProviderProxy proxy = getHostProviderProxy(provider);
    String vmHostName = vm.getDynamicData().getVmHost();
    if (StringUtils.isBlank(vmHostName)) {
        failWith(EngineMessage.NO_HOST_NAME_FOR_VM);
    }
    ErrataData errataForVm = proxy.getErrataForHost(vmHostName, getParameters().getErrataFilter());
    setReturnValue(errataForVm.getErrataCounts());
}
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)

Example 5 with ErrataData

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

the class KatelloProvider method runErrataListMethod.

protected ErrataData runErrataListMethod(String relativeUrl, String hostName) {
    ErrataData errataData = new ErrataData();
    try {
        ErrataWrapper wrapper = objectMapper.readValue(provider.runHttpGetMethod(relativeUrl), ErrataWrapper.class);
        errataData.setErrata(mapErrata(Arrays.asList(wrapper.getResults())));
        errataData.setErrataCounts(mapErrataCounts(wrapper));
        Stream.of(Erratum.ErrataType.values()).forEach(errataType -> addErrataCountForType(errataData, errataType));
    } catch (Exception e) {
        log.error("Failed to retrieve errata for content host '{}' via url '{}': {}", hostName, relativeUrl, e.getMessage());
        log.debug("Exception", e);
        return ErrataData.emptyData();
    }
    return errataData;
}
Also used : ErrataData(org.ovirt.engine.core.common.businessentities.ErrataData) IOException(java.io.IOException)

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