Search in sources :

Example 1 with ExternalProvider

use of org.ovirt.engine.api.model.ExternalProvider in project ovirt-engine by oVirt.

the class BackendExternalProviderHelperTest method completeExternalProvidersTest.

@Test
public void completeExternalProvidersTest() {
    setUpQueryExpectations();
    ExternalProviders providers = getExternalProviders(PROVIDER_COUNT);
    BackendExternalProviderHelper.completeExternalProviders(resource, providers);
    List<ExternalProvider> providerList = providers.getExternalProviders();
    for (int i = 0; i < PROVIDER_COUNT; i++) {
        verifyModel(providerList.get(i), i);
    }
}
Also used : ExternalProvider(org.ovirt.engine.api.model.ExternalProvider) ExternalProviders(org.ovirt.engine.api.model.ExternalProviders) Test(org.junit.Test)

Example 2 with ExternalProvider

use of org.ovirt.engine.api.model.ExternalProvider in project ovirt-engine by oVirt.

the class ClusterMapper method map.

@Mapping(from = org.ovirt.engine.api.model.Cluster.class, to = Cluster.class)
public static Cluster map(org.ovirt.engine.api.model.Cluster model, Cluster template) {
    Cluster entity = template != null ? template : new Cluster();
    if (model.isSetSwitchType()) {
        entity.setRequiredSwitchTypeForCluster(SwitchTypeMapper.mapFromModel(model.getSwitchType()));
    }
    if (model.isSetFirewallType()) {
        entity.setFirewallType(FirewallTypeMapper.mapFromModel(model.getFirewallType()));
    }
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetDescription()) {
        entity.setDescription(model.getDescription());
    }
    if (model.isSetComment()) {
        entity.setComment(model.getComment());
    }
    if (model.isSetCpu() && model.getCpu().isSetType()) {
        entity.setCpuName(model.getCpu().getType());
    }
    if (model.isSetCpu() && model.getCpu().isSetArchitecture()) {
        entity.setArchitecture(CPUMapper.map(model.getCpu().getArchitecture(), null));
    }
    if (model.isSetDataCenter() && model.getDataCenter().isSetId()) {
        entity.setStoragePoolId(GuidUtils.asGuid(model.getDataCenter().getId()));
    }
    if (model.isSetVersion() && model.getVersion().getMajor() != null && model.getVersion().getMinor() != null) {
        entity.setCompatibilityVersion(VersionMapper.map(model.getVersion()));
    }
    if (model.isSetMemoryPolicy()) {
        entity = map(model.getMemoryPolicy(), entity);
    } else if (model.isSetVersion() && model.getVersion().getMajor() != null && model.getVersion().getMinor() != null && greaterOrEqual(model.getVersion(), min_thp_version)) {
        entity.setTransparentHugepages(true);
    }
    SchedulingPolicy schedulingPolicy = model.getSchedulingPolicy();
    if (schedulingPolicy != null) {
        if (schedulingPolicy.isSetName()) {
            entity.setClusterPolicyName(schedulingPolicy.getName());
        }
        if (schedulingPolicy.isSetId()) {
            entity.setClusterPolicyId(GuidUtils.asGuid(schedulingPolicy.getId()));
        }
    }
    if (model.isSetErrorHandling() && model.getErrorHandling().isSetOnError()) {
        entity.setMigrateOnError(map(model.getErrorHandling().getOnError(), null));
    }
    if (model.isSetVirtService()) {
        entity.setVirtService(model.isVirtService());
    }
    if (model.isSetGlusterService()) {
        entity.setGlusterService(model.isGlusterService());
    }
    if (model.isSetThreadsAsCores()) {
        entity.setCountThreadsAsCores(model.isThreadsAsCores());
    }
    if (model.isSetTunnelMigration()) {
        entity.setTunnelMigration(model.isTunnelMigration());
    }
    if (model.isSetTrustedService()) {
        entity.setTrustedService(model.isTrustedService());
    }
    if (model.isSetHaReservation()) {
        entity.setHaReservation(model.isHaReservation());
    }
    if (model.isSetOptionalReason()) {
        entity.setOptionalReasonRequired(model.isOptionalReason());
    }
    if (model.isSetMaintenanceReasonRequired()) {
        entity.setMaintenanceReasonRequired(model.isMaintenanceReasonRequired());
    }
    if (model.isSetBallooningEnabled()) {
        entity.setEnableBallooning(model.isBallooningEnabled());
    }
    if (model.isSetKsm()) {
        if (model.getKsm().isSetEnabled()) {
            entity.setEnableKsm(model.getKsm().isEnabled());
        }
        if (model.getKsm().isSetMergeAcrossNodes()) {
            entity.setKsmMergeAcrossNumaNodes(model.getKsm().isMergeAcrossNodes());
        }
    }
    if (model.isSetDisplay() && model.getDisplay().isSetProxy()) {
        entity.setSpiceProxy("".equals(model.getDisplay().getProxy()) ? null : model.getDisplay().getProxy());
    }
    if (model.isSetSerialNumber()) {
        SerialNumberMapper.copySerialNumber(model.getSerialNumber(), entity);
    }
    /*
         * For backward compatibility additional rng sources are presented in <required_rng_sources> together with
         * implicit /dev/urandom or /dev/random source. <required_rng_sources> should be changed to
         * <additional_rng_sources> during next api change.
         */
    if (model.isSetRequiredRngSources()) {
        entity.getAdditionalRngSources().clear();
        entity.getAdditionalRngSources().addAll(RngDeviceMapper.mapRngSources(model.getRequiredRngSources().getRequiredRngSources()));
        entity.getAdditionalRngSources().remove(VmRngDevice.Source.RANDOM);
        entity.getAdditionalRngSources().remove(VmRngDevice.Source.URANDOM);
    }
    if (model.isSetFencingPolicy()) {
        entity.setFencingPolicy(FencingPolicyMapper.map(model.getFencingPolicy(), null));
    }
    if (model.isSetMigration()) {
        ClusterMigrationOptionsMapper.copyMigrationOptions(model.getMigration(), entity);
    }
    if (model.isSetMacPool() && model.getMacPool().isSetId()) {
        entity.setMacPoolId(GuidUtils.asGuid(model.getMacPool().getId()));
    }
    // properties will override thresholds
    if (model.isSetCustomSchedulingPolicyProperties()) {
        Map<String, String> properties = entity.getClusterPolicyProperties();
        if (properties == null) {
            properties = new HashMap<>();
            entity.setClusterPolicyProperties(properties);
        }
        Map<String, String> customProperties = CustomPropertiesParser.toMap(model.getCustomSchedulingPolicyProperties());
        properties.putAll(customProperties);
    }
    if (model.isSetGlusterTunedProfile()) {
        entity.setGlusterTunedProfile(model.getGlusterTunedProfile());
    }
    if (model.isSetExternalNetworkProviders()) {
        List<ExternalProvider> externalNetworkProviders = model.getExternalNetworkProviders().getExternalProviders();
        if (externalNetworkProviders.size() == 0) {
            entity.setDefaultNetworkProviderId(null);
        } else {
            // Ignore everything but the first external provider, because engine's Cluster currently supports
            // only a single external network provider
            String providerId = externalNetworkProviders.get(0).getId();
            entity.setDefaultNetworkProviderId(providerId == null ? null : GuidUtils.asGuid(providerId));
        }
    }
    return entity;
}
Also used : ExternalProvider(org.ovirt.engine.api.model.ExternalProvider) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) SchedulingPolicy(org.ovirt.engine.api.model.SchedulingPolicy)

Example 3 with ExternalProvider

use of org.ovirt.engine.api.model.ExternalProvider in project ovirt-engine by oVirt.

the class V3ExternalProviderInAdapter method adapt.

@Override
public ExternalProvider adapt(V3ExternalProvider from) {
    ExternalProvider to = new ExternalProvider();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetAuthenticationUrl()) {
        to.setAuthenticationUrl(from.getAuthenticationUrl());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetPassword()) {
        to.setPassword(from.getPassword());
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    if (from.isSetRequiresAuthentication()) {
        to.setRequiresAuthentication(from.isRequiresAuthentication());
    }
    if (from.isSetUrl()) {
        to.setUrl(from.getUrl());
    }
    if (from.isSetUsername()) {
        to.setUsername(from.getUsername());
    }
    return to;
}
Also used : ExternalProvider(org.ovirt.engine.api.model.ExternalProvider) V3ExternalProvider(org.ovirt.engine.api.v3.types.V3ExternalProvider) Properties(org.ovirt.engine.api.model.Properties)

Example 4 with ExternalProvider

use of org.ovirt.engine.api.model.ExternalProvider in project ovirt-engine by oVirt.

the class BackendExternalProviderHelperTest method getExternalProvider.

private ExternalProvider getExternalProvider(int index) {
    ExternalProvider externalProvider = new ExternalProvider();
    externalProvider.setName(NAMES[index]);
    if (index == LAST_PROVIDER_INDEX) {
        externalProvider.setId(GUIDS[index].toString());
    }
    return externalProvider;
}
Also used : ExternalProvider(org.ovirt.engine.api.model.ExternalProvider)

Example 5 with ExternalProvider

use of org.ovirt.engine.api.model.ExternalProvider in project ovirt-engine by oVirt.

the class ExternalNetworkProviderConfigurationMapper method map.

@Mapping(from = Provider.class, to = ExternalNetworkProviderConfiguration.class)
public static ExternalNetworkProviderConfiguration map(Provider entity, ExternalNetworkProviderConfiguration template) {
    if (entity == null) {
        return template;
    }
    ExternalNetworkProviderConfiguration model = template == null ? new ExternalNetworkProviderConfiguration() : template;
    model.setId(HexUtils.string2hex(entity.getId().toString()));
    ExternalProvider externalProvider = new ExternalProvider();
    externalProvider.setId(entity.getId().toString());
    model.setExternalNetworkProvider(externalProvider);
    return model;
}
Also used : ExternalProvider(org.ovirt.engine.api.model.ExternalProvider) ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration)

Aggregations

ExternalProvider (org.ovirt.engine.api.model.ExternalProvider)5 Test (org.junit.Test)1 ExternalNetworkProviderConfiguration (org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration)1 ExternalProviders (org.ovirt.engine.api.model.ExternalProviders)1 Properties (org.ovirt.engine.api.model.Properties)1 SchedulingPolicy (org.ovirt.engine.api.model.SchedulingPolicy)1 V3ExternalProvider (org.ovirt.engine.api.v3.types.V3ExternalProvider)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1