Search in sources :

Example 1 with HostProviderProxy

use of org.ovirt.engine.core.bll.host.provider.HostProviderProxy 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 2 with HostProviderProxy

use of org.ovirt.engine.core.bll.host.provider.HostProviderProxy 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 3 with HostProviderProxy

use of org.ovirt.engine.core.bll.host.provider.HostProviderProxy in project ovirt-engine by oVirt.

the class GetErrataForEngineQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    HostProviderProxy proxy = engineProviderFinder.findEngineProvider();
    if (proxy == null) {
        getQueryReturnValue().setSucceeded(false);
        getQueryReturnValue().setExceptionString(EngineMessage.NO_FOREMAN_PROVIDER_FOR_ENGINE.name());
        getQueryReturnValue().setReturnValue(ErrataData.emptyData());
    } else {
        ErrataData errataForEngine = proxy.getErrataForHost(engineProviderFinder.getEngineHostName(), getParameters().getErrataFilter());
        setReturnValue(errataForEngine);
    }
}
Also used : ErrataData(org.ovirt.engine.core.common.businessentities.ErrataData) HostProviderProxy(org.ovirt.engine.core.bll.host.provider.HostProviderProxy)

Example 4 with HostProviderProxy

use of org.ovirt.engine.core.bll.host.provider.HostProviderProxy in project ovirt-engine by oVirt.

the class GetErratumByIdForHostQuery method executeQueryCommand.

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

Example 5 with HostProviderProxy

use of org.ovirt.engine.core.bll.host.provider.HostProviderProxy in project ovirt-engine by oVirt.

the class AddVdsCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid oVirtId = getParameters().getVdsForUniqueId();
    if (oVirtId != null) {
        // if fails to remove deprecated entry, we might attempt to add new oVirt host with an existing unique-id.
        if (!removeDeprecatedOvirtEntry(oVirtId)) {
            log.error("Failed to remove duplicated oVirt entry with id '{}'. Abort adding oVirt Host type", oVirtId);
            throw new EngineException(EngineError.HOST_ALREADY_EXISTS);
        }
    }
    completeOpenstackNetworkProviderId();
    TransactionSupport.executeInNewTransaction(() -> {
        addVdsStaticToDb();
        addVdsDynamicToDb();
        addVdsStatisticsToDb();
        addAffinityLabels();
        getCompensationContext().stateChanged();
        return null;
    });
    if (getParameters().isProvisioned()) {
        HostProviderProxy proxy = providerProxyFactory.create(getHostProvider());
        proxy.provisionHost(getParameters().getvds(), getParameters().getHostGroup(), getParameters().getComputeResource(), getParameters().getHostMac(), getParameters().getDiscoverName(), getParameters().getPassword(), getParameters().getDiscoverIp());
        addCustomValue("HostGroupName", getParameters().getHostGroup().getName());
        auditLogDirector.log(this, AuditLogType.VDS_PROVISION);
    }
    // set vds spm id
    if (getCluster().getStoragePoolId() != null) {
        VdsActionParameters tempVar = new VdsActionParameters(getVdsIdRef());
        tempVar.setSessionId(getParameters().getSessionId());
        tempVar.setCompensationEnabled(true);
        ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, tempVar, cloneContext().withoutLock().withoutExecutionContext());
        if (!addVdsSpmIdReturn.getSucceeded()) {
            setSucceeded(false);
            getReturnValue().setFault(addVdsSpmIdReturn.getFault());
            return;
        }
    }
    TransactionSupport.executeInNewTransaction(() -> {
        initializeVds(true);
        alertIfPowerManagementNotConfigured(getParameters().getVdsStaticData());
        testVdsPowerManagementStatus(getParameters().getVdsStaticData());
        setSucceeded(true);
        setActionReturnValue(getVdsIdRef());
        // If the installation failed, we don't want to compensate for the failure since it will remove the
        // host, but instead the host should be left in an "install failed" status.
        getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
        return null;
    });
    // clients). they are installed as part of the approve process or automatically after provision
    if (Config.<Boolean>getValue(ConfigValues.InstallVds) && !getParameters().isPending() && !getParameters().isProvisioned()) {
        final InstallVdsParameters installVdsParameters = new InstallVdsParameters(getVdsId(), getParameters().getPassword());
        installVdsParameters.setAuthMethod(getParameters().getAuthMethod());
        installVdsParameters.setOverrideFirewall(getParameters().getOverrideFirewall());
        installVdsParameters.setActivateHost(getParameters().getActivateHost());
        installVdsParameters.setNetworkProviderId(getParameters().getVdsStaticData().getOpenstackNetworkProviderId());
        installVdsParameters.setNetworkMappings(getParameters().getNetworkMappings());
        installVdsParameters.setEnableSerialConsole(getParameters().getEnableSerialConsole());
        if (getParameters().getHostedEngineDeployConfiguration() != null) {
            Map<String, String> vdsDeployParams = hostedEngineHelper.createVdsDeployParams(getVdsId(), getParameters().getHostedEngineDeployConfiguration().getDeployAction());
            installVdsParameters.setHostedEngineConfiguration(vdsDeployParams);
        }
        Map<String, String> values = new HashMap<>();
        values.put(VdcObjectType.VDS.name().toLowerCase(), getParameters().getvds().getName());
        Step installStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.INSTALLING_HOST, ExecutionMessageDirector.resolveStepMessage(StepEnum.INSTALLING_HOST, values));
        final ExecutionContext installCtx = new ExecutionContext();
        installCtx.setJob(getExecutionContext().getJob());
        installCtx.setStep(installStep);
        installCtx.setMonitored(true);
        installCtx.setShouldEndJob(true);
        ThreadPoolUtil.execute(() -> runInternalAction(ActionType.InstallVdsInternal, installVdsParameters, cloneContextAndDetachFromParent().withExecutionContext(installCtx)));
        ExecutionHandler.setAsyncJob(getExecutionContext(), true);
    }
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HashMap(java.util.HashMap) InstallVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.core.common.job.Step) HostProviderProxy(org.ovirt.engine.core.bll.host.provider.HostProviderProxy)

Aggregations

HostProviderProxy (org.ovirt.engine.core.bll.host.provider.HostProviderProxy)9 ErrataData (org.ovirt.engine.core.common.businessentities.ErrataData)5 VM (org.ovirt.engine.core.common.businessentities.VM)3 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)3 HashMap (java.util.HashMap)1 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)1 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)1 InstallVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters)1 Provider (org.ovirt.engine.core.common.businessentities.Provider)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 Step (org.ovirt.engine.core.common.job.Step)1 Guid (org.ovirt.engine.core.compat.Guid)1