public void testCreateAndDeleteRouterInterfaceForPort() {
for (String zone : api.getConfiguredZones()) {
RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
NetworkApi networkApi = api.getNetworkApiForZone(zone);
SubnetApi subnetApi = api.getSubnetApiForZone(zone);
PortApi portApi = api.getPortApiForZone(zone);
Network network = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
assertNotNull(network);
Subnet subnet = subnetApi.create(network.getId(), 4, "192.168.0.0/16");
assertNotNull(subnet);
Network network2 = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build());
assertNotNull(network2);
Subnet subnet2 = subnetApi.create(network2.getId(), 4, "192.169.0.0/16");
assertNotNull(subnet2);
Port port = portApi.create(network.getId());
assertNotNull(port);
Port port2 = portApi.create(network2.getId());
assertNotNull(port2);
Router router = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test").build());
assertNotNull(router);
RouterInterface routerInterface = routerApi.addInterfaceForPort(router.getId(), port.getId());
assertNotNull(routerInterface);
RouterInterface routerInterface2 = routerApi.addInterfaceForPort(router.getId(), port2.getId());
assertNotNull(routerInterface2);
assertTrue(routerApi.removeInterfaceForPort(router.getId(), port.getId()));
assertTrue(routerApi.removeInterfaceForPort(router.getId(), port2.getId()));
assertTrue(routerApi.delete(router.getId()));
assertTrue(subnetApi.delete(subnet.getId()));
assertTrue(networkApi.delete(network.getId()));
assertTrue(subnetApi.delete(subnet2.getId()));
assertTrue(networkApi.delete(network2.getId()));
}
}