Search in sources :

Example 11 with ProviderNetwork

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

the class ExternalNetworkManagerTest method createNetwork.

private Network createNetwork() {
    final Network network = new Network();
    providerNetwork = new ProviderNetwork();
    providerNetwork.setProviderId(PROVIDER_ID);
    network.setProvidedBy(providerNetwork);
    return network;
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)

Example 12 with ProviderNetwork

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

the class NetworkMapper method map.

@Mapping(from = Network.class, to = org.ovirt.engine.core.common.businessentities.network.Network.class)
public static org.ovirt.engine.core.common.businessentities.network.Network map(Network model, org.ovirt.engine.core.common.businessentities.network.Network template) {
    org.ovirt.engine.core.common.businessentities.network.Network entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.network.Network();
    entity.setCluster(template != null && template.getCluster() != null ? template.getCluster() : new NetworkCluster());
    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.isSetDataCenter() && model.getDataCenter().isSetId()) {
        entity.setDataCenterId(GuidUtils.asGuid(model.getDataCenter().getId()));
    }
    if (model.isSetIp()) {
        if (model.getIp().isSetAddress()) {
            entity.setAddr(model.getIp().getAddress());
        }
        if (model.getIp().isSetNetmask()) {
            entity.setSubnet(model.getIp().getNetmask());
        }
        if (model.getIp().isSetGateway()) {
            entity.setGateway(model.getIp().getGateway());
        }
    }
    if (model.isSetVlan()) {
        entity.setVlanId(model.getVlan().getId());
    }
    if (model.isSetStp()) {
        entity.setStp(model.isStp());
    }
    if (model.isSetDisplay()) {
        // for backward compatibility use display tag or usage tag
        entity.getCluster().setDisplay(model.isDisplay());
    }
    if (model.isSetUsages()) {
        List<NetworkUsage> networkUsages = new ArrayList<>();
        for (NetworkUsage usage : model.getUsages().getUsages()) {
            networkUsages.add(usage);
        }
        entity.getCluster().setDisplay(networkUsages.contains(NetworkUsage.DISPLAY));
        entity.getCluster().setMigration(networkUsages.contains(NetworkUsage.MIGRATION));
        entity.getCluster().setManagement(networkUsages.contains(NetworkUsage.MANAGEMENT));
        entity.getCluster().setGluster(networkUsages.contains(NetworkUsage.GLUSTER));
        entity.getCluster().setDefaultRoute(networkUsages.contains(NetworkUsage.DEFAULT_ROUTE));
        entity.setVmNetwork(networkUsages.contains(NetworkUsage.VM));
    }
    if (model.isSetMtu()) {
        entity.setMtu(model.getMtu());
    }
    if (model.isSetRequired()) {
        entity.getCluster().setRequired(model.isRequired());
    }
    if (model.isSetQos()) {
        entity.setQosId(Guid.createGuidFromString(model.getQos().getId()));
    }
    if (model.isSetDnsResolverConfiguration()) {
        entity.setDnsResolverConfiguration(DnsResolverConfigurationMapper.map(entity.getDnsResolverConfiguration(), model.getDnsResolverConfiguration()));
    }
    if (model.isSetExternalProvider() && model.getExternalProvider().isSetId()) {
        ProviderNetwork providerNetwork = new ProviderNetwork();
        providerNetwork.setProviderId(GuidUtils.asGuid(model.getExternalProvider().getId()));
        if (model.isSetExternalProviderPhysicalNetwork() && model.getExternalProviderPhysicalNetwork().isSetId()) {
            providerNetwork.setPhysicalNetworkId(GuidUtils.asGuid(model.getExternalProviderPhysicalNetwork().getId()));
        }
        entity.setProvidedBy(providerNetwork);
    }
    return entity;
}
Also used : NetworkUsage(org.ovirt.engine.api.model.NetworkUsage) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)

Example 13 with ProviderNetwork

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

the class BackendOpenStackNetworkResourceTest method getEntity.

@Override
protected Network getEntity(int index) {
    Network network = mock(Network.class);
    when(network.getId()).thenReturn(GUIDS[index]);
    when(network.getName()).thenReturn(NAMES[index]);
    ProviderNetwork providedBy = new ProviderNetwork();
    providedBy.setProviderId(GUIDS[0]);
    providedBy.setExternalId(string2hex(NAMES[index]));
    when(network.getProvidedBy()).thenReturn(providedBy);
    return network;
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) OpenStackNetwork(org.ovirt.engine.api.model.OpenStackNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)

Example 14 with ProviderNetwork

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

the class BackendOpenStackNetworksResourceTest method getEntity.

@Override
protected Network getEntity(int index) {
    Network network = mock(Network.class);
    when(network.getId()).thenReturn(GUIDS[index]);
    when(network.getName()).thenReturn(NAMES[index]);
    ProviderNetwork providedBy = new ProviderNetwork();
    providedBy.setProviderId(GUIDS[0]);
    providedBy.setExternalId(string2hex(NAMES[index]));
    when(network.getProvidedBy()).thenReturn(providedBy);
    return network;
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) OpenStackNetwork(org.ovirt.engine.api.model.OpenStackNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)

Example 15 with ProviderNetwork

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

the class BackendOpenStackNetworkResource method doImport.

@Override
public Response doImport(Action action) {
    validateParameters(action, "dataCenter.id|name");
    Guid dataCenterId = getDataCenterId(action);
    ProviderNetwork providerNetwork = new ProviderNetwork(new Guid(providerId), id);
    Network network = new Network();
    network.setProvidedBy(providerNetwork);
    network.setDataCenterId(dataCenterId);
    network.setName(getNetwork().getName());
    AddNetworkStoragePoolParameters parameters = new AddNetworkStoragePoolParameters(dataCenterId, network);
    return doAction(ActionType.AddNetwork, parameters, action);
}
Also used : AddNetworkStoragePoolParameters(org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) OpenStackNetwork(org.ovirt.engine.api.model.OpenStackNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)22 Network (org.ovirt.engine.core.common.businessentities.network.Network)13 OpenStackNetwork (org.ovirt.engine.api.model.OpenStackNetwork)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Guid (org.ovirt.engine.core.compat.Guid)2 HashMap (java.util.HashMap)1 Set (java.util.Set)1 NetworkUsage (org.ovirt.engine.api.model.NetworkUsage)1 Mapping (org.ovirt.engine.api.restapi.types.Mapping)1 AbstractQueryTest (org.ovirt.engine.core.bll.AbstractQueryTest)1 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)1 ProviderValidator (org.ovirt.engine.core.bll.provider.ProviderValidator)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 AddExternalSubnetParameters (org.ovirt.engine.core.common.action.AddExternalSubnetParameters)1 AddNetworkStoragePoolParameters (org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters)1 AddNetworkWithSubnetParameters (org.ovirt.engine.core.common.action.AddNetworkWithSubnetParameters)1 Provider (org.ovirt.engine.core.common.businessentities.Provider)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)1