PortApi portApi = api.getPortApi(region);
Network network = networkApi.create(Network.createOptions("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
assertNotNull(network);
Subnet subnet = subnetApi.create(Subnet.createOptions(network.getId(), "192.168.0.0/16").ipVersion(4).build());
assertNotNull(subnet);
Network network2 = networkApi.create(Network.createOptions("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build());
assertNotNull(network2);
Subnet subnet2 = subnetApi.create(Subnet.createOptions(network2.getId(), "192.169.0.0/16").ipVersion(4).build());
assertNotNull(subnet2);
Port port = portApi.create(Port.createOptions(network.getId()).build());
assertNotNull(port);
Port port2 = portApi.create(Port.createOptions(network2.getId()).build());
assertNotNull(port2);
Router router = routerApi.create(Router.createOptions().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()));
}
}