From 465a62aa2767427018d83c2711fd427e90e97ef4 Mon Sep 17 00:00:00 2001 From: Daniel Broudy Date: Wed, 20 May 2015 13:28:57 -0700 Subject: [PATCH] Remove firewall-tag filtering --- .../functions/FirewallTagNamingConvention.java | 12 ------------ .../functions/InstanceToNodeMetadata.java | 17 +---------------- .../functions/InstanceToNodeMetadataTest.java | 13 +------------ 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java index 1fe5928c1d..61e4fd054c 100644 --- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java +++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java @@ -22,8 +22,6 @@ import javax.inject.Inject; import org.jclouds.compute.functions.GroupNamingConvention; -import com.google.common.base.Predicate; - /** * The convention for naming instance tags that firewall rules recognise. */ @@ -58,14 +56,4 @@ public final class FirewallTagNamingConvention { return String.format("%s-%s", sharedResourceName, Integer.toHexString(result)); } - - - public Predicate isFirewallTag() { - return new Predicate() { - @Override - public boolean apply(String input) { - return input != null && input.startsWith(sharedResourceName + "-port-"); - } - }; - } } diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadata.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadata.java index 81e40b9f99..aab8cf9cbf 100644 --- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadata.java +++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadata.java @@ -16,11 +16,9 @@ */ package org.jclouds.googlecomputeengine.compute.functions; -import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.compute.util.ComputeServiceUtils.groupFromMapOrName; import java.net.URI; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -36,7 +34,6 @@ import org.jclouds.domain.Location; import org.jclouds.googlecomputeengine.domain.Instance; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; @@ -47,33 +44,21 @@ public final class InstanceToNodeMetadata implements Function diskToSourceImage; private final Supplier> hardwares; private final Supplier> locationsByUri; - private final FirewallTagNamingConvention.Factory firewallTagNamingConvention; @Inject InstanceToNodeMetadata(Map toPortableNodeStatus, GroupNamingConvention.Factory namingConvention, Map diskToSourceImage, @Memoized Supplier> hardwares, - @Memoized Supplier> locationsByUri, - FirewallTagNamingConvention.Factory firewallTagNamingConvention) { + @Memoized Supplier> locationsByUri) { this.toPortableNodeStatus = toPortableNodeStatus; this.nodeNamingConvention = namingConvention.createWithoutPrefix(); this.diskToSourceImage = diskToSourceImage; this.hardwares = hardwares; this.locationsByUri = locationsByUri; - this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention"); } @Override public NodeMetadata apply(Instance input) { String group = groupFromMapOrName(input.metadata().asMap(), input.name(), nodeNamingConvention); - Predicate isFirewallTag = firewallTagNamingConvention.get(group).isFirewallTag(); - if (group != null) { - for (Iterator tag = input.tags().items().iterator(); tag.hasNext(); ) { - if (isFirewallTag.apply(tag.next())) { - tag.remove(); - } - } - } - NodeMetadataBuilder builder = new NodeMetadataBuilder(); Location zone = locationsByUri.get().get(input.zone()); diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadataTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadataTest.java index 6888b244c3..fff0891139 100644 --- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadataTest.java +++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadataTest.java @@ -178,18 +178,7 @@ public class InstanceToNodeMetadataTest { namingConventionFactory, ImmutableMap.of(instance.disks().get(0).source(), imageUrl), hardwareSupplier, - locationSupplier, - new FirewallTagNamingConvention.Factory(namingConventionFactory)); - } - - @Test - public final void testTagFilteringWorks() { - NodeMetadata nodeMetadata = groupGroupNodeParser.apply(instance); - assertEquals(nodeMetadata.getId(), instance.selfLink().toString()); - assertEquals(nodeMetadata.getTags(), ImmutableSet.of( - "aTag" // "aTag" kept as a non firewall tag. - // "Group-port-42" filtered out as a firewall tag. - )); + locationSupplier); } @Test