diff --git a/README.txt b/README.txt index d8ab8e9d21..b57a6a9e2f 100644 --- a/README.txt +++ b/README.txt @@ -95,7 +95,7 @@ Compute Example (Java): template = client.templateBuilder().osFamily(UBUNTU).smallest().build(); // these nodes will be accessible via ssh when the call returns - nodes = client.runNodesWithTag("mycluster", 2, template); + nodes = client.createNodesInGroup("mycluster", 2, template); Compute Example (Clojure): (use 'org.jclouds.compute) @@ -107,7 +107,7 @@ Compute Example (Clojure): ; use the default node template and launch a couple nodes ; these will have your ~/.ssh/id_rsa.pub authorized when complete (with-compute-service [compute] - (run-nodes "mycluster" 2)) + (create-nodes "mycluster" 2)) Downloads: * distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-8.zip diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java index 072dc04401..8e59ed055a 100644 --- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java +++ b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java @@ -189,19 +189,19 @@ public class ComputeTask extends Task { private void list(ComputeService computeService) { log("list"); for (ComputeMetadata node : computeService.listNodes()) { - log(String.format(" location=%s, id=%s, tag=%s", node.getLocation(), node.getProviderId(), node.getName())); + log(String.format(" location=%s, id=%s, group=%s", node.getLocation(), node.getProviderId(), node.getName())); } } private void create(ComputeService computeService) throws RunNodesException, IOException { - String tag = nodeElement.getTag(); + String group = nodeElement.getGroup(); - log(String.format("create tag: %s, count: %d, hardware: %s, os: %s", tag, nodeElement.getCount(), nodeElement + log(String.format("create group: %s, count: %d, hardware: %s, os: %s", group, nodeElement.getCount(), nodeElement .getHardware(), nodeElement.getOs())); Template template = createTemplateFromElement(nodeElement, computeService); - for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(), template)) { + for (NodeMetadata createdNode : computeService.createNodesInGroup(group, nodeElement.getCount(), template)) { logDetails(computeService, createdNode); addNodeDetailsAsProjectProperties(createdNode); } @@ -223,8 +223,8 @@ public class ComputeTask extends Task { log(String.format("reboot id: %s", nodeElement.getId())); computeService.rebootNode(nodeElement.getId()); } else { - log(String.format("reboot tag: %s", nodeElement.getTag())); - computeService.rebootNodesMatching(NodePredicates.withTag(nodeElement.getTag())); + log(String.format("reboot group: %s", nodeElement.getGroup())); + computeService.rebootNodesMatching(NodePredicates.inGroup(nodeElement.getGroup())); } } @@ -233,8 +233,8 @@ public class ComputeTask extends Task { log(String.format("destroy id: %s", nodeElement.getId())); computeService.destroyNode(nodeElement.getId()); } else { - log(String.format("destroy tag: %s", nodeElement.getTag())); - computeService.destroyNodesMatching(NodePredicates.withTag(nodeElement.getTag())); + log(String.format("destroy group: %s", nodeElement.getGroup())); + computeService.destroyNodesMatching(NodePredicates.inGroup(nodeElement.getGroup())); } } @@ -243,9 +243,9 @@ public class ComputeTask extends Task { log(String.format("get id: %s", nodeElement.getId())); logDetails(computeService, computeService.getNodeMetadata(nodeElement.getId())); } else { - log(String.format("get tag: %s", nodeElement.getTag())); + log(String.format("get group: %s", nodeElement.getGroup())); for (ComputeMetadata node : Iterables.filter(computeService.listNodesDetailsMatching(NodePredicates.all()), - NodePredicates.withTag(nodeElement.getTag()))) { + NodePredicates.inGroup(nodeElement.getGroup()))) { logDetails(computeService, node); } } @@ -254,8 +254,8 @@ public class ComputeTask extends Task { private void logDetails(ComputeService computeService, ComputeMetadata node) { NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node) : computeService .getNodeMetadata(node.getId()); - log(String.format(" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, hardware=%s", - metadata.getProviderId(), metadata.getName(), metadata.getTag(), metadata.getLocation(), metadata + log(String.format(" node id=%s, name=%s, group=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, hardware=%s", + metadata.getProviderId(), metadata.getName(), metadata.getGroup(), metadata.getLocation(), metadata .getState(), ComputeTaskUtils.ipOrEmptyString(metadata.getPublicAddresses()), ipOrEmptyString(metadata.getPrivateAddresses()), metadata.getHardware())); } diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java index 70050c35a2..40049a974d 100644 --- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java +++ b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java @@ -27,7 +27,7 @@ import java.io.File; */ public class NodeElement { private String id; - private String tag; + private String group; private String hardware; private String os; private String image; @@ -147,12 +147,12 @@ public class NodeElement { return count; } - public void setTag(String tag) { - this.tag = tag; + public void setGroup(String group) { + this.group = group; } - public String getTag() { - return tag; + public String getGroup() { + return group; } public void setPrivatekeyfile(File privatekeyfile) { diff --git a/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java index c51b6d9f2e..f1d819fd77 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java +++ b/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java @@ -71,7 +71,7 @@ public class NodeToNodeMetadata implements Function { builder.ids(from.getId()); builder.name(from.getName()); builder.location(location.get()); - builder.tag(from.getGroup()); + builder.group(from.getGroup()); // TODO add tags! builder.operatingSystem(new OperatingSystemBuilder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) diff --git a/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java b/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java index 1017031ccf..092c9bba2e 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java +++ b/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java @@ -60,7 +60,7 @@ public class BYONComputeServiceAdapter implements JCloudsNativeComputeServiceAda } @Override - public NodeMetadata runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + public NodeMetadata createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore) { throw new UnsupportedOperationException(); } diff --git a/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java b/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java index e5e4546099..0a1186664d 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java @@ -53,7 +53,7 @@ public class NodeToNodeMetadataTest { public static NodeMetadata expectedNodeMetadataFromResource(String resource) { Location location = expectedLocationFromResource(resource); - return new NodeMetadataBuilder().ids("cluster-1").tag("hadoop").name("cluster-1").location(location).state( + return new NodeMetadataBuilder().ids("cluster-1").group("hadoop").name("cluster-1").location(location).state( NodeState.RUNNING).operatingSystem( new OperatingSystemBuilder().description("redhat").family(OsFamily.RHEL).arch("x86").version("5.3") .build()).publicAddresses(ImmutableSet.of("cluster-1.mydomain.com")).credentials( diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersBindComputeStrategiesByClass.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersBindComputeStrategiesByClass.java index 99923bde57..f864b75430 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersBindComputeStrategiesByClass.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersBindComputeStrategiesByClass.java @@ -20,14 +20,14 @@ package org.jclouds.cloudservers.compute.config; import org.jclouds.compute.config.BindComputeStrategiesByClass; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.cloudservers.compute.strategy.CloudServersAddNodeWithTagStrategy; +import org.jclouds.cloudservers.compute.strategy.CloudServersCreateNodeWithGroupEncodedIntoName; import org.jclouds.cloudservers.compute.strategy.CloudServersDestroyNodeStrategy; import org.jclouds.cloudservers.compute.strategy.CloudServersGetNodeMetadataStrategy; import org.jclouds.cloudservers.compute.strategy.CloudServersListNodesStrategy; @@ -41,8 +41,8 @@ import org.jclouds.cloudservers.compute.strategy.CloudServersLifeCycleStrategy; public class CloudServersBindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override - protected Class defineAddNodeWithTagStrategy() { - return CloudServersAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return CloudServersCreateNodeWithGroupEncodedIntoName.class; } @Override diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java index 4d06f7cf30..4ea7a23122 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.cloudservers.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.NoSuchElementException; @@ -112,7 +112,7 @@ public class ServerToNodeMetadata implements Function { builder.location(new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()).description( from.getHostId()).parent(location.get()).build()); builder.userMetadata(from.getMetadata()); - builder.tag(parseTagFromName(from.getName())); + builder.group(parseGroupFromName(from.getName())); builder.imageId(from.getImageId() + ""); builder.operatingSystem(parseOperatingSystem(from)); builder.hardware(parseHardware(from)); diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersCreateNodeWithGroupEncodedIntoName.java similarity index 83% rename from apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java rename to apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersCreateNodeWithGroupEncodedIntoName.java index 781155ede1..e99e0316a3 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersCreateNodeWithGroupEncodedIntoName.java @@ -28,7 +28,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.domain.Credentials; import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.domain.Server; @@ -39,13 +39,13 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class CloudServersAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class CloudServersCreateNodeWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName { protected final CloudServersClient client; protected final Map credentialStore; protected final Function serverToNodeMetadata; @Inject - protected CloudServersAddNodeWithTagStrategy(CloudServersClient client, Map credentialStore, + protected CloudServersCreateNodeWithGroupEncodedIntoName(CloudServersClient client, Map credentialStore, Function serverToNodeMetadata) { this.client = checkNotNull(client, "client"); this.credentialStore = checkNotNull(credentialStore, "credentialStore"); @@ -53,7 +53,7 @@ public class CloudServersAddNodeWithTagStrategy implements AddNodeWithTagStrateg } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { Server from = client.createServer(name, Integer.parseInt(template.getImage().getProviderId()), Integer .parseInt(template.getHardware().getProviderId())); credentialStore.put("node#" + from.getId(), new Credentials("root", from.getAdminPass())); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java index 8714f52f68..e190a00f0e 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java @@ -74,11 +74,11 @@ public class ServerToNodeMetadataTest { NodeMetadata metadata = parser.apply(server); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")).tag( - "NOTAG#sample-server").imageId("2").id("1234").providerId("1234").name("sample-server").credentials( - creds).location( new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0").description( - "e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()).userMetadata( - ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").id("1234").providerId("1234").name("sample-server").credentials(creds).location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } @Test @@ -95,11 +95,11 @@ public class ServerToNodeMetadataTest { NodeMetadata metadata = parser.apply(server); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")).tag( - "NOTAG#sample-server").imageId("2").id("1234").providerId("1234").name("sample-server").location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0").description( - "e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()).userMetadata( - ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").id("1234").providerId("1234").name("sample-server").location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } @@ -118,13 +118,13 @@ public class ServerToNodeMetadataTest { NodeMetadata metadata = parser.apply(server); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")).tag( - "NOTAG#sample-server").imageId("2").operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2").is64Bit( - true).build()).id("1234").providerId("1234").name("sample-server").location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0").description( - "e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()).userMetadata( - ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").operatingSystem( + new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } @@ -142,16 +142,16 @@ public class ServerToNodeMetadataTest { NodeMetadata metadata = parser.apply(server); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")).tag( - "NOTAG#sample-server").imageId("2").hardware( - new HardwareBuilder().ids("1").name("256 MB Server").processors( - ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes( - ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true) - .bootDevice(true).build())).build()).operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2").is64Bit( - true).build()).id("1234").providerId("1234").name("sample-server").location( - new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0").description( - "e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()).userMetadata( - ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); + ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) + .imageId("2").hardware( + new HardwareBuilder().ids("1").name("256 MB Server").processors( + ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes( + ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true) + .bootDevice(true).build())).build()).operatingSystem( + new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( + new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") + .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) + .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index 2e5af2b371..9a83767055 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -46,7 +46,7 @@ import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -75,7 +75,7 @@ public class EC2ComputeService extends BaseComputeService { protected EC2ComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, + GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy, Provider templateBuilderProvider, Provider templateOptionsProvider, @@ -96,26 +96,26 @@ public class EC2ComputeService extends BaseComputeService { } @VisibleForTesting - void deleteSecurityGroup(String region, String tag) { - Preconditions2.checkNotEmpty(tag, "tag"); - String group = String.format("jclouds#%s#%s", tag, region); - if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, group).size() > 0) { - logger.debug(">> deleting securityGroup(%s)", group); + void deleteSecurityGroup(String region, String group) { + Preconditions2.checkNotEmpty(group, "group"); + String groupName = String.format("jclouds#%s#%s", group, region); + if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, groupName).size() > 0) { + logger.debug(">> deleting securityGroup(%s)", groupName); try { - ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, group); + ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, groupName); // TODO: test this clear happens - securityGroupMap.remove(new RegionNameAndIngressRules(region, group, null, false)); - logger.debug("<< deleted securityGroup(%s)", group); + securityGroupMap.remove(new RegionNameAndIngressRules(region, groupName, null, false)); + logger.debug("<< deleted securityGroup(%s)", groupName); } catch (IllegalStateException e) { - logger.debug("<< inUse securityGroup(%s)", group); + logger.debug("<< inUse securityGroup(%s)", groupName); } } } @VisibleForTesting - void deleteKeyPair(String region, String tag) { + void deleteKeyPair(String region, String group) { for (KeyPair keyPair : ec2Client.getKeyPairServices().describeKeyPairsInRegion(region)) { - if (keyPair.getKeyName().matches(String.format("jclouds#%s#%s#%s", tag, region, "[0-9a-f]+"))) { + if (keyPair.getKeyName().matches(String.format("jclouds#%s#%s#%s", group, region, "[0-9a-f]+"))) { logger.debug(">> deleting keyPair(%s)", keyPair.getKeyName()); ec2Client.getKeyPairServices().deleteKeyPairInRegion(region, keyPair.getKeyName()); // TODO: test this clear happens @@ -134,8 +134,8 @@ public class EC2ComputeService extends BaseComputeService { Set deadOnes = super.destroyNodesMatching(filter); Map regionTags = Maps.newHashMap(); for (NodeMetadata nodeMetadata : deadOnes) { - if (nodeMetadata.getTag() != null) - regionTags.put(AWSUtils.parseHandle(nodeMetadata.getId())[0], nodeMetadata.getTag()); + if (nodeMetadata.getGroup() != null) + regionTags.put(AWSUtils.parseHandle(nodeMetadata.getId())[0], nodeMetadata.getGroup()); } for (Entry regionTag : regionTags.entrySet()) { cleanUpIncidentalResources(regionTag); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java index ae05dedee9..48983704a4 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java @@ -23,16 +23,16 @@ import org.jclouds.ec2.compute.strategy.EC2DestroyNodeStrategy; import org.jclouds.ec2.compute.strategy.EC2GetNodeMetadataStrategy; import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy; import org.jclouds.ec2.compute.strategy.EC2RebootNodeStrategy; -import org.jclouds.ec2.compute.strategy.EC2RunNodesAndAddToSetStrategy; +import org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet; import org.jclouds.ec2.compute.strategy.EC2ResumeNodeStrategy; import org.jclouds.ec2.compute.strategy.EC2SuspendNodeStrategy; import org.jclouds.compute.config.BindComputeStrategiesByClass; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; @@ -41,23 +41,23 @@ import org.jclouds.compute.strategy.SuspendNodeStrategy; */ public class EC2BindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override - protected Class defineRunNodesAndAddToSetStrategy() { - return EC2RunNodesAndAddToSetStrategy.class; + protected Class defineRunNodesAndAddToSetStrategy() { + return EC2CreateNodesInGroupThenAddToSet.class; } /** - * not needed, as {@link EC2RunNodesAndAddToSetStrategy} is used and is already set-based. + * not needed, as {@link EC2CreateNodesInGroupThenAddToSet} is used and is already set-based. */ @Override - protected Class defineAddNodeWithTagStrategy() { + protected Class defineAddNodeWithTagStrategy() { return null; } /** - * not needed, as {@link EC2RunNodesAndAddToSetStrategy} is used and is already set-based. + * not needed, as {@link EC2CreateNodesInGroupThenAddToSet} is used and is already set-based. */ @Override - protected void bindAddNodeWithTagStrategy(Class clazz) { + protected void bindAddNodeWithTagStrategy(Class clazz) { } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java index a5f265e436..5944293b8f 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -89,8 +89,8 @@ public class RunningInstanceToNodeMetadata implements Function() { + group = Iterables.getOnlyElement(Iterables.filter(instance.getGroupIds(), new Predicate() { @Override public boolean apply(String input) { @@ -169,13 +169,13 @@ public class RunningInstanceToNodeMetadata implements Function credentialStore; @Inject - EC2RunNodesAndAddToSetStrategy( + EC2CreateNodesInGroupThenAddToSet( EC2Client client, CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, @Named("PRESENT") Predicate instancePresent, @@ -96,10 +96,10 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate } @Override - public Map> execute(String tag, int count, Template template, Set goodNodes, + public Map> execute(String group, int count, Template template, Set goodNodes, Map badNodes, Multimap customizationResponses) { - Iterable started = createKeyPairAndSecurityGroupsAsNeededThenRunInstances(tag, count, + Iterable started = createKeyPairAndSecurityGroupsAsNeededThenRunInstances(group, count, template); Iterable ids = transform(started, instanceToId); @@ -130,13 +130,13 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate // TODO write test for this @VisibleForTesting - Iterable createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String tag, int count, + Iterable createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String group, int count, Template template) { String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); String zone = getZoneFromLocationOrNull(template.getLocation()); RunInstancesOptions instanceOptions = createKeyPairAndSecurityGroupsAsNeededAndReturncustomize.execute(region, - tag, template); + group, template); int countStarted = 0; int tries = 0; diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 46c7bd7cf1..1c7f95a671 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -107,26 +107,26 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) .getInstanceServices(); - String tag = this.tag + "o"; + String group = this.group + "o"; TemplateOptions options = client.templateOptions(); - options.as(EC2TemplateOptions.class).securityGroups(tag); - options.as(EC2TemplateOptions.class).keyPair(tag); + options.as(EC2TemplateOptions.class).securityGroups(group); + options.as(EC2TemplateOptions.class).keyPair(group); String startedId = null; try { - cleanupExtendedStuff(securityGroupClient, keyPairClient, tag); + cleanupExtendedStuff(securityGroupClient, keyPairClient, group); // create a security group that allows ssh in so that our scripts later // will work - securityGroupClient.createSecurityGroupInRegion(null, tag, tag); - securityGroupClient.authorizeSecurityGroupIngressInRegion(null, tag, IpProtocol.TCP, 22, 22, "0.0.0.0/0"); + securityGroupClient.createSecurityGroupInRegion(null, group, group); + securityGroupClient.authorizeSecurityGroupIngressInRegion(null, group, IpProtocol.TCP, 22, 22, "0.0.0.0/0"); // create a keypair to pass in as well - KeyPair result = keyPairClient.createKeyPairInRegion(null, tag); + KeyPair result = keyPairClient.createKeyPairInRegion(null, group); - Set nodes = client.runNodesWithTag(tag, 1, options); + Set nodes = client.createNodesInGroup(group, 1, options); NodeMetadata first = Iterables.get(nodes, 0); assert first.getCredentials() != null : first; assert first.getCredentials().identity != null : first; @@ -135,29 +135,29 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { RunningInstance instance = getInstance(instanceClient, startedId); - assertEquals(instance.getKeyName(), tag); + assertEquals(instance.getKeyName(), group); // make sure we made our dummy group and also let in the user's group - assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet. of("jclouds#" + tag + "#" - + instance.getRegion(), tag)); + assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet. of("jclouds#" + group + "#" + + instance.getRegion(), group)); // make sure our dummy group has no rules - SecurityGroup group = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null, - "jclouds#" + tag + "#" + instance.getRegion())); - assert group.getIpPermissions().size() == 0 : group; + SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null, + "jclouds#" + group + "#" + instance.getRegion())); + assert secgroup.getIpPermissions().size() == 0 : secgroup; // try to run a script with the original keyPair - runScriptWithCreds(tag, first.getOperatingSystem(), new Credentials(first.getCredentials().identity, result + runScriptWithCreds(group, first.getOperatingSystem(), new Credentials(first.getCredentials().identity, result .getKeyMaterial())); } finally { - client.destroyNodesMatching(NodePredicates.withTag(tag)); + client.destroyNodesMatching(NodePredicates.inGroup(group)); if (startedId != null) { // ensure we didn't delete these resources! - assertEquals(keyPairClient.describeKeyPairsInRegion(null, tag).size(), 1); - assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, tag).size(), 1); + assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1); + assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1); } - cleanupExtendedStuff(securityGroupClient, keyPairClient, tag); + cleanupExtendedStuff(securityGroupClient, keyPairClient, group); } } @@ -173,7 +173,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { ElasticBlockStoreClient ebsClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) .getElasticBlockStoreServices(); - String tag = this.tag + "e"; + String group = this.group + "e"; int volumeSize = 8; Location zone = Iterables.find(context.getComputeService().listAssignableLocations(), new Predicate() { @@ -200,7 +200,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { .mapEBSSnapshotToDeviceName("/dev/sdo", snapshot.getId(), volumeSize, true); try { - NodeMetadata node = Iterables.getOnlyElement(client.runNodesWithTag(tag, 1, template)); + NodeMetadata node = Iterables.getOnlyElement(client.createNodesInGroup(group, 1, template)); // TODO figure out how to validate the ephemeral drive. perhaps with df -k? @@ -228,7 +228,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { assertEquals(snapshot.getId(), volume.getSnapshotId()); } finally { - client.destroyNodesMatching(NodePredicates.withTag(tag)); + client.destroyNodesMatching(NodePredicates.inGroup(group)); ebsClient.deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId()); } } @@ -239,19 +239,19 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { return instance; } - protected void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient, String tag) + protected void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient, String group) throws InterruptedException { try { - for (SecurityGroup group : securityGroupClient.describeSecurityGroupsInRegion(null)) - if (group.getName().startsWith("jclouds#" + tag) || group.getName().equals(tag)) { - securityGroupClient.deleteSecurityGroupInRegion(null, group.getName()); + for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(null)) + if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) { + securityGroupClient.deleteSecurityGroupInRegion(null, secgroup.getName()); } } catch (Exception e) { } try { for (KeyPair pair : keyPairClient.describeKeyPairsInRegion(null)) - if (pair.getKeyName().startsWith("jclouds#" + tag) || pair.getKeyName().equals(tag)) { + if (pair.getKeyName().startsWith("jclouds#" + group) || pair.getKeyName().equals(group)) { keyPairClient.deleteKeyPairInRegion(null, pair.getKeyName()); } } catch (Exception e) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateTagLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java similarity index 92% rename from apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateTagLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index b60e820ea8..504d3654ae 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateTagLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -46,7 +46,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class TestCanRecreateTagLiveTest { +public class TestCanRecreateGroupLiveTest { private ComputeServiceContext context; protected String provider = "ec2"; @@ -85,21 +85,21 @@ public class TestCanRecreateTagLiveTest { ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides); } - public void testCanRecreateTag() throws Exception { + public void testCanRecreateGroup() throws Exception { String tag = PREFIX + "recreate"; - context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); + context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); try { Template template = context.getComputeService().templateBuilder().locationId("us-west-1").build(); - context.getComputeService().runNodesWithTag(tag, 1, template); - context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); - context.getComputeService().runNodesWithTag(tag, 1, template); + context.getComputeService().createNodesInGroup(tag, 1, template); + context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); + context.getComputeService().createNodesInGroup(tag, 1, template); } catch (RunNodesException e) { System.err.println(e.getNodeErrors().keySet()); Throwables.propagate(e); } finally { - context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); + context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CredentialsForInstanceTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CredentialsForInstanceTest.java deleted file mode 100644 index 4a41652874..0000000000 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CredentialsForInstanceTest.java +++ /dev/null @@ -1,833 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.ec2.compute.functions; - -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit") -public class CredentialsForInstanceTest { - - DateService dateService = new SimpleDateFormatDateService(); - -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void testApplyWithEBSWhenBootIsInstanceStoreAndAvailabilityZoneNotFound() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce(); -// Map credentialsMap = createMock(Map.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m1_small().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// Image image = createMock(Image.class); -// -// expect(instance.getId()).andReturn("i-3d640055").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet.of("default")).atLeastOnce(); -// expect(instance.getKeyName()).andReturn("jclouds#tag#us-east-1#50").atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1d", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(instance.getIpAddress()).andReturn("174.129.1.50"); -// expect(instance.getPrivateIpAddress()).andReturn("10.202.117.241"); -// -// expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("ami-1515f07c").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "ami-1515f07c"))).andReturn(jcImage); -// -// expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("ami-1515f07c"))).andReturn( -// (Set) ImmutableSet. of(image)); -// -// expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); -// -// expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "jclouds#tag#us-east-1#50"))).andReturn( -// new KeyPair(Region.US_EAST_1, "jclouds#tag#us-east-1#50", "keyFingerprint", "pass")); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.M1_SMALL).atLeastOnce(); -// expect(instance.getEbsBlockDevices()).andReturn( -// ImmutableMap. of( -// "/dev/sdg", -// new EbsBlockDevice("vol-1f20d376", Attachment.Status.ATTACHED, dateService -// .iso8601DateParse("2009-12-11T16:32:46.000Z"), false), -// "/dev/sdj", -// new EbsBlockDevice("vol-c0eb78aa", Attachment.Status.ATTACHED, dateService -// .iso8601DateParse("2010-06-17T10:43:28.000Z"), false))); -// expect(instance.getRootDeviceType()).andReturn(RootDeviceType.INSTANCE_STORE); -// expect(instance.getRootDeviceName()).andReturn(null).atLeastOnce(); -// -// replay(imageMap); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// replay(jcImage); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// -// assertEquals(metadata.getTag(), "NOTAG#i-3d640055"); -// assertEquals(metadata.getLocation(), null); -// assertEquals(metadata.getImageId(), "us-east-1/ami-1515f07c"); -// assertEquals(metadata.getHardware().getId(), "m1.small"); -// assertEquals(metadata.getHardware().getName(), "m1.small"); -// assertEquals(metadata.getHardware().getProviderId(), "m1.small"); -// assertEquals(metadata.getHardware().getProcessors(), ImmutableList. of(new Processor(1.0, 1.0))); -// assertEquals(metadata.getHardware().getRam(), 1740); -// assertEquals(metadata.getHardware().getVolumes(), -// ImmutableList. of(new VolumeImpl(null, Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),// -// new VolumeImpl(null, Volume.Type.LOCAL, 150.0f, "/dev/sda2", false, false),// -// new VolumeImpl("vol-1f20d376", Volume.Type.SAN, null, "/dev/sdg", false, true),// -// new VolumeImpl("vol-c0eb78aa", Volume.Type.SAN, null, "/dev/sdj", false, true))); -// -// assertEquals(metadata.getCredentials(), new Credentials("user", "pass")); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// -// } -// -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void testApplyForNovaWhereNullAvailabilityZoneIpAddressNoGroups() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce(); -// Map credentialsMap = createMock(Map.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m1_small().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// Image image = createMock(Image.class); -// -// expect(instance.getId()).andReturn("i-3d640055").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn("nebulatanimislam").atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// Location region = new LocationImpl(LocationScope.REGION, "us-east-1", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(region)); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(instance.getIpAddress()).andReturn(null); -// expect(instance.getPrivateIpAddress()).andReturn("10.202.117.241"); -// -// expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("ami-1515f07c").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "ami-1515f07c"))).andReturn(jcImage); -// -// expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("ami-1515f07c"))).andReturn( -// (Set) ImmutableSet. of(image)); -// -// expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); -// -// expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "nebulatanimislam"))).andReturn(null); -// -// expect(instance.getAvailabilityZone()).andReturn(null).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.M1_SMALL).atLeastOnce(); -// expect(instance.getEbsBlockDevices()).andReturn(Maps. newHashMap()); -// expect(instance.getRootDeviceType()).andReturn(RootDeviceType.INSTANCE_STORE); -// -// replay(imageMap); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// replay(jcImage); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// -// assertEquals(metadata.getTag(), "NOTAG#i-3d640055"); -// assertEquals(metadata.getLocation(), region); -// assertEquals(metadata.getImageId(), "us-east-1/ami-1515f07c"); -// assertEquals(metadata.getHardware().getId(), "m1.small"); -// assertEquals(metadata.getHardware().getName(), "m1.small"); -// assertEquals(metadata.getHardware().getProviderId(), "m1.small"); -// assertEquals(metadata.getHardware().getProcessors(), ImmutableList. of(new Processor(1.0, 1.0))); -// assertEquals(metadata.getHardware().getRam(), 1740); -// assertEquals(metadata.getHardware().getVolumes(), -// ImmutableList. of(new VolumeImpl(null, Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),// -// new VolumeImpl(null, Volume.Type.LOCAL, 150.0f, "/dev/sda2", false, false))); -// -// assertEquals(metadata.getCredentials(), new Credentials("user", null)); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// -// } -// -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void testApplyWhereUnknownInstanceType() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce(); -// Map credentialsMap = createMock(Map.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m1_small().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// Image image = createMock(Image.class); -// -// expect(instance.getId()).andReturn("i-3d640055").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn("nebulatanimislam").atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// Location region = new LocationImpl(LocationScope.REGION, "us-east-1", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(region)); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(instance.getIpAddress()).andReturn(null); -// expect(instance.getPrivateIpAddress()).andReturn("10.202.117.241"); -// -// expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("ami-1515f07c").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "ami-1515f07c"))).andReturn(jcImage); -// -// expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("ami-1515f07c"))).andReturn( -// (Set) ImmutableSet. of(image)); -// -// expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); -// -// expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "nebulatanimislam"))).andReturn(null); -// -// expect(instance.getAvailabilityZone()).andReturn(null).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn("hhttpp").atLeastOnce(); -// -// replay(imageMap); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// replay(jcImage); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// -// assertEquals(metadata.getTag(), "NOTAG#i-3d640055"); -// assertEquals(metadata.getLocation(), region); -// assertEquals(metadata.getImageId(), "us-east-1/ami-1515f07c"); -// assertEquals(metadata.getHardware(), null); -// -// assertEquals(metadata.getCredentials(), new Credentials("user", null)); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// -// } -// -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void testApplyForNovaWhereImageNotFound() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce(); -// Map credentialsMap = createMock(Map.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m1_small().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// -// expect(instance.getId()).andReturn("i-3d640055").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn("nebulatanimislam").atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// Location region = new LocationImpl(LocationScope.REGION, "us-east-1", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(region)); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(instance.getIpAddress()).andReturn(null); -// expect(instance.getPrivateIpAddress()).andReturn("10.202.117.241"); -// -// expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("ami-1515f07c").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "ami-1515f07c"))).andReturn(jcImage); -// -// expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("ami-1515f07c"))).andReturn( -// (Set) ImmutableSet. of()); -// -// expect(credentialProvider.execute(null)).andReturn(new Credentials("root", null)); -// -// expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "nebulatanimislam"))).andReturn(null); -// -// expect(instance.getAvailabilityZone()).andReturn(null).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.M1_SMALL).atLeastOnce(); -// expect(instance.getEbsBlockDevices()).andReturn(Maps. newHashMap()); -// expect(instance.getRootDeviceType()).andReturn(RootDeviceType.INSTANCE_STORE); -// -// replay(imageMap); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// replay(jcImage); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// -// assertEquals(metadata.getTag(), "NOTAG#i-3d640055"); -// assertEquals(metadata.getLocation(), region); -// assertEquals(metadata.getImageId(), "us-east-1/ami-1515f07c"); -// assertEquals(metadata.getHardware().getId(), "m1.small"); -// assertEquals(metadata.getHardware().getName(), "m1.small"); -// assertEquals(metadata.getHardware().getProviderId(), "m1.small"); -// assertEquals(metadata.getHardware().getProcessors(), ImmutableList. of(new Processor(1.0, 1.0))); -// assertEquals(metadata.getHardware().getRam(), 1740); -// assertEquals(metadata.getHardware().getVolumes(), -// ImmutableList. of(new VolumeImpl(null, Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),// -// new VolumeImpl(null, Volume.Type.LOCAL, 150.0f, "/dev/sda2", false, false))); -// -// assertEquals(metadata.getCredentials(), new Credentials("root", null)); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testImageNotFoundAndLazyReturnsNull() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// -// Map credentialsMap = createMock(Map.class); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn(null).atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce(); -// -// expect(imageMap.get(new RegionAndName("us-east-1", "imageId"))).andReturn(null); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(imageMap); -// replay(jcImage); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// assertEquals(metadata.getLocation(), locations.get().iterator().next()); -// assertEquals(metadata.getImageId(), "us-east-1/imageId"); -// assertEquals(metadata.getTag(), "NOTAG#id"); -// assertEquals(metadata.getCredentials(), null); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testImageNotFoundStillSetsImageId() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// Map credentialsMap = createMock(Map.class); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn(null).atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce(); -// -// expect(imageMap.get(new RegionAndName("us-east-1", "imageId"))).andThrow(new NullPointerException()) -// .atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(imageMap); -// replay(jcImage); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// assertEquals(metadata.getLocation(), locations.get().iterator().next()); -// assertEquals(metadata.getImageId(), "us-east-1/imageId"); -// assertEquals(metadata.getTag(), "NOTAG#id"); -// assertEquals(metadata.getCredentials(), null); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testImageNotFoundAndLazySucceeds() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// Map credentialsMap = createMock(Map.class); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn(null).atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce(); -// -// org.jclouds.compute.domain.Image lateImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(imageMap.get(new RegionAndName("us-east-1", "imageId"))).andReturn(lateImage).atLeastOnce(); -// expect(lateImage.getId()).andReturn("us-east-1/imageId").atLeastOnce(); -// expect(lateImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(lateImage); -// replay(imageMap); -// replay(jcImage); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// assertEquals(metadata.getLocation(), locations.get().iterator().next()); -// assertEquals(metadata.getImageId(), lateImage.getId()); -// assertEquals(metadata.getTag(), "NOTAG#id"); -// assertEquals(metadata.getCredentials(), null); -// -// verify(lateImage); -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testApplyWithNoSecurityGroupCreatesTagOfIdPrefixedByTagAndNullCredentials() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// Map credentialsMap = createMock(Map.class); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); -// expect(instance.getKeyName()).andReturn(null).atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(imageMap); -// replay(jcImage); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// assertEquals(metadata.getLocation(), locations.get().iterator().next()); -// assertEquals(metadata.getImageId(), "us-east-1/imageId"); -// assertEquals(metadata.getTag(), "NOTAG#id"); -// assertEquals(metadata.getCredentials(), null); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testApplyWithNoKeyPairCreatesTagOfParsedSecurityGroupAndNullCredentials() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// Map credentialsMap = createMock(Map.class); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag#us-east-1")).atLeastOnce(); -// expect(instance.getKeyName()).andReturn(null).atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(imageMap); -// replay(jcImage); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// assertEquals(metadata.getLocation(), locations.get().iterator().next()); -// assertEquals(metadata.getImageId(), "us-east-1/imageId"); -// assertEquals(metadata.getTag(), "tag"); -// assertEquals(metadata.getCredentials(), null); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// } -// -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void testApplyWithKeyPairCreatesTagOfParsedSecurityGroupAndCredentialsBasedOnIt() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce(); -// Map credentialsMap = createMock(Map.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// Image image = createMock(Image.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag#us-east-1")).atLeastOnce(); -// expect(instance.getKeyName()).andReturn("jclouds#tag#us-east-1#50").atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage); -// -// expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("imageId"))).andReturn( -// (Set) ImmutableSet. of(image)); -// -// expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); -// -// expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "jclouds#tag#us-east-1#50"))).andReturn( -// new KeyPair(Region.US_EAST_1, "jclouds#tag#us-east-1#50", "keyFingerprint", "pass")); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(imageMap); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// replay(jcImage); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// NodeMetadata metadata = parser.apply(instance); -// -// assertEquals(metadata.getTag(), "tag"); -// assertEquals(metadata.getLocation(), location); -// assertEquals(metadata.getImageId(), "us-east-1/imageId"); -// -// assertEquals(metadata.getCredentials(), new Credentials("user", "pass")); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// -// } -// -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void testApplyWithTwoSecurityGroups() throws UnknownHostException { -// EC2Client client = createMock(EC2Client.class); -// AMIClient amiClient = createMock(AMIClient.class); -// expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce(); -// Map credentialsMap = createMock(Map.class); -// ConcurrentMap imageMap = createMock(ConcurrentMap.class); -// @Memoized Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet -// . of(m2_4xlarge().build())); -// PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); -// RunningInstance instance = createMock(RunningInstance.class); -// Image image = createMock(Image.class); -// -// expect(instance.getId()).andReturn("id").atLeastOnce(); -// expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds1", "jclouds2")).atLeastOnce(); -// expect(instance.getKeyName()).andReturn("jclouds#tag#us-east-1#50").atLeastOnce(); -// expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); -// -// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); -// @Memoized Supplier> locations = Suppliers.> ofInstance(ImmutableSet -// . of(location)); -// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); -// -// expect(instance.getIpAddress()).andReturn("127.0.0.1"); -// expect(instance.getPrivateIpAddress()).andReturn("127.0.0.1"); -// -// expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); -// -// expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); -// -// expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); -// expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage); -// -// expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("imageId"))).andReturn( -// (Set) ImmutableSet. of(image)); -// -// expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); -// -// expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "jclouds#tag#us-east-1#50"))).andReturn( -// new KeyPair(Region.US_EAST_1, "jclouds#tag#us-east-1#50", "keyFingerprint", "pass")); -// -// expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); -// -// expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); -// -// replay(imageMap); -// replay(client); -// replay(amiClient); -// replay(credentialsMap); -// replay(credentialProvider); -// replay(instance); -// replay(jcImage); -// -// Function parser = new CredentialsForInstance(client, credentialsMap, -// credentialProvider, imageMap, locations, hardwares); -// -// NodeMetadata metadata = parser.apply(instance); -// -// assertEquals(metadata.getTag(), "NOTAG#id"); -// assertEquals(metadata.getLocation(), location); -// assertEquals(metadata.getImageId(), "us-east-1/imageId"); -// -// assertEquals(metadata.getCredentials(), new Credentials("user", "pass")); -// -// verify(imageMap); -// verify(jcImage); -// verify(client); -// verify(amiClient); -// verify(credentialsMap); -// verify(credentialProvider); -// verify(instance); -// -// } -} diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java index 2752a8cbf6..e71aef38ac 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java @@ -83,8 +83,8 @@ public class RunningInstanceToNodeMetadataTest { assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses( ImmutableSet. of()).privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses( - ImmutableSet.of("174.129.81.68")).tag("NOTAG#i-0799056f").credentials(creds).imageId( - "us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").build()); + ImmutableSet.of("174.129.81.68")).credentials(creds).imageId("us-east-1/ami-82e4b5c7").id( + "us-east-1/i-0799056f").providerId("i-0799056f").build()); } @Test @@ -96,8 +96,8 @@ public class RunningInstanceToNodeMetadataTest { assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses( ImmutableSet. of()).privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses( - ImmutableSet.of("174.129.81.68")).tag("NOTAG#i-0799056f").imageId("us-east-1/ami-82e4b5c7").id( - "us-east-1/i-0799056f").providerId("i-0799056f").build()); + ImmutableSet.of("174.129.81.68")).imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f") + .providerId("i-0799056f").build()); } @Test @@ -108,9 +108,8 @@ public class RunningInstanceToNodeMetadataTest { RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( - ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).tag( - "NOTAG#i-0799056f").imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f") - .providerId("i-0799056f").location(provider).build()); + ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( + "us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").location(provider).build()); } @Test @@ -121,8 +120,8 @@ public class RunningInstanceToNodeMetadataTest { RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( - ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).tag( - "NOTAG#i-0799056f").imageId("us-east-1/ami-82e4b5c7").operatingSystem( + ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( + "us-east-1/ami-82e4b5c7").operatingSystem( new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description( "137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f") .providerId("i-0799056f").location(provider).build()); @@ -137,8 +136,8 @@ public class RunningInstanceToNodeMetadataTest { RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( - ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).tag( - "NOTAG#i-0799056f").imageId("us-east-1/ami-82e4b5c7").hardware(m1_small().build()).operatingSystem( + ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( + "us-east-1/ami-82e4b5c7").hardware(m1_small().build()).operatingSystem( new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description( "137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f") .providerId("i-0799056f").location(provider).build()); @@ -166,9 +165,9 @@ public class RunningInstanceToNodeMetadataTest { RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( - ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).tag( - "NOTAG#i-0799056f").imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f") - .providerId("i-0799056f").hardware(m1_small().build()).location(provider).build()); + ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( + "us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").hardware( + m1_small().build()).location(provider).build()); } protected RunningInstance firstInstanceFromResource(String resource) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java index 0fb031777e..605a6660fe 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java @@ -99,7 +99,7 @@ public class EC2RunNodesAndAddToSetStrategyTest { String imageId = "ami1"; String instanceCreatedId = "instance1"; // setup mocks - EC2RunNodesAndAddToSetStrategy strategy = setupStrategy(); + EC2CreateNodesInGroupThenAddToSet strategy = setupStrategy(); InputParams input = new InputParams(location); InstanceClient instanceClient = createMock(InstanceClient.class); RunInstancesOptions ec2Options = createMock(RunInstancesOptions.class); @@ -200,7 +200,7 @@ public class EC2RunNodesAndAddToSetStrategyTest { } } - private void verifyStrategy(EC2RunNodesAndAddToSetStrategy strategy) { + private void verifyStrategy(EC2CreateNodesInGroupThenAddToSet strategy) { verify(strategy.createKeyPairAndSecurityGroupsAsNeededAndReturncustomize); verify(strategy.client); verify(strategy.instancePresent); @@ -211,7 +211,7 @@ public class EC2RunNodesAndAddToSetStrategyTest { } @SuppressWarnings("unchecked") - private EC2RunNodesAndAddToSetStrategy setupStrategy() { + private EC2CreateNodesInGroupThenAddToSet setupStrategy() { EC2Client client = createMock(EC2Client.class); CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize = createMock(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class); Predicate instanceStateRunning = createMock(Predicate.class); @@ -219,11 +219,11 @@ public class EC2RunNodesAndAddToSetStrategyTest { Function instanceToCredentials = createMock(Function.class); Map credentialStore = createMock(Map.class); ComputeUtils utils = createMock(ComputeUtils.class); - return new EC2RunNodesAndAddToSetStrategy(client, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, + return new EC2CreateNodesInGroupThenAddToSet(client, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, instanceStateRunning, runningInstanceToNodeMetadata, instanceToCredentials, credentialStore, utils); } - private void replayStrategy(EC2RunNodesAndAddToSetStrategy strategy) { + private void replayStrategy(EC2CreateNodesInGroupThenAddToSet strategy) { replay(strategy.createKeyPairAndSecurityGroupsAsNeededAndReturncustomize); replay(strategy.client); replay(strategy.instancePresent); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java index 1a3e31dd50..572994a71c 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java @@ -86,7 +86,7 @@ public class ElasticStackComputeServiceAdapter implements } @Override - public ServerInfo runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + public ServerInfo createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore) { long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l); logger.debug(">> creating boot drive bytes(%d)", bootSize); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java index eed46bb5f6..ed4b82f86a 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.elasticstack.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.List; import java.util.Map; @@ -92,7 +92,7 @@ public class ServerInfoToNodeMetadata implements Function elbs = elbClient.describeLoadBalancersInRegion(null); assertNotNull(elbs); for (LoadBalancer elb : elbs) { - if (elb.getName().equals(tag)) + if (elb.getName().equals(group)) assertEquals(elb.getInstanceIds(), instanceIds); } } diff --git a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java index 74068e26c4..1cc6166b2c 100644 --- a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java +++ b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java @@ -38,7 +38,7 @@ public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest public EucalyptusComputeServiceLiveTest() { provider = "eucalyptus"; // security groups must be <30 characters - tag = "eu"; + group = "eu"; } @Override diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java index db0039012e..5d11f4e8f5 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java @@ -66,7 +66,7 @@ public class BindCaptureVAppParamsToXmlPayload implements MapBinder { @Override public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index 9eaea0a971..e076338735 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -94,7 +94,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder @Override public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudBindComputeStrategiesByClass.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudBindComputeStrategiesByClass.java index 83e89e4344..39710af9f0 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudBindComputeStrategiesByClass.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudBindComputeStrategiesByClass.java @@ -19,14 +19,14 @@ package org.jclouds.vcloud.compute.config; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.vcloud.compute.strategy.VCloudAddNodeWithTagStrategy; +import org.jclouds.vcloud.compute.strategy.InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn; import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy; import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy; import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy; @@ -36,8 +36,8 @@ import org.jclouds.vcloud.compute.strategy.VCloudLifeCycleStrategy; */ public class VCloudBindComputeStrategiesByClass extends CommonVCloudBindComputeStrategiesByClass { @Override - protected Class defineAddNodeWithTagStrategy() { - return VCloudAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class; } @Override diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java index 6f2f8e9f77..a60128c890 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom; import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getPrivateIpsFromVApp; import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getPublicIpsFromVApp; @@ -71,12 +71,7 @@ public class VAppToNodeMetadata implements Function { builder.uri(from.getHref()); builder.name(from.getName()); builder.location(findLocationForResourceInVDC.apply(from.getVDC())); - String tag = parseTagFromName(from.getName()); - builder.tag(tag); - if (logger.isTraceEnabled()) { - if (tag.startsWith("NOTAG#")) - logger.warn("failed to parse tag from name %s", from); - } + builder.group(parseGroupFromName(from.getName())); builder.operatingSystem(toComputeOs(from, null)); builder.hardware(hardwareForVApp.apply(from)); builder.state(vAppStatusToNodeState.get(from.getStatus())); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java similarity index 92% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java rename to apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index 000ef311eb..c49fa8ebf1 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -32,7 +32,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.logging.Logger; import org.jclouds.vcloud.VCloudClient; @@ -50,7 +50,7 @@ import com.google.common.collect.Iterables; * @author Adrian Cole */ @Singleton -public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn implements CreateNodeWithGroupEncodedIntoName { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; @@ -60,7 +60,7 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { protected final Predicate successTester; @Inject - protected VCloudAddNodeWithTagStrategy(Predicate successTester, VCloudClient client, + protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(Predicate successTester, VCloudClient client, GetNodeMetadataStrategy getNode) { this.client = client; this.successTester = successTester; @@ -68,7 +68,7 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) { InstantiateVAppTemplateOptions options = processorCount((int) getCores(template.getHardware())).memory( template.getHardware().getRam()).disk( (long) ((template.getHardware().getVolumes().get(0).getSize()) * 1024 * 1024l)); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java index 6ea071285d..b87f329f28 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java @@ -51,7 +51,7 @@ public class CaptureVAppLiveTest { protected ComputeService client; - protected String tag = System.getProperty("user.name") + "cap"; + protected String group = System.getProperty("user.name") + "cap"; protected String provider = "vcloud"; protected String identity; @@ -94,7 +94,7 @@ public class CaptureVAppLiveTest { VAppTemplate vappTemplate = null; try { - node = getOnlyElement(client.runNodesWithTag(tag, 1)); + node = getOnlyElement(client.createNodesInGroup(group, 1)); VCloudClient vcloudApi = VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); @@ -117,7 +117,7 @@ public class CaptureVAppLiveTest { // vdc is equiv to the node's location // vapp uri is the same as the node's id vappTemplate = vcloudApi.captureVAppInVDC(URI.create(node.getLocation().getId()), URI.create(node.getId()), - tag); + group); task = vappTemplate.getTasks().get(0); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java index 5c424e55c5..09acac0efe 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java @@ -50,7 +50,7 @@ import com.google.inject.Module; /** * This tests that we can use guest customization as an alternative to bootstrapping with ssh. There - * are a few advantages to this, including the fact that it can work inside google appengine where + * are a few advangroupes to this, including the fact that it can work inside google appengine where * network sockets (ssh:22) are prohibited. * * @author Adrian Cole @@ -110,7 +110,7 @@ public class VCloudGuestCustomizationLiveTest { @Test public void testExtendedOptionsWithCustomizationScript() throws Exception { - String tag = "customize"; + String group = "customize"; String script = "cat > /root/foo.txt< R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressBindComputeStrategiesByClass.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressBindComputeStrategiesByClass.java index 65039af16a..d64f1c4483 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressBindComputeStrategiesByClass.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressBindComputeStrategiesByClass.java @@ -19,14 +19,14 @@ package org.jclouds.vcloud.compute.config; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.vcloud.compute.strategy.VCloudExpressAddNodeWithTagStrategy; +import org.jclouds.vcloud.compute.strategy.StartVAppWithGroupEncodedIntoName; import org.jclouds.vcloud.compute.strategy.VCloudExpressDestroyNodeStrategy; import org.jclouds.vcloud.compute.strategy.VCloudExpressGetNodeMetadataStrategy; import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy; @@ -38,8 +38,8 @@ import org.jclouds.vcloud.compute.strategy.VCloudExpressLifeCycleStrategy; public class VCloudExpressBindComputeStrategiesByClass extends CommonVCloudBindComputeStrategiesByClass { @Override - protected Class defineAddNodeWithTagStrategy() { - return VCloudExpressAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return StartVAppWithGroupEncodedIntoName.class; } @Override diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java index 06eeb101d6..d23ecc3cf4 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.Set; @@ -75,7 +75,7 @@ public class VCloudExpressVAppToNodeMetadata implements Function vAppToNodeMetadata; @Inject - protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient, + protected StartVAppWithGroupEncodedIntoName(VCloudExpressClient client, VCloudExpressComputeClient computeClient, Function vAppToNodeMetadata) { this.client = client; this.computeClient = computeClient; @@ -55,7 +55,7 @@ public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrate } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) { InstantiateVAppTemplateOptions options = processorCount((int) getCores(template.getHardware())).memory( template.getHardware().getRam()).disk( (long) ((template.getHardware().getVolumes().get(0).getSize()) * 1024 * 1024l)); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java index 54264ca16b..66ac91e874 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java @@ -45,7 +45,7 @@ import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -69,7 +69,7 @@ public class TerremarkVCloudComputeService extends BaseComputeService { protected TerremarkVCloudComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, + GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy, Provider templateBuilderProvider, Provider templateOptionsProvider, diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkBindComputeStrategiesByClass.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkBindComputeStrategiesByClass.java index ddda7bfd16..20f280945c 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkBindComputeStrategiesByClass.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkBindComputeStrategiesByClass.java @@ -19,23 +19,23 @@ package org.jclouds.vcloud.terremark.compute.config; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.vcloud.compute.config.VCloudExpressBindComputeStrategiesByClass; import org.jclouds.vcloud.terremark.compute.strategy.TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy; -import org.jclouds.vcloud.terremark.compute.strategy.TerremarkVCloudAddNodeWithTagStrategy; +import org.jclouds.vcloud.terremark.compute.strategy.StartVAppWithGroupEncodedIntoName; /** * @author Adrian Cole */ public class TerremarkBindComputeStrategiesByClass extends VCloudExpressBindComputeStrategiesByClass { @Override - protected Class defineRunNodesAndAddToSetStrategy() { + protected Class defineRunNodesAndAddToSetStrategy() { return TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.class; } @Override - protected Class defineAddNodeWithTagStrategy() { - return TerremarkVCloudAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return StartVAppWithGroupEncodedIntoName.class; } } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/functions/NodeMetadataToOrgAndName.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/functions/NodeMetadataToOrgAndName.java index cf61611705..c8d3219de1 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/functions/NodeMetadataToOrgAndName.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/functions/NodeMetadataToOrgAndName.java @@ -61,12 +61,12 @@ public class NodeMetadataToOrgAndName implements Function orgTags = filter(transform(deadOnes, nodeToOrgAndName), notNull()); - for (OrgAndName orgTag : orgTags) { - Iterable nodesInOrg = listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag + Iterable orgGroups = filter(transform(deadOnes, nodeToOrgAndName), notNull()); + for (OrgAndName orgGroup : orgGroups) { + Iterable nodesInOrg = listNodes.listDetailsOnNodesMatching(parentLocationId(orgGroup .getOrg().toASCIIString())); - Iterable nodesWithTag = filter(nodesInOrg, withTag(orgTag.getName())); - if (size(nodesWithTag) == 0 || all(nodesWithTag, TERMINATED)) - deleteKeyPair.execute(orgTag); + Iterable nodesInGroup = filter(nodesInOrg, inGroup(orgGroup.getName())); + if (size(nodesInGroup) == 0 || all(nodesInGroup, TERMINATED)) + deleteKeyPair.execute(orgGroup); } } diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudAddNodeWithTagStrategy.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/StartVAppWithGroupEncodedIntoName.java similarity index 90% rename from common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudAddNodeWithTagStrategy.java rename to common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/StartVAppWithGroupEncodedIntoName.java index 0a1789e570..c8e11bef6f 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudAddNodeWithTagStrategy.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/StartVAppWithGroupEncodedIntoName.java @@ -30,7 +30,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient; @@ -43,14 +43,14 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class TerremarkVCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class StartVAppWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName { protected final TerremarkVCloudComputeClient computeClient; protected final TemplateToInstantiateOptions getOptions; protected final Function vAppToNodeMetadata; private final Map credentialStore; @Inject - protected TerremarkVCloudAddNodeWithTagStrategy(TerremarkVCloudComputeClient computeClient, + protected StartVAppWithGroupEncodedIntoName(TerremarkVCloudComputeClient computeClient, Function vAppToNodeMetadata, TemplateToInstantiateOptions getOptions, Map credentialStore) { this.computeClient = computeClient; @@ -60,7 +60,7 @@ public class TerremarkVCloudAddNodeWithTagStrategy implements AddNodeWithTagStra } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { TerremarkInstantiateVAppTemplateOptions options = getOptions.apply(template); VCloudExpressVApp vApp = computeClient.start(URI.create(template.getLocation().getId()), URI.create(template .getImage().getId()), name, options, template.getOptions().getInboundPorts()); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.java index 47f52204d1..b3062d13c2 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.java @@ -33,10 +33,10 @@ 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.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; import org.jclouds.domain.LocationScope; import org.jclouds.vcloud.terremark.compute.options.TerremarkVCloudTemplateOptions; @@ -48,13 +48,13 @@ import com.google.common.collect.Multimap; * @author Adrian Cole */ @Singleton -public class TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy extends EncodeTagIntoNameRunNodesAndAddToSetStrategy { +public class TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy extends CreateNodesWithGroupEncodedIntoNameThenAddToSet { private final CreateNewKeyPairUnlessUserSpecifiedOtherwise createNewKeyPairUnlessUserSpecifiedOtherwise; @Inject protected TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy( - AddNodeWithTagStrategy addNodeWithTagStrategy, + CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy, ListNodesStrategy listNodesStrategy, @Named("NAMING_CONVENTION") String nodeNamingConvention, CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/compute/strategy/CleanupOrphanKeysTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/compute/strategy/CleanupOrphanKeysTest.java index 30110cb7a4..5a06f15d76 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/compute/strategy/CleanupOrphanKeysTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/compute/strategy/CleanupOrphanKeysTest.java @@ -88,13 +88,13 @@ public class CleanupOrphanKeysTest { CleanupOrphanKeys strategy = setupStrategy(); NodeMetadata nodeMetadata = createMock(NodeMetadata.class); Iterable deadOnes = ImmutableSet. of(nodeMetadata); - OrgAndName orgTag = new OrgAndName(URI.create("location"), "tag"); + OrgAndName orgTag = new OrgAndName(URI.create("location"), "group"); // setup expectations expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(orgTag).atLeastOnce(); expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString()))) .andReturn(ImmutableSet.of(nodeMetadata)); - expect(nodeMetadata.getTag()).andReturn(orgTag.getName()).atLeastOnce(); + expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce(); expect(nodeMetadata.getState()).andReturn(NodeState.RUNNING).atLeastOnce(); expectCleanupCredentialStore(strategy, nodeMetadata); @@ -115,13 +115,13 @@ public class CleanupOrphanKeysTest { CleanupOrphanKeys strategy = setupStrategy(); NodeMetadata nodeMetadata = createMock(NodeMetadata.class); Iterable deadOnes = ImmutableSet. of(nodeMetadata); - OrgAndName orgTag = new OrgAndName(URI.create("location"), "tag"); + OrgAndName orgTag = new OrgAndName(URI.create("location"), "group"); // setup expectations expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(orgTag).atLeastOnce(); expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString()))) .andReturn(ImmutableSet.of(nodeMetadata)); - expect(nodeMetadata.getTag()).andReturn(orgTag.getName()).atLeastOnce(); + expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce(); expect(nodeMetadata.getState()).andReturn(NodeState.TERMINATED).atLeastOnce(); strategy.deleteKeyPair.execute(orgTag); expectCleanupCredentialStore(strategy, nodeMetadata); @@ -149,7 +149,7 @@ public class CleanupOrphanKeysTest { CleanupOrphanKeys strategy = setupStrategy(); NodeMetadata nodeMetadata = createMock(NodeMetadata.class); Iterable deadOnes = ImmutableSet. of(nodeMetadata); - OrgAndName orgTag = new OrgAndName(URI.create("location"), "tag"); + OrgAndName orgTag = new OrgAndName(URI.create("location"), "group"); // setup expectations expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(orgTag).atLeastOnce(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/common/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java index fa460fd7e3..2ce7e8b5ab 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java @@ -66,7 +66,7 @@ public class BindCloneVAppParamsToXmlPayload implements MapBinder { @Override public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeStrategiesByClass.java b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeStrategiesByClass.java index 07df6bccc1..8541eaf173 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeStrategiesByClass.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeStrategiesByClass.java @@ -20,8 +20,8 @@ package org.jclouds.vcloud.compute.config; import org.jclouds.compute.config.BindComputeStrategiesByClass; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; -import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; +import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; /** * @author Adrian Cole @@ -29,8 +29,8 @@ import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStr public abstract class CommonVCloudBindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override - protected Class defineRunNodesAndAddToSetStrategy() { - return EncodeTagIntoNameRunNodesAndAddToSetStrategy.class; + protected Class defineRunNodesAndAddToSetStrategy() { + return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class; } } \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java index 797a34c1f9..3a14171817 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java @@ -27,7 +27,6 @@ import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.config.BindComputeStrategiesByClass; import org.jclouds.compute.config.BindComputeSuppliersByClass; import org.jclouds.compute.domain.NodeState; -import org.jclouds.location.config.LocationModule; import org.jclouds.vcloud.domain.Status; import com.google.common.annotations.VisibleForTesting; diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index a19c17890e..a6ef16b1d8 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -47,7 +47,7 @@ Here's an example of getting some compute configuration from rackspace: (pprint (nodes)) (pprint (hardware-profiles))) -Here's an example of creating and running a small linux node with the tag +Here's an example of creating and running a small linux node in the group webserver: ;; create a compute service using ssh and log4j extensions @@ -55,7 +55,7 @@ webserver: (compute-service provider provider-identity provider-credential :ssh :log4j)) - (run-node \"webserver\" compute) + (create-node \"webserver\" compute) See http://code.google.com/p/jclouds for details." (:use org.jclouds.core @@ -144,11 +144,11 @@ See http://code.google.com/p/jclouds for details." ([#^ComputeService compute] (seq (.listNodesDetailsMatching compute (NodePredicates/all))))) -(defn nodes-with-tag - "list details of all the nodes with the given tag." - ([tag] (nodes-with-tag tag *compute*)) - ([#^String tag #^ComputeService compute] - (filter #(= (.getTag %) tag) (nodes-with-details compute)))) +(defn nodes-in-group + "list details of all the nodes in the given group." + ([group] (nodes-in-group group *compute*)) + ([#^String group #^ComputeService compute] + (filter #(= (.getTag %) group) (nodes-with-details compute)))) (defn images "Retrieve the available images for the compute context." @@ -171,66 +171,66 @@ See http://code.google.com/p/jclouds for details." (slurp (str (. System getProperty "user.home") "/.ssh/id_rsa.pub")))) build))) -(defn run-nodes +(defn create-nodes "Create the specified number of nodes using the default or specified template. ;; Simplest way to add 2 small linux nodes to the group webserver is to run - (run-nodes \"webserver\" 2 compute) + (create-nodes \"webserver\" 2 compute) - ;; which is the same as wrapping the run-nodes command with an implicit + ;; which is the same as wrapping the create-nodes command with an implicit ;; compute service. ;; Note that this will actually add another 2 nodes to the set called ;; \"webserver\" (with-compute-service [compute] - (run-nodes \"webserver\" 2 )) + (create-nodes \"webserver\" 2 )) ;; which is the same as specifying the default template (with-compute-service [compute] - (run-nodes \"webserver\" 2 (default-template))) + (create-nodes \"webserver\" 2 (default-template))) ;; which, on gogrid, is the same as constructing the smallest centos template ;; that has no layered software (with-compute-service [compute] - (run-nodes \"webserver\" 2 + (create-nodes \"webserver\" 2 (build-template service {:os-family :centos :smallest true :image-name-matches \".*w/ None.*\"})))" - ([tag count] - (run-nodes tag count (default-template *compute*) *compute*)) - ([tag count compute-or-template] + ([group count] + (create-nodes group count (default-template *compute*) *compute*)) + ([group count compute-or-template] (if (compute-service? compute-or-template) - (run-nodes - tag count (default-template compute-or-template) compute-or-template) - (run-nodes tag count compute-or-template *compute*))) - ([tag count template #^ComputeService compute] + (create-nodes + group count (default-template compute-or-template) compute-or-template) + (create-nodes group count compute-or-template *compute*))) + ([group count template #^ComputeService compute] (seq - (.runNodesWithTag compute tag count template)))) + (.createNodesInGroup compute group count template)))) -(defn run-node +(defn create-node "Create a node using the default or specified template. ;; simplest way to add a small linux node to the group webserver is to run - (run-node \"webserver\" compute) + (create-node \"webserver\" compute) - ;; which is the same as wrapping the run-node command with an implicit compute + ;; which is the same as wrapping the create-node command with an implicit compute ;; service. ;; Note that this will actually add another node to the set called ;; \"webserver\" (with-compute-service [compute] - (run-node \"webserver\" ))" - ([tag] - (first (run-nodes tag 1 (default-template *compute*) *compute*))) - ([tag compute-or-template] + (create-node \"webserver\" ))" + ([group] + (first (create-nodes group 1 (default-template *compute*) *compute*))) + ([group compute-or-template] (if (compute-service? compute-or-template) (first - (run-nodes - tag 1 (default-template compute-or-template) compute-or-template)) - (first (run-nodes tag 1 compute-or-template *compute*)))) - ([tag template compute] - (first (run-nodes tag 1 template compute)))) + (create-nodes + group 1 (default-template compute-or-template) compute-or-template)) + (first (create-nodes group 1 compute-or-template *compute*)))) + ([group template compute] + (first (create-nodes group 1 template compute)))) (defn #^NodeMetadata node-details "Retrieve the node metadata, given its id." @@ -238,11 +238,11 @@ See http://code.google.com/p/jclouds for details." ([id #^ComputeService compute] (.getNodeMetadata compute id))) -(defn suspend-nodes-with-tag - "Reboot all the nodes with the given tag." - ([tag] (suspend-nodes-with-tag tag *compute*)) - ([#^String tag #^ComputeService compute] - (.suspendNodesMatching compute (NodePredicates/withTag tag)))) +(defn suspend-nodes-in-group + "Reboot all the nodes in the given group." + ([group] (suspend-nodes-in-group group *compute*)) + ([#^String group #^ComputeService compute] + (.suspendNodesMatching compute (NodePredicates/inGroup group)))) (defn suspend-node "Suspend a node, given its id." @@ -250,11 +250,11 @@ See http://code.google.com/p/jclouds for details." ([id #^ComputeService compute] (.suspendNode compute id))) -(defn resume-nodes-with-tag - "Suspend all the nodes with the given tag." - ([tag] (resume-nodes-with-tag tag *compute*)) - ([#^String tag #^ComputeService compute] - (.resumeNodesMatching compute (NodePredicates/withTag tag)))) +(defn resume-nodes-in-group + "Suspend all the nodes in the given group." + ([group] (resume-nodes-in-group group *compute*)) + ([#^String group #^ComputeService compute] + (.resumeNodesMatching compute (NodePredicates/inGroup group)))) (defn resume-node "Resume a node, given its id." @@ -262,11 +262,11 @@ See http://code.google.com/p/jclouds for details." ([id #^ComputeService compute] (.resumeNode compute id))) -(defn reboot-nodes-with-tag - "Reboot all the nodes with the given tag." - ([tag] (reboot-nodes-with-tag tag *compute*)) - ([#^String tag #^ComputeService compute] - (.rebootNodesMatching compute (NodePredicates/withTag tag)))) +(defn reboot-nodes-in-group + "Reboot all the nodes in the given group." + ([group] (reboot-nodes-in-group group *compute*)) + ([#^String group #^ComputeService compute] + (.rebootNodesMatching compute (NodePredicates/inGroup group)))) (defn reboot-node "Reboot a node, given its id." @@ -274,11 +274,11 @@ See http://code.google.com/p/jclouds for details." ([id #^ComputeService compute] (.rebootNode compute id))) -(defn destroy-nodes-with-tag - "Destroy all the nodes with the given tag." - ([tag] (destroy-nodes-with-tag tag *compute*)) - ([#^String tag #^ComputeService compute] - (.destroyNodesMatching compute (NodePredicates/withTag tag)))) +(defn destroy-nodes-in-group + "Destroy all the nodes in the given group." + ([group] (destroy-nodes-in-group group *compute*)) + ([#^String group #^ComputeService compute] + (.destroyNodesMatching compute (NodePredicates/inGroup group)))) (defn destroy-node "Destroy a node, given its id." @@ -330,10 +330,10 @@ See http://code.google.com/p/jclouds for details." [#^NodeMetadata node] (.getPrivateAddresses node)) -(defn tag - "Returns a the node's tag" +(defn group + "Returns a the node's group" [#^NodeMetadata node] - (.getTag node)) + (.getGroup node)) (defn hostname "Returns the compute node's name" @@ -353,7 +353,7 @@ See http://code.google.com/p/jclouds for details." (define-accessors Template image hardware location options) (define-accessors Image version os-family os-description architecture) (define-accessors Hardware processors ram volumes) -(define-accessors NodeMetadata "node" credentials hardware state tag) +(define-accessors NodeMetadata "node" credentials hardware state group) (defn builder-options [builder] (or diff --git a/compute/src/main/clojure/org/jclouds/modules.clj b/compute/src/main/clojure/org/jclouds/modules.clj index 1a81be2b06..2e89d93043 100644 --- a/compute/src/main/clojure/org/jclouds/modules.clj +++ b/compute/src/main/clojure/org/jclouds/modules.clj @@ -40,7 +40,7 @@ (class ComputeService) (defrecord ClojureComputeServiceAdapter [] org.jclouds.compute.JCloudsNativeComputeServiceAdapter - (^NodeMetadata runNodeWithTagAndNameAndStoreCredentials [this ^String tag ^String name ^Template template ^Map credentialStore] + (^NodeMetadata createNodeWithGroupEncodedIntoNameThenStoreCredentials [this ^String group ^String name ^Template template ^Map credentialStore] ()) (^Iterable listNodes [this ] ()) diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index fc6a92b615..12c0ac4b44 100755 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -20,6 +20,7 @@ package org.jclouds.compute; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; import org.jclouds.compute.domain.ComputeMetadata; @@ -98,8 +99,8 @@ public interface ComputeService { /** * - * The compute api treats nodes as a group based on a tag you specify. Using this tag, you can - * choose to operate one or many nodes as a logical unit without regard to the implementation + * The compute api treats nodes as a group based on the name you specify. Using this group, you + * can choose to operate one or many nodes as a logical unit without regard to the implementation * details of the cloud. *

* @@ -119,7 +120,7 @@ public interface ComputeService { * If resources such as security groups are needed, they will be reused or created for you. * Inbound port 22 will always be opened up. * - * @param tag + * @param group * - common identifier to group nodes by, cannot contain hyphens * @param count * - how many to fire up. @@ -131,19 +132,38 @@ public interface ComputeService { * when there's a problem applying options to nodes. Note that successful and failed * nodes are a part of this exception, so be sure to inspect this carefully. */ + Set createNodesInGroup(String group, int count, Template template) throws RunNodesException; + + /** + * Like {@link ComputeService#createNodesInGroup(String,int,Template)}, except that the template + * is default, equivalent to {@code templateBuilder().any().options(templateOptions)}. + */ + Set createNodesInGroup(String group, int count, TemplateOptions templateOptions) + throws RunNodesException; + + /** + * Like {@link ComputeService#createNodesInGroup(String,int,TemplateOptions)}, except that the + * options are default, as specified in {@link ComputeService#templateOptions}. + */ + Set createNodesInGroup(String group, int count) throws RunNodesException; + + /** + * @see #createNodesInGroup(String , int , Template ) + */ + @Deprecated Set runNodesWithTag(String tag, int count, Template template) throws RunNodesException; /** - * Like {@link ComputeService#runNodesWithTag(String,int,Template)}, except that the template is - * default, equivalent to {@code templateBuilder().any().options(templateOptions)}. + * @see #createNodesInGroup(String , int , TemplateOptions ) */ + @Deprecated Set runNodesWithTag(String tag, int count, TemplateOptions templateOptions) throws RunNodesException; /** - * Like {@link ComputeService#runNodesWithTag(String,int,TemplateOptions)}, except that the - * options are default, as specified in {@link ComputeService#templateOptions}. + * @see #createNodesInGroup(String , int ) */ + @Deprecated Set runNodesWithTag(String tag, int count) throws RunNodesException; /** @@ -272,6 +292,13 @@ public interface ComputeService { Map runScriptOnNodesMatching(Predicate filter, Statement runScript) throws RunScriptOnNodesException; + /** + * + * @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions) + */ + Map runScriptOnNodesMatching(Predicate filter, String runScript, + RunScriptOptions options) throws RunScriptOnNodesException; + /** * Run the script on all nodes with the specific predicate. * diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java index 55ec6ad6b1..06f086b1dc 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java @@ -60,7 +60,7 @@ public interface ComputeServiceAdapter { * @see ComputeService#runNodesWithTag(String, int, Template) * @see ComputeServiceContext#getCredentialStore */ - N runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + N createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore); /** diff --git a/compute/src/main/java/org/jclouds/compute/JCloudsNativeComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/JCloudsNativeComputeServiceAdapter.java index dfa70466ab..b39b19b5e8 100644 --- a/compute/src/main/java/org/jclouds/compute/JCloudsNativeComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/JCloudsNativeComputeServiceAdapter.java @@ -40,7 +40,7 @@ public interface JCloudsNativeComputeServiceAdapter extends * {@inheritDoc} */ @Override - NodeMetadata runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + NodeMetadata createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore); /** diff --git a/compute/src/main/java/org/jclouds/compute/config/BindComputeStrategiesByClass.java b/compute/src/main/java/org/jclouds/compute/config/BindComputeStrategiesByClass.java index 0e3264fa39..647d47273f 100644 --- a/compute/src/main/java/org/jclouds/compute/config/BindComputeStrategiesByClass.java +++ b/compute/src/main/java/org/jclouds/compute/config/BindComputeStrategiesByClass.java @@ -19,15 +19,15 @@ package org.jclouds.compute.config; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; import com.google.inject.AbstractModule; import com.google.inject.Scopes; @@ -49,15 +49,15 @@ public abstract class BindComputeStrategiesByClass extends AbstractModule { bindDestroyNodeStrategy(defineDestroyNodeStrategy()); } - protected void bindRunNodesAndAddToSetStrategy(Class clazz) { - bind(RunNodesAndAddToSetStrategy.class).to(clazz).in(Scopes.SINGLETON); + protected void bindRunNodesAndAddToSetStrategy(Class clazz) { + bind(CreateNodesInGroupThenAddToSet.class).to(clazz).in(Scopes.SINGLETON); } /** - * needed, if {@link RunNodesAndAddToSetStrategy} requires it + * needed, if {@link CreateNodesInGroupThenAddToSet} requires it */ - protected void bindAddNodeWithTagStrategy(Class clazz) { - bind(AddNodeWithTagStrategy.class).to(clazz).in(Scopes.SINGLETON); + protected void bindAddNodeWithTagStrategy(Class clazz) { + bind(CreateNodeWithGroupEncodedIntoName.class).to(clazz).in(Scopes.SINGLETON); } protected void bindDestroyNodeStrategy(Class clazz) { @@ -84,14 +84,14 @@ public abstract class BindComputeStrategiesByClass extends AbstractModule { bind(ListNodesStrategy.class).to(clazz).in(Scopes.SINGLETON); } - protected Class defineRunNodesAndAddToSetStrategy() { - return EncodeTagIntoNameRunNodesAndAddToSetStrategy.class; + protected Class defineRunNodesAndAddToSetStrategy() { + return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class; } /** - * needed, if {@link RunNodesAndAddToSetStrategy} requires it + * needed, if {@link CreateNodesInGroupThenAddToSet} requires it */ - protected abstract Class defineAddNodeWithTagStrategy(); + protected abstract Class defineAddNodeWithTagStrategy(); protected abstract Class defineDestroyNodeStrategy(); diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java index 717d777576..9d568e2efa 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java @@ -29,7 +29,7 @@ import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; @@ -114,7 +114,7 @@ public class ComputeServiceAdapterContextModule extends BaseCo @Provides @Singleton - protected AddNodeWithTagStrategy defineAddNodeWithTagStrategy(AdaptingComputeServiceStrategies in) { + protected CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy(AdaptingComputeServiceStrategies in) { return in; } diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java index 7607904935..1ff3894820 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java @@ -37,11 +37,17 @@ public interface NodeMetadata extends ComputeMetadata { /** * Tag used for all resources that belong to the same logical group. run, destroy commands are - * scoped to tag. + * scoped to group. * - * @return tag for this node, or null, if not a part of a group + * @return group for this node, or null, if not a part of a group * */ + String getGroup(); + + /** + * @see #getGroup + */ + @Deprecated String getTag(); /** diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java index 0cb46e7d6a..a3a5efff55 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java @@ -46,7 +46,7 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { @Nullable private Credentials credentials; @Nullable - private String tag; + private String group; private int loginPort = 22; @Nullable private String imageId; @@ -89,8 +89,8 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { return this; } - public NodeMetadataBuilder tag(@Nullable String tag) { - this.tag = tag; + public NodeMetadataBuilder group(@Nullable String group) { + this.group = group; return this; } @@ -146,13 +146,13 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { @Override public NodeMetadata build() { - return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, tag, hardware, imageId, os, state, + return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, group, hardware, imageId, os, state, loginPort, publicAddresses, privateAddresses, adminPassword, credentials); } public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( - node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tag(node.getTag()).hardware( + node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).group(node.getGroup()).hardware( node.getHardware()).imageId(node.getImageId()).operatingSystem(node.getOperatingSystem()).state( node.getState()).loginPort(node.getLoginPort()).publicAddresses(node.getPublicAddresses()) .privateAddresses(node.getPrivateAddresses()).adminPassword(node.getAdminPassword()).credentials( diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java index ad92ebda1f..e7f14b4f6b 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java @@ -55,7 +55,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat @Nullable private final Credentials credentials; @Nullable - private final String tag; + private final String group; @Nullable private final String imageId; @Nullable @@ -64,12 +64,12 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat private final OperatingSystem os; public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri, - Map userMetadata, @Nullable String tag, @Nullable Hardware hardware, + Map userMetadata, @Nullable String group, @Nullable Hardware hardware, @Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort, Iterable publicAddresses, Iterable privateAddresses, @Nullable String adminPassword, @Nullable Credentials credentials) { super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata); - this.tag = tag; + this.group = group; this.hardware = hardware; this.imageId = imageId; this.os = os; @@ -86,7 +86,15 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat */ @Override public String getTag() { - return tag; + return getGroup(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getGroup() { + return group; } /** @@ -163,7 +171,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat @Override public String toString() { - return "[id=" + getId() + ", providerId=" + getProviderId() + ", tag=" + getTag() + ", name=" + getName() + return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getTag() + ", name=" + getName() + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os=" + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + ", hardware=" @@ -178,7 +186,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat result = prime * result + loginPort; result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode()); result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode()); - result = prime * result + ((tag == null) ? 0 : tag.hashCode()); + result = prime * result + ((group == null) ? 0 : group.hashCode()); result = prime * result + ((imageId == null) ? 0 : imageId.hashCode()); result = prime * result + ((hardware == null) ? 0 : hardware.hashCode()); result = prime * result + ((os == null) ? 0 : os.hashCode()); @@ -208,10 +216,10 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat return false; } else if (!publicAddresses.equals(other.publicAddresses)) return false; - if (tag == null) { - if (other.tag != null) + if (group == null) { + if (other.group != null) return false; - } else if (!tag.equals(other.tag)) + } else if (!group.equals(other.group)) return false; if (imageId == null) { if (other.imageId != null) diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 4104e6821c..33be65a04c 100755 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -76,7 +76,7 @@ import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; @@ -116,7 +116,7 @@ public class BaseComputeService implements ComputeService { private final Supplier> locations; private final ListNodesStrategy listNodesStrategy; private final GetNodeMetadataStrategy getNodeMetadataStrategy; - private final RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy; + private final CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy; private final RebootNodeStrategy rebootNodeStrategy; private final DestroyNodeStrategy destroyNodeStrategy; private final ResumeNodeStrategy resumeNodeStrategy; @@ -135,7 +135,7 @@ public class BaseComputeService implements ComputeService { @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, + GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy, Provider templateBuilderProvider, Provider templateOptionsProvider, @@ -178,45 +178,63 @@ public class BaseComputeService implements ComputeService { * {@inheritDoc} */ @Override - public Set runNodesWithTag(String tag, int count, Template template) + public Set runNodesWithTag(String group, int count, Template template) throws RunNodesException { - checkNotNull(tag, "tag cannot be null"); + return createNodesInGroup(group, count, template); + } + + /** + * {@inheritDoc} + */ + @Override + public Set runNodesWithTag(String group, int count, TemplateOptions templateOptions) + throws RunNodesException { + return createNodesInGroup(group, count, templateBuilder().any().options(templateOptions).build()); + } + + /** + * {@inheritDoc} + */ + @Override + public Set runNodesWithTag(String group, int count) throws RunNodesException { + return createNodesInGroup(group, count, templateOptions()); + } + + @Override + public Set createNodesInGroup(String group, int count, Template template) + throws RunNodesException { + checkNotNull(group, "group cannot be null"); checkNotNull(template.getLocation(), "location"); - logger.debug(">> running %d node%s tag(%s) location(%s) image(%s) hardwareProfile(%s) options(%s)", count, - count > 1 ? "s" : "", tag, template.getLocation().getId(), template.getImage().getId(), template + logger.debug(">> running %d node%s group(%s) location(%s) image(%s) hardwareProfile(%s) options(%s)", count, + count > 1 ? "s" : "", group, template.getLocation().getId(), template.getImage().getId(), template .getHardware().getId(), template.getOptions()); Set goodNodes = newLinkedHashSet(); Map badNodes = newLinkedHashMap(); Multimap customizationResponses = LinkedHashMultimap.create(); - Map> responses = runNodesAndAddToSetStrategy.execute(tag, count, template, goodNodes, badNodes, + Map> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes, customizationResponses); Map executionExceptions = awaitCompletion(responses, executor, null, logger, "runNodesWithTag(" - + tag + ")"); + + group + ")"); for (NodeMetadata node : concat(goodNodes, badNodes.keySet())) if (node.getCredentials() != null) credentialStore.put("node#" + node.getId(), node.getCredentials()); if (executionExceptions.size() > 0 || badNodes.size() > 0) { - throw new RunNodesException(tag, count, template, goodNodes, executionExceptions, badNodes); + throw new RunNodesException(group, count, template, goodNodes, executionExceptions, badNodes); } return goodNodes; } - /** - * {@inheritDoc} - */ @Override - public Set runNodesWithTag(String tag, int count, TemplateOptions templateOptions) + public Set createNodesInGroup(String group, int count, TemplateOptions templateOptions) throws RunNodesException { - return runNodesWithTag(tag, count, templateBuilder().any().options(templateOptions).build()); + return createNodesInGroup(group, count, templateBuilder().any().options(templateOptions).build()); + } - /** - * {@inheritDoc} - */ @Override - public Set runNodesWithTag(String tag, int count) throws RunNodesException { - return runNodesWithTag(tag, count, templateOptions()); + public Set createNodesInGroup(String group, int count) throws RunNodesException { + return createNodesInGroup(group, count, templateOptions()); } /** @@ -492,6 +510,13 @@ public class BaseComputeService implements ComputeService { return runScriptOnNodesMatching(filter, runScript, RunScriptOptions.NONE); } + @Override + public Map runScriptOnNodesMatching(Predicate filter, + String runScript, RunScriptOptions options) throws RunScriptOnNodesException { + return runScriptOnNodesMatching(filter, Statements.exec(checkNotNull(runScript, "runScript")), + RunScriptOptions.NONE); + } + /** * {@inheritDoc} */ @@ -562,4 +587,5 @@ public class BaseComputeService implements ComputeService { return executor.submit(initScriptRunnerFactory.create(node, script, options, badNodes)); } } + } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java index 4b503c854c..6be88dc194 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java @@ -42,11 +42,10 @@ public class ComputeServiceContextImpl implements ComputeServiceContext { private final Utils utils; private final Map credentialStore; - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings( { "unchecked" }) @Inject public ComputeServiceContextImpl(ComputeService computeService, Map credentialStore, - Utils utils, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { this.credentialStore = credentialStore; this.utils = utils; this.providerSpecificContext = providerSpecificContext; @@ -57,7 +56,7 @@ public class ComputeServiceContextImpl implements ComputeServiceContext { return computeService; } - @SuppressWarnings({ "unchecked", "hiding" }) + @SuppressWarnings( { "unchecked", "hiding" }) @Override public RestContext getProviderSpecificContext() { return (RestContext) providerSpecificContext; @@ -67,7 +66,7 @@ public class ComputeServiceContextImpl implements ComputeServiceContext { public void close() { providerSpecificContext.close(); } - + @Override public Utils getUtils() { return utils(); diff --git a/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java b/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java index e13fba7fc0..05bcaf1029 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java @@ -42,8 +42,7 @@ import com.google.common.collect.Sets; */ public class NodePredicates { - private static class ParentLocationId implements - Predicate { + private static class ParentLocationId implements Predicate { private final String id; private ParentLocationId(String id) { @@ -156,8 +155,7 @@ public class NodePredicates { } /** - * Return nodes with the specific ids Note: returns all nodes, regardless of - * the state. + * Return nodes with the specific ids Note: returns all nodes, regardless of the state. * * @param ids * ids of the resources @@ -187,51 +185,67 @@ public class NodePredicates { } /** - * Return nodes with specified tag. Note: returns all nodes, regardless of - * the state. + * Return nodes in the specified group. Note: returns all nodes, regardless of the state. * - * @param tag - * tag to match the items + * @param group + * group to match the items * @return predicate */ - public static Predicate withTag(final String tag) { - Preconditions2.checkNotEmpty(tag, "Tag must be defined"); + public static Predicate inGroup(final String group) { + Preconditions2.checkNotEmpty(group, "group must be defined"); return new Predicate() { @Override public boolean apply(NodeMetadata nodeMetadata) { - return tag.equals(nodeMetadata.getTag()); + return group.equals(nodeMetadata.getGroup()); } @Override public String toString() { - return "withTag(" + tag + ")"; + return "inGroup(" + group + ")"; } }; } /** - * Return nodes with specified tag that are in the NODE_RUNNING state. * - * @param tag - * tag to match the items + * @see #inGroup(String) + */ + @Deprecated + public static Predicate withTag(final String tag) { + return inGroup(tag); + } + + /** + * Return nodes with specified group that are in the NODE_RUNNING state. + * + * @param group + * group to match the items * @return predicate */ - public static Predicate runningWithTag(final String tag) { - Preconditions2.checkNotEmpty(tag, "Tag must be defined"); + public static Predicate runningInGroup(final String group) { + Preconditions2.checkNotEmpty(group, "Tag must be defined"); return new Predicate() { @Override public boolean apply(NodeMetadata nodeMetadata) { - return tag.equals(nodeMetadata.getTag()) - && nodeMetadata.getState() == NodeState.RUNNING; + return group.equals(nodeMetadata.getGroup()) && nodeMetadata.getState() == NodeState.RUNNING; } @Override public String toString() { - return "runningWithTag(" + tag + ")"; + return "runningInGroup(" + group + ")"; } }; } + /** + * + * @see #inGroup(String) + */ + @Deprecated + public static Predicate runningWithTag(final String tag) { + return runningInGroup(tag); + } + /** * Match nodes with State == RUNNING */ diff --git a/compute/src/main/java/org/jclouds/compute/strategy/AddNodeWithTagStrategy.java b/compute/src/main/java/org/jclouds/compute/strategy/CreateNodeWithGroupEncodedIntoName.java similarity index 80% rename from compute/src/main/java/org/jclouds/compute/strategy/AddNodeWithTagStrategy.java rename to compute/src/main/java/org/jclouds/compute/strategy/CreateNodeWithGroupEncodedIntoName.java index d4904ccf54..6d91e532cf 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/AddNodeWithTagStrategy.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/CreateNodeWithGroupEncodedIntoName.java @@ -27,21 +27,21 @@ import org.jclouds.compute.domain.Template; * * @author Adrian Cole */ -public interface AddNodeWithTagStrategy { +public interface CreateNodeWithGroupEncodedIntoName { /** * create a node given the name and template parameters such as imageid, hardwareid, and * locationid. * - * @param tag - * tag supplied by the user + * @param group + * group name supplied by the user * @param name - * supplied by {@link RunNodesAndAddToSetStrategy } and must have the tag encoded into + * supplied by {@link CreateNodesInGroupThenAddToSet } and must have the tag encoded into * it. * @param template * supplied by the user * @return NodeMetadata from the new object, most likely in some pending state. */ - NodeMetadata addNodeWithTag(String tag, String name, Template template); + NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template); } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/strategy/RunNodesAndAddToSetStrategy.java b/compute/src/main/java/org/jclouds/compute/strategy/CreateNodesInGroupThenAddToSet.java similarity index 79% rename from compute/src/main/java/org/jclouds/compute/strategy/RunNodesAndAddToSetStrategy.java rename to compute/src/main/java/org/jclouds/compute/strategy/CreateNodesInGroupThenAddToSet.java index bfdcb17b83..0b89940ea0 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/RunNodesAndAddToSetStrategy.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/CreateNodesInGroupThenAddToSet.java @@ -26,19 +26,18 @@ import java.util.concurrent.Future; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; import com.google.common.collect.Multimap; import com.google.inject.ImplementedBy; /** - * creates futures that correlate to * * @author Adrian Cole */ -@ImplementedBy(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class) -public interface RunNodesAndAddToSetStrategy { +@ImplementedBy(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class) +public interface CreateNodesInGroupThenAddToSet { - Map> execute(String tag, int count, Template template, Set goodNodes, + Map> execute(String group, int count, Template template, Set goodNodes, Map badNodes, Multimap customizationResponses); } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index fcb601adce..6ec428006d 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -36,7 +36,7 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Template; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; @@ -55,7 +55,7 @@ import com.google.common.collect.Iterables; * */ @Singleton -public class AdaptingComputeServiceStrategies implements AddNodeWithTagStrategy, DestroyNodeStrategy, +public class AdaptingComputeServiceStrategies implements CreateNodeWithGroupEncodedIntoName, DestroyNodeStrategy, GetNodeMetadataStrategy, ListNodesStrategy, RebootNodeStrategy, ResumeNodeStrategy, SuspendNodeStrategy { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) @@ -129,12 +129,12 @@ public class AdaptingComputeServiceStrategies implements AddNodeWith * {@inheritDoc} */ @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { - checkState(tag != null, "tag (that which groups identical nodes together) must be specified"); - checkState(name != null && name.indexOf(tag) != -1, "name should have %s encoded into it", tag); + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { + checkState(group != null, "group (that which groups identical nodes together) must be specified"); + checkState(name != null && name.indexOf(group) != -1, "name should have %s encoded into it", group); checkState(template != null, "template must be specified"); - N from = client.runNodeWithTagAndNameAndStoreCredentials(tag, name, template, credentialStore); + N from = client.createNodeWithGroupEncodedIntoNameThenStoreCredentials(group, name, template, credentialStore); NodeMetadata node = nodeMetadataAdapter.apply(from); return node; } diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java similarity index 92% rename from compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java rename to compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java index aaadaab3a3..939bbeda00 100755 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java @@ -44,10 +44,10 @@ import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.logging.Logger; import com.google.common.base.Predicate; @@ -59,7 +59,7 @@ import com.google.common.collect.Multimap; * @author Adrian Cole */ @Singleton -public class EncodeTagIntoNameRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrategy { +public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNodesInGroupThenAddToSet { private class AddNode implements Callable { private final String name; @@ -78,7 +78,7 @@ public class EncodeTagIntoNameRunNodesAndAddToSetStrategy implements RunNodesAnd logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware() .getProviderId()); - node = addNodeWithTagStrategy.addNodeWithTag(tag, name, template); + node = addNodeWithTagStrategy.createNodeWithGroupEncodedIntoName(tag, name, template); logger.debug("<< %s node(%s)", node.getState(), node.getId()); return node; } @@ -92,15 +92,15 @@ public class EncodeTagIntoNameRunNodesAndAddToSetStrategy implements RunNodesAnd @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final AddNodeWithTagStrategy addNodeWithTagStrategy; + protected final CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy; protected final ListNodesStrategy listNodesStrategy; protected final String nodeNamingConvention; protected final ExecutorService executor; protected final CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory; @Inject - protected EncodeTagIntoNameRunNodesAndAddToSetStrategy( - AddNodeWithTagStrategy addNodeWithTagStrategy, + protected CreateNodesWithGroupEncodedIntoNameThenAddToSet( + CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy, ListNodesStrategy listNodesStrategy, @Named("NAMING_CONVENTION") String nodeNamingConvention, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java index c96a3ad16c..6b85faf226 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java @@ -80,13 +80,13 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda } @Override - public NodeMetadata runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + public NodeMetadata createNodeWithGroupEncodedIntoNameThenStoreCredentials(String group, String name, Template template, Map credentialStore) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); String id = idProvider.get() + ""; builder.ids(id); builder.name(name); - builder.tag(tag); + builder.group(group); builder.location(location.get()); builder.imageId(template.getImage().getId()); builder.operatingSystem(template.getImage().getOperatingSystem()); diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index e0bcc661a2..86007ddb5b 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -103,12 +103,11 @@ public class ComputeServiceUtils { /** * - * - * @return NOTAG#+from if tag cannot be parsed + * @return null if group cannot be parsed */ - public static String parseTagFromName(String from) { + public static String parseGroupFromName(String from) { Matcher matcher = DELIMETED_BY_HYPHEN_ENDING_IN_HYPHEN_HEX.matcher(from); - return matcher.find() ? matcher.group(1) : "NOTAG#" + from; + return matcher.find() ? matcher.group(1) : null; } public static double getCores(Hardware input) { diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 843123647f..7b37036fb1 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -99,7 +99,7 @@ import com.google.inject.Module; @Test(groups = { "integration", "live" }, sequential = true) public abstract class BaseComputeServiceLiveTest { - protected String tag; + protected String group; protected RetryablePredicate socketTester; protected SortedSet nodes; @@ -132,10 +132,10 @@ public abstract class BaseComputeServiceLiveTest { @BeforeGroups(groups = { "integration", "live" }) public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { setServiceDefaults(); - if (tag == null) - tag = checkNotNull(provider, "provider"); - if (tag.indexOf('-') == -1) - tag = tag + "-"; + if (group == null) + group = checkNotNull(provider, "provider"); + if (group.indexOf('-') == -1) + group = group + "-"; setupCredentials(); setupKeyPairForTest(); initializeContextAndClient(); @@ -215,7 +215,7 @@ public abstract class BaseComputeServiceLiveTest { // starting this one alphabetically before create2nodes.. @Test(enabled = true, dependsOnMethods = { "testCompareSizes" }) public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception { - String tag = this.tag + "r"; + String tag = this.group + "r"; try { client.destroyNodesMatching(withTag(tag)); } catch (Exception e) { @@ -267,19 +267,19 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testCreateTwoNodesWithRunScript() throws Exception { try { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(withTag(group)); } catch (NoSuchElementException e) { } refreshTemplate(); try { - nodes = newTreeSet(client.runNodesWithTag(tag, 2, template)); + nodes = newTreeSet(client.runNodesWithTag(group, 2, template)); } catch (RunNodesException e) { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; } assertEquals(nodes.size(), 2); - checkNodes(nodes, tag); + checkNodes(nodes, group); NodeMetadata node1 = nodes.first(); NodeMetadata node2 = nodes.last(); // credentials aren't always the same @@ -324,8 +324,8 @@ public abstract class BaseComputeServiceLiveTest { public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { initializeContextAndClient(); refreshTemplate(); - TreeSet nodes = newTreeSet(client.runNodesWithTag(tag, 1, template)); - checkNodes(nodes, tag); + TreeSet nodes = newTreeSet(client.runNodesWithTag(group, 1, template)); + checkNodes(nodes, group); NodeMetadata node = nodes.first(); this.nodes.add(node); assertEquals(nodes.size(), 1); @@ -375,7 +375,7 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testGet() throws Exception { Map metadataMap = newLinkedHashMap(uniqueIndex(filter(client - .listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))), + .listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED))), new Function() { @Override @@ -407,14 +407,14 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testGet") public void testReboot() throws Exception { - client.rebootNodesMatching(withTag(tag));// TODO test + client.rebootNodesMatching(withTag(group));// TODO test // validation testGet(); } @Test(enabled = true, dependsOnMethods = "testReboot") public void testSuspendResume() throws Exception { - client.suspendNodesMatching(withTag(tag)); + client.suspendNodesMatching(withTag(group)); Set stoppedNodes = refreshNodes(); @@ -430,7 +430,7 @@ public abstract class BaseComputeServiceLiveTest { }) : stoppedNodes; - client.resumeNodesMatching(withTag(tag)); + client.resumeNodesMatching(withTag(group)); testGet(); } @@ -467,22 +467,22 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" }) public void testDestroyNodes() { int toDestroy = refreshNodes().size(); - Set destroyed = client.destroyNodesMatching(withTag(tag)); + Set destroyed = client.destroyNodesMatching(withTag(group)); assertEquals(toDestroy, destroyed.size()); - for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), withTag(tag))) { + for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), withTag(group))) { assert node.getState() == NodeState.TERMINATED : node; assertEquals(context.getCredentialStore().get("node#" + node.getId()), null); } } private Set refreshNodes() { - return filter(client.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))); + return filter(client.listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED))); } @Test(enabled = true) public void testCreateAndRunAService() throws Exception { - String tag = this.tag + "s"; + String tag = this.group + "s"; try { client.destroyNodesMatching(withTag(tag)); } catch (Exception e) { @@ -554,7 +554,7 @@ public abstract class BaseComputeServiceLiveTest { } public void testOptionToNotBlock() throws Exception { - String tag = this.tag + "block"; + String tag = this.group + "block"; try { client.destroyNodesMatching(withTag(tag)); } catch (Exception e) { diff --git a/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java b/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java index cc008f9aae..89c2912b07 100644 --- a/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java +++ b/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java @@ -19,7 +19,7 @@ package org.jclouds.compute.util; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -41,7 +41,7 @@ public class ComputeServiceUtilsTest { @Test public void testParseTagFromName() { - assertEquals(parseTagFromName("gogrid--849"), "gogrid-"); + assertEquals(parseGroupFromName("gogrid--849"), "gogrid-"); } @Test diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java index 9438b69af5..3f86e3a9ad 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java @@ -60,7 +60,7 @@ import com.google.inject.Module; public abstract class BaseLoadBalancerServiceLiveTest { protected SshClient.Factory sshFactory; - protected String tag; + protected String group; protected RetryablePredicate socketTester; protected Set nodes; @@ -126,8 +126,8 @@ public abstract class BaseLoadBalancerServiceLiveTest { @BeforeGroups(groups = { "integration", "live" }) public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { setServiceDefaults(); - if (tag == null) - tag = checkNotNull(provider, "provider"); + if (group == null) + group = checkNotNull(provider, "provider"); setupCredentials(); initializeContext(); initializeComputeContext(); @@ -166,7 +166,7 @@ public abstract class BaseLoadBalancerServiceLiveTest { @BeforeGroups(groups = { "integration", "live" }, dependsOnMethods = "setupClient") public void createNodes() throws RunNodesException { try { - nodes = computeContext.getComputeService().runNodesWithTag(tag, 2); + nodes = computeContext.getComputeService().createNodesInGroup(group, 2); } catch (RunNodesException e) { nodes = e.getSuccessfulNodes(); throw e; @@ -177,7 +177,7 @@ public abstract class BaseLoadBalancerServiceLiveTest { public void testLoadBalanceNodesMatching() throws Exception { // create load balancers - loadbalancer = context.getLoadBalancerService().createLoadBalancerInLocation(null, tag, "HTTP", 80, 80, nodes); + loadbalancer = context.getLoadBalancerService().createLoadBalancerInLocation(null, group, "HTTP", 80, 80, nodes); assertNotNull(loadbalancer); validateNodesInLoadBalancer(); @@ -197,7 +197,7 @@ public abstract class BaseLoadBalancerServiceLiveTest { context.getLoadBalancerService().destroyLoadBalancer(loadbalancer.getId()); } if (nodes != null) { - computeContext.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); + computeContext.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); } computeContext.close(); context.close(); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java index a480b10105..57247c8ad1 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java @@ -49,7 +49,7 @@ import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -77,7 +77,7 @@ public class AWSEC2ComputeService extends EC2ComputeService { protected AWSEC2ComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, + GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy, Provider templateBuilderProvider, Provider templateOptionsProvider, diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index aa4327621f..937339785f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -52,7 +52,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public AWSEC2ComputeServiceLiveTest() { provider = "aws-ec2"; - tag = "ec2"; + group = "ec2"; } @Override @@ -67,29 +67,29 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) .getInstanceServices(); - String tag = this.tag + "o"; + String group = this.group + "o"; TemplateOptions options = client.templateOptions(); // Date before = new Date(); - options.as(AWSEC2TemplateOptions.class).securityGroups(tag); - options.as(AWSEC2TemplateOptions.class).keyPair(tag); + options.as(AWSEC2TemplateOptions.class).securityGroups(group); + options.as(AWSEC2TemplateOptions.class).keyPair(group); options.as(AWSEC2TemplateOptions.class).enableMonitoring(); String startedId = null; try { - cleanupExtendedStuff(securityGroupClient, keyPairClient, tag); + cleanupExtendedStuff(securityGroupClient, keyPairClient, group); // create a security group that allows ssh in so that our scripts later // will work - securityGroupClient.createSecurityGroupInRegion(null, tag, tag); - securityGroupClient.authorizeSecurityGroupIngressInRegion(null, tag, IpProtocol.TCP, 22, 22, "0.0.0.0/0"); + securityGroupClient.createSecurityGroupInRegion(null, group, group); + securityGroupClient.authorizeSecurityGroupIngressInRegion(null, group, IpProtocol.TCP, 22, 22, "0.0.0.0/0"); // create a keypair to pass in as well - KeyPair result = keyPairClient.createKeyPairInRegion(null, tag); + KeyPair result = keyPairClient.createKeyPairInRegion(null, group); - Set nodes = client.runNodesWithTag(tag, 1, options); + Set nodes = client.createNodesInGroup(group, 1, options); NodeMetadata first = Iterables.get(nodes, 0); assert first.getCredentials() != null : first; assert first.getCredentials().identity != null : first; @@ -98,7 +98,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { AWSRunningInstance instance = AWSRunningInstance.class.cast(getInstance(instanceClient, startedId)); - assertEquals(instance.getKeyName(), tag); + assertEquals(instance.getKeyName(), group); assertEquals(instance.getMonitoringState(), MonitoringState.ENABLED); // TODO when the cloudwatchclient is finished @@ -117,26 +117,26 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { // } // make sure we made our dummy group and also let in the user's group - assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet. of("jclouds#" + tag + "#" - + instance.getRegion(), tag)); + assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet. of("jclouds#" + group + "#" + + instance.getRegion(), group)); // make sure our dummy group has no rules - SecurityGroup group = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null, - "jclouds#" + tag + "#" + instance.getRegion())); - assert group.getIpPermissions().size() == 0 : group; + SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null, + "jclouds#" +group + "#" + instance.getRegion())); + assert secgroup.getIpPermissions().size() == 0 : secgroup; // try to run a script with the original keyPair - runScriptWithCreds(tag, first.getOperatingSystem(), new Credentials(first.getCredentials().identity, result + runScriptWithCreds(group, first.getOperatingSystem(), new Credentials(first.getCredentials().identity, result .getKeyMaterial())); } finally { - client.destroyNodesMatching(NodePredicates.withTag(tag)); + client.destroyNodesMatching(NodePredicates.inGroup(group)); if (startedId != null) { // ensure we didn't delete these resources! - assertEquals(keyPairClient.describeKeyPairsInRegion(null, tag).size(), 1); - assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, tag).size(), 1); + assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1); + assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1); } - cleanupExtendedStuff(securityGroupClient, keyPairClient, tag); + cleanupExtendedStuff(securityGroupClient, keyPairClient, group); } } @@ -157,26 +157,26 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) .getInstanceServices(); - String tag = this.tag + "g"; + String group = this.group + "g"; TemplateOptions options = client.templateOptions(); - // options.as(AWSEC2TemplateOptions.class).securityGroups(tag); - options.as(AWSEC2TemplateOptions.class).keyPair(tag); + // options.as(AWSEC2TemplateOptions.class).securityGroups(group); + options.as(AWSEC2TemplateOptions.class).keyPair(group); options.as(AWSEC2TemplateOptions.class).subnetId(subnetId); String startedId = null; String nodeId = null; try { - cleanupExtendedStuff(securityGroupClient, keyPairClient, tag); + cleanupExtendedStuff(securityGroupClient, keyPairClient, group); // create the security group - // securityGroupClient.createSecurityGroupInRegion(null, tag, tag); + // securityGroupClient.createSecurityGroupInRegion(null, group, group); // create a keypair to pass in as well - keyPairClient.createKeyPairInRegion(null, tag); + keyPairClient.createKeyPairInRegion(null, group); - Set nodes = client.runNodesWithTag(tag, 1, options); + Set nodes = client.createNodesInGroup(group, 1, options); NodeMetadata first = Iterables.get(nodes, 0); assert first.getCredentials() != null : first; @@ -194,9 +194,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { client.destroyNode(nodeId); if (startedId != null) { // ensure we didn't delete these resources! - assertEquals(keyPairClient.describeKeyPairsInRegion(null, tag).size(), 1); + assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1); } - cleanupExtendedStuff(securityGroupClient, keyPairClient, tag); + cleanupExtendedStuff(securityGroupClient, keyPairClient, group); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index de12ec2d0a..c735d8750f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -199,13 +199,13 @@ public class PlacementGroupClientLiveTest { template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) .runScript(buildScript(template.getImage().getOperatingSystem())); - String tag = PREFIX + "cccluster"; - context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); + String group = PREFIX + "cccluster"; + context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); // TODO make this not lookup an explicit region - client.getPlacementGroupServices().deletePlacementGroupInRegion(null, "jclouds#" + tag + "#us-east-1"); + client.getPlacementGroupServices().deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1"); try { - Set nodes = context.getComputeService().runNodesWithTag(tag, 1, template); + Set nodes = context.getComputeService().createNodesInGroup(group, 1, template); NodeMetadata node = getOnlyElement(nodes); getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, @@ -215,7 +215,7 @@ public class PlacementGroupClientLiveTest { System.err.println(e.getNodeErrors().keySet()); Throwables.propagate(e); } finally { - context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); + context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); } } diff --git a/providers/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java b/providers/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java index 3e73cda334..0ca48925ee 100644 --- a/providers/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java +++ b/providers/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java @@ -32,7 +32,7 @@ public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiv public AWSELBLoadBalancerServiceLiveTest() { provider = "aws-elb"; computeProvider = "aws-ec2"; - tag = "elb"; + group = "elb"; } } diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java index 4504a7f330..75e2b5717a 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java @@ -43,7 +43,7 @@ public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeS @Override public void setServiceDefaults() { - tag = "director"; + group = "director"; } @Test diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKComputeServiceLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKComputeServiceLiveTest.java index 44c8307490..c8902508bb 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKComputeServiceLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKComputeServiceLiveTest.java @@ -31,7 +31,7 @@ public class CloudServersUKComputeServiceLiveTest extends CloudServersComputeSer public CloudServersUKComputeServiceLiveTest() { provider = "cloudservers-uk"; - tag = "cs"; + group = "cs"; } } diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSComputeServiceLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSComputeServiceLiveTest.java index 6ba4037c67..7efb40a8aa 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSComputeServiceLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSComputeServiceLiveTest.java @@ -31,7 +31,7 @@ public class CloudServersUSComputeServiceLiveTest extends CloudServersComputeSer public CloudServersUSComputeServiceLiveTest() { provider = "cloudservers-us"; - tag = "cs"; + group = "cs"; } } diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java index ec6fc4a9f2..847d2586bd 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java @@ -109,7 +109,7 @@ public class CloudSigmaComputeServiceAdapter implements } @Override - public ServerInfo runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + public ServerInfo createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore) { long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l); logger.debug(">> imaging boot drive source(%s) bytes(%d)", template.getImage().getId(), bootSize); diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java index 0d838a1b0a..6a2306fe51 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.cloudsigma.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.List; import java.util.Map; @@ -92,7 +92,7 @@ public class ServerInfoToNodeMetadata implements Function defineAddNodeWithTagStrategy() { - return GoGridAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return FindPublicIpThenCreateNodeInGroup.class; } @Override diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java index 28670853c2..37c3a584b7 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.gogrid.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.NoSuchElementException; @@ -109,7 +109,7 @@ public class ServerToNodeMetadata implements Function { builder.ids(from.getId() + ""); builder.name(from.getName()); builder.location(locations.get().get(from.getDatacenter().getId() + "")); - builder.tag(parseTagFromName(from.getName())); + builder.group(parseGroupFromName(from.getName())); builder.hardware(parseHardware(from)); builder.imageId(from.getImage().getId() + ""); diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridAddNodeWithTagStrategy.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindPublicIpThenCreateNodeInGroup.java similarity index 93% rename from providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridAddNodeWithTagStrategy.java rename to providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindPublicIpThenCreateNodeInGroup.java index 221791acdd..a2a8788fb5 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridAddNodeWithTagStrategy.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindPublicIpThenCreateNodeInGroup.java @@ -31,7 +31,7 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Template; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.IpType; @@ -49,7 +49,7 @@ import com.google.common.collect.Iterables; * @author Oleksiy Yarmula */ @Singleton -public class GoGridAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class FindPublicIpThenCreateNodeInGroup implements CreateNodeWithGroupEncodedIntoName { private final GoGridClient client; private final Function sizeToRam; private final Function serverToNodeMetadata; @@ -57,7 +57,7 @@ public class GoGridAddNodeWithTagStrategy implements AddNodeWithTagStrategy { private RetryablePredicate serverLatestJobCompletedShort; @Inject - protected GoGridAddNodeWithTagStrategy(GoGridClient client, + protected FindPublicIpThenCreateNodeInGroup(GoGridClient client, Function serverToNodeMetadata, Function sizeToRam, Timeouts timeouts) { this.client = client; @@ -71,7 +71,7 @@ public class GoGridAddNodeWithTagStrategy implements AddNodeWithTagStrategy { } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { Server addedServer = null; boolean notStarted = true; int numOfRetries = 20; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java index 9fb673bc75..c6dcb174eb 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java @@ -73,7 +73,7 @@ public class ServerToNodeMetadataTest { Server server = createMock(Server.class); expect(server.getId()).andReturn(1000l).atLeastOnce(); - expect(server.getName()).andReturn("tag-ff").atLeastOnce(); + expect(server.getName()).andReturn("group-ff").atLeastOnce(); expect(server.getState()).andReturn(ServerState.ON).atLeastOnce(); expect(serverStateToNodeState.get(ServerState.ON)).andReturn(NodeState.RUNNING); @@ -83,7 +83,7 @@ public class ServerToNodeMetadataTest { Map credentialsMap = createMock(Map.class); expect(client.getServerCredentialsList()).andReturn(credentialsMap); - expect(credentialsMap.get("tag-ff")).andReturn(new Credentials("user", "pass")); + expect(credentialsMap.get("group-ff")).andReturn(new Credentials("user", "pass")); expect(server.getIp()).andReturn(new Ip("127.0.0.1")); @@ -112,7 +112,7 @@ public class ServerToNodeMetadataTest { NodeMetadata metadata = parser.apply(server); assertEquals(metadata.getLocation(), location); assertEquals(metadata.getImageId(), "2000"); - assertEquals(metadata.getTag(), "tag"); + assertEquals(metadata.getGroup(), "group"); assertEquals(metadata.getCredentials(), new Credentials("user", "pass")); verify(caller); diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1ComputeServiceLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1ComputeServiceLiveTest.java index 194eb058d2..9c3454acb0 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1ComputeServiceLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1ComputeServiceLiveTest.java @@ -31,7 +31,7 @@ public class OpenHostingEast1ComputeServiceLiveTest extends ElasticStackComputeS public OpenHostingEast1ComputeServiceLiveTest() { provider = "openhosting-east1"; - tag = "openhosting"; + group = "openhosting"; } } diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterComputeServiceLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterComputeServiceLiveTest.java index b25780226e..f3376ae49b 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterComputeServiceLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterComputeServiceLiveTest.java @@ -31,7 +31,7 @@ public class ServerloveManchesterComputeServiceLiveTest extends ElasticStackComp public ServerloveManchesterComputeServiceLiveTest() { provider = "serverlove-z1-man"; - tag = "serverlove"; + group = "serverlove"; } } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostBindComputeStrategiesByClass.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostBindComputeStrategiesByClass.java index 0e203eb781..91dd79dc81 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostBindComputeStrategiesByClass.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostBindComputeStrategiesByClass.java @@ -20,14 +20,14 @@ package org.jclouds.slicehost.compute.config; import org.jclouds.compute.config.BindComputeStrategiesByClass; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.slicehost.compute.strategy.SlicehostAddNodeWithTagStrategy; +import org.jclouds.slicehost.compute.strategy.SlicehostCreateNodeWithGroupEncodedIntoName; import org.jclouds.slicehost.compute.strategy.SlicehostDestroyNodeStrategy; import org.jclouds.slicehost.compute.strategy.SlicehostGetNodeMetadataStrategy; import org.jclouds.slicehost.compute.strategy.SlicehostListNodesStrategy; @@ -41,8 +41,8 @@ import org.jclouds.slicehost.compute.strategy.SlicehostLifeCycleStrategy; public class SlicehostBindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override - protected Class defineAddNodeWithTagStrategy() { - return SlicehostAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return SlicehostCreateNodeWithGroupEncodedIntoName.class; } @Override diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java index ed602dc4e6..eed42aa14b 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.slicehost.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.NoSuchElementException; @@ -104,7 +104,7 @@ public class SliceToNodeMetadata implements Function { builder.ids(from.getId() + ""); builder.name(from.getName()); builder.location(location.get()); - builder.tag(parseTagFromName(from.getName())); + builder.group(parseGroupFromName(from.getName())); builder.imageId(from.getImageId() + ""); builder.operatingSystem(parseOperatingSystem(from)); builder.hardware(parseHardware(from)); diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostCreateNodeWithGroupEncodedIntoName.java similarity index 83% rename from providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java rename to providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostCreateNodeWithGroupEncodedIntoName.java index 4c3e94f0c6..5151f819b6 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostCreateNodeWithGroupEncodedIntoName.java @@ -28,7 +28,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.domain.Credentials; import org.jclouds.slicehost.SlicehostClient; import org.jclouds.slicehost.domain.Slice; @@ -40,13 +40,13 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class SlicehostAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class SlicehostCreateNodeWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName { protected final SlicehostClient client; protected final Map credentialStore; protected final Function sliceToNodeMetadata; @Inject - protected SlicehostAddNodeWithTagStrategy(SlicehostClient client, Map credentialStore, + protected SlicehostCreateNodeWithGroupEncodedIntoName(SlicehostClient client, Map credentialStore, Function sliceToNodeMetadata) { this.client = checkNotNull(client, "client"); this.credentialStore = checkNotNull(credentialStore, "credentialStore"); @@ -54,7 +54,7 @@ public class SlicehostAddNodeWithTagStrategy implements AddNodeWithTagStrategy { } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { Slice from = client.createSlice(name, Integer.parseInt(template.getImage().getProviderId()), Integer.parseInt(template.getHardware().getProviderId())); credentialStore.put("node#" + from.getId(), new Credentials("root", from.getRootPassword())); diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java index 3051a0d225..553973a7ff 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java @@ -72,7 +72,7 @@ public class SliceToNodeMetadataTest { NodeMetadata metadata = parser.apply(slice); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).tag("jclouds") + ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") .imageId("2").id("1").providerId("1").name("jclouds-foo").location(provider).credentials(creds) .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } @@ -91,7 +91,7 @@ public class SliceToNodeMetadataTest { NodeMetadata metadata = parser.apply(slice); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).tag("jclouds") + ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") .imageId("2").id("1").providerId("1").name("jclouds-foo").location(provider).userMetadata( ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } @@ -110,7 +110,7 @@ public class SliceToNodeMetadataTest { NodeMetadata metadata = parser.apply(slice); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).tag("jclouds") + ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") .imageId("2").operatingSystem( new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") .is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").location(provider) @@ -130,7 +130,7 @@ public class SliceToNodeMetadataTest { NodeMetadata metadata = parser.apply(slice); assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( - ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).tag("jclouds") + ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") .imageId("2").hardware( new HardwareBuilder().ids("1").name("256 slice").processors( ImmutableList.of(new Processor(0.25, 1.0))).ram(256).volumes( diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java index 5a6fe2e759..b4bdc74cf4 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java @@ -52,7 +52,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv @Override public void setServiceDefaults() { - tag = "te"; + group = "te"; } @Test diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index 5887f2e4c1..3184af9fa4 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -52,7 +52,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer @Override public void setServiceDefaults() { - tag = "vcx"; + group = "vcx"; } @Test diff --git a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/LibvirtComputeService.java b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/LibvirtComputeService.java index 9c2be3ef6b..b8a14ac0b8 100644 --- a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/LibvirtComputeService.java +++ b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/LibvirtComputeService.java @@ -45,7 +45,7 @@ import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -73,7 +73,7 @@ public class LibvirtComputeService extends BaseComputeService { @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, + GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy, Provider templateBuilderProvider, Provider templateOptionsProvider, diff --git a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/functions/DomainToNodeMetadata.java b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/functions/DomainToNodeMetadata.java index d4b0ced0a4..3d0bde6814 100644 --- a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/functions/DomainToNodeMetadata.java +++ b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/functions/DomainToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.libvirt.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.Set; @@ -88,7 +88,7 @@ public class DomainToNodeMetadata implements Function { builder.providerId(from.getID() + ""); builder.name(from.getName()); builder.location(findLocationForDomain.apply(from)); - builder.tag(parseTagFromName(from.getName())); + builder.group(parseGroupFromName(from.getName())); builder.operatingSystem(new OperatingSystemBuilder().description(from.getOSType()).build()); builder.hardware(findHardwareForDomain.apply(from)); diff --git a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/strategy/LibvirtComputeServiceAdapter.java b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/strategy/LibvirtComputeServiceAdapter.java index 8c7d433e46..92d81acf6f 100644 --- a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/strategy/LibvirtComputeServiceAdapter.java +++ b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/compute/strategy/LibvirtComputeServiceAdapter.java @@ -81,7 +81,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter credentialStore) { try { String domainName = tag; diff --git a/sandbox-apis/libvirt/src/test/java/org/jclouds/libvirt/compute/LibvirtExperimentLiveTest.java b/sandbox-apis/libvirt/src/test/java/org/jclouds/libvirt/compute/LibvirtExperimentLiveTest.java index 6f4647025d..e0c16bc8d8 100644 --- a/sandbox-apis/libvirt/src/test/java/org/jclouds/libvirt/compute/LibvirtExperimentLiveTest.java +++ b/sandbox-apis/libvirt/src/test/java/org/jclouds/libvirt/compute/LibvirtExperimentLiveTest.java @@ -77,7 +77,7 @@ public class LibvirtExperimentLiveTest { * the default template via overriding a method in standalonecomputeservicexontextmodule */ - Set nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1); + Set nodeMetadataSet = context.getComputeService().createNodesInGroup("tty", 1); for (NodeMetadata nodeMetadata : nodeMetadataSet) { /* * context.getComputeService().suspendNode(nodeMetadata.getId()); diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java index 1df1dc6c67..ce9b803b5e 100755 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java +++ b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java @@ -47,7 +47,7 @@ public class SDNAuthAsyncClientTest extends RestClientTest { Method method = SDNAuthAsyncClient.class.getMethod("authenticate", String.class, String.class, String.class); HttpRequest httpRequest = processor.createRequest(method, "apple", "foo", "bar"); assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/ws/Authentication/Login.ashx?output=json&appKey=apple&password=bar&username=foo HTTP/1.1"); + "GET http://localhost:8080/ws/Authentication/Login.ashx?output=json&appKey=apple&password=bar&username=foo HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest, null, null, false); @@ -69,8 +69,8 @@ public class SDNAuthAsyncClientTest extends RestClientTest { @Override public RestContextSpec createContextSpec() { - return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", SDNAuthClient.class, - SDNAuthAsyncClient.class); + return contextSpec("test", "http://localhost:8080", "1", "", "identity", "credential", SDNAuthClient.class, + SDNAuthAsyncClient.class); } } diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java index f2f3f083db..e870a20312 100644 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java +++ b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java @@ -74,7 +74,7 @@ public class SDNAuthenticationLiveTest { identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity"); credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential"); - RestContextSpec contextSpec = contextSpec("test", endpoint, "1", identity, + RestContextSpec contextSpec = contextSpec("test", endpoint, "1", "", identity, credential, SDNAuthClient.class, SDNAuthAsyncClient.class); context = createContextBuilder( diff --git a/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/ViComputeService.java b/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/ViComputeService.java index 566dab7489..d5b7c14798 100644 --- a/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/ViComputeService.java +++ b/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/ViComputeService.java @@ -44,7 +44,7 @@ import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -69,7 +69,7 @@ public class ViComputeService extends BaseComputeService { @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, + GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy, Provider templateBuilderProvider, Provider templateOptionsProvider, diff --git a/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java b/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java index f11883f2a9..21e91f94a5 100644 --- a/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java +++ b/sandbox-apis/vi/src/main/java/org/jclouds/vi/compute/functions/VirtualMachineToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.vi.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.Set; @@ -83,7 +83,7 @@ public class VirtualMachineToNodeMetadata implements Function credentialStore) { try { diff --git a/sandbox-apis/vi/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java b/sandbox-apis/vi/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java index e1766f2ad2..bc7774eeaf 100644 --- a/sandbox-apis/vi/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java +++ b/sandbox-apis/vi/src/test/java/org/jclouds/vi/compute/ViExperimentLiveTest.java @@ -23,22 +23,17 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; -import javax.annotation.Resource; - import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; -import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; -import com.google.inject.name.Named; /** * diff --git a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudBindComputeStrategiesByClass.java b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudBindComputeStrategiesByClass.java index 1091eeac93..a20bd01ec9 100644 --- a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudBindComputeStrategiesByClass.java +++ b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudBindComputeStrategiesByClass.java @@ -20,14 +20,14 @@ package org.jclouds.ibmdev.compute.config; import org.jclouds.compute.config.BindComputeStrategiesByClass; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudAddNodeWithTagStrategy; +import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName; import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudDestroyNodeStrategy; import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudGetNodeMetadataStrategy; import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudLifeCycleStrategy; @@ -39,8 +39,8 @@ import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudListNodesStrategy; public class IBMDeveloperCloudBindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override - protected Class defineAddNodeWithTagStrategy() { - return IBMDeveloperCloudAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName.class; } @Override diff --git a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java index 9507b5134b..8f3147953f 100644 --- a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java +++ b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.ibmdev.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.Set; @@ -86,12 +86,12 @@ public class InstanceToNodeMetadata implements Function @Override public NodeMetadata apply(Instance from) { //TODO hardware - String tag = parseTagFromName(from.getName()); + String group = parseGroupFromName(from.getName()); Set ipSet = from.getIp() != null ? ImmutableSet.of(from.getIp()) : ImmutableSet. of(); Image image = images.get().get(from.getImageId()); - String key = tag != null ? credentialsMap.get(tag) : null; + String key = group != null ? credentialsMap.get(group) : null; return new NodeMetadataBuilder().ids(from.getId() + "").name(from.getName()) - .location(locations.get().get(image.getLocation())).tag(tag).imageId(from.getImageId()) + .location(locations.get().get(image.getLocation())).group(group).imageId(from.getImageId()) .state(instanceStateToNodeState.get(from.getStatus())) .operatingSystem(image != null ? image.getOperatingSystem() : null).publicAddresses(ipSet) .credentials(new Credentials(image.getDefaultCredentials().identity, key)).build(); diff --git a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet.java b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/CreateKeyCreateNodesWithGroupEncodedIntoNameThenAddToSet.java similarity index 77% rename from sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet.java rename to sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/CreateKeyCreateNodesWithGroupEncodedIntoNameThenAddToSet.java index ba489734b8..3c918fd156 100644 --- a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet.java +++ b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/CreateKeyCreateNodesWithGroupEncodedIntoNameThenAddToSet.java @@ -34,10 +34,10 @@ 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.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; +import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; import org.jclouds.ibmdev.IBMDeveloperCloudClient; import com.google.common.collect.Multimap; @@ -46,13 +46,13 @@ import com.google.common.collect.Multimap; * @author Adrian Cole */ @Singleton -public class CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet extends EncodeTagIntoNameRunNodesAndAddToSetStrategy { +public class CreateKeyCreateNodesWithGroupEncodedIntoNameThenAddToSet extends CreateNodesWithGroupEncodedIntoNameThenAddToSet { private final IBMDeveloperCloudClient client; private final Map credentialsMap; @Inject - protected CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet( - AddNodeWithTagStrategy addNodeWithTagStrategy, + protected CreateKeyCreateNodesWithGroupEncodedIntoNameThenAddToSet( + CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy, ListNodesStrategy listNodesStrategy, @Named("NAMING_CONVENTION") String nodeNamingConvention, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @@ -65,21 +65,21 @@ public class CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet extends EncodeTag } @Override - public Map> execute(String tag, int count, Template template, Set goodNodes, + public Map> execute(String group, int count, Template template, Set goodNodes, Map badNodes, Multimap customizationResponses) { String keyAsText = template.getOptions().getPublicKey(); if (keyAsText != null) { template.getOptions().dontAuthorizePublicKey(); try { - client.addPublicKey(tag, keyAsText); + client.addPublicKey(group, keyAsText); } catch (IllegalStateException e) { // must not have been found - client.updatePublicKey(tag, keyAsText); + client.updatePublicKey(group, keyAsText); } } else { - credentialsMap.put(tag, client.generateKeyPair(tag).getKeyMaterial()); + credentialsMap.put(group, client.generateKeyPair(group).getKeyMaterial()); } - return super.execute(tag, count, template, goodNodes, badNodes, customizationResponses); + return super.execute(group, count, template, goodNodes, badNodes, customizationResponses); } } \ No newline at end of file diff --git a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudAddNodeWithTagStrategy.java b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName.java similarity index 82% rename from sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudAddNodeWithTagStrategy.java rename to sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName.java index b7ddecac5b..d5228bde8b 100644 --- a/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudAddNodeWithTagStrategy.java +++ b/sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName.java @@ -27,7 +27,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.ibmdev.IBMDeveloperCloudClient; import org.jclouds.ibmdev.domain.Instance; @@ -37,22 +37,22 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class IBMDeveloperCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName { private final IBMDeveloperCloudClient client; private final Function instanceToNodeMetadata; @Inject - protected IBMDeveloperCloudAddNodeWithTagStrategy(IBMDeveloperCloudClient client, + protected IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName(IBMDeveloperCloudClient client, Function instanceToNodeMetadata) { this.client = checkNotNull(client, "client"); this.instanceToNodeMetadata = checkNotNull(instanceToNodeMetadata, "instanceToNodeMetadata"); } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { Instance instance = client.createInstanceInLocation(template.getLocation().getId(), name, template.getImage() - .getProviderId(), template.getHardware().getProviderId(), authorizePublicKey(tag)); + .getProviderId(), template.getHardware().getProviderId(), authorizePublicKey(group)); return instanceToNodeMetadata.apply(client.getInstance(instance.getId())); } } \ No newline at end of file diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java index aa1790a9a2..3785da058b 100644 --- a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java +++ b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java @@ -1,14 +1,14 @@ package org.jclouds.rimuhosting.miro.compute.config; import org.jclouds.compute.config.BindComputeStrategiesByClass; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingAddNodeWithTagStrategy; +import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingCreateNodeWithGroupEncodedIntoName; import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingDestroyNodeStrategy; import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingGetNodeMetadataStrategy; import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingLifeCycleStrategy; @@ -16,8 +16,8 @@ import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingListNodesStrateg public class RimuHostingBindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override - protected Class defineAddNodeWithTagStrategy() { - return RimuHostingAddNodeWithTagStrategy.class; + protected Class defineAddNodeWithTagStrategy() { + return RimuHostingCreateNodeWithGroupEncodedIntoName.class; } @Override diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java index 62d0029fb6..3014fa7430 100644 --- a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java +++ b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.rimuhosting.miro.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.NoSuchElementException; @@ -97,7 +97,7 @@ public class ServerToNodeMetadata implements Function { builder.name(from.getName()); Location location = findLocationWithId(from.getLocation().getId()); builder.location(location); - builder.tag(parseTagFromName(from.getName())); + builder.group(parseGroupFromName(from.getName())); builder.imageId(from.getImageId() + ""); builder.operatingSystem(parseOperatingSystem(from, location)); builder.hardware(null);// TODO diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java similarity index 84% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java rename to sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java index 22928ad679..eba0f63b56 100644 --- a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java +++ b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java @@ -28,7 +28,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.domain.Credentials; import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.rimuhosting.miro.domain.NewServerResponse; @@ -41,13 +41,13 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class RimuHostingAddNodeWithTagStrategy implements AddNodeWithTagStrategy { +public class RimuHostingCreateNodeWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName { protected final RimuHostingClient client; protected final Map credentialStore; protected final Function serverToNodeMetadata; @Inject - protected RimuHostingAddNodeWithTagStrategy(RimuHostingClient client, Map credentialStore, + protected RimuHostingCreateNodeWithGroupEncodedIntoName(RimuHostingClient client, Map credentialStore, Function serverToNodeMetadata) { this.client = client; this.credentialStore = credentialStore; @@ -55,7 +55,7 @@ public class RimuHostingAddNodeWithTagStrategy implements AddNodeWithTagStrategy } @Override - public NodeMetadata addNodeWithTag(String tag, String name, Template template) { + public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { NewServerResponse serverResponse = client.createServer(name, checkNotNull(template.getImage().getProviderId(), "imageId"), checkNotNull(template.getHardware().getProviderId(), "hardwareId")); Server from = client.getServer(serverResponse.getServer().getId()); diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index f3ed959f14..86443924e8 100755 --- a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -41,7 +41,7 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes @BeforeClass @Override public void setServiceDefaults() { - tag = "rimuhosting.jclouds"; + group = "rimuhosting.jclouds"; } @Test diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java index 8d29a0efda..1604203e8f 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.servermanager.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import java.util.Map; import java.util.Set; @@ -78,7 +78,7 @@ public class ServerToNodeMetadata implements Function { builder.ids(from.id + ""); builder.name(from.name); builder.location(findLocationForServer.apply(from)); - builder.tag(parseTagFromName(from.name)); + builder.group(parseGroupFromName(from.name)); builder.imageId(from.imageId + ""); Image image = findImageForServer.apply(from); if (image != null) diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/strategy/ServerManagerComputeServiceAdapter.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/strategy/ServerManagerComputeServiceAdapter.java index a1dbc73d43..1dea1816bd 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/strategy/ServerManagerComputeServiceAdapter.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/strategy/ServerManagerComputeServiceAdapter.java @@ -34,7 +34,7 @@ public class ServerManagerComputeServiceAdapter implements ComputeServiceAdapter } @Override - public Server runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template, + public Server createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore) { // create the backend object using parameters from the template. Server from = client.createServerInDC(template.getLocation().getId(), name,