Search in sources :

Example 1 with ExternalNetworkProviderConfiguration

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

the class BackendExternalProviderHelper method completeExternalNetworkProviderConfigurations.

/**
 * Completes the identifier that corresponds to the given name of the external network providers in the external
 * network provider configurations the provider. If no such provider exists, an exception will be thrown.
 *
 * @param resource the resource that will be used to perform the required queries
 * @param externalNetworkProviderConfigurations the external network provider configurations which contains the
 *                                              external network providers
 */
public static void completeExternalNetworkProviderConfigurations(BackendResource resource, ExternalNetworkProviderConfigurations externalNetworkProviderConfigurations) {
    if (externalNetworkProviderConfigurations != null) {
        for (ExternalNetworkProviderConfiguration externalNetworkProviderConfiguration : externalNetworkProviderConfigurations.getExternalNetworkProviderConfigurations()) {
            resource.validateParameters(externalNetworkProviderConfiguration, "externalNetworkProvider.id|name");
            completeProviderId(resource, externalNetworkProviderConfiguration.getExternalNetworkProvider());
        }
    }
}
Also used : ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration)

Example 2 with ExternalNetworkProviderConfiguration

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

the class BackendHostExternalNetworkProviderConfigurationResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetProviderById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { PROVIDER_ID }, getEntityList());
    ExternalNetworkProviderConfiguration config = resource.get();
    verifyModel(config, PROVIDER_INDEX);
}
Also used : ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration) Test(org.junit.Test)

Example 3 with ExternalNetworkProviderConfiguration

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

the class BackendExternalProviderHelperTest method getExternalNetworkProviderConfiguration.

private ExternalNetworkProviderConfiguration getExternalNetworkProviderConfiguration(int index) {
    ExternalNetworkProviderConfiguration externalNetworkProviderConfiguration = new ExternalNetworkProviderConfiguration();
    externalNetworkProviderConfiguration.setExternalNetworkProvider(getExternalProvider(index));
    return externalNetworkProviderConfiguration;
}
Also used : ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration)

Example 4 with ExternalNetworkProviderConfiguration

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

the class BackendExternalProviderHelperTest method completeExternalNetworkProviderConfigurationsTest.

@Test
public void completeExternalNetworkProviderConfigurationsTest() {
    setUpQueryExpectations();
    ExternalNetworkProviderConfigurations configurations = getExternalNetworkProviderConfigurations(PROVIDER_COUNT);
    BackendExternalProviderHelper.completeExternalNetworkProviderConfigurations(resource, configurations);
    List<ExternalNetworkProviderConfiguration> configurationList = configurations.getExternalNetworkProviderConfigurations();
    for (int i = 0; i < PROVIDER_COUNT; i++) {
        verifyModel(configurationList.get(i).getExternalNetworkProvider(), i);
    }
}
Also used : ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration) ExternalNetworkProviderConfigurations(org.ovirt.engine.api.model.ExternalNetworkProviderConfigurations) Test(org.junit.Test)

Example 5 with ExternalNetworkProviderConfiguration

use of org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration 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)

Aggregations

ExternalNetworkProviderConfiguration (org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration)6 Test (org.junit.Test)2 ExternalNetworkProviderConfigurations (org.ovirt.engine.api.model.ExternalNetworkProviderConfigurations)1 ExternalProvider (org.ovirt.engine.api.model.ExternalProvider)1 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)1