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;
}
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();
}
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);
}
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;
}
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;
}
Aggregations