diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java index 9c1abc26cb..98b9a149e6 100644 --- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java +++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java @@ -17,6 +17,7 @@ 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.Map; @@ -77,7 +78,9 @@ public class InstanceInZoneToNodeMetadata implements Function tags = FluentIterable.from(input.getTags().getItems()) .filter(Predicates.not(firewallTagNamingConvention.get(group).isFirewallTag())); diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java index b5d74ed5d4..04ebaf4658 100644 --- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java +++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java @@ -232,6 +232,14 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions { return GoogleComputeEngineTemplateOptions.class.cast(super.userMetadata(key, value)); } + /** + * {@inheritDoc} + */ + @Override + public GoogleComputeEngineTemplateOptions nodeNames(Iterable nodeNames) { + return GoogleComputeEngineTemplateOptions.class.cast(super.nodeNames(nodeNames)); + } + /** * {@inheritDoc} */ diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java index 0d28673bd7..52d807c466 100644 --- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java +++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java @@ -31,12 +31,12 @@ import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; -import com.google.common.collect.Sets; import org.jclouds.Constants; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.functions.GroupNamingConvention; +import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; @@ -47,16 +47,16 @@ import org.jclouds.googlecomputeengine.config.UserProject; import org.jclouds.googlecomputeengine.domain.Firewall; import org.jclouds.googlecomputeengine.domain.Network; import org.jclouds.googlecomputeengine.domain.Operation; -import org.jclouds.googlecomputeengine.features.FirewallApi; import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange; +import org.jclouds.googlecomputeengine.features.FirewallApi; import org.jclouds.googlecomputeengine.options.FirewallOptions; -import org.jclouds.net.domain.IpProtocol; import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -124,6 +124,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet extends Network network = getOrCreateNetwork(templateOptions, sharedResourceName); getOrCreateFirewalls(templateOptions, network, firewallTagNamingConvention.get(group)); templateOptions.network(network.getSelfLink()); + templateOptions.userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group); return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses); } diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java index c0161a09e2..c6ea7eba6e 100644 --- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java +++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java @@ -19,7 +19,6 @@ package org.jclouds.googlecomputeengine.compute; import static com.google.common.collect.Iterables.getOnlyElement; import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; -import static org.jclouds.googlecomputeengine.features.FirewallApiExpectTest.GET_FIREWALL_REQUEST; import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_REQUEST; import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_RESPONSE; import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_GOOGLE_IMAGES_REQUEST; @@ -162,7 +161,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin } } - private HttpRequest createInstanceRequestForInstance(String instanceName, String networkName, String publicKey) { + private HttpRequest createInstanceRequestForInstance(String instanceName, String groupName, + String networkName, String publicKey) { return HttpRequest .builder() .method("POST") @@ -180,7 +180,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin "\"accessConfigs\":[{\"type\":\"ONE_TO_ONE_NAT\"}]}]," + "\"metadata\":{\"kind\":\"compute#metadata\",\"items\":[{\"key\":\"sshKeys\"," + "\"value\":\"jclouds:" + - publicKey + " jclouds@localhost\"}]}}", + publicKey + " jclouds@localhost\"},{\"key\":\"jclouds-group\"," + + "\"value\":\"" + groupName + "\"}]}}", MediaType.APPLICATION_JSON)).build(); } @@ -440,7 +441,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin .add(LIST_PROJECT_IMAGES_REQUEST) .add(LIST_GOOGLE_IMAGES_REQUEST) .add(LIST_MACHINE_TYPES_REQUEST) - .add(createInstanceRequestForInstance("test-1", "jclouds-test", openSshKey)) + .add(createInstanceRequestForInstance("test-1", "test", "jclouds-test", openSshKey)) .add(GET_ZONE_OPERATION_REQUEST) .add(getInstanceRequestForInstance("test-1")) .add(SET_TAGS_REQUEST)