public void testListNetworks() { for (String zoneId : quantumContext.getApi().getConfiguredZones()) { Set<? extends Reference> ids = quantumContext.getApi().getNetworkApiForZone(zoneId).listReferences().toImmutableSet(); Set<? extends Network> networks = quantumContext.getApi().getNetworkApiForZone(zoneId).list().toImmutableSet(); assertNotNull(ids); assertEquals(ids.size(), networks.size()); for (Network network : networks) { assertNotNull(network.getName()); assertTrue(ids.contains(Reference.builder().id(network.getId()).build())); } } }
public void testCreateUpdateAndDeleteNetwork() { for (String zoneId : quantumContext.getApi().getConfiguredZones()) { NetworkApi api = quantumContext.getApi().getNetworkApiForZone(zoneId); Reference net = api.create("jclouds-test"); assertNotNull(net); Network network = api.get(net.getId()); NetworkDetails details = api.getDetails(net.getId()); for (Network checkme : ImmutableList.of(network, details)) { assertEquals(checkme.getId(), net.getId()); assertEquals(checkme.getName(), "jclouds-test"); } assertTrue(details.getPorts().isEmpty()); assertTrue(api.rename(net.getId(), "jclouds-live-test")); // Grab the updated metadata network = api.get(net.getId()); details = api.getDetails(net.getId()); for (Network checkme : ImmutableList.of(network, details)) { assertEquals(checkme.getId(), net.getId()); assertEquals(checkme.getName(), "jclouds-live-test"); } assertTrue(details.getPorts().isEmpty()); Reference net2 = api.create("jclouds-test2"); assertNotNull(net2); assertTrue(api.delete(net.getId())); assertTrue(api.delete(net2.getId())); } }