public Network findPrivateNetwork(String accountName, String domainId) { // note: listNetworks includes networks with "null" account Set<Network> networks = client.getNetworkClient().listNetworks(ListNetworksOptions.Builder.accountInDomain(accountName, domainId).isShared(false)); for (Network network : networks) { if (accountName.equals(network.getAccount())) { LOG.debug("Found private network in {} for account {} in domain {}: {}", new Object[] {loc, accountName, domainId, network}); return network; } } LOG.debug("No private network found in {} for account {} in domain {}: contenders {}", new Object[] {loc, accountName, domainId, networks}); return null; }
public void testAccountIdStatic() { ListNetworksOptions options = accountInDomain("moo", "1"); assertEquals(ImmutableList.of("moo"), options.buildQueryParameters().get("account")); assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("domainid")); }
public void testAccountIdStatic() { ListNetworksOptions options = accountInDomain("moo", "1"); assertEquals(ImmutableList.of("moo"), options.buildQueryParameters().get("account")); assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("domainid")); }
@Test public void testListNetworks() throws Exception { if (!networksSupported) return; Set<Network> response = client.getNetworkApi().listNetworks( accountInDomain(user.getAccount(), user.getDomainId())); assert null != response; long networkCount = response.size(); assertTrue(networkCount >= 0); for (Network network : response) { Network newDetails = getOnlyElement(client.getNetworkApi().listNetworks(id(network.getId()))); assertEquals(network, newDetails); assertEquals(network, client.getNetworkApi().getNetwork(network.getId())); checkNetwork(network); } }
@Override public Map<String, Network> get() { User currentUser = currentUserSupplier.get(); NetworkApi networkClient = client.getNetworkApi(); return Maps.uniqueIndex( networkClient.listNetworks(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())), new Function<Network, String>() { @Override public String apply(Network arg0) { return arg0.getId(); } }); } }
@Test public void testListNetworks() throws Exception { if (!networksSupported) return; Set<Network> response = client.getNetworkClient().listNetworks( accountInDomain(user.getAccount(), user.getDomainId())); assert null != response; long networkCount = response.size(); assertTrue(networkCount >= 0); for (Network network : response) { Network newDetails = getOnlyElement(client.getNetworkClient().listNetworks(id(network.getId()))); assertEquals(network, newDetails); assertEquals(network, client.getNetworkClient().getNetwork(network.getId())); checkNetwork(network); } }
@Override public Map<String, Network> get() { User currentUser = currentUserSupplier.get(); NetworkClient networkClient = client.getNetworkClient(); return Maps.uniqueIndex( networkClient.listNetworks(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())), new Function<Network, String>() { @Override public String apply(Network arg0) { return arg0.getId(); } }); } }
@Override public Map<String, Network> get() { User currentUser = currentUserSupplier.get(); NetworkClient networkClient = client.getNetworkClient(); return Maps.uniqueIndex( networkClient.listNetworks(accountInDomain(currentUser.getAccount(), currentUser.getDomainId())), new Function<Network, String>() { @Override public String apply(Network arg0) { return arg0.getId(); } }); } }