Search in sources :

Example 41 with VdsStatic

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

the class VdsHandlerTest method testInvalidUpdateOfNonEditableFieldOnRunningHost.

@Test
public void testInvalidUpdateOfNonEditableFieldOnRunningHost() {
    // Given
    VdsStatic src = new VdsStatic();
    src.setServerSslEnabled(true);
    VdsStatic dest = new VdsStatic();
    dest.setServerSslEnabled(false);
    // When
    boolean updateIsValid = vdsHandler.isUpdateValid(src, dest, VDSStatus.Up);
    // Then
    assertFalse("Update should not be valid for different server SSL enabled states", updateIsValid);
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Test(org.junit.Test)

Example 42 with VdsStatic

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

the class VdsHandlerTest method testValidUpdateOfStatusRestrictedEditableFieldOnDownHost.

@Test
public void testValidUpdateOfStatusRestrictedEditableFieldOnDownHost() {
    // Given
    int srcSshPort = 22;
    int destSshPort = 23;
    VdsStatic src = new VdsStatic();
    src.setSshPort(srcSshPort);
    VdsStatic dest = new VdsStatic();
    dest.setSshPort(destSshPort);
    // When
    boolean updateIsValid = vdsHandler.isUpdateValid(src, dest, VDSStatus.Down);
    // Then
    assertTrue("Update should be valid for different SSH ports in Down status", updateIsValid);
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Test(org.junit.Test)

Example 43 with VdsStatic

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

the class HostMapper method map.

@Mapping(from = Host.class, to = VdsStatic.class)
public static VdsStatic map(Host model, VdsStatic template) {
    VdsStatic entity = template != null ? template : new VdsStatic();
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetCluster() && model.getCluster().isSetId()) {
        entity.setClusterId(GuidUtils.asGuid(model.getCluster().getId()));
    }
    if (model.isSetAddress()) {
        entity.setHostName(model.getAddress());
    }
    if (model.isSetPort() && model.getPort() > 0) {
        entity.setPort(model.getPort());
    } else {
        entity.setPort(DEFAULT_VDSM_PORT);
    }
    if (model.isSetSsh()) {
        map(model.getSsh(), entity);
    }
    if (model.isSetPowerManagement()) {
        entity = map(model.getPowerManagement(), entity);
    }
    if (model.isSetSpm()) {
        if (model.getSpm().getPriority() != null) {
            entity.setVdsSpmPriority(model.getSpm().getPriority());
        }
    }
    if (model.isSetDisplay() && model.getDisplay().isSetAddress()) {
        entity.setConsoleAddress("".equals(model.getDisplay().getAddress()) ? null : model.getDisplay().getAddress());
    }
    if (model.isSetComment()) {
        entity.setComment(model.getComment());
    }
    if (model.isSetExternalHostProvider()) {
        String providerId = model.getExternalHostProvider().getId();
        entity.setHostProviderId(providerId == null ? null : GuidUtils.asGuid(providerId));
    }
    if (model.isSetOs()) {
        mapOperatingSystem(model.getOs(), entity);
    }
    if (model.isSetExternalNetworkProviderConfigurations() && model.getExternalNetworkProviderConfigurations().isSetExternalNetworkProviderConfigurations()) {
        List<ExternalNetworkProviderConfiguration> externalProviders = model.getExternalNetworkProviderConfigurations().getExternalNetworkProviderConfigurations();
        if (externalProviders.size() > 0) {
            // Ignore everything but the first external provider, because engine's VdsStatic currently supports
            // only a single external network provider
            String providerId = externalProviders.get(0).getExternalNetworkProvider().getId();
            entity.setOpenstackNetworkProviderId(providerId == null ? null : GuidUtils.asGuid(providerId));
        }
    }
    return entity;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration)

Example 44 with VdsStatic

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

the class HostMapper method mapOperatingSystem.

public static VdsStatic mapOperatingSystem(OperatingSystem model, VdsStatic template) {
    final VdsStatic entity = template != null ? template : new VdsStatic();
    if (model.isSetCustomKernelCmdline()) {
        entity.setCurrentKernelCmdline(model.getCustomKernelCmdline());
        entity.setKernelCmdlineParsable(false);
    }
    return entity;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic)

Example 45 with VdsStatic

use of org.ovirt.engine.core.common.businessentities.VdsStatic 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)

Aggregations

VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)49 Test (org.junit.Test)10 Guid (org.ovirt.engine.core.compat.Guid)8 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 Objects (java.util.Objects)3 Before (org.junit.Before)3 HostProviderProxy (org.ovirt.engine.core.bll.host.provider.HostProviderProxy)3 VdsDynamic (org.ovirt.engine.core.common.businessentities.VdsDynamic)3 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 StringUtils (org.apache.commons.lang.StringUtils)2 Host (org.ovirt.engine.api.model.Host)2