Search in sources :

Example 6 with ExternalSubnet

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

the class OpenStackSubnetMapper method map.

@Mapping(from = OpenStackSubnet.class, to = ExternalSubnet.class)
public static ExternalSubnet map(OpenStackSubnet model, ExternalSubnet template) {
    ExternalSubnet entity = template != null ? template : new ExternalSubnet();
    if (model.isSetId()) {
        entity.setId(model.getId());
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetCidr()) {
        entity.setCidr(model.getCidr());
    }
    if (model.isSetIpVersion()) {
        entity.setIpVersion(IpVersionMapper.map(IpVersion.fromValue(model.getIpVersion())));
    }
    if (model.isSetGateway()) {
        entity.setGateway(model.getGateway());
    }
    List<String> entityDnsServers = new ArrayList<>(1);
    if (model.isSetDnsServers()) {
        List<String> modelDnsServers = model.getDnsServers().getDnsServers();
        entityDnsServers.addAll(modelDnsServers);
    }
    entity.setDnsServers(entityDnsServers);
    return entity;
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet) ArrayList(java.util.ArrayList) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 7 with ExternalSubnet

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

the class BackendOpenStackSubnetResource method get.

@Override
public OpenStackSubnet get() {
    GetExternalSubnetsOnProviderByExternalNetworkQueryParameters parameters = new GetExternalSubnetsOnProviderByExternalNetworkQueryParameters();
    parameters.setProviderId(asGuid(providerId));
    parameters.setNetworkId(networkId);
    List<ExternalSubnet> subnets = getBackendCollection(ExternalSubnet.class, QueryType.GetExternalSubnetsOnProviderByExternalNetwork, parameters);
    if (subnets != null) {
        for (ExternalSubnet subnet : subnets) {
            if (Objects.equals(subnet.getId(), id)) {
                return addLinks(populate(map(subnet), subnet));
            }
        }
    }
    return notFound();
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet) GetExternalSubnetsOnProviderByExternalNetworkQueryParameters(org.ovirt.engine.core.common.queries.GetExternalSubnetsOnProviderByExternalNetworkQueryParameters)

Example 8 with ExternalSubnet

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

the class BackendOpenStackSubnetResource method remove.

@Override
public Response remove() {
    ExternalSubnet subnet = lookupSubnetById(id);
    if (subnet != null) {
        ExternalSubnetParameters parameters = new ExternalSubnetParameters();
        parameters.setSubnet(subnet);
        return performAction(ActionType.RemoveSubnetFromProvider, parameters);
    }
    throw new WebApplicationException(Response.Status.NOT_FOUND);
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet) WebApplicationException(javax.ws.rs.WebApplicationException) ExternalSubnetParameters(org.ovirt.engine.core.common.action.ExternalSubnetParameters)

Example 9 with ExternalSubnet

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

the class BackendOpenStackSubnetResourceTest method getEntity.

@Override
protected ExternalSubnet getEntity(int index) {
    ExternalSubnet subnet = mock(ExternalSubnet.class);
    when(subnet.getId()).thenReturn(string2hex(NAMES[index]));
    when(subnet.getName()).thenReturn(NAMES[index]);
    return subnet;
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet)

Example 10 with ExternalSubnet

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

the class BaseNetworkProviderProxy method map.

private ExternalSubnet map(Subnet subnet, ProviderNetwork network) {
    ExternalSubnet s = new ExternalSubnet();
    s.setId(subnet.getId());
    s.setCidr(subnet.getCidr());
    s.setIpVersion(Subnet.IpVersion.IPV6.equals(subnet.getIpversion()) ? IpVersion.IPV6 : IpVersion.IPV4);
    s.setName(subnet.getName());
    s.setExternalNetwork(network);
    s.setGateway(subnet.getGw());
    s.setDnsServers(subnet.getDnsNames());
    return s;
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet)

Aggregations

ExternalSubnet (org.ovirt.engine.core.common.businessentities.network.ExternalSubnet)12 ArrayList (java.util.ArrayList)4 Subnet (com.woorea.openstack.quantum.model.Subnet)3 ExternalSubnetParameters (org.ovirt.engine.core.common.action.ExternalSubnetParameters)2 Subnets (com.woorea.openstack.quantum.model.Subnets)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Mapping (org.ovirt.engine.api.restapi.types.Mapping)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 AddExternalSubnetParameters (org.ovirt.engine.core.common.action.AddExternalSubnetParameters)1 GetExternalSubnetsOnProviderByExternalNetworkQueryParameters (org.ovirt.engine.core.common.queries.GetExternalSubnetsOnProviderByExternalNetworkQueryParameters)1