use of com.att.cdp.openstack.model.OpenStackSubnet in project AJSC by att.
the class OpenStackNetworkService method getSubnetById.
/**
* @see com.att.cdp.zones.NetworkService#getSubnetById(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Subnet getSubnetById(String id) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SUBNET, id);
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
try {
Quantum client = quantumConnector.getClient();
SubnetsResource resource = client.subnets();
for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
if (net.getId().equals(id)) {
return new OpenStackSubnet(context, net);
}
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return null;
}
use of com.att.cdp.openstack.model.OpenStackSubnet in project AJSC by att.
the class OpenStackNetworkService method createSubnet.
@Override
public Subnet createSubnet(Subnet subnet) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SUBNET, subnet.getName());
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
try {
Quantum client = quantumConnector.getClient();
com.woorea.openstack.quantum.model.Subnet subnetToCreate = new com.woorea.openstack.quantum.model.Subnet();
subnetToCreate.setName(subnet.getName());
subnetToCreate.setNetworkId(subnet.getNetwork());
subnetToCreate.setCidr(subnet.getRouting());
subnetToCreate.setGw(subnet.getGatewayIp());
subnetToCreate.setEnableDHCP(subnet.isDhcp());
subnetToCreate.setDnsNames(subnet.getDns());
if (subnet.isIpv4()) {
subnetToCreate.setIpversion(IpVersion.IPV4);
} else {
subnetToCreate.setIpversion(IpVersion.IPV6);
}
if (!subnet.getHostRoutes().isEmpty()) {
List<com.woorea.openstack.quantum.model.Route> routesToCreate = new ArrayList<>();
List<Route> routes = subnet.getHostRoutes();
for (Route route : routes) {
com.woorea.openstack.quantum.model.Route newRoute = new com.woorea.openstack.quantum.model.Route();
newRoute.setDestination(route.getDestination());
newRoute.setNexthop(route.getNexthop());
routesToCreate.add(newRoute);
}
subnetToCreate.setHostRoutes(routesToCreate);
}
com.woorea.openstack.quantum.model.Subnet openstackSubnet = client.subnets().create(subnetToCreate).execute();
return new OpenStackSubnet(context, openstackSubnet);
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return null;
}
use of com.att.cdp.openstack.model.OpenStackSubnet in project AJSC by att.
the class OpenStackNetworkService method getSubnetsByName.
/**
* @see com.att.cdp.zones.NetworkService#getSubnetsByName(java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public List<Subnet> getSubnetsByName(String name) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SUBNET, name);
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
List<Subnet> list = new ArrayList<>();
try {
Quantum client = quantumConnector.getClient();
SubnetsResource resource = client.subnets();
for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
if (net.getName().equals(name)) {
list.add(new OpenStackSubnet(context, net));
}
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
use of com.att.cdp.openstack.model.OpenStackSubnet in project AJSC by att.
the class OpenStackNetworkService method getSubnets.
/**
* @see com.att.cdp.zones.NetworkService#getSubnets()
*/
@SuppressWarnings("nls")
@Override
public List<Subnet> getSubnets() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Network");
RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
ArrayList<Subnet> list = new ArrayList<>();
try {
Quantum client = quantumConnector.getClient();
SubnetsResource resource = client.subnets();
for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
list.add(new OpenStackSubnet(context, net));
}
} catch (OpenStackBaseException e) {
ExceptionMapper.mapException(e);
}
return list;
}
Aggregations