mirror of https://github.com/apache/jclouds.git
Issue 457: rename tag -> group
This commit is contained in:
parent
a1dbbd203c
commit
4a52218565
|
@ -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
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -71,7 +71,7 @@ public class NodeToNodeMetadata implements Function<Node, NodeMetadata> {
|
|||
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())
|
||||
|
|
|
@ -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<String, Credentials> credentialStore) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return CloudServersAddNodeWithTagStrategy.class;
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
|
||||
return CloudServersCreateNodeWithGroupEncodedIntoName.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Server, NodeMetadata> {
|
|||
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));
|
||||
|
|
|
@ -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<String, Credentials> credentialStore;
|
||||
protected final Function<Server, NodeMetadata> serverToNodeMetadata;
|
||||
|
||||
@Inject
|
||||
protected CloudServersAddNodeWithTagStrategy(CloudServersClient client, Map<String, Credentials> credentialStore,
|
||||
protected CloudServersCreateNodeWithGroupEncodedIntoName(CloudServersClient client, Map<String, Credentials> credentialStore,
|
||||
Function<Server, NodeMetadata> 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()));
|
|
@ -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(
|
||||
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());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, Credentials> credentialStore,
|
||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> 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<? extends NodeMetadata> deadOnes = super.destroyNodesMatching(filter);
|
||||
Map<String, String> 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<String, String> regionTag : regionTags.entrySet()) {
|
||||
cleanUpIncidentalResources(regionTag);
|
||||
|
|
|
@ -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<? extends RunNodesAndAddToSetStrategy> defineRunNodesAndAddToSetStrategy() {
|
||||
return EC2RunNodesAndAddToSetStrategy.class;
|
||||
protected Class<? extends CreateNodesInGroupThenAddToSet> 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<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> 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<? extends AddNodeWithTagStrategy> clazz) {
|
||||
protected void bindAddNodeWithTagStrategy(Class<? extends CreateNodeWithGroupEncodedIntoName> clazz) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,8 +89,8 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
|||
String providerId = checkNotNull(instance, "instance").getId();
|
||||
builder.providerId(providerId);
|
||||
builder.id(instance.getRegion() + "/" + providerId);
|
||||
String tag = getTagForInstance(instance);
|
||||
builder.tag(tag);
|
||||
String group = getGroupForInstance(instance);
|
||||
builder.group(group);
|
||||
builder.credentials(credentialStore.get("node#" + instance.getRegion() + "/" + providerId));
|
||||
builder.state(instanceToNodeState.get(instance.getInstanceState()));
|
||||
builder.publicAddresses(NullSafeCollections.nullSafeSet(instance.getIpAddress()));
|
||||
|
@ -157,10 +157,10 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
String getTagForInstance(final RunningInstance instance) {
|
||||
String tag = String.format("NOTAG#%s", instance.getId());// default
|
||||
String getGroupForInstance(final RunningInstance instance) {
|
||||
String group = null;
|
||||
try {
|
||||
tag = Iterables.getOnlyElement(Iterables.filter(instance.getGroupIds(), new Predicate<String>() {
|
||||
group = Iterables.getOnlyElement(Iterables.filter(instance.getGroupIds(), new Predicate<String>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
|
@ -169,13 +169,13 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
|||
|
||||
})).substring(8).replaceAll("#" + instance.getRegion() + "$", "");
|
||||
} catch (NoSuchElementException e) {
|
||||
logger.debug("no tag parsed from %s's groups: %s", instance.getId(), instance.getGroupIds());
|
||||
logger.debug("no group parsed from %s's security groups: %s", instance.getId(), instance.getGroupIds());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger
|
||||
.debug("too many groups match %s; %s's groups: %s", "jclouds#", instance.getId(), instance
|
||||
.debug("too many groups match %s; %s's security groups: %s", "jclouds#", instance.getId(), instance
|
||||
.getGroupIds());
|
||||
}
|
||||
return tag;
|
||||
return group;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.jclouds.compute.config.CustomizationResponse;
|
|||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
|
||||
import org.jclouds.compute.util.ComputeUtils;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
|
@ -60,7 +60,7 @@ import com.google.common.collect.Multimap;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrategy {
|
||||
public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThenAddToSet {
|
||||
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
|
@ -79,7 +79,7 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate
|
|||
final Map<String, Credentials> credentialStore;
|
||||
|
||||
@Inject
|
||||
EC2RunNodesAndAddToSetStrategy(
|
||||
EC2CreateNodesInGroupThenAddToSet(
|
||||
EC2Client client,
|
||||
CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
|
||||
@Named("PRESENT") Predicate<RunningInstance> instancePresent,
|
||||
|
@ -96,10 +96,10 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<?, Future<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> goodNodes,
|
||||
public Map<?, Future<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
|
||||
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
|
||||
|
||||
Iterable<? extends RunningInstance> started = createKeyPairAndSecurityGroupsAsNeededThenRunInstances(tag, count,
|
||||
Iterable<? extends RunningInstance> started = createKeyPairAndSecurityGroupsAsNeededThenRunInstances(group, count,
|
||||
template);
|
||||
Iterable<String> ids = transform(started, instanceToId);
|
||||
|
||||
|
@ -130,13 +130,13 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate
|
|||
|
||||
// TODO write test for this
|
||||
@VisibleForTesting
|
||||
Iterable<? extends RunningInstance> createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String tag, int count,
|
||||
Iterable<? extends RunningInstance> 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;
|
|
@ -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<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
|
||||
Set<? extends NodeMetadata> 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.<String> of("jclouds#" + tag + "#"
|
||||
+ instance.getRegion(), tag));
|
||||
assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet.<String> 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<Location>() {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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.<Module> 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));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,833 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> 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.<Image> 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.<String, EbsBlockDevice> 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<RunningInstance, NodeMetadata> 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.<Processor> of(new Processor(1.0, 1.0)));
|
||||
// assertEquals(metadata.getHardware().getRam(), 1740);
|
||||
// assertEquals(metadata.getHardware().getVolumes(),
|
||||
// ImmutableList.<Volume> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> 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.<Image> 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.<String, EbsBlockDevice> newHashMap());
|
||||
// expect(instance.getRootDeviceType()).andReturn(RootDeviceType.INSTANCE_STORE);
|
||||
//
|
||||
// replay(imageMap);
|
||||
// replay(client);
|
||||
// replay(amiClient);
|
||||
// replay(credentialsMap);
|
||||
// replay(credentialProvider);
|
||||
// replay(instance);
|
||||
// replay(jcImage);
|
||||
//
|
||||
// Function<RunningInstance, NodeMetadata> 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.<Processor> of(new Processor(1.0, 1.0)));
|
||||
// assertEquals(metadata.getHardware().getRam(), 1740);
|
||||
// assertEquals(metadata.getHardware().getVolumes(),
|
||||
// ImmutableList.<Volume> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> 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.<Image> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> 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.<Image> 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.<String, EbsBlockDevice> newHashMap());
|
||||
// expect(instance.getRootDeviceType()).andReturn(RootDeviceType.INSTANCE_STORE);
|
||||
//
|
||||
// replay(imageMap);
|
||||
// replay(client);
|
||||
// replay(amiClient);
|
||||
// replay(credentialsMap);
|
||||
// replay(credentialProvider);
|
||||
// replay(instance);
|
||||
// replay(jcImage);
|
||||
//
|
||||
// Function<RunningInstance, NodeMetadata> 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.<Processor> of(new Processor(1.0, 1.0)));
|
||||
// assertEquals(metadata.getHardware().getRam(), 1740);
|
||||
// assertEquals(metadata.getHardware().getVolumes(),
|
||||
// ImmutableList.<Volume> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||
//
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
//
|
||||
// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||
// @Memoized Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> of(location));
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||
//
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
//
|
||||
// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||
// @Memoized Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> of(location));
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||
//
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
//
|
||||
// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||
// @Memoized Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> of(location));
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||
//
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
//
|
||||
// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||
// @Memoized Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> of(location));
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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.<String> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
//
|
||||
// Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||
// @Memoized Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> of(location));
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> 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.<Image> 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<RunningInstance, NodeMetadata> 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<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
// ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
// @Memoized Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
// .<Hardware> 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<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
// .<Location> 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.<Image> 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<RunningInstance, NodeMetadata> 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);
|
||||
//
|
||||
// }
|
||||
}
|
|
@ -83,8 +83,8 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses(
|
||||
ImmutableSet.<String> 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.<String> 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) {
|
||||
|
|
|
@ -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<RunningInstance> instanceStateRunning = createMock(Predicate.class);
|
||||
|
@ -219,11 +219,11 @@ public class EC2RunNodesAndAddToSetStrategyTest {
|
|||
Function<RunningInstance, Credentials> instanceToCredentials = createMock(Function.class);
|
||||
Map<String, Credentials> 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);
|
||||
|
|
|
@ -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<String, Credentials> credentialStore) {
|
||||
long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);
|
||||
logger.debug(">> creating boot drive bytes(%d)", bootSize);
|
||||
|
|
|
@ -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<ServerInfo, NodeMetada
|
|||
builder.ids(from.getUuid());
|
||||
builder.name(from.getName());
|
||||
builder.location(locationSupplier.get());
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
builder.group(parseGroupFromName(from.getName()));
|
||||
|
||||
String imageId = getImageIdFromServer.apply(from);
|
||||
if (imageId != null) {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveT
|
|||
Set<? extends LoadBalancer> elbs = elbClient.describeLoadBalancersInRegion(null);
|
||||
assertNotNull(elbs);
|
||||
for (LoadBalancer elb : elbs) {
|
||||
if (elb.getName().equals(tag))
|
||||
if (elb.getName().equals(group))
|
||||
assertEquals(elb.getInstanceIds(), instanceIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest
|
|||
public EucalyptusComputeServiceLiveTest() {
|
||||
provider = "eucalyptus";
|
||||
// security groups must be <30 characters
|
||||
tag = "eu";
|
||||
group = "eu";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class BindCaptureVAppParamsToXmlPayload implements MapBinder {
|
|||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> 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");
|
||||
|
|
|
@ -94,7 +94,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> 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");
|
||||
|
|
|
@ -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<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return VCloudAddNodeWithTagStrategy.class;
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
|
||||
return InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<VApp, NodeMetadata> {
|
|||
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()));
|
||||
|
|
|
@ -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<URI> successTester;
|
||||
|
||||
@Inject
|
||||
protected VCloudAddNodeWithTagStrategy(Predicate<URI> successTester, VCloudClient client,
|
||||
protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(Predicate<URI> 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));
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<<EOF\nI love candy\nEOF\n";
|
||||
|
||||
TemplateOptions options = client.templateOptions();
|
||||
|
@ -119,7 +119,7 @@ public class VCloudGuestCustomizationLiveTest {
|
|||
NodeMetadata node = null;
|
||||
try {
|
||||
|
||||
node = getOnlyElement(client.runNodesWithTag(tag, 1, options));
|
||||
node = getOnlyElement(client.createNodesInGroup(group, 1, options));
|
||||
|
||||
IPSocket socket = new IPSocket(get(node.getPublicAddresses(), 0), 22);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload implemen
|
|||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> 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");
|
||||
|
|
|
@ -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<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return VCloudExpressAddNodeWithTagStrategy.class;
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
|
||||
return StartVAppWithGroupEncodedIntoName.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<VCloudExpressVA
|
|||
builder.uri(from.getHref());
|
||||
builder.name(from.getName());
|
||||
builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
builder.group(parseGroupFromName(from.getName()));
|
||||
builder.operatingSystem(from.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType
|
||||
.fromValue(from.getOsType()), null, null, from.getOperatingSystemDescription()) : null);
|
||||
builder.hardware(hardwareForVCloudExpressVApp.apply(from));
|
||||
|
|
|
@ -29,7 +29,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.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
|
||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
||||
|
@ -41,13 +41,13 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
||||
public class StartVAppWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName {
|
||||
protected final VCloudExpressClient client;
|
||||
protected final VCloudExpressComputeClient computeClient;
|
||||
protected final Function<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata;
|
||||
|
||||
@Inject
|
||||
protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
|
||||
protected StartVAppWithGroupEncodedIntoName(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
|
||||
Function<VCloudExpressVApp, NodeMetadata> 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));
|
|
@ -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<String, Credentials> credentialStore,
|
||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> templateOptionsProvider,
|
||||
|
|
|
@ -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<? extends RunNodesAndAddToSetStrategy> defineRunNodesAndAddToSetStrategy() {
|
||||
protected Class<? extends CreateNodesInGroupThenAddToSet> defineRunNodesAndAddToSetStrategy() {
|
||||
return TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return TerremarkVCloudAddNodeWithTagStrategy.class;
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
|
||||
return StartVAppWithGroupEncodedIntoName.class;
|
||||
}
|
||||
}
|
|
@ -61,12 +61,12 @@ public class NodeMetadataToOrgAndName implements Function<NodeMetadata, OrgAndNa
|
|||
|
||||
@Override
|
||||
public OrgAndName apply(NodeMetadata from) {
|
||||
if (from.getTag() != null) {
|
||||
if (from.getGroup() != null) {
|
||||
Org org = client.findOrgNamed(vdcToOrg.get().get(from.getLocation().getId()));
|
||||
if (org == null) {
|
||||
logger.warn("did not find an association for vdc %s in %s", from.getLocation().getId(), vdcToOrg);
|
||||
} else {
|
||||
return new OrgAndName(org.getHref(), from.getTag());
|
||||
return new OrgAndName(org.getHref(), from.getGroup());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TerremarkVCloudExpressVAppToNodeMetadata extends VCloudExpressVAppT
|
|||
NodeMetadata node = super.apply(from);
|
||||
if (node == null)
|
||||
return null;
|
||||
if (node.getTag() != null) {
|
||||
if (node.getGroup() != null) {
|
||||
node = installCredentialsFromCache(node);
|
||||
}
|
||||
return node;
|
||||
|
@ -94,7 +94,7 @@ public class TerremarkVCloudExpressVAppToNodeMetadata extends VCloudExpressVAppT
|
|||
|
||||
OrgAndName getOrgAndNameFromNode(NodeMetadata node) {
|
||||
URI orgId = URI.create(node.getLocation().getParent().getId());
|
||||
OrgAndName orgAndName = new OrgAndName(orgId, node.getTag());
|
||||
OrgAndName orgAndName = new OrgAndName(orgId, node.getGroup());
|
||||
return orgAndName;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import static com.google.common.collect.Iterables.size;
|
|||
import static com.google.common.collect.Iterables.transform;
|
||||
import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
|
||||
import static org.jclouds.compute.predicates.NodePredicates.parentLocationId;
|
||||
import static org.jclouds.compute.predicates.NodePredicates.withTag;
|
||||
import static org.jclouds.compute.predicates.NodePredicates.inGroup;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -68,13 +68,13 @@ public class CleanupOrphanKeys {
|
|||
credentialStore.remove("node#" + node.getId());
|
||||
credentialStore.remove("node#" + node.getId() + "#adminPassword");
|
||||
}
|
||||
Iterable<OrgAndName> orgTags = filter(transform(deadOnes, nodeToOrgAndName), notNull());
|
||||
for (OrgAndName orgTag : orgTags) {
|
||||
Iterable<? extends NodeMetadata> nodesInOrg = listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag
|
||||
Iterable<OrgAndName> orgGroups = filter(transform(deadOnes, nodeToOrgAndName), notNull());
|
||||
for (OrgAndName orgGroup : orgGroups) {
|
||||
Iterable<? extends NodeMetadata> nodesInOrg = listNodes.listDetailsOnNodesMatching(parentLocationId(orgGroup
|
||||
.getOrg().toASCIIString()));
|
||||
Iterable<? extends NodeMetadata> nodesWithTag = filter(nodesInOrg, withTag(orgTag.getName()));
|
||||
if (size(nodesWithTag) == 0 || all(nodesWithTag, TERMINATED))
|
||||
deleteKeyPair.execute(orgTag);
|
||||
Iterable<? extends NodeMetadata> nodesInGroup = filter(nodesInOrg, inGroup(orgGroup.getName()));
|
||||
if (size(nodesInGroup) == 0 || all(nodesInGroup, TERMINATED))
|
||||
deleteKeyPair.execute(orgGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata;
|
||||
private final Map<String, Credentials> credentialStore;
|
||||
|
||||
@Inject
|
||||
protected TerremarkVCloudAddNodeWithTagStrategy(TerremarkVCloudComputeClient computeClient,
|
||||
protected StartVAppWithGroupEncodedIntoName(TerremarkVCloudComputeClient computeClient,
|
||||
Function<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata, TemplateToInstantiateOptions getOptions,
|
||||
Map<String, Credentials> 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());
|
|
@ -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,
|
||||
|
|
|
@ -88,13 +88,13 @@ public class CleanupOrphanKeysTest {
|
|||
CleanupOrphanKeys strategy = setupStrategy();
|
||||
NodeMetadata nodeMetadata = createMock(NodeMetadata.class);
|
||||
Iterable<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> 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<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> 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<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> 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();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class BindCloneVAppParamsToXmlPayload implements MapBinder {
|
|||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> 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");
|
||||
|
|
|
@ -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<? extends RunNodesAndAddToSetStrategy> defineRunNodesAndAddToSetStrategy() {
|
||||
return EncodeTagIntoNameRunNodesAndAddToSetStrategy.class;
|
||||
protected Class<? extends CreateNodesInGroupThenAddToSet> defineRunNodesAndAddToSetStrategy() {
|
||||
return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ]
|
||||
())
|
||||
|
|
|
@ -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.
|
||||
* <p/>
|
||||
*
|
||||
|
@ -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<? extends NodeMetadata> 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<? extends NodeMetadata> 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<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException;
|
||||
|
||||
/**
|
||||
* @see #createNodesInGroup(String , int , Template )
|
||||
*/
|
||||
@Deprecated
|
||||
Set<? extends NodeMetadata> 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<? extends NodeMetadata> 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<? extends NodeMetadata> runNodesWithTag(String tag, int count) throws RunNodesException;
|
||||
|
||||
/**
|
||||
|
@ -272,6 +292,13 @@ public interface ComputeService {
|
|||
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter,
|
||||
Statement runScript) throws RunScriptOnNodesException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
|
||||
*/
|
||||
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, String runScript,
|
||||
RunScriptOptions options) throws RunScriptOnNodesException;
|
||||
|
||||
/**
|
||||
* Run the script on all nodes with the specific predicate.
|
||||
*
|
||||
|
|
|
@ -60,7 +60,7 @@ public interface ComputeServiceAdapter<N, H, I, L> {
|
|||
* @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<String, Credentials> credentialStore);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<String, Credentials> credentialStore);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<? extends RunNodesAndAddToSetStrategy> clazz) {
|
||||
bind(RunNodesAndAddToSetStrategy.class).to(clazz).in(Scopes.SINGLETON);
|
||||
protected void bindRunNodesAndAddToSetStrategy(Class<? extends CreateNodesInGroupThenAddToSet> 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<? extends AddNodeWithTagStrategy> clazz) {
|
||||
bind(AddNodeWithTagStrategy.class).to(clazz).in(Scopes.SINGLETON);
|
||||
protected void bindAddNodeWithTagStrategy(Class<? extends CreateNodeWithGroupEncodedIntoName> clazz) {
|
||||
bind(CreateNodeWithGroupEncodedIntoName.class).to(clazz).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
protected void bindDestroyNodeStrategy(Class<? extends DestroyNodeStrategy> clazz) {
|
||||
|
@ -84,14 +84,14 @@ public abstract class BindComputeStrategiesByClass extends AbstractModule {
|
|||
bind(ListNodesStrategy.class).to(clazz).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
protected Class<? extends RunNodesAndAddToSetStrategy> defineRunNodesAndAddToSetStrategy() {
|
||||
return EncodeTagIntoNameRunNodesAndAddToSetStrategy.class;
|
||||
protected Class<? extends CreateNodesInGroupThenAddToSet> defineRunNodesAndAddToSetStrategy() {
|
||||
return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* needed, if {@link RunNodesAndAddToSetStrategy} requires it
|
||||
* needed, if {@link CreateNodesInGroupThenAddToSet} requires it
|
||||
*/
|
||||
protected abstract Class<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy();
|
||||
protected abstract Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy();
|
||||
|
||||
protected abstract Class<? extends DestroyNodeStrategy> defineDestroyNodeStrategy();
|
||||
|
||||
|
|
|
@ -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<S, A, N, H, I, L> extends BaseCo
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected AddNodeWithTagStrategy defineAddNodeWithTagStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
|
||||
protected CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<String, String> userMetadata, @Nullable String tag, @Nullable Hardware hardware,
|
||||
Map<String, String> userMetadata, @Nullable String group, @Nullable Hardware hardware,
|
||||
@Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort,
|
||||
Iterable<String> publicAddresses, Iterable<String> 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)
|
||||
|
|
|
@ -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<Set<? extends Location>> 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<Set<? extends Image>> images,
|
||||
@Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> templateOptionsProvider,
|
||||
|
@ -178,45 +178,63 @@ public class BaseComputeService implements ComputeService {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<? extends NodeMetadata> runNodesWithTag(String tag, int count, Template template)
|
||||
public Set<? extends NodeMetadata> runNodesWithTag(String group, int count, Template template)
|
||||
throws RunNodesException {
|
||||
checkNotNull(tag, "tag cannot be null");
|
||||
return createNodesInGroup(group, count, template);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<? extends NodeMetadata> runNodesWithTag(String group, int count, TemplateOptions templateOptions)
|
||||
throws RunNodesException {
|
||||
return createNodesInGroup(group, count, templateBuilder().any().options(templateOptions).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<? extends NodeMetadata> runNodesWithTag(String group, int count) throws RunNodesException {
|
||||
return createNodesInGroup(group, count, templateOptions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends NodeMetadata> 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<NodeMetadata> goodNodes = newLinkedHashSet();
|
||||
Map<NodeMetadata, Exception> badNodes = newLinkedHashMap();
|
||||
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
||||
|
||||
Map<?, Future<Void>> responses = runNodesAndAddToSetStrategy.execute(tag, count, template, goodNodes, badNodes,
|
||||
Map<?, Future<Void>> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes,
|
||||
customizationResponses);
|
||||
Map<?, Exception> 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<? extends NodeMetadata> runNodesWithTag(String tag, int count, TemplateOptions templateOptions)
|
||||
public Set<? extends NodeMetadata> 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<? extends NodeMetadata> runNodesWithTag(String tag, int count) throws RunNodesException {
|
||||
return runNodesWithTag(tag, count, templateOptions());
|
||||
public Set<? extends NodeMetadata> 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<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> 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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -45,8 +45,7 @@ public class ComputeServiceContextImpl<S, A> implements ComputeServiceContext {
|
|||
@SuppressWarnings( { "unchecked" })
|
||||
@Inject
|
||||
public ComputeServiceContextImpl(ComputeService computeService, Map<String, Credentials> credentialStore,
|
||||
Utils utils,
|
||||
@SuppressWarnings("rawtypes") RestContext providerSpecificContext) {
|
||||
Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) {
|
||||
this.credentialStore = credentialStore;
|
||||
this.utils = utils;
|
||||
this.providerSpecificContext = providerSpecificContext;
|
||||
|
|
|
@ -42,8 +42,7 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
public class NodePredicates {
|
||||
|
||||
private static class ParentLocationId implements
|
||||
Predicate<ComputeMetadata> {
|
||||
private static class ParentLocationId implements Predicate<ComputeMetadata> {
|
||||
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<NodeMetadata> withTag(final String tag) {
|
||||
Preconditions2.checkNotEmpty(tag, "Tag must be defined");
|
||||
public static Predicate<NodeMetadata> inGroup(final String group) {
|
||||
Preconditions2.checkNotEmpty(group, "group must be defined");
|
||||
return new Predicate<NodeMetadata>() {
|
||||
@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<NodeMetadata> 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<NodeMetadata> runningWithTag(final String tag) {
|
||||
Preconditions2.checkNotEmpty(tag, "Tag must be defined");
|
||||
public static Predicate<NodeMetadata> runningInGroup(final String group) {
|
||||
Preconditions2.checkNotEmpty(group, "Tag must be defined");
|
||||
return new Predicate<NodeMetadata>() {
|
||||
@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<NodeMetadata> runningWithTag(final String tag) {
|
||||
return runningInGroup(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Match nodes with State == RUNNING
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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<?, Future<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> goodNodes,
|
||||
Map<?, Future<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
|
||||
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses);
|
||||
}
|
|
@ -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<N, H, I, L> implements AddNodeWithTagStrategy, DestroyNodeStrategy,
|
||||
public class AdaptingComputeServiceStrategies<N, H, I, L> implements CreateNodeWithGroupEncodedIntoName, DestroyNodeStrategy,
|
||||
GetNodeMetadataStrategy, ListNodesStrategy, RebootNodeStrategy, ResumeNodeStrategy, SuspendNodeStrategy {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
|
@ -129,12 +129,12 @@ public class AdaptingComputeServiceStrategies<N, H, I, L> 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;
|
||||
}
|
||||
|
|
|
@ -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<NodeMetadata> {
|
||||
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,
|
|
@ -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<String, Credentials> 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());
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<IPSocket> socketTester;
|
||||
protected SortedSet<NodeMetadata> 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<NodeMetadata> nodes = newTreeSet(client.runNodesWithTag(tag, 1, template));
|
||||
checkNodes(nodes, tag);
|
||||
TreeSet<NodeMetadata> 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<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(client
|
||||
.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))),
|
||||
.listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED))),
|
||||
new Function<NodeMetadata, String>() {
|
||||
|
||||
@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<? extends NodeMetadata> 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<? extends NodeMetadata> destroyed = client.destroyNodesMatching(withTag(tag));
|
||||
Set<? extends NodeMetadata> 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<? extends NodeMetadata> 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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<IPSocket> socketTester;
|
||||
protected Set<? extends NodeMetadata> 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();
|
||||
|
|
|
@ -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<String, Credentials> credentialStore,
|
||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy startNodeStrategy, SuspendNodeStrategy stopNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> templateOptionsProvider,
|
||||
|
|
|
@ -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<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
|
||||
Set<? extends NodeMetadata> 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.<String> of("jclouds#" + tag + "#"
|
||||
+ instance.getRegion(), tag));
|
||||
assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet.<String> 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<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
|
||||
Set<? extends NodeMetadata> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<? extends NodeMetadata> nodes = context.getComputeService().runNodesWithTag(tag, 1, template);
|
||||
Set<? extends NodeMetadata> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiv
|
|||
public AWSELBLoadBalancerServiceLiveTest() {
|
||||
provider = "aws-elb";
|
||||
computeProvider = "aws-ec2";
|
||||
tag = "elb";
|
||||
group = "elb";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeS
|
|||
|
||||
@Override
|
||||
public void setServiceDefaults() {
|
||||
tag = "director";
|
||||
group = "director";
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -31,7 +31,7 @@ public class CloudServersUKComputeServiceLiveTest extends CloudServersComputeSer
|
|||
|
||||
public CloudServersUKComputeServiceLiveTest() {
|
||||
provider = "cloudservers-uk";
|
||||
tag = "cs";
|
||||
group = "cs";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class CloudServersUSComputeServiceLiveTest extends CloudServersComputeSer
|
|||
|
||||
public CloudServersUSComputeServiceLiveTest() {
|
||||
provider = "cloudservers-us";
|
||||
tag = "cs";
|
||||
group = "cs";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, Credentials> 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);
|
||||
|
|
|
@ -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<ServerInfo, NodeMetada
|
|||
builder.ids(from.getUuid());
|
||||
builder.name(from.getName());
|
||||
builder.location(locationSupplier.get());
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
builder.group(parseGroupFromName(from.getName()));
|
||||
|
||||
String imageId = getImageIdFromServer.apply(from);
|
||||
if (imageId != null) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ElasticHostsBlueSquareLondonComputeServiceLiveTest extends ElasticS
|
|||
|
||||
public ElasticHostsBlueSquareLondonComputeServiceLiveTest() {
|
||||
provider = "elastichosts-lon-b";
|
||||
tag = "elastichosts";
|
||||
group = "elastichosts";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ElasticHostsPeer1LondonComputeServiceLiveTest extends ElasticStackC
|
|||
|
||||
public ElasticHostsPeer1LondonComputeServiceLiveTest() {
|
||||
provider = "elastichosts-lon-p";
|
||||
tag = "elastichosts";
|
||||
group = "elastichosts";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ElasticHostsPeer1SanAntonioComputeServiceLiveTest extends ElasticSt
|
|||
|
||||
public ElasticHostsPeer1SanAntonioComputeServiceLiveTest() {
|
||||
provider = "elastichosts-sat-p";
|
||||
tag = "elastichosts";
|
||||
group = "elastichosts";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class EucalyptusPartnerCloudEucalyptusComputeServiceLiveTest extends Euca
|
|||
public EucalyptusPartnerCloudEucalyptusComputeServiceLiveTest() {
|
||||
provider = "eucalyptus-partnercloud-ec2";
|
||||
// security groups must be <30 characters
|
||||
tag = "eu";
|
||||
group = "eu";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,4 +45,9 @@ public class EucalyptusPartnerCloudEucalyptusComputeServiceLiveTest extends Euca
|
|||
.getProperty("test.eucalyptus-partnercloud-ec2.virtualization-type"));
|
||||
return overrides;
|
||||
}
|
||||
|
||||
// test hangs
|
||||
@Override
|
||||
public void testExtendedOptionsAndLogin() throws Exception {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
package org.jclouds.gogrid.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.gogrid.compute.strategy.GoGridAddNodeWithTagStrategy;
|
||||
import org.jclouds.gogrid.compute.strategy.FindPublicIpThenCreateNodeInGroup;
|
||||
import org.jclouds.gogrid.compute.strategy.GoGridDestroyNodeStrategy;
|
||||
import org.jclouds.gogrid.compute.strategy.GoGridGetNodeMetadataStrategy;
|
||||
import org.jclouds.gogrid.compute.strategy.GoGridLifeCycleStrategy;
|
||||
|
@ -40,8 +40,8 @@ import org.jclouds.gogrid.compute.strategy.GoGridListNodesStrategy;
|
|||
*/
|
||||
public class GoGridBindComputeStrategiesByClass extends BindComputeStrategiesByClass {
|
||||
@Override
|
||||
protected Class<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return GoGridAddNodeWithTagStrategy.class;
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
|
||||
return FindPublicIpThenCreateNodeInGroup.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Server, NodeMetadata> {
|
|||
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() + "");
|
||||
|
||||
|
|
|
@ -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<Hardware, String> sizeToRam;
|
||||
private final Function<Server, NodeMetadata> serverToNodeMetadata;
|
||||
|
@ -57,7 +57,7 @@ public class GoGridAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
|||
private RetryablePredicate<Server> serverLatestJobCompletedShort;
|
||||
|
||||
@Inject
|
||||
protected GoGridAddNodeWithTagStrategy(GoGridClient client,
|
||||
protected FindPublicIpThenCreateNodeInGroup(GoGridClient client,
|
||||
Function<Server, NodeMetadata> serverToNodeMetadata, Function<Hardware, String> 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;
|
|
@ -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<String, Credentials> 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);
|
||||
|
|
|
@ -31,7 +31,7 @@ public class OpenHostingEast1ComputeServiceLiveTest extends ElasticStackComputeS
|
|||
|
||||
public OpenHostingEast1ComputeServiceLiveTest() {
|
||||
provider = "openhosting-east1";
|
||||
tag = "openhosting";
|
||||
group = "openhosting";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ServerloveManchesterComputeServiceLiveTest extends ElasticStackComp
|
|||
|
||||
public ServerloveManchesterComputeServiceLiveTest() {
|
||||
provider = "serverlove-z1-man";
|
||||
tag = "serverlove";
|
||||
group = "serverlove";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return SlicehostAddNodeWithTagStrategy.class;
|
||||
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
|
||||
return SlicehostCreateNodeWithGroupEncodedIntoName.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Slice, NodeMetadata> {
|
|||
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));
|
||||
|
|
|
@ -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<String, Credentials> credentialStore;
|
||||
protected final Function<Slice, NodeMetadata> sliceToNodeMetadata;
|
||||
|
||||
@Inject
|
||||
protected SlicehostAddNodeWithTagStrategy(SlicehostClient client, Map<String, Credentials> credentialStore,
|
||||
protected SlicehostCreateNodeWithGroupEncodedIntoName(SlicehostClient client, Map<String, Credentials> credentialStore,
|
||||
Function<Slice, NodeMetadata> 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()));
|
|
@ -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(
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
|
|||
|
||||
@Override
|
||||
public void setServiceDefaults() {
|
||||
tag = "te";
|
||||
group = "te";
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer
|
|||
|
||||
@Override
|
||||
public void setServiceDefaults() {
|
||||
tag = "vcx";
|
||||
group = "vcx";
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -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<Set<? extends Image>> images,
|
||||
@Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> templateOptionsProvider,
|
||||
|
|
|
@ -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<Domain, NodeMetadata> {
|
|||
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));
|
||||
|
|
|
@ -81,7 +81,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
}
|
||||
|
||||
@Override
|
||||
public Domain runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
|
||||
public Domain createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template,
|
||||
Map<String, Credentials> credentialStore) {
|
||||
try {
|
||||
String domainName = tag;
|
||||
|
|
|
@ -77,7 +77,7 @@ public class LibvirtExperimentLiveTest {
|
|||
* the default template via overriding a method in standalonecomputeservicexontextmodule
|
||||
*/
|
||||
|
||||
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().runNodesWithTag("tty", 1);
|
||||
Set<? extends NodeMetadata> nodeMetadataSet = context.getComputeService().createNodesInGroup("tty", 1);
|
||||
for (NodeMetadata nodeMetadata : nodeMetadataSet) {
|
||||
/*
|
||||
* context.getComputeService().suspendNode(nodeMetadata.getId());
|
||||
|
|
|
@ -69,7 +69,7 @@ public class SDNAuthAsyncClientTest extends RestClientTest<SDNAuthAsyncClient> {
|
|||
|
||||
@Override
|
||||
public RestContextSpec<SDNAuthClient, SDNAuthAsyncClient> createContextSpec() {
|
||||
return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", SDNAuthClient.class,
|
||||
return contextSpec("test", "http://localhost:8080", "1", "", "identity", "credential", SDNAuthClient.class,
|
||||
SDNAuthAsyncClient.class);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<SDNAuthClient, SDNAuthAsyncClient> contextSpec = contextSpec("test", endpoint, "1", identity,
|
||||
RestContextSpec<SDNAuthClient, SDNAuthAsyncClient> contextSpec = contextSpec("test", endpoint, "1", "", identity,
|
||||
credential, SDNAuthClient.class, SDNAuthAsyncClient.class);
|
||||
|
||||
context = createContextBuilder(
|
||||
|
|
|
@ -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<Set<? extends Image>> images,
|
||||
@Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||
ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy,
|
||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> templateOptionsProvider,
|
||||
|
|
|
@ -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<VirtualMachine, No
|
|||
builder.providerId(from.getConfig().getLocationId() + "");
|
||||
builder.name(from.getName());
|
||||
builder.location(findLocationForVirtualMachine.apply(from));
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
builder.group(parseGroupFromName(from.getName()));
|
||||
|
||||
builder.operatingSystem(new OperatingSystemBuilder()
|
||||
.name(from.getConfig().getGuestFullName())
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue