@Override public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) { checkNotNull(group, "group"); checkNotNull(ipPermission, "ipPermission"); checkNotNull(api.getNetworkApiForProject(userProject.get()).get(group.getId()) == null, "network for group is null"); ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName()); FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat(); for (Firewall fw : fws) { if (equalsIpPermission(ipPermission).apply(fw)) { AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get()) .delete(fw.getName())); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); checkState(!operation.get().getHttpError().isPresent(), "Could not delete firewall, operation failed" + operation); } } return getSecurityGroupById(group.getId()); }
@Override public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) { checkNotNull(group, "group"); checkNotNull(ipPermission, "ipPermission"); checkNotNull(api.getNetworkApiForProject(userProject.get()).get(group.getId()) == null, "network for group is null"); ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName()); FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat(); for (Firewall fw : fws) { if (equalsIpPermission(ipPermission).apply(fw)) { AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get()) .delete(fw.getName())); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); checkState(!operation.get().getHttpError().isPresent(), "Could not delete firewall, operation failed" + operation); } } return getSecurityGroupById(group.getId()); }
@Override public boolean removeSecurityGroup(String id) { checkNotNull(id, "id"); if (api.getNetworkApiForProject(userProject.get()).get(id) == null) { return false; } ListOptions options = new ListOptions.Builder().filter("network eq .*/" + id); FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat(); for (Firewall fw : fws) { AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get()) .delete(fw.getName())); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); checkState(!operation.get().getHttpError().isPresent(), "Could not delete firewall, operation failed" + operation); } AtomicReference<Operation> operation = Atomics.newReference( api.getNetworkApiForProject(userProject.get()).delete(id)); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation); return true; }
@Override public boolean removeSecurityGroup(String id) { checkNotNull(id, "id"); if (api.getNetworkApiForProject(userProject.get()).get(id) == null) { return false; } ListOptions options = new ListOptions.Builder().filter("network eq .*/" + id); FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat(); for (Firewall fw : fws) { AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get()) .delete(fw.getName())); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); checkState(!operation.get().getHttpError().isPresent(), "Could not delete firewall, operation failed" + operation); } AtomicReference<Operation> operation = Atomics.newReference( api.getNetworkApiForProject(userProject.get()).delete(id)); retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(operation); checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation); return true; }
operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName())));
operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName())));