private void validateFirewall(Firewall firewall, Network network) { if (firewall == null || !firewall.network().equals(network.selfLink())) { throw new IllegalArgumentException(String.format("Can't find firewall %s in network %s.", firewall.name(), network)); } }
private void validateFirewall(Firewall firewall, Network network) { if (firewall == null || !firewall.network().equals(network.selfLink())) { throw new IllegalArgumentException(String.format("Can't find firewall %s in network %s.", firewall.name(), network)); } }
private void validateFirewall(Firewall firewall, Network network) { if (firewall == null || !firewall.network().equals(network.selfLink())) { throw new IllegalArgumentException(String.format("Can't find firewall %s in network %s.", firewall.name(), network)); } }
private void cleanUpFirewallsForGroup(final String groupName) { GroupNamingConvention namingScheme = namingConvention.create(); FirewallApi firewallApi = api.firewalls(); for (Firewall firewall : concat(firewallApi.list())) { String foundGroup = namingScheme.groupInUniqueNameOrNull(firewall.name()); if ((foundGroup != null) && foundGroup.equals(groupName)){ AtomicReference<Operation> operation = Atomics.newReference(firewallApi.delete(firewall.name())); operationDone.apply(operation); if (operation.get().httpErrorStatusCode() != null) { logger.warn("delete orphaned firewall %s failed. Http Error Code: %d HttpError: %s", operation.get().targetId(), operation.get().httpErrorStatusCode(), operation.get().httpErrorMessage()); } } } }
private void cleanUpFirewallsForGroup(final String groupName) { GroupNamingConvention namingScheme = namingConvention.create(); FirewallApi firewallApi = api.firewalls(); for (Firewall firewall : concat(firewallApi.list())) { String foundGroup = namingScheme.groupInUniqueNameOrNull(firewall.name()); if ((foundGroup != null) && foundGroup.equals(groupName)){ AtomicReference<Operation> operation = Atomics.newReference(firewallApi.delete(firewall.name())); operationDone.apply(operation); if (operation.get().httpErrorStatusCode() != null) { logger.warn("delete orphaned firewall %s failed. Http Error Code: %d HttpError: %s", operation.get().targetId(), operation.get().httpErrorStatusCode(), operation.get().httpErrorMessage()); } } } }
private void cleanUpFirewallsForGroup(final String groupName) { GroupNamingConvention namingScheme = namingConvention.create(); FirewallApi firewallApi = api.firewalls(); for (Firewall firewall : concat(firewallApi.list())) { String foundGroup = namingScheme.groupInUniqueNameOrNull(firewall.name()); if ((foundGroup != null) && foundGroup.equals(groupName)){ AtomicReference<Operation> operation = Atomics.newReference(firewallApi.delete(firewall.name())); operationDone.apply(operation); if (operation.get().httpErrorStatusCode() != null) { logger.warn("delete orphaned firewall %s failed. Http Error Code: %d HttpError: %s", operation.get().targetId(), operation.get().httpErrorStatusCode(), operation.get().httpErrorMessage()); } } } }
private void assertFirewallEquals(Firewall result, FirewallOptions expected) { assertEquals(result.name(), expected.name()); assertEquals(getOnlyElement(result.sourceRanges()), getOnlyElement(expected.sourceRanges())); assertEquals(getOnlyElement(result.sourceTags()), getOnlyElement(expected.sourceTags())); assertEquals(getOnlyElement(result.targetTags()), getOnlyElement(expected.targetTags())); assertEquals(result.allowed(), expected.getAllowed()); } }
private void cleanUpNetworksAndFirewallsForGroup(final String groupName) { String resourceName = namingConvention.create().sharedNameForGroup(groupName); Network network = api.networks().get(resourceName); FirewallApi firewallApi = api.firewalls(); if (network != null) { for (Firewall firewall : concat(firewallApi.list())) { if (firewall == null || firewall.network() == null || !firewall.network().equals(network.selfLink())) { continue; } AtomicReference<Operation> operation = Atomics.newReference(firewallApi.delete(firewall.name())); operationDone.apply(operation); if (operation.get().httpErrorStatusCode() != null) { logger.warn("delete orphaned firewall %s failed. Http Error Code: %d HttpError: %s", operation.get().targetId(), operation.get().httpErrorStatusCode(), operation.get().httpErrorMessage()); } } AtomicReference<Operation> operation = Atomics.newReference(api.networks().delete(resourceName)); operationDone.apply(operation); if (operation.get().httpErrorStatusCode() != null) { logger.warn("delete orphaned network failed. Http Error Code: " + operation.get().httpErrorStatusCode() + " HttpError: " + operation.get().httpErrorMessage()); } } }