Search in sources :

Example 1 with ExternalSubnet

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

the class ExternalSubnetModel method flush.

public void flush() {
    subnet = new ExternalSubnet();
    subnet.setName(getName().getEntity());
    subnet.setExternalNetwork(getExternalNetwork());
    subnet.setCidr(getCidr().getEntity());
    subnet.setIpVersion(getIpVersion().getSelectedItem());
    subnet.setGateway(getGateway().getEntity());
    List<String> dnsServers = new ArrayList<>();
    for (EntityModel<String> dnsServer : getDnsServers().getItems()) {
        if (StringHelper.isNotNullOrEmpty(dnsServer.getEntity())) {
            dnsServers.add(dnsServer.getEntity());
        }
    }
    subnet.setDnsServers(dnsServers);
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet) ArrayList(java.util.ArrayList)

Example 2 with ExternalSubnet

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

the class BaseNetworkProviderProxy method addSubnet.

@Override
public void addSubnet(ExternalSubnet subnet) {
    com.woorea.openstack.quantum.model.Network externalNetwork = getExternalNetwork(subnet.getExternalNetwork());
    Subnet subnetForCreate = createNewSubnetEntity(subnet, externalNetwork);
    execute(getClient().subnets().create(subnetForCreate));
}
Also used : Subnet(com.woorea.openstack.quantum.model.Subnet) ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet)

Example 3 with ExternalSubnet

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

the class BaseNetworkProviderProxy method getAllSubnets.

@Override
public List<ExternalSubnet> getAllSubnets(ProviderNetwork network) {
    List<ExternalSubnet> result = new ArrayList<>();
    Subnets subnets = execute(getClient().subnets().list());
    for (Subnet subnet : subnets.getList()) {
        if (network.getExternalId().equals(subnet.getNetworkId())) {
            result.add(map(subnet, network));
        }
    }
    return result;
}
Also used : Subnets(com.woorea.openstack.quantum.model.Subnets) ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet) ArrayList(java.util.ArrayList) Subnet(com.woorea.openstack.quantum.model.Subnet) ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet)

Example 4 with ExternalSubnet

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

the class BaseNetworkProviderProxy method createNewSubnetEntity.

protected Subnet createNewSubnetEntity(ExternalSubnet subnet, com.woorea.openstack.quantum.model.Network externalNetwork) {
    Subnet subnetForCreate = new Subnet();
    subnetForCreate.setCidr(subnet.getCidr());
    subnetForCreate.setIpversion(subnet.getIpVersion() == IpVersion.IPV6 ? Subnet.IpVersion.IPV6 : Subnet.IpVersion.IPV4);
    subnetForCreate.setName(subnet.getName());
    subnetForCreate.setNetworkId(externalNetwork.getId());
    subnetForCreate.setEnableDHCP(true);
    subnetForCreate.setGw(subnet.getGateway());
    subnetForCreate.setDnsNames(subnet.getDnsServers());
    subnetForCreate.setTenantId(externalNetwork.getTenantId());
    return subnetForCreate;
}
Also used : Subnet(com.woorea.openstack.quantum.model.Subnet) ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet)

Example 5 with ExternalSubnet

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

the class BackendOpenStackSubnetsResourceTest 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)

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