use of com.att.cdp.zones.model.Route 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.zones.model.Route in project AJSC by att.
the class TestNetworkService method createSubnetWithHostRoutes.
/**
* Verifies that we can create a subnet with a specified set of host routes on a provider
*
* @throws ZoneException
* If the connection fails, user is not authorized, or the provider cannot perform the operation.
*/
@Test
@Ignore
public void createSubnetWithHostRoutes() throws ZoneException {
Context context = connect();
NetworkService service = context.getNetworkService();
try {
// verify test network exists
verifyTestNetworkHelper();
List<Network> networks = service.getNetworksByName("CDP_Test_Network");
assertNotNull(networks);
assertFalse(networks.isEmpty());
Network testNetwork = networks.get(0);
Subnet subnetWithGateway = new Subnet();
subnetWithGateway.setName("CDP_Test_IPV4_Subnet_With_Host_Routes");
subnetWithGateway.setNetwork(testNetwork.getId());
subnetWithGateway.setIpv4(true);
subnetWithGateway.setRouting("10.10.40.0/24");
subnetWithGateway.setGatewayIp("10.10.40.1");
List<Route> hostRoutes = new ArrayList<Route>();
Route newRoute1 = new Route();
Route newRoute2 = new Route();
newRoute1.setDestination("10.10.10.0/24");
newRoute1.setNexthop("10.10.20.1");
newRoute2.setDestination("10.10.30.0/24");
newRoute2.setNexthop("10.10.40.1");
hostRoutes.add(newRoute1);
hostRoutes.add(newRoute2);
subnetWithGateway.setHostRoutes(hostRoutes);
service.createSubnet(subnetWithGateway);
List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_With_Host_Routes");
assertFalse(subnets.isEmpty());
for (Subnet subnet : subnets) {
assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.40.0/24"));
assertTrue(subnet.getGatewayIp().equalsIgnoreCase("10.10.40.1"));
assertFalse(subnet.getHostRoutes().isEmpty());
assertTrue(subnet.getHostRoutes().contains(newRoute1));
assertTrue(subnet.getHostRoutes().contains(newRoute2));
}
} catch (ZoneException ze) {
ze.printStackTrace();
fail("Failed to create the ipv4 test subnet with host routes");
}
}
Aggregations