mirror of https://github.com/apache/jclouds.git
revised load balancer code and implemented Issue 254: compute handle
This commit is contained in:
parent
0d1d28a972
commit
467f815c17
|
@ -20,6 +20,7 @@ package org.jclouds.aws.ec2.compute;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.parseHandle;
|
||||||
import static org.jclouds.util.Utils.checkNotEmpty;
|
import static org.jclouds.util.Utils.checkNotEmpty;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -35,7 +36,6 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.ec2.EC2Client;
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromLocation;
|
|
||||||
import org.jclouds.aws.ec2.compute.domain.RegionAndName;
|
import org.jclouds.aws.ec2.compute.domain.RegionAndName;
|
||||||
import org.jclouds.aws.ec2.compute.domain.RegionNameAndIngressRules;
|
import org.jclouds.aws.ec2.compute.domain.RegionNameAndIngressRules;
|
||||||
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
|
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
|
||||||
|
@ -68,9 +68,9 @@ import com.google.common.collect.Maps;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class EC2ComputeService extends BaseComputeService {
|
public class EC2ComputeService extends BaseComputeService {
|
||||||
private final EC2Client ec2Client;
|
private final EC2Client ec2Client;
|
||||||
private final GetRegionFromLocation getRegionFromLocation;
|
|
||||||
private final Map<RegionAndName, KeyPair> credentialsMap;
|
private final Map<RegionAndName, KeyPair> credentialsMap;
|
||||||
private final Map<RegionAndName, String> securityGroupMap;
|
private final Map<RegionAndName, String> securityGroupMap;
|
||||||
|
private final LoadBalancerStrategy loadBalancerStrategy;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2ComputeService(ComputeServiceContext context,
|
protected EC2ComputeService(ComputeServiceContext context,
|
||||||
|
@ -79,17 +79,16 @@ public class EC2ComputeService extends BaseComputeService {
|
||||||
GetNodeMetadataStrategy getNodeMetadataStrategy,
|
GetNodeMetadataStrategy getNodeMetadataStrategy,
|
||||||
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||||
LoadBalancerStrategy loadBalancerStrategy,
|
|
||||||
Provider<TemplateBuilder> templateBuilderProvider,
|
Provider<TemplateBuilder> templateBuilderProvider,
|
||||||
Provider<TemplateOptions> templateOptionsProvider, ComputeUtils utils,
|
Provider<TemplateOptions> templateOptionsProvider, ComputeUtils utils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, EC2Client ec2Client,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||||
GetRegionFromLocation getRegionFromLocation,
|
LoadBalancerStrategy loadBalancerStrategy, EC2Client ec2Client,
|
||||||
Map<RegionAndName, KeyPair> credentialsMap, Map<RegionAndName, String> securityGroupMap) {
|
Map<RegionAndName, KeyPair> credentialsMap, Map<RegionAndName, String> securityGroupMap) {
|
||||||
super(context, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
super(context, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
||||||
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
|
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
|
||||||
loadBalancerStrategy, templateBuilderProvider, templateOptionsProvider, utils, executor);
|
templateBuilderProvider, templateOptionsProvider, utils, executor);
|
||||||
|
this.loadBalancerStrategy = checkNotNull(loadBalancerStrategy, "loadBalancerStrategy");
|
||||||
this.ec2Client = ec2Client;
|
this.ec2Client = ec2Client;
|
||||||
this.getRegionFromLocation = getRegionFromLocation;
|
|
||||||
this.credentialsMap = credentialsMap;
|
this.credentialsMap = credentialsMap;
|
||||||
this.securityGroupMap = securityGroupMap;
|
this.securityGroupMap = securityGroupMap;
|
||||||
}
|
}
|
||||||
|
@ -128,69 +127,53 @@ public class EC2ComputeService extends BaseComputeService {
|
||||||
Map<String, String> regionTags = Maps.newHashMap();
|
Map<String, String> regionTags = Maps.newHashMap();
|
||||||
for (NodeMetadata nodeMetadata : deadOnes) {
|
for (NodeMetadata nodeMetadata : deadOnes) {
|
||||||
if (nodeMetadata.getTag() != null)
|
if (nodeMetadata.getTag() != null)
|
||||||
regionTags.put(getRegionFromLocation.apply(nodeMetadata.getLocation()), nodeMetadata
|
regionTags.put(parseHandle(nodeMetadata.getHandle())[0], nodeMetadata.getTag());
|
||||||
.getTag());
|
|
||||||
}
|
}
|
||||||
for (Entry<String, String> regionTag : regionTags.entrySet()) {
|
for (Entry<String, String> regionTag : regionTags.entrySet()) {
|
||||||
deleteKeyPair(regionTag.getKey(), regionTag.getValue());
|
deleteKeyPair(regionTag.getKey(), regionTag.getValue());
|
||||||
deleteSecurityGroup(regionTag.getKey(), regionTag.getValue());
|
deleteSecurityGroup(regionTag.getKey(), regionTag.getValue());
|
||||||
}
|
}
|
||||||
return deadOnes;
|
return deadOnes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String loadBalanceNodesMatching(String loadBalancerName,
|
|
||||||
String protocol, Integer loadBalancerPort, Integer instancePort,
|
|
||||||
Predicate<NodeMetadata> filter)
|
|
||||||
{
|
|
||||||
checkNotNull(loadBalancerName, "loadBalancerName");
|
|
||||||
checkNotNull(protocol, "protocol");
|
|
||||||
checkArgument(protocol.toUpperCase().equals("HTTP")
|
|
||||||
|| protocol.toUpperCase().equals("TCP"),
|
|
||||||
"Acceptable values for protocol are HTTP or TCP");
|
|
||||||
checkNotNull(loadBalancerPort, "loadBalancerPort");
|
|
||||||
checkNotNull(instancePort, "instancePort");
|
|
||||||
|
|
||||||
Location location = null;
|
/**
|
||||||
Set<String> ids = new HashSet<String>();
|
|
||||||
for (final NodeMetadata node : Iterables.filter(super
|
|
||||||
.listNodesDetailsMatching(NodePredicates.all()), Predicates
|
|
||||||
.and(filter, Predicates.not(NodePredicates.TERMINATED))))
|
|
||||||
{
|
|
||||||
ids.add(node.getId());
|
|
||||||
location = node.getLocation();
|
|
||||||
}
|
|
||||||
logger.debug(">> creating load balancer (%s)", loadBalancerName);
|
|
||||||
String dnsName = loadBalancerStrategy
|
|
||||||
.execute(location, loadBalancerName, protocol,
|
|
||||||
loadBalancerPort, instancePort, ids);
|
|
||||||
logger.debug("<< created load balancer (%s) DNS (%s)",
|
|
||||||
loadBalancerName, dnsName);
|
|
||||||
return dnsName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteLoadBalancer(String loadBalancerName,
|
|
||||||
Predicate<NodeMetadata> filter)
|
|
||||||
{
|
|
||||||
|
|
||||||
Location location = Iterables.filter(
|
|
||||||
super.listNodesDetailsMatching(NodePredicates.all()),
|
|
||||||
Predicates.and(filter, Predicates
|
|
||||||
.not(NodePredicates.TERMINATED))).iterator().next()
|
|
||||||
.getLocation();
|
|
||||||
ec2Client.getElasticLoadBalancerServices().deleteLoadBalancer(
|
|
||||||
getRegionFromLocation.apply(location), loadBalancerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns template options, except of type {@link EC2TemplateOptions}.
|
* returns template options, except of type {@link EC2TemplateOptions}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public EC2TemplateOptions templateOptions() {
|
public EC2TemplateOptions templateOptions() {
|
||||||
return EC2TemplateOptions.class.cast(super.templateOptions());
|
return EC2TemplateOptions.class.cast(super.templateOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String loadBalanceNodesMatching(Predicate<NodeMetadata> filter, String loadBalancerName,
|
||||||
|
String protocol, int loadBalancerPort, int instancePort) {
|
||||||
|
checkNotNull(loadBalancerName, "loadBalancerName");
|
||||||
|
checkNotNull(protocol, "protocol");
|
||||||
|
checkArgument(protocol.toUpperCase().equals("HTTP") || protocol.toUpperCase().equals("TCP"),
|
||||||
|
"Acceptable values for protocol are HTTP or TCP");
|
||||||
|
|
||||||
|
Location location = null;
|
||||||
|
Set<String> ids = new HashSet<String>();
|
||||||
|
for (NodeMetadata node : Iterables.filter(super
|
||||||
|
.listNodesDetailsMatching(NodePredicates.all()), Predicates.and(filter, Predicates
|
||||||
|
.not(NodePredicates.TERMINATED)))) {
|
||||||
|
ids.add(node.getId());
|
||||||
|
location = node.getLocation();
|
||||||
|
}
|
||||||
|
logger.debug(">> creating load balancer (%s)", loadBalancerName);
|
||||||
|
String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol,
|
||||||
|
loadBalancerPort, instancePort, ids);
|
||||||
|
logger.debug("<< created load balancer (%s) DNS (%s)", loadBalancerName, dnsName);
|
||||||
|
return dnsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteLoadBalancer(String loadBalancerName, Predicate<NodeMetadata> filter) {
|
||||||
|
String region = parseHandle(Iterables.get(
|
||||||
|
Iterables.filter(super.listNodesDetailsMatching(NodePredicates.all()), Predicates
|
||||||
|
.and(filter, Predicates.not(NodePredicates.TERMINATED))), 0).getHandle())[0];
|
||||||
|
ec2Client.getElasticLoadBalancerServices().deleteLoadBalancerInRegion(region,
|
||||||
|
loadBalancerName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,9 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.compute.config;
|
package org.jclouds.aws.ec2.compute.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.ownedBy;
|
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.ownedBy;
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.getAllRunningInstancesInRegion;
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.parseHandle;
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
import static org.jclouds.concurrent.ConcurrentUtils.awaitCompletion;
|
import static org.jclouds.concurrent.ConcurrentUtils.awaitCompletion;
|
||||||
|
|
||||||
|
@ -126,12 +127,12 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
|
bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
|
||||||
bind(TemplateOptions.class).to(EC2TemplateOptions.class);
|
bind(TemplateOptions.class).to(EC2TemplateOptions.class);
|
||||||
bind(ComputeService.class).to(EC2ComputeService.class);
|
bind(ComputeService.class).to(EC2ComputeService.class);
|
||||||
|
bind(LoadBalancerStrategy.class).to(EC2LoadBalancerStrategy.class);
|
||||||
bind(RunNodesAndAddToSetStrategy.class).to(EC2RunNodesAndAddToSetStrategy.class);
|
bind(RunNodesAndAddToSetStrategy.class).to(EC2RunNodesAndAddToSetStrategy.class);
|
||||||
bind(ListNodesStrategy.class).to(EC2ListNodesStrategy.class);
|
bind(ListNodesStrategy.class).to(EC2ListNodesStrategy.class);
|
||||||
bind(GetNodeMetadataStrategy.class).to(EC2GetNodeMetadataStrategy.class);
|
bind(GetNodeMetadataStrategy.class).to(EC2GetNodeMetadataStrategy.class);
|
||||||
bind(RebootNodeStrategy.class).to(EC2RebootNodeStrategy.class);
|
bind(RebootNodeStrategy.class).to(EC2RebootNodeStrategy.class);
|
||||||
bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class);
|
bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class);
|
||||||
bind(LoadBalancerStrategy.class).to(EC2LoadBalancerStrategy.class);
|
|
||||||
bind(new TypeLiteral<Function<RunningInstance, Map<String, String>>>() {
|
bind(new TypeLiteral<Function<RunningInstance, Map<String, String>>>() {
|
||||||
}).annotatedWith(Jsr330.named("volumeMapping")).to(RunningInstanceToStorageMappingUnix.class)
|
}).annotatedWith(Jsr330.named("volumeMapping")).to(RunningInstanceToStorageMappingUnix.class)
|
||||||
.in(Scopes.SINGLETON);
|
.in(Scopes.SINGLETON);
|
||||||
|
@ -164,7 +165,7 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final InstanceClient client;
|
private final InstanceClient client;
|
||||||
private final Map<String, URI> regionMap;
|
private final Map<String, URI> regionMap;
|
||||||
private final RunningInstanceToNodeMetadata runningInstanceToNodeMetadata;
|
private final RunningInstanceToNodeMetadata runningInstanceToNodeMetadata;
|
||||||
|
@ -214,61 +215,45 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public static class GetRegionFromLocation implements Function<Location, String> {
|
|
||||||
public String apply(Location location) {
|
|
||||||
String region = location.getScope() == LocationScope.REGION ? location.getId() : location
|
|
||||||
.getParent().getId();
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
public static class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
||||||
|
|
||||||
private final InstanceClient client;
|
private final InstanceClient client;
|
||||||
private final RunningInstanceToNodeMetadata runningInstanceToNodeMetadata;
|
private final RunningInstanceToNodeMetadata runningInstanceToNodeMetadata;
|
||||||
private final GetRegionFromLocation getRegionFromLocation;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2GetNodeMetadataStrategy(InstanceClient client,
|
protected EC2GetNodeMetadataStrategy(InstanceClient client,
|
||||||
GetRegionFromLocation getRegionFromLocation,
|
|
||||||
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata) {
|
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.getRegionFromLocation = getRegionFromLocation;
|
|
||||||
this.runningInstanceToNodeMetadata = runningInstanceToNodeMetadata;
|
this.runningInstanceToNodeMetadata = runningInstanceToNodeMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(Location location, String id) {
|
public NodeMetadata execute(String handle) {
|
||||||
String region = getRegionFromLocation.apply(checkNotNull(location, "location"));
|
String[] parts = parseHandle(handle);
|
||||||
|
String region = parts[0];
|
||||||
|
String id = parts[1];
|
||||||
RunningInstance runningInstance = Iterables.getOnlyElement(getAllRunningInstancesInRegion(
|
RunningInstance runningInstance = Iterables.getOnlyElement(getAllRunningInstancesInRegion(
|
||||||
client, region, checkNotNull(id, "id")));
|
client, region, id));
|
||||||
return runningInstanceToNodeMetadata.apply(runningInstance);
|
return runningInstanceToNodeMetadata.apply(runningInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Iterable<RunningInstance> getAllRunningInstancesInRegion(InstanceClient client,
|
|
||||||
String region, String id) {
|
|
||||||
return Iterables.concat(client.describeInstancesInRegion(region, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class EC2RebootNodeStrategy implements RebootNodeStrategy {
|
public static class EC2RebootNodeStrategy implements RebootNodeStrategy {
|
||||||
private final InstanceClient client;
|
private final InstanceClient client;
|
||||||
private final GetRegionFromLocation getRegionFromLocation;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2RebootNodeStrategy(InstanceClient client,
|
protected EC2RebootNodeStrategy(InstanceClient client) {
|
||||||
GetRegionFromLocation getRegionFromLocation) {
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.getRegionFromLocation = getRegionFromLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
String region = getRegionFromLocation.apply(location);
|
String[] parts = parseHandle(handle);
|
||||||
|
String region = parts[0];
|
||||||
|
String id = parts[1];
|
||||||
client.rebootInstancesInRegion(region, id);
|
client.rebootInstancesInRegion(region, id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,8 @@ public class EC2Size extends SizeImpl {
|
||||||
|
|
||||||
EC2Size(String instanceType, Double cores, Integer ram, Integer disk,
|
EC2Size(String instanceType, Double cores, Integer ram, Integer disk,
|
||||||
Iterable<Architecture> supportedArchitectures) {
|
Iterable<Architecture> supportedArchitectures) {
|
||||||
super(instanceType,
|
super(instanceType, instanceType, instanceType, null, null, ImmutableMap
|
||||||
instanceType, null, null,
|
.<String, String> of(), cores, ram, disk, supportedArchitectures);
|
||||||
ImmutableMap.<String, String> of(),cores, ram, disk, supportedArchitectures);
|
|
||||||
this.instanceType = instanceType;
|
this.instanceType = instanceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,7 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
|
||||||
return new ImageImpl(
|
return new ImageImpl(
|
||||||
from.getId(),
|
from.getId(),
|
||||||
name,
|
name,
|
||||||
|
from.getRegion() + "/" + from.getId(),
|
||||||
location,
|
location,
|
||||||
null,
|
null,
|
||||||
ImmutableMap.<String, String> of("owner", from.getImageOwnerId()),
|
ImmutableMap.<String, String> of("owner", from.getImageOwnerId()),
|
||||||
|
|
|
@ -170,8 +170,9 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
|
|
||||||
Image image = resolveImageForInstanceInLocation(instance, location);
|
Image image = resolveImageForInstanceInLocation(instance, location);
|
||||||
|
|
||||||
return new NodeMetadataImpl(id, name, location, uri, userMetadata, tag, image, state,
|
return new NodeMetadataImpl(id, name, instance.getRegion() + "/" + instance.getId(),
|
||||||
publicAddresses, privateAddresses, extra, credentials);
|
location, uri, userMetadata, tag, image, state, publicAddresses, privateAddresses,
|
||||||
|
extra, credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Credentials getCredentialsForInstanceWithTag(final RunningInstance instance, String tag) {
|
private Credentials getCredentialsForInstanceWithTag(final RunningInstance instance, String tag) {
|
||||||
|
|
|
@ -19,18 +19,18 @@
|
||||||
|
|
||||||
package org.jclouds.aws.ec2.compute.strategy;
|
package org.jclouds.aws.ec2.compute.strategy;
|
||||||
|
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.parseHandle;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2Client;
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromLocation;
|
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -47,23 +47,22 @@ public class EC2DestroyNodeStrategy implements DestroyNodeStrategy {
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
protected final EC2Client ec2Client;
|
protected final EC2Client ec2Client;
|
||||||
protected final Predicate<RunningInstance> instanceStateTerminated;
|
protected final Predicate<RunningInstance> instanceStateTerminated;
|
||||||
protected final GetRegionFromLocation getRegionFromLocation;
|
|
||||||
protected final GetNodeMetadataStrategy getNodeMetadataStrategy;
|
protected final GetNodeMetadataStrategy getNodeMetadataStrategy;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2DestroyNodeStrategy(EC2Client ec2Client,
|
protected EC2DestroyNodeStrategy(EC2Client ec2Client,
|
||||||
@Named("TERMINATED") Predicate<RunningInstance> instanceStateTerminated,
|
@Named("TERMINATED") Predicate<RunningInstance> instanceStateTerminated,
|
||||||
GetRegionFromLocation getRegionFromLocation,
|
|
||||||
GetNodeMetadataStrategy getNodeMetadataStrategy) {
|
GetNodeMetadataStrategy getNodeMetadataStrategy) {
|
||||||
this.ec2Client = ec2Client;
|
this.ec2Client = ec2Client;
|
||||||
this.instanceStateTerminated = instanceStateTerminated;
|
this.instanceStateTerminated = instanceStateTerminated;
|
||||||
this.getRegionFromLocation = getRegionFromLocation;
|
|
||||||
this.getNodeMetadataStrategy = getNodeMetadataStrategy;
|
this.getNodeMetadataStrategy = getNodeMetadataStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
String region = getRegionFromLocation.apply(location);
|
String[] parts = parseHandle(handle);
|
||||||
|
String region = parts[0];
|
||||||
|
String id = parts[1];
|
||||||
ec2Client.getInstanceServices().terminateInstancesInRegion(region, id);
|
ec2Client.getInstanceServices().terminateInstancesInRegion(region, id);
|
||||||
return instanceStateTerminated.apply(Iterables.getOnlyElement(Iterables.concat(ec2Client
|
return instanceStateTerminated.apply(Iterables.getOnlyElement(Iterables.concat(ec2Client
|
||||||
.getInstanceServices().describeInstancesInRegion(region, id))));
|
.getInstanceServices().describeInstancesInRegion(region, id))));
|
||||||
|
|
|
@ -29,9 +29,9 @@ import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2Client;
|
import org.jclouds.aws.ec2.EC2Client;
|
||||||
import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromLocation;
|
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.services.ElasticLoadBalancerClient;
|
import org.jclouds.aws.ec2.services.ElasticLoadBalancerClient;
|
||||||
|
import org.jclouds.aws.ec2.util.EC2Utils.GetRegionFromLocation;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.LoadBalancerStrategy;
|
import org.jclouds.compute.strategy.LoadBalancerStrategy;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -42,69 +42,59 @@ import org.jclouds.logging.Logger;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class EC2LoadBalancerStrategy implements LoadBalancerStrategy
|
public class EC2LoadBalancerStrategy implements LoadBalancerStrategy {
|
||||||
{
|
@Resource
|
||||||
@Resource
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
protected Logger logger = Logger.NULL;
|
||||||
protected Logger logger = Logger.NULL;
|
protected final EC2Client ec2Client;
|
||||||
protected final EC2Client ec2Client;
|
protected final GetRegionFromLocation getRegionFromLocation;
|
||||||
protected final GetRegionFromLocation getRegionFromLocation;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2LoadBalancerStrategy(EC2Client ec2Client, GetRegionFromLocation getRegionFromLocation)
|
protected EC2LoadBalancerStrategy(EC2Client ec2Client,
|
||||||
{
|
GetRegionFromLocation getRegionFromLocation) {
|
||||||
this.ec2Client = ec2Client;
|
this.ec2Client = ec2Client;
|
||||||
this.getRegionFromLocation = getRegionFromLocation;
|
this.getRegionFromLocation = getRegionFromLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String execute(Location location, String name,
|
public String execute(Location location, String name, String protocol, int loadBalancerPort,
|
||||||
String protocol, Integer loadBalancerPort, Integer instancePort,
|
int instancePort, Set<String> instanceIds) {
|
||||||
Set<String> instanceIds)
|
String region = getRegionFromLocation.apply(location);
|
||||||
{
|
String dnsName = new String();
|
||||||
String region = getRegionFromLocation.apply(location);
|
|
||||||
String dnsName = new String();
|
|
||||||
|
|
||||||
// TODO: Fix temp hack
|
// TODO: Fix temp hack
|
||||||
String availabilityZone = new String();
|
String availabilityZone = new String();
|
||||||
for (String az : AvailabilityZone.zones)
|
for (String az : AvailabilityZone.zones) {
|
||||||
{
|
if (az.startsWith(region))
|
||||||
if (az.startsWith(region))
|
availabilityZone = az;
|
||||||
availabilityZone = az;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ElasticLoadBalancerClient elbClient = ec2Client
|
ElasticLoadBalancerClient elbClient = ec2Client.getElasticLoadBalancerServices();
|
||||||
.getElasticLoadBalancerServices();
|
|
||||||
|
|
||||||
dnsName = elbClient.createLoadBalancer(region, name, protocol,
|
dnsName = elbClient.createLoadBalancerInRegion(region, name, protocol, loadBalancerPort,
|
||||||
loadBalancerPort, instancePort, availabilityZone);
|
instancePort, availabilityZone);
|
||||||
|
|
||||||
List<String> instanceIdlist = new ArrayList<String>(instanceIds);
|
List<String> instanceIdlist = new ArrayList<String>(instanceIds);
|
||||||
String[] instanceIdArray = new String[instanceIdlist.size()];
|
String[] instanceIdArray = new String[instanceIdlist.size()];
|
||||||
for(int i=0; i<instanceIdlist.size(); i++)
|
for (int i = 0; i < instanceIdlist.size(); i++) {
|
||||||
{
|
instanceIdArray[i] = instanceIdlist.get(i);
|
||||||
instanceIdArray[i] = instanceIdlist.get(i);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> registeredInstanceIds = elbClient
|
|
||||||
.registerInstancesWithLoadBalancer(region, name,
|
|
||||||
instanceIdArray);
|
|
||||||
|
|
||||||
// deregister instances
|
Set<String> registeredInstanceIds = elbClient.registerInstancesWithLoadBalancerInRegion(
|
||||||
boolean changed = registeredInstanceIds.removeAll(instanceIds);
|
region, name, instanceIdArray);
|
||||||
if (changed)
|
|
||||||
{
|
|
||||||
List<String> list = new ArrayList<String>(registeredInstanceIds);
|
|
||||||
instanceIdArray = new String[list.size()];
|
|
||||||
for(int i=0; i<list.size(); i++)
|
|
||||||
{
|
|
||||||
instanceIdArray[i] = list.get(i);
|
|
||||||
}
|
|
||||||
if(instanceIdArray.length>0)
|
|
||||||
elbClient.deregisterInstancesWithLoadBalancer(region, name,
|
|
||||||
instanceIdArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dnsName;
|
// deregister instances
|
||||||
}
|
boolean changed = registeredInstanceIds.removeAll(instanceIds);
|
||||||
|
if (changed) {
|
||||||
|
List<String> list = new ArrayList<String>(registeredInstanceIds);
|
||||||
|
instanceIdArray = new String[list.size()];
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
instanceIdArray[i] = list.get(i);
|
||||||
|
}
|
||||||
|
if (instanceIdArray.length > 0)
|
||||||
|
elbClient.deregisterInstancesWithLoadBalancerInRegion(region, name, instanceIdArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dnsName;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,525 +1,420 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 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.aws.ec2.domain;
|
package org.jclouds.aws.ec2.domain;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Lili Nader
|
||||||
|
*/
|
||||||
|
public class ElasticLoadBalancer implements Comparable<ElasticLoadBalancer> {
|
||||||
|
|
||||||
public class ElasticLoadBalancer implements Comparable<ElasticLoadBalancer>
|
private String region;
|
||||||
{
|
private String name;
|
||||||
|
private Set<String> instanceIds;
|
||||||
|
private Set<String> availabilityZones;
|
||||||
|
private String dnsName;
|
||||||
|
private AppCookieStickinessPolicy appCookieStickinessPolicy;
|
||||||
|
private LBCookieStickinessPolicy lBCookieStickinessPolicy;
|
||||||
|
private Set<LoadBalancerListener> loadBalancerListeners;
|
||||||
|
|
||||||
private String region;
|
public ElasticLoadBalancer() {
|
||||||
private String name;
|
super();
|
||||||
private Set<String> instanceIds;
|
this.instanceIds = new HashSet<String>();
|
||||||
private Set<String> availabilityZones;
|
this.availabilityZones = new HashSet<String>();
|
||||||
private String dnsName;
|
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
||||||
private AppCookieStickinessPolicy appCookieStickinessPolicy;
|
}
|
||||||
private LBCookieStickinessPolicy lBCookieStickinessPolicy;
|
|
||||||
private Set<LoadBalancerListener> loadBalancerListeners;
|
|
||||||
|
|
||||||
public ElasticLoadBalancer()
|
public ElasticLoadBalancer(String region, String name, Set<String> instanceIds,
|
||||||
{
|
Set<String> availabilityZones, String dnsName) {
|
||||||
super();
|
super();
|
||||||
this.instanceIds = new HashSet<String>();
|
this.region = region;
|
||||||
this.availabilityZones = new HashSet<String>();
|
this.name = name;
|
||||||
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
this.instanceIds = instanceIds;
|
||||||
}
|
this.availabilityZones = availabilityZones;
|
||||||
|
this.dnsName = dnsName;
|
||||||
|
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
||||||
|
}
|
||||||
|
|
||||||
public ElasticLoadBalancer(String region, String name,
|
public void setRegion(String region) {
|
||||||
Set<String> instanceIds, Set<String> availabilityZones,
|
this.region = region;
|
||||||
String dnsName)
|
}
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.region = region;
|
|
||||||
this.name = name;
|
|
||||||
this.instanceIds = instanceIds;
|
|
||||||
this.availabilityZones = availabilityZones;
|
|
||||||
this.dnsName = dnsName;
|
|
||||||
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRegion(String region)
|
public void setInstanceIds(Set<String> instanceIds) {
|
||||||
{
|
this.instanceIds = instanceIds;
|
||||||
this.region = region;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name)
|
public void setAvailabilityZones(Set<String> availabilityZones) {
|
||||||
{
|
this.availabilityZones = availabilityZones;
|
||||||
this.name = name;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstanceIds(Set<String> instanceIds)
|
public void setDnsName(String dnsName) {
|
||||||
{
|
this.dnsName = dnsName;
|
||||||
this.instanceIds = instanceIds;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setAvailabilityZones(Set<String> availabilityZones)
|
public void setAppCookieStickinessPolicy(AppCookieStickinessPolicy appCookieStickinessPolicy) {
|
||||||
{
|
this.appCookieStickinessPolicy = appCookieStickinessPolicy;
|
||||||
this.availabilityZones = availabilityZones;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDnsName(String dnsName)
|
public void setlBCookieStickinessPolicy(LBCookieStickinessPolicy lBCookieStickinessPolicy) {
|
||||||
{
|
this.lBCookieStickinessPolicy = lBCookieStickinessPolicy;
|
||||||
this.dnsName = dnsName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppCookieStickinessPolicy(
|
public void setLoadBalancerListeners(Set<LoadBalancerListener> loadBalancerListeners) {
|
||||||
AppCookieStickinessPolicy appCookieStickinessPolicy)
|
this.loadBalancerListeners = loadBalancerListeners;
|
||||||
{
|
}
|
||||||
this.appCookieStickinessPolicy = appCookieStickinessPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setlBCookieStickinessPolicy(
|
public String getName() {
|
||||||
LBCookieStickinessPolicy lBCookieStickinessPolicy)
|
return name;
|
||||||
{
|
}
|
||||||
this.lBCookieStickinessPolicy = lBCookieStickinessPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoadBalancerListeners(
|
public Set<String> getInstanceIds() {
|
||||||
Set<LoadBalancerListener> loadBalancerListeners)
|
return instanceIds;
|
||||||
{
|
}
|
||||||
this.loadBalancerListeners = loadBalancerListeners;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public Set<String> getAvailabilityZones() {
|
||||||
{
|
return availabilityZones;
|
||||||
return name;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getInstanceIds()
|
public String getDnsName() {
|
||||||
{
|
return dnsName;
|
||||||
return instanceIds;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getAvailabilityZones()
|
public AppCookieStickinessPolicy getAppCookieStickinessPolicy() {
|
||||||
{
|
return appCookieStickinessPolicy;
|
||||||
return availabilityZones;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDnsName()
|
public LBCookieStickinessPolicy getlBCookieStickinessPolicy() {
|
||||||
{
|
return lBCookieStickinessPolicy;
|
||||||
return dnsName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public AppCookieStickinessPolicy getAppCookieStickinessPolicy()
|
public Set<LoadBalancerListener> getLoadBalancerListeners() {
|
||||||
{
|
return loadBalancerListeners;
|
||||||
return appCookieStickinessPolicy;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public LBCookieStickinessPolicy getlBCookieStickinessPolicy()
|
public String getRegion() {
|
||||||
{
|
return region;
|
||||||
return lBCookieStickinessPolicy;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Set<LoadBalancerListener> getLoadBalancerListeners()
|
@Override
|
||||||
{
|
public int compareTo(ElasticLoadBalancer that) {
|
||||||
return loadBalancerListeners;
|
return name.compareTo(that.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegion()
|
@Override
|
||||||
{
|
public int hashCode() {
|
||||||
return region;
|
final int prime = 31;
|
||||||
}
|
int result = 1;
|
||||||
|
result = prime * result
|
||||||
|
+ ((appCookieStickinessPolicy == null) ? 0 : appCookieStickinessPolicy.hashCode());
|
||||||
|
result = prime * result + ((availabilityZones == null) ? 0 : availabilityZones.hashCode());
|
||||||
|
result = prime * result + ((dnsName == null) ? 0 : dnsName.hashCode());
|
||||||
|
result = prime * result + ((instanceIds == null) ? 0 : instanceIds.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((lBCookieStickinessPolicy == null) ? 0 : lBCookieStickinessPolicy.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((loadBalancerListeners == null) ? 0 : loadBalancerListeners.hashCode());
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ElasticLoadBalancer that)
|
public boolean equals(Object obj) {
|
||||||
{
|
if (this == obj)
|
||||||
return name.compareTo(that.name);
|
return true;
|
||||||
}
|
if (obj == null)
|
||||||
|
return false;
|
||||||
@Override
|
if (getClass() != obj.getClass())
|
||||||
public int hashCode()
|
return false;
|
||||||
{
|
ElasticLoadBalancer other = (ElasticLoadBalancer) obj;
|
||||||
final int prime = 31;
|
if (appCookieStickinessPolicy == null) {
|
||||||
int result = 1;
|
if (other.appCookieStickinessPolicy != null)
|
||||||
result = prime
|
return false;
|
||||||
* result
|
} else if (!appCookieStickinessPolicy.equals(other.appCookieStickinessPolicy))
|
||||||
+ ((appCookieStickinessPolicy == null) ? 0
|
return false;
|
||||||
: appCookieStickinessPolicy.hashCode());
|
if (availabilityZones == null) {
|
||||||
result = prime
|
if (other.availabilityZones != null)
|
||||||
* result
|
return false;
|
||||||
+ ((availabilityZones == null) ? 0 : availabilityZones
|
} else if (!availabilityZones.equals(other.availabilityZones))
|
||||||
.hashCode());
|
return false;
|
||||||
result = prime * result + ((dnsName == null) ? 0 : dnsName.hashCode());
|
if (dnsName == null) {
|
||||||
result = prime * result
|
if (other.dnsName != null)
|
||||||
+ ((instanceIds == null) ? 0 : instanceIds.hashCode());
|
return false;
|
||||||
result = prime
|
} else if (!dnsName.equals(other.dnsName))
|
||||||
* result
|
return false;
|
||||||
+ ((lBCookieStickinessPolicy == null) ? 0
|
if (instanceIds == null) {
|
||||||
: lBCookieStickinessPolicy.hashCode());
|
if (other.instanceIds != null)
|
||||||
result = prime
|
return false;
|
||||||
* result
|
} else if (!instanceIds.equals(other.instanceIds))
|
||||||
+ ((loadBalancerListeners == null) ? 0 : loadBalancerListeners
|
return false;
|
||||||
.hashCode());
|
if (lBCookieStickinessPolicy == null) {
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
if (other.lBCookieStickinessPolicy != null)
|
||||||
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
return false;
|
||||||
return result;
|
} else if (!lBCookieStickinessPolicy.equals(other.lBCookieStickinessPolicy))
|
||||||
}
|
return false;
|
||||||
|
if (loadBalancerListeners == null) {
|
||||||
|
if (other.loadBalancerListeners != null)
|
||||||
|
return false;
|
||||||
|
} else if (!loadBalancerListeners.equals(other.loadBalancerListeners))
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (region == null) {
|
||||||
|
if (other.region != null)
|
||||||
|
return false;
|
||||||
|
} else if (!region.equals(other.region))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public static class AppCookieStickinessPolicy {
|
||||||
public boolean equals(Object obj)
|
private String policyName;
|
||||||
{
|
private String cookieName;
|
||||||
if (this == obj)
|
|
||||||
|
public AppCookieStickinessPolicy() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppCookieStickinessPolicy(String policyName, String cookieName) {
|
||||||
|
super();
|
||||||
|
this.policyName = policyName;
|
||||||
|
this.cookieName = cookieName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPolicyName() {
|
||||||
|
return policyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCookieName() {
|
||||||
|
return cookieName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolicyName(String policyName) {
|
||||||
|
this.policyName = policyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCookieName(String cookieName) {
|
||||||
|
this.cookieName = cookieName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((cookieName == null) ? 0 : cookieName.hashCode());
|
||||||
|
result = prime * result + ((policyName == null) ? 0 : policyName.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
ElasticLoadBalancer other = (ElasticLoadBalancer) obj;
|
AppCookieStickinessPolicy other = (AppCookieStickinessPolicy) obj;
|
||||||
if (appCookieStickinessPolicy == null)
|
if (cookieName == null) {
|
||||||
{
|
if (other.cookieName != null)
|
||||||
if (other.appCookieStickinessPolicy != null)
|
return false;
|
||||||
return false;
|
} else if (!cookieName.equals(other.cookieName))
|
||||||
}
|
|
||||||
else if (!appCookieStickinessPolicy
|
|
||||||
.equals(other.appCookieStickinessPolicy))
|
|
||||||
return false;
|
return false;
|
||||||
if (availabilityZones == null)
|
if (policyName == null) {
|
||||||
{
|
if (other.policyName != null)
|
||||||
if (other.availabilityZones != null)
|
return false;
|
||||||
return false;
|
} else if (!policyName.equals(other.policyName))
|
||||||
}
|
|
||||||
else if (!availabilityZones.equals(other.availabilityZones))
|
|
||||||
return false;
|
return false;
|
||||||
if (dnsName == null)
|
return true;
|
||||||
{
|
}
|
||||||
if (other.dnsName != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!dnsName.equals(other.dnsName))
|
|
||||||
return false;
|
|
||||||
if (instanceIds == null)
|
|
||||||
{
|
|
||||||
if (other.instanceIds != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!instanceIds.equals(other.instanceIds))
|
|
||||||
return false;
|
|
||||||
if (lBCookieStickinessPolicy == null)
|
|
||||||
{
|
|
||||||
if (other.lBCookieStickinessPolicy != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!lBCookieStickinessPolicy
|
|
||||||
.equals(other.lBCookieStickinessPolicy))
|
|
||||||
return false;
|
|
||||||
if (loadBalancerListeners == null)
|
|
||||||
{
|
|
||||||
if (other.loadBalancerListeners != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!loadBalancerListeners.equals(other.loadBalancerListeners))
|
|
||||||
return false;
|
|
||||||
if (name == null)
|
|
||||||
{
|
|
||||||
if (other.name != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!name.equals(other.name))
|
|
||||||
return false;
|
|
||||||
if (region == null)
|
|
||||||
{
|
|
||||||
if (other.region != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!region.equals(other.region))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LBCookieStickinessPolicy {
|
||||||
|
private String policyName;
|
||||||
|
private Integer cookieExpirationPeriod;
|
||||||
|
|
||||||
|
public LBCookieStickinessPolicy() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LBCookieStickinessPolicy(String policyName, Integer cookieExpirationPeriod) {
|
||||||
|
super();
|
||||||
|
this.policyName = policyName;
|
||||||
|
this.cookieExpirationPeriod = cookieExpirationPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPolicyName() {
|
||||||
|
return policyName;
|
||||||
|
}
|
||||||
|
|
||||||
public static class AppCookieStickinessPolicy
|
public Integer getCookieExpirationPeriod() {
|
||||||
{
|
return cookieExpirationPeriod;
|
||||||
private String policyName;
|
}
|
||||||
private String cookieName;
|
|
||||||
|
|
||||||
|
public void setPolicyName(String policyName) {
|
||||||
public AppCookieStickinessPolicy()
|
this.policyName = policyName;
|
||||||
{
|
}
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppCookieStickinessPolicy(String policyName, String cookieName)
|
public void setCookieExpirationPeriod(Integer cookieExpirationPeriod) {
|
||||||
{
|
this.cookieExpirationPeriod = cookieExpirationPeriod;
|
||||||
super();
|
}
|
||||||
this.policyName = policyName;
|
|
||||||
this.cookieName = cookieName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPolicyName()
|
@Override
|
||||||
{
|
public int hashCode() {
|
||||||
return policyName;
|
final int prime = 31;
|
||||||
}
|
int result = 1;
|
||||||
|
result = prime * result
|
||||||
|
+ ((cookieExpirationPeriod == null) ? 0 : cookieExpirationPeriod.hashCode());
|
||||||
|
result = prime * result + ((policyName == null) ? 0 : policyName.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCookieName()
|
@Override
|
||||||
{
|
public boolean equals(Object obj) {
|
||||||
return cookieName;
|
if (this == obj)
|
||||||
}
|
|
||||||
|
|
||||||
public void setPolicyName(String policyName)
|
|
||||||
{
|
|
||||||
this.policyName = policyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCookieName(String cookieName)
|
|
||||||
{
|
|
||||||
this.cookieName = cookieName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result
|
|
||||||
+ ((cookieName == null) ? 0 : cookieName.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((policyName == null) ? 0 : policyName.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
AppCookieStickinessPolicy other = (AppCookieStickinessPolicy) obj;
|
|
||||||
if (cookieName == null)
|
|
||||||
{
|
|
||||||
if (other.cookieName != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!cookieName.equals(other.cookieName))
|
|
||||||
return false;
|
|
||||||
if (policyName == null)
|
|
||||||
{
|
|
||||||
if (other.policyName != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!policyName.equals(other.policyName))
|
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
LBCookieStickinessPolicy other = (LBCookieStickinessPolicy) obj;
|
||||||
|
if (cookieExpirationPeriod == null) {
|
||||||
|
if (other.cookieExpirationPeriod != null)
|
||||||
|
return false;
|
||||||
|
} else if (!cookieExpirationPeriod.equals(other.cookieExpirationPeriod))
|
||||||
|
return false;
|
||||||
|
if (policyName == null) {
|
||||||
|
if (other.policyName != null)
|
||||||
|
return false;
|
||||||
|
} else if (!policyName.equals(other.policyName))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LBCookieStickinessPolicy
|
public static class LoadBalancerListener {
|
||||||
{
|
private Set<String> policyNames;
|
||||||
private String policyName;
|
private Integer instancePort;
|
||||||
private Integer cookieExpirationPeriod;
|
private Integer loadBalancerPort;
|
||||||
|
private String protocol;
|
||||||
|
|
||||||
public LBCookieStickinessPolicy()
|
public LoadBalancerListener(Set<String> policyNames, Integer instancePort,
|
||||||
{
|
Integer loadBalancerPort, String protocol) {
|
||||||
super();
|
super();
|
||||||
}
|
this.policyNames = policyNames;
|
||||||
|
this.instancePort = instancePort;
|
||||||
|
this.loadBalancerPort = loadBalancerPort;
|
||||||
|
this.protocol = protocol;
|
||||||
|
}
|
||||||
|
|
||||||
public LBCookieStickinessPolicy(String policyName,
|
public LoadBalancerListener() {
|
||||||
Integer cookieExpirationPeriod)
|
super();
|
||||||
{
|
}
|
||||||
super();
|
|
||||||
this.policyName = policyName;
|
|
||||||
this.cookieExpirationPeriod = cookieExpirationPeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPolicyName()
|
public Set<String> getPolicyNames() {
|
||||||
{
|
return policyNames;
|
||||||
return policyName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCookieExpirationPeriod()
|
public Integer getInstancePort() {
|
||||||
{
|
return instancePort;
|
||||||
return cookieExpirationPeriod;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPolicyName(String policyName)
|
public Integer getLoadBalancerPort() {
|
||||||
{
|
return loadBalancerPort;
|
||||||
this.policyName = policyName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setCookieExpirationPeriod(Integer cookieExpirationPeriod)
|
public String getProtocol() {
|
||||||
{
|
return protocol;
|
||||||
this.cookieExpirationPeriod = cookieExpirationPeriod;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void setPolicyNames(Set<String> policyNames) {
|
||||||
public int hashCode()
|
this.policyNames = policyNames;
|
||||||
{
|
}
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime
|
|
||||||
* result
|
|
||||||
+ ((cookieExpirationPeriod == null) ? 0
|
|
||||||
: cookieExpirationPeriod.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((policyName == null) ? 0 : policyName.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void setInstancePort(Integer instancePort) {
|
||||||
public boolean equals(Object obj)
|
this.instancePort = instancePort;
|
||||||
{
|
}
|
||||||
if (this == obj)
|
|
||||||
return true;
|
public void setLoadBalancerPort(Integer loadBalancerPort) {
|
||||||
if (obj == null)
|
this.loadBalancerPort = loadBalancerPort;
|
||||||
return false;
|
}
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
public void setProtocol(String protocol) {
|
||||||
LBCookieStickinessPolicy other = (LBCookieStickinessPolicy) obj;
|
this.protocol = protocol;
|
||||||
if (cookieExpirationPeriod == null)
|
}
|
||||||
{
|
|
||||||
if (other.cookieExpirationPeriod != null)
|
@Override
|
||||||
return false;
|
public int hashCode() {
|
||||||
}
|
final int prime = 31;
|
||||||
else if (!cookieExpirationPeriod
|
int result = 1;
|
||||||
.equals(other.cookieExpirationPeriod))
|
result = prime * result + ((instancePort == null) ? 0 : instancePort.hashCode());
|
||||||
return false;
|
result = prime * result + ((loadBalancerPort == null) ? 0 : loadBalancerPort.hashCode());
|
||||||
if (policyName == null)
|
result = prime * result + ((policyNames == null) ? 0 : policyNames.hashCode());
|
||||||
{
|
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
|
||||||
if (other.policyName != null)
|
return result;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
else if (!policyName.equals(other.policyName))
|
@Override
|
||||||
return false;
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
}
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
LoadBalancerListener other = (LoadBalancerListener) obj;
|
||||||
|
if (instancePort == null) {
|
||||||
|
if (other.instancePort != null)
|
||||||
|
return false;
|
||||||
|
} else if (!instancePort.equals(other.instancePort))
|
||||||
|
return false;
|
||||||
|
if (loadBalancerPort == null) {
|
||||||
|
if (other.loadBalancerPort != null)
|
||||||
|
return false;
|
||||||
|
} else if (!loadBalancerPort.equals(other.loadBalancerPort))
|
||||||
|
return false;
|
||||||
|
if (policyNames == null) {
|
||||||
|
if (other.policyNames != null)
|
||||||
|
return false;
|
||||||
|
} else if (!policyNames.equals(other.policyNames))
|
||||||
|
return false;
|
||||||
|
if (protocol == null) {
|
||||||
|
if (other.protocol != null)
|
||||||
|
return false;
|
||||||
|
} else if (!protocol.equals(other.protocol))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LoadBalancerListener
|
|
||||||
{
|
|
||||||
private Set<String> policyNames;
|
|
||||||
private Integer instancePort;
|
|
||||||
private Integer loadBalancerPort;
|
|
||||||
private String protocol;
|
|
||||||
|
|
||||||
public LoadBalancerListener(Set<String> policyNames,
|
|
||||||
Integer instancePort, Integer loadBalancerPort, String protocol)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.policyNames = policyNames;
|
|
||||||
this.instancePort = instancePort;
|
|
||||||
this.loadBalancerPort = loadBalancerPort;
|
|
||||||
this.protocol = protocol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadBalancerListener()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getPolicyNames()
|
|
||||||
{
|
|
||||||
return policyNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getInstancePort()
|
|
||||||
{
|
|
||||||
return instancePort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLoadBalancerPort()
|
|
||||||
{
|
|
||||||
return loadBalancerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProtocol()
|
|
||||||
{
|
|
||||||
return protocol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPolicyNames(Set<String> policyNames)
|
|
||||||
{
|
|
||||||
this.policyNames = policyNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstancePort(Integer instancePort)
|
|
||||||
{
|
|
||||||
this.instancePort = instancePort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoadBalancerPort(Integer loadBalancerPort)
|
|
||||||
{
|
|
||||||
this.loadBalancerPort = loadBalancerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProtocol(String protocol)
|
|
||||||
{
|
|
||||||
this.protocol = protocol;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result
|
|
||||||
+ ((instancePort == null) ? 0 : instancePort.hashCode());
|
|
||||||
result = prime
|
|
||||||
* result
|
|
||||||
+ ((loadBalancerPort == null) ? 0 : loadBalancerPort
|
|
||||||
.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((policyNames == null) ? 0 : policyNames.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((protocol == null) ? 0 : protocol.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
LoadBalancerListener other = (LoadBalancerListener) obj;
|
|
||||||
if (instancePort == null)
|
|
||||||
{
|
|
||||||
if (other.instancePort != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!instancePort.equals(other.instancePort))
|
|
||||||
return false;
|
|
||||||
if (loadBalancerPort == null)
|
|
||||||
{
|
|
||||||
if (other.loadBalancerPort != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!loadBalancerPort.equals(other.loadBalancerPort))
|
|
||||||
return false;
|
|
||||||
if (policyNames == null)
|
|
||||||
{
|
|
||||||
if (other.policyNames != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!policyNames.equals(other.policyNames))
|
|
||||||
return false;
|
|
||||||
if (protocol == null)
|
|
||||||
{
|
|
||||||
if (other.protocol != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!protocol.equals(other.protocol))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,64 +53,63 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@RequestFilters(FormSigner.class)
|
@RequestFilters(FormSigner.class)
|
||||||
@FormParams(keys = VERSION, values = "2009-11-25")
|
@FormParams(keys = VERSION, values = "2009-11-25")
|
||||||
@VirtualHost
|
@VirtualHost
|
||||||
public interface ElasticLoadBalancerAsyncClient
|
public interface ElasticLoadBalancerAsyncClient {
|
||||||
{
|
/**
|
||||||
/**
|
* @see ElasticLoadBalancerClient#createLoadBalancerInRegion
|
||||||
* @see ElasticLoadBalancerClient#createLoadBalancer
|
*/
|
||||||
*/
|
@POST
|
||||||
@POST
|
@Path("/")
|
||||||
@Path("/")
|
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
||||||
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
||||||
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
ListenableFuture<String> createLoadBalancerInRegion(
|
||||||
ListenableFuture<String> createLoadBalancer(
|
|
||||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name,
|
@FormParam("LoadBalancerName") String name,
|
||||||
@FormParam("Listeners.member.1.Protocol") String protocol,
|
@FormParam("Listeners.member.1.Protocol") String protocol,
|
||||||
@FormParam("Listeners.member.1.LoadBalancerPort") Integer loadBalancerPort,
|
@FormParam("Listeners.member.1.LoadBalancerPort") int loadBalancerPort,
|
||||||
@FormParam("Listeners.member.1.InstancePort") Integer instancePort,
|
@FormParam("Listeners.member.1.InstancePort") int instancePort,
|
||||||
@FormParam("AvailabilityZones.member.1") String availabilityZone);
|
@FormParam("AvailabilityZones.member.1") String availabilityZone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticLoadBalancerClient#deleteLoadBalancer
|
* @see ElasticLoadBalancerClient#deleteLoadBalancerInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteLoadBalancer")
|
@FormParams(keys = ACTION, values = "DeleteLoadBalancer")
|
||||||
ListenableFuture<Void> deleteLoadBalancer(
|
ListenableFuture<Void> deleteLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name);
|
@FormParam("LoadBalancerName") String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticLoadBalancerClient#registerInstancesWithLoadBalancer
|
* @see ElasticLoadBalancerClient#registerInstancesWithLoadBalancerInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@XMLResponseParser(RegisterInstancesWithLoadBalancerResponseHandler.class)
|
@XMLResponseParser(RegisterInstancesWithLoadBalancerResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer")
|
@FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer")
|
||||||
ListenableFuture<? extends Set<String>> registerInstancesWithLoadBalancer(
|
ListenableFuture<? extends Set<String>> registerInstancesWithLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name,
|
@FormParam("LoadBalancerName") String name,
|
||||||
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticLoadBalancerClient#deregisterInstancesWithLoadBalancer
|
* @see ElasticLoadBalancerClient#deregisterInstancesWithLoadBalancerInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer")
|
@FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer")
|
||||||
ListenableFuture<Void> deregisterInstancesWithLoadBalancer(
|
ListenableFuture<Void> deregisterInstancesWithLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name,
|
@FormParam("LoadBalancerName") String name,
|
||||||
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElasticLoadBalancerClient#describeLoadBalancers
|
* @see ElasticLoadBalancerClient#describeLoadBalancersInRegion
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
||||||
ListenableFuture<? extends Set<ElasticLoadBalancer>> describeLoadBalancers(
|
ListenableFuture<? extends Set<ElasticLoadBalancer>> describeLoadBalancersInRegion(
|
||||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") @Nullable String name);
|
@FormParam("LoadBalancerName") @Nullable String name);
|
||||||
|
|
||||||
|
|
|
@ -34,48 +34,64 @@ import org.jclouds.concurrent.Timeout;
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface ElasticLoadBalancerClient {
|
public interface ElasticLoadBalancerClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a load balancer
|
* Creates a load balancer
|
||||||
*
|
*
|
||||||
* @param name Name of the load balancer
|
* @param name
|
||||||
* @param loadBalancerPort Port for the load balancer to listen on
|
* Name of the load balancer
|
||||||
* @param instancePort Port to forward the request to
|
* @param loadBalancerPort
|
||||||
* @return dns the DNS name for the load balancer
|
* Port for the load balancer to listen on
|
||||||
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/"
|
* @param instancePort
|
||||||
*/
|
* Port to forward the request to
|
||||||
String createLoadBalancer(@Nullable String region, String name, String protocol, Integer loadBalancerPort, Integer instancePort, String availabilityZone);
|
* @return dns the DNS name for the load balancer
|
||||||
|
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/"
|
||||||
|
*/
|
||||||
|
String createLoadBalancerInRegion(@Nullable String region, String name, String protocol,
|
||||||
|
int loadBalancerPort, int instancePort, String availabilityZone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete load balancer
|
* Delete load balancer
|
||||||
*
|
*
|
||||||
* @param name Name of the load balancer
|
* @param name
|
||||||
|
* Name of the load balancer
|
||||||
* @return
|
* @return
|
||||||
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/2009-05-15/DeveloperGuide/"
|
* @see <a
|
||||||
|
* href="http://docs.amazonwebservices.com/ElasticLoadBalancing/2009-05-15/DeveloperGuide/"
|
||||||
*/
|
*/
|
||||||
void deleteLoadBalancer(@Nullable String region, String name);
|
void deleteLoadBalancerInRegion(@Nullable String region, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register instances with an existing load balancer
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* Load Balancer name
|
||||||
|
* @param instanceIds
|
||||||
|
* Set of instance Ids to register with load balancer
|
||||||
|
* @return instanceIds registered with load balancer
|
||||||
|
*
|
||||||
|
* @see <a
|
||||||
|
* href="http://docs.amazonwebservices.com/ElasticLoadBalancing/2009-05-15/DeveloperGuide/"
|
||||||
|
*/
|
||||||
|
Set<String> registerInstancesWithLoadBalancerInRegion(@Nullable String region, String name,
|
||||||
|
String... instanceIds);
|
||||||
|
|
||||||
/**
|
|
||||||
* Register instances with an existing load balancer
|
|
||||||
* @param name Load Balancer name
|
|
||||||
* @param instanceIds Set of instance Ids to register with load balancer
|
|
||||||
* @return instanceIds registered with load balancer
|
|
||||||
*
|
|
||||||
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/2009-05-15/DeveloperGuide/"
|
|
||||||
*/
|
|
||||||
Set<String> registerInstancesWithLoadBalancer(@Nullable String region, String name, String... instanceIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deregister instances with an existing load balancer
|
* Deregister instances with an existing load balancer
|
||||||
* @param name Load Balancer name
|
*
|
||||||
* @param instanceIds Set of instance Ids to deregister with load balancer
|
* @param name
|
||||||
|
* Load Balancer name
|
||||||
|
* @param instanceIds
|
||||||
|
* Set of instance Ids to deregister with load balancer
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/2009-05-15/DeveloperGuide/"
|
* @see <a
|
||||||
|
* href="http://docs.amazonwebservices.com/ElasticLoadBalancing/2009-05-15/DeveloperGuide/"
|
||||||
*/
|
*/
|
||||||
void deregisterInstancesWithLoadBalancer(@Nullable String region, String name, String... instanceIds);
|
void deregisterInstancesWithLoadBalancerInRegion(@Nullable String region, String name,
|
||||||
|
String... instanceIds);
|
||||||
|
|
||||||
|
Set<ElasticLoadBalancer> describeLoadBalancersInRegion(@Nullable String region,
|
||||||
Set<ElasticLoadBalancer> describeLoadBalancers(@Nullable String region, @Nullable String name);
|
@Nullable String name);
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,15 +21,32 @@ package org.jclouds.aws.ec2.util;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
|
import org.jclouds.aws.ec2.services.InstanceClient;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class EC2Utils {
|
public class EC2Utils {
|
||||||
|
@Singleton
|
||||||
|
public static class GetRegionFromLocation implements Function<Location, String> {
|
||||||
|
public String apply(Location location) {
|
||||||
|
String region = location.getScope() == LocationScope.REGION ? location.getId() : location
|
||||||
|
.getParent().getId();
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void indexStringArrayToFormValuesWithPrefix(GeneratedHttpRequest<?> request,
|
public static void indexStringArrayToFormValuesWithPrefix(GeneratedHttpRequest<?> request,
|
||||||
String prefix, Object input) {
|
String prefix, Object input) {
|
||||||
|
@ -42,6 +59,17 @@ public class EC2Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Iterable<RunningInstance> getAllRunningInstancesInRegion(InstanceClient client,
|
||||||
|
String region, String id) {
|
||||||
|
return Iterables.concat(client.describeInstancesInRegion(region, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] parseHandle(String handle) {
|
||||||
|
String[] parts = checkNotNull(handle, "handle").split("/");
|
||||||
|
checkArgument(parts.length == 2, "handle syntax is region/id");
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
public static void indexIterableToFormValuesWithPrefix(GeneratedHttpRequest<?> request,
|
public static void indexIterableToFormValuesWithPrefix(GeneratedHttpRequest<?> request,
|
||||||
String prefix, Object input) {
|
String prefix, Object input) {
|
||||||
checkArgument(checkNotNull(input, "input") instanceof Iterable<?>,
|
checkArgument(checkNotNull(input, "input") instanceof Iterable<?>,
|
||||||
|
|
|
@ -178,39 +178,37 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, tag);
|
cleanupExtendedStuff(securityGroupClient, keyPairClient, tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLoadBalanceNodesMatching() throws Exception{
|
|
||||||
|
|
||||||
ElasticLoadBalancerClient elbClient = EC2Client.class.cast(
|
@Test
|
||||||
context.getProviderSpecificContext().getApi())
|
public void testLoadBalanceNodesMatching() throws Exception {
|
||||||
.getElasticLoadBalancerServices();
|
|
||||||
|
|
||||||
String tag = "jcloudsElbTest";
|
ElasticLoadBalancerClient elbClient = EC2Client.class.cast(
|
||||||
Template template = client.templateBuilder().build();
|
context.getProviderSpecificContext().getApi()).getElasticLoadBalancerServices();
|
||||||
Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 2,
|
|
||||||
template);
|
String tag = "jcloudsElbTest";
|
||||||
Set<String> instanceIds = new HashSet<String>();
|
Template template = client.templateBuilder().build();
|
||||||
for (NodeMetadata node : nodes)
|
try {
|
||||||
{
|
Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 2, template);
|
||||||
|
Set<String> instanceIds = new HashSet<String>();
|
||||||
|
for (NodeMetadata node : nodes) {
|
||||||
instanceIds.add(node.getId());
|
instanceIds.add(node.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// create load balancer
|
// create load balancer
|
||||||
String dnsName = client.loadBalanceNodesMatching(tag, "HTTP", 80, 80,
|
String dnsName = client.loadBalanceNodesMatching(NodePredicates.withTag(tag), tag, "HTTP",
|
||||||
NodePredicates.withTag(tag));
|
80, 80);
|
||||||
assertNotNull(dnsName);
|
assertNotNull(dnsName);
|
||||||
Set<ElasticLoadBalancer> elbs = elbClient.describeLoadBalancers(
|
Set<ElasticLoadBalancer> elbs = elbClient.describeLoadBalancersInRegion(Region.US_EAST_1,
|
||||||
Region.US_EAST_1, tag);
|
tag);
|
||||||
assertNotNull(elbs);
|
assertNotNull(elbs);
|
||||||
ElasticLoadBalancer elb = elbs.iterator().next();
|
ElasticLoadBalancer elb = elbs.iterator().next();
|
||||||
assertEquals(elb.getInstanceIds(), instanceIds);
|
assertEquals(elb.getInstanceIds(), instanceIds);
|
||||||
|
} finally {
|
||||||
elbClient.deleteLoadBalancer(Region.US_EAST_1, tag);
|
elbClient.deleteLoadBalancerInRegion(Region.US_EAST_1, tag);
|
||||||
//finaly destroy nodes
|
// finaly destroy nodes
|
||||||
client.destroyNodesMatching(NodePredicates.withTag(tag));
|
client.destroyNodesMatching(NodePredicates.withTag(tag));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningInstance getInstance(InstanceClient instanceClient, String id) {
|
private RunningInstance getInstance(InstanceClient instanceClient, String id) {
|
||||||
RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(instanceClient
|
RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(instanceClient
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class EC2ComputeServiceTest {
|
||||||
|
|
||||||
expect(optionsProvider.get()).andReturn(defaultOptions);
|
expect(optionsProvider.get()).andReturn(defaultOptions);
|
||||||
|
|
||||||
Image image = new ImageImpl("ami-image", "image", location, null, Maps
|
Image image = new ImageImpl("ami-image", "image", "us-east-1/ami-image", location, null, Maps
|
||||||
.<String, String> newHashMap(), "description", "1.0", null, "ubuntu",
|
.<String, String> newHashMap(), "description", "1.0", null, "ubuntu",
|
||||||
Architecture.X86_64, new Credentials("root", null));
|
Architecture.X86_64, new Credentials("root", null));
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
|
|
|
@ -271,6 +271,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
RunningInstance instance = createMock(RunningInstance.class);
|
RunningInstance instance = createMock(RunningInstance.class);
|
||||||
|
|
||||||
expect(instance.getId()).andReturn("id").atLeastOnce();
|
expect(instance.getId()).andReturn("id").atLeastOnce();
|
||||||
|
expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce();
|
||||||
expect(instance.getGroupIds()).andReturn(ImmutableSet.<String> of()).atLeastOnce();
|
expect(instance.getGroupIds()).andReturn(ImmutableSet.<String> of()).atLeastOnce();
|
||||||
expect(instance.getKeyName()).andReturn(null).atLeastOnce();
|
expect(instance.getKeyName()).andReturn(null).atLeastOnce();
|
||||||
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
||||||
|
@ -328,6 +329,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
RunningInstance instance = createMock(RunningInstance.class);
|
RunningInstance instance = createMock(RunningInstance.class);
|
||||||
|
|
||||||
expect(instance.getId()).andReturn("id").atLeastOnce();
|
expect(instance.getId()).andReturn("id").atLeastOnce();
|
||||||
|
expect(instance.getRegion()).andReturn("us-east-1").atLeastOnce();
|
||||||
expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag")).atLeastOnce();
|
expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag")).atLeastOnce();
|
||||||
expect(instance.getKeyName()).andReturn(null).atLeastOnce();
|
expect(instance.getKeyName()).andReturn(null).atLeastOnce();
|
||||||
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
Location location = new LocationImpl(LocationScope.REGION, "region", "region", null);
|
Location location = new LocationImpl(LocationScope.REGION, "region", "region", null);
|
||||||
Set<Location> locations = ImmutableSet.<Location> of(location);
|
Set<Location> locations = ImmutableSet.<Location> of(location);
|
||||||
Set<Image> images = ImmutableSet.<Image> of();
|
Set<Image> images = ImmutableSet.<Image> of();
|
||||||
Set<Size> sizes = ImmutableSet.<Size> of(new SizeImpl(null, null, location, null,
|
Set<Size> sizes = ImmutableSet.<Size> of(new SizeImpl("1", "1", "region/1", location, null,
|
||||||
ImmutableMap.<String, String> of(), 1, 1, 1, EnumSet.allOf(Architecture.class)));
|
ImmutableMap.<String, String> of(), 1, 1, 1, EnumSet.allOf(Architecture.class)));
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||||
|
@ -127,7 +127,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
Location location = new LocationImpl(LocationScope.REGION, "region", "region", null);
|
Location location = new LocationImpl(LocationScope.REGION, "region", "region", null);
|
||||||
Set<Location> locations = ImmutableSet.<Location> of(location);
|
Set<Location> locations = ImmutableSet.<Location> of(location);
|
||||||
Set<Image> images = ImmutableSet.<Image> of();
|
Set<Image> images = ImmutableSet.<Image> of();
|
||||||
Set<Size> sizes = ImmutableSet.<Size> of(new SizeImpl(null, null, location, null,
|
Set<Size> sizes = ImmutableSet.<Size> of(new SizeImpl("1", "1", "region/1", location, null,
|
||||||
ImmutableMap.<String, String> of(), 1, 1, 1, EnumSet.allOf(Architecture.class)));
|
ImmutableMap.<String, String> of(), 1, 1, 1, EnumSet.allOf(Architecture.class)));
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class ElasticLoadBalancerAsyncClientTest extends
|
||||||
public void testRegisterInstancesWithLoadBalancer() throws SecurityException,
|
public void testRegisterInstancesWithLoadBalancer() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = ElasticLoadBalancerAsyncClient.class.getMethod(
|
Method method = ElasticLoadBalancerAsyncClient.class.getMethod(
|
||||||
"registerInstancesWithLoadBalancer", String.class, String.class, String[].class);
|
"registerInstancesWithLoadBalancerInRegion", String.class, String.class, String[].class);
|
||||||
|
|
||||||
GeneratedHttpRequest<ElasticLoadBalancerAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticLoadBalancerAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, null, "ReferenceAP1", "i-6055fa09");
|
method, null, "ReferenceAP1", "i-6055fa09");
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ElasticLoadBalancerClientLiveTest {
|
||||||
AvailabilityZone.US_EAST_1A, Region.US_WEST_1, AvailabilityZone.US_WEST_1A,
|
AvailabilityZone.US_EAST_1A, Region.US_WEST_1, AvailabilityZone.US_WEST_1A,
|
||||||
Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, Region.AP_SOUTHEAST_1,
|
Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, Region.AP_SOUTHEAST_1,
|
||||||
AvailabilityZone.AP_SOUTHEAST_1A).entrySet()) {
|
AvailabilityZone.AP_SOUTHEAST_1A).entrySet()) {
|
||||||
String dnsName = client.createLoadBalancer(regionZone.getKey(), name, "http", 80, 80,
|
String dnsName = client.createLoadBalancerInRegion(regionZone.getKey(), name, "http", 80, 80,
|
||||||
regionZone.getValue());
|
regionZone.getValue());
|
||||||
assertNotNull(dnsName);
|
assertNotNull(dnsName);
|
||||||
assert (dnsName.startsWith(name));
|
assert (dnsName.startsWith(name));
|
||||||
|
@ -79,7 +79,7 @@ public class ElasticLoadBalancerClientLiveTest {
|
||||||
String name = "TestDescribeLoadBalancer";
|
String name = "TestDescribeLoadBalancer";
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
|
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
||||||
Set<ElasticLoadBalancer> allResults = client.describeLoadBalancers(region, name);
|
Set<ElasticLoadBalancer> allResults = client.describeLoadBalancersInRegion(region, name);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert (allResults.size() >= 1);
|
assert (allResults.size() >= 1);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class ElasticLoadBalancerClientLiveTest {
|
||||||
void testDeleteLoadBalancer() {
|
void testDeleteLoadBalancer() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
|
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
||||||
client.deleteLoadBalancer(region, "TestLoadBalancer");
|
client.deleteLoadBalancerInRegion(region, "TestLoadBalancer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.xml;
|
package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.expect;
|
|
||||||
import static org.easymock.classextension.EasyMock.createMock;
|
|
||||||
import static org.easymock.classextension.EasyMock.replay;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,31 +33,26 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.RegisterInstancesWithLoadBalancerResponseHandlerTest")
|
@Test(groups = "unit", testName = "ec2.RegisterInstancesWithLoadBalancerResponseHandlerTest")
|
||||||
public class RegisterInstancesWithLoadBalancerResponseHandlerTest extends
|
public class RegisterInstancesWithLoadBalancerResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
BaseEC2HandlerTest
|
|
||||||
{
|
|
||||||
|
|
||||||
public void testParse()
|
public void testParse() {
|
||||||
{
|
InputStream is = getClass().getResourceAsStream(
|
||||||
InputStream is = getClass().getResourceAsStream(
|
"/ec2/register_instances_with_loadbalancer.xml");
|
||||||
"/ec2/register_instances_with_loadbalancer.xml");
|
|
||||||
|
|
||||||
Set<String> instanceIds = Sets.newHashSet();
|
Set<String> instanceIds = Sets.newHashSet();
|
||||||
instanceIds.add("i-6055fa09");
|
instanceIds.add("i-6055fa09");
|
||||||
instanceIds.add("i-9055fa55");
|
instanceIds.add("i-9055fa55");
|
||||||
|
|
||||||
|
|
||||||
Set<String> result = parseXML(is);
|
Set<String> result = parseXML(is);
|
||||||
|
|
||||||
assertEquals(result, instanceIds);
|
assertEquals(result, instanceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> parseXML(InputStream is)
|
private Set<String> parseXML(InputStream is) {
|
||||||
{
|
RegisterInstancesWithLoadBalancerResponseHandler handler = injector
|
||||||
RegisterInstancesWithLoadBalancerResponseHandler handler = injector
|
.getInstance(RegisterInstancesWithLoadBalancerResponseHandler.class);
|
||||||
.getInstance(RegisterInstancesWithLoadBalancerResponseHandler.class);
|
Set<String> result = factory.create(handler).parse(is);
|
||||||
Set<String> result = factory.create(handler).parse(is);
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.samples.googleappengine.functions;
|
package org.jclouds.samples.googleappengine.functions;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -48,9 +49,9 @@ public class ComputeServiceContextToStatusResult implements Function<String, Sta
|
||||||
String name = "not found";
|
String name = "not found";
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Map<String, ? extends ComputeMetadata> nodes = context.getComputeService().getNodes();
|
Set<? extends ComputeMetadata> nodes = context.getComputeService().listNodes();
|
||||||
if (nodes.size() > 0)
|
if (nodes.size() > 0)
|
||||||
name = Iterables.get(nodes.keySet(), 0);
|
name = Iterables.get(nodes, 0).getId();
|
||||||
status = ((System.currentTimeMillis() - start) + "ms");
|
status = ((System.currentTimeMillis() - start) + "ms");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e, "Error listing service %s", contextName);
|
logger.error(e, "Error listing service %s", contextName);
|
||||||
|
|
|
@ -207,10 +207,10 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(first (run-nodes tag 1 template compute))))
|
(first (run-nodes tag 1 template compute))))
|
||||||
|
|
||||||
(defn #^NodeMetadata node-details
|
(defn #^NodeMetadata node-details
|
||||||
"Retrieve the node metadata."
|
"Retrieve the node metadata, given its handle."
|
||||||
([location id] (node-details location id *compute*))
|
([handle] (node-details handle *compute*))
|
||||||
([#^Location location id #^ComputeService compute]
|
([handle #^ComputeService compute]
|
||||||
(.getNodeMetadata compute location id)))
|
(.getNodeMetadata compute handle)))
|
||||||
|
|
||||||
(defn reboot-nodes-with-tag
|
(defn reboot-nodes-with-tag
|
||||||
"Reboot all the nodes with the given tag."
|
"Reboot all the nodes with the given tag."
|
||||||
|
@ -219,10 +219,10 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(.rebootNodesMatching compute (NodePredicates/withTag tag))))
|
(.rebootNodesMatching compute (NodePredicates/withTag tag))))
|
||||||
|
|
||||||
(defn reboot-node
|
(defn reboot-node
|
||||||
"Reboot a given node."
|
"Reboot a node, given its handle."
|
||||||
([location id] (reboot-node location id *compute*))
|
([handle] (reboot-node handle *compute*))
|
||||||
([#^Location location id #^ComputeService compute]
|
([handle #^ComputeService compute]
|
||||||
(.rebootNode compute location id)))
|
(.rebootNode compute handle)))
|
||||||
|
|
||||||
(defn destroy-nodes-with-tag
|
(defn destroy-nodes-with-tag
|
||||||
"Destroy all the nodes with the given tag."
|
"Destroy all the nodes with the given tag."
|
||||||
|
@ -231,10 +231,10 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(.destroyNodesMatching compute (NodePredicates/withTag tag))))
|
(.destroyNodesMatching compute (NodePredicates/withTag tag))))
|
||||||
|
|
||||||
(defn destroy-node
|
(defn destroy-node
|
||||||
"Destroy a given node."
|
"Destroy a node, given its handle."
|
||||||
([location id] (destroy-node location id *compute*))
|
([handle] (destroy-node handle *compute*))
|
||||||
([#^Location location id #^ComputeService compute]
|
([handle #^ComputeService compute]
|
||||||
(.destroyNode compute location id)))
|
(.destroyNode compute handle)))
|
||||||
|
|
||||||
(defmacro state-predicate [node state]
|
(defmacro state-predicate [node state]
|
||||||
`(= (.getState ~node)
|
`(= (.getState ~node)
|
||||||
|
@ -295,6 +295,11 @@ See http://code.google.com/p/jclouds for details."
|
||||||
[#^ComputeMetadata node]
|
[#^ComputeMetadata node]
|
||||||
(-?> node .getLocation .getId))
|
(-?> node .getLocation .getId))
|
||||||
|
|
||||||
|
(defn handle
|
||||||
|
"Returns the compute node's handle"
|
||||||
|
[#^ComputeMetadata node]
|
||||||
|
(.getHandle node))
|
||||||
|
|
||||||
(define-accessors Template image size location options)
|
(define-accessors Template image size location options)
|
||||||
(define-accessors Image version os-family os-description architecture)
|
(define-accessors Image version os-family os-description architecture)
|
||||||
(define-accessors Size cores ram disk)
|
(define-accessors Size cores ram disk)
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
import org.jclouds.ssh.ExecResponse;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
|
@ -145,10 +146,10 @@ public interface ComputeService {
|
||||||
Set<? extends NodeMetadata> runNodesWithTag(String tag, int count) throws RunNodesException;
|
Set<? extends NodeMetadata> runNodesWithTag(String tag, int count) throws RunNodesException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy the node. If it is the only node in a tag set, the dependent resources will also be
|
* destroy the node, given its handle. If it is the only node in a tag set, the dependent
|
||||||
* destroyed.
|
* resources will also be destroyed.
|
||||||
*/
|
*/
|
||||||
void destroyNode(Location location, String id);
|
void destroyNode(String handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nodes matching the filter are treated as a logical set. Using the delete command, you can save
|
* nodes matching the filter are treated as a logical set. Using the delete command, you can save
|
||||||
|
@ -160,9 +161,9 @@ public interface ComputeService {
|
||||||
Set<? extends NodeMetadata> destroyNodesMatching(Predicate<NodeMetadata> filter);
|
Set<? extends NodeMetadata> destroyNodesMatching(Predicate<NodeMetadata> filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reboot the node.
|
* reboot the node, given its handle.
|
||||||
*/
|
*/
|
||||||
void rebootNode(Location location, String id);
|
void rebootNode(String handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nodes matching the filter are treated as a logical set. Using this command, you can save time
|
* nodes matching the filter are treated as a logical set. Using this command, you can save time
|
||||||
|
@ -171,9 +172,9 @@ public interface ComputeService {
|
||||||
void rebootNodesMatching(Predicate<NodeMetadata> filter);
|
void rebootNodesMatching(Predicate<NodeMetadata> filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a node by its id
|
* Find a node by its handle.
|
||||||
*/
|
*/
|
||||||
NodeMetadata getNodeMetadata(Location location, String id);
|
NodeMetadata getNodeMetadata(String handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all nodes including details such as image and ip addresses even if it incurs extra
|
* get all nodes including details such as image and ip addresses even if it incurs extra
|
||||||
|
@ -213,33 +214,31 @@ public interface ComputeService {
|
||||||
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(
|
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(
|
||||||
Predicate<NodeMetadata> filter, byte[] runScript, RunScriptOptions options)
|
Predicate<NodeMetadata> filter, byte[] runScript, RunScriptOptions options)
|
||||||
throws RunScriptOnNodesException;
|
throws RunScriptOnNodesException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param loadBalancerName
|
* @param filter
|
||||||
* Load balancer name
|
* Predicate-based filter to define which nodes to loadbalance
|
||||||
* @param protocol
|
* @param loadBalancerName
|
||||||
* LoadBalancer transport protocol to use for routing - TCP or
|
* Load balancer name
|
||||||
* HTTP. This property cannot be modified for the life of the
|
* @param protocol
|
||||||
* LoadBalancer.
|
* LoadBalancer transport protocol to use for routing - TCP or HTTP. This property
|
||||||
* @param loadBalancerPort
|
* cannot be modified for the life of the LoadBalancer.
|
||||||
* The external TCP port of the LoadBalancer. Valid LoadBalancer
|
* @param loadBalancerPort
|
||||||
* ports are - 80, 443 and 1024 through 65535. This property
|
* The external TCP port of the LoadBalancer. Valid LoadBalancer ports are - 80, 443
|
||||||
* cannot be modified for the life of the LoadBalancer.
|
* and 1024 through 65535. This property cannot be modified for the life of the
|
||||||
* @param instancePort
|
* LoadBalancer.
|
||||||
* The InstancePort data type is simple type of type: integer. It
|
* @param instancePort
|
||||||
* is the TCP port on which the server on the instance is
|
* The InstancePort data type is simple type of type: integer. It is the TCP port on
|
||||||
* listening. Valid instance ports are one (1) through 65535.
|
* which the server on the instance is listening. Valid instance ports are one (1)
|
||||||
* This property cannot be modified for the life of the
|
* through 65535. This property cannot be modified for the life of the LoadBalancer.
|
||||||
* LoadBalancer.
|
*
|
||||||
* @param filter
|
* @return DNS Name of the load balancer
|
||||||
* Predicate-based filter to define on which nodes the script is
|
*/
|
||||||
* to be executed
|
@Beta
|
||||||
* @return DNS Name of the load balancer
|
String loadBalanceNodesMatching(Predicate<NodeMetadata> filter, String loadBalancerName,
|
||||||
*/
|
String protocol, int loadBalancerPort, int instancePort);
|
||||||
String loadBalanceNodesMatching(String loadBalancerName, String protocol,
|
|
||||||
Integer loadBalancerPort, Integer instancePort,
|
@Beta
|
||||||
Predicate<NodeMetadata> filter);
|
void deleteLoadBalancer(String loadBalancerName, Predicate<NodeMetadata> filter);
|
||||||
|
|
||||||
void deleteLoadBalancer(String loadBalancerName, Predicate<NodeMetadata> filter);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,12 @@ public interface ComputeMetadata extends ResourceMetadata<ComputeType> {
|
||||||
@Override
|
@Override
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A means to uniquely address this resource within a provider. For example, if the namespace of
|
||||||
|
* a node or image is region based, the handle will likely include both the region and the id
|
||||||
|
* encoded to avoid collisions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getHandle();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain.internal;
|
package org.jclouds.compute.domain.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -35,10 +37,20 @@ public class ComputeMetadataImpl extends ResourceMetadataImpl<ComputeType> imple
|
||||||
|
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 7374704415964898694L;
|
private static final long serialVersionUID = 7374704415964898694L;
|
||||||
|
private final String handle;
|
||||||
|
|
||||||
public ComputeMetadataImpl(ComputeType type, String id, String name, Location location, URI uri,
|
public ComputeMetadataImpl(ComputeType type, String id, String name, String handle,
|
||||||
Map<String, String> userMetadata) {
|
Location location, URI uri, Map<String, String> userMetadata) {
|
||||||
super(type, id, name, location, uri, userMetadata);
|
super(type, id, name, location, uri, userMetadata);
|
||||||
|
this.handle = checkNotNull(handle, "handle");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getHandle() {
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,12 +52,11 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
private final Architecture architecture;
|
private final Architecture architecture;
|
||||||
private final Credentials defaultCredentials;
|
private final Credentials defaultCredentials;
|
||||||
|
|
||||||
|
public ImageImpl(String id, String name, String handle, Location location, URI uri,
|
||||||
public ImageImpl(String id, String name, Location location, URI uri,
|
|
||||||
Map<String, String> userMetadata, String description, String version,
|
Map<String, String> userMetadata, String description, String version,
|
||||||
@Nullable OsFamily osFamily, String osDescription, Architecture architecture,
|
@Nullable OsFamily osFamily, String osDescription, Architecture architecture,
|
||||||
Credentials defaultCredentials) {
|
Credentials defaultCredentials) {
|
||||||
super(ComputeType.IMAGE, id, name, location, uri, userMetadata);
|
super(ComputeType.IMAGE, id, name, handle, location, uri, userMetadata);
|
||||||
this.version = checkNotNull(version, "version");
|
this.version = checkNotNull(version, "version");
|
||||||
this.osFamily = osFamily;
|
this.osFamily = osFamily;
|
||||||
this.description = checkNotNull(description, "description");
|
this.description = checkNotNull(description, "description");
|
||||||
|
@ -107,14 +106,14 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Credentials getDefaultCredentials() {
|
public Credentials getDefaultCredentials() {
|
||||||
return defaultCredentials;
|
return defaultCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", name=" + getName() + ", locationId=" + getLocation()
|
return "[id=" + getId() + ", name=" + getName() + ", locationId=" + getLocation()
|
||||||
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
||||||
|
|
|
@ -54,12 +54,12 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
private final String tag;
|
private final String tag;
|
||||||
private final Image image;
|
private final Image image;
|
||||||
|
|
||||||
public NodeMetadataImpl(String id, String name, Location location, URI uri,
|
public NodeMetadataImpl(String id, String name, String handle, Location location, URI uri,
|
||||||
Map<String, String> userMetadata, @Nullable String tag, @Nullable Image image,
|
Map<String, String> userMetadata, @Nullable String tag, @Nullable Image image,
|
||||||
NodeState state, Iterable<InetAddress> publicAddresses,
|
NodeState state, Iterable<InetAddress> publicAddresses,
|
||||||
Iterable<InetAddress> privateAddresses, Map<String, String> extra,
|
Iterable<InetAddress> privateAddresses, Map<String, String> extra,
|
||||||
@Nullable Credentials credentials) {
|
@Nullable Credentials credentials) {
|
||||||
super(ComputeType.NODE, id, name, location, uri, userMetadata);
|
super(ComputeType.NODE, id, name, handle, location, uri, userMetadata);
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.image = image;
|
this.image = image;
|
||||||
this.state = checkNotNull(state, "state");
|
this.state = checkNotNull(state, "state");
|
||||||
|
|
|
@ -48,10 +48,10 @@ public class SizeImpl extends ComputeMetadataImpl implements Size {
|
||||||
|
|
||||||
private final Set<Architecture> supportedArchitectures = Sets.newHashSet();
|
private final Set<Architecture> supportedArchitectures = Sets.newHashSet();
|
||||||
|
|
||||||
public SizeImpl(String id, String name, @Nullable Location location, URI uri,
|
public SizeImpl(String id, String name, String handle, @Nullable Location location, URI uri,
|
||||||
Map<String, String> userMetadata, double cores, int ram, int disk,
|
Map<String, String> userMetadata, double cores, int ram, int disk,
|
||||||
Iterable<Architecture> supportedArchitectures) {
|
Iterable<Architecture> supportedArchitectures) {
|
||||||
super(ComputeType.SIZE, id, name, location, uri, userMetadata);
|
super(ComputeType.SIZE, id, name, handle, location, uri, userMetadata);
|
||||||
this.cores = cores;
|
this.cores = cores;
|
||||||
this.ram = ram;
|
this.ram = ram;
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
|
|
|
@ -58,7 +58,6 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
import org.jclouds.compute.strategy.LoadBalancerStrategy;
|
|
||||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||||
import org.jclouds.compute.util.ComputeUtils;
|
import org.jclouds.compute.util.ComputeUtils;
|
||||||
|
@ -96,7 +95,6 @@ public class BaseComputeService implements ComputeService {
|
||||||
protected final RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy;
|
protected final RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy;
|
||||||
protected final RebootNodeStrategy rebootNodeStrategy;
|
protected final RebootNodeStrategy rebootNodeStrategy;
|
||||||
protected final DestroyNodeStrategy destroyNodeStrategy;
|
protected final DestroyNodeStrategy destroyNodeStrategy;
|
||||||
protected final LoadBalancerStrategy loadBalancerStrategy;
|
|
||||||
protected final Provider<TemplateBuilder> templateBuilderProvider;
|
protected final Provider<TemplateBuilder> templateBuilderProvider;
|
||||||
protected final Provider<TemplateOptions> templateOptionsProvider;
|
protected final Provider<TemplateOptions> templateOptionsProvider;
|
||||||
protected final ComputeUtils utils;
|
protected final ComputeUtils utils;
|
||||||
|
@ -109,7 +107,7 @@ public class BaseComputeService implements ComputeService {
|
||||||
GetNodeMetadataStrategy getNodeMetadataStrategy,
|
GetNodeMetadataStrategy getNodeMetadataStrategy,
|
||||||
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
|
||||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
||||||
LoadBalancerStrategy loadBalancerStrategy, Provider<TemplateBuilder> templateBuilderProvider,
|
Provider<TemplateBuilder> templateBuilderProvider,
|
||||||
Provider<TemplateOptions> templateOptionsProvider, ComputeUtils utils,
|
Provider<TemplateOptions> templateOptionsProvider, ComputeUtils utils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
this.context = checkNotNull(context, "context");
|
this.context = checkNotNull(context, "context");
|
||||||
|
@ -123,7 +121,6 @@ public class BaseComputeService implements ComputeService {
|
||||||
"runNodesAndAddToSetStrategy");
|
"runNodesAndAddToSetStrategy");
|
||||||
this.rebootNodeStrategy = checkNotNull(rebootNodeStrategy, "rebootNodeStrategy");
|
this.rebootNodeStrategy = checkNotNull(rebootNodeStrategy, "rebootNodeStrategy");
|
||||||
this.destroyNodeStrategy = checkNotNull(destroyNodeStrategy, "destroyNodeStrategy");
|
this.destroyNodeStrategy = checkNotNull(destroyNodeStrategy, "destroyNodeStrategy");
|
||||||
this.loadBalancerStrategy = checkNotNull(loadBalancerStrategy, "loadBalancerStrategy");
|
|
||||||
this.templateBuilderProvider = checkNotNull(templateBuilderProvider,
|
this.templateBuilderProvider = checkNotNull(templateBuilderProvider,
|
||||||
"templateBuilderProvider");
|
"templateBuilderProvider");
|
||||||
this.templateOptionsProvider = checkNotNull(templateOptionsProvider,
|
this.templateOptionsProvider = checkNotNull(templateOptionsProvider,
|
||||||
|
@ -151,8 +148,8 @@ public class BaseComputeService implements ComputeService {
|
||||||
logger.debug(">> running %d node%s tag(%s) location(%s) image(%s) size(%s) options(%s)",
|
logger.debug(">> running %d node%s tag(%s) location(%s) image(%s) size(%s) options(%s)",
|
||||||
count, count > 1 ? "s" : "", tag, template.getLocation().getId(), template
|
count, count > 1 ? "s" : "", tag, template.getLocation().getId(), template
|
||||||
.getImage().getId(), template.getSize().getId(), template.getOptions());
|
.getImage().getId(), template.getSize().getId(), template.getOptions());
|
||||||
final Set<NodeMetadata> nodes = Sets.newHashSet();
|
Set<NodeMetadata> nodes = Sets.newHashSet();
|
||||||
final Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
||||||
Map<?, ListenableFuture<Void>> responses = runNodesAndAddToSetStrategy.execute(tag, count,
|
Map<?, ListenableFuture<Void>> responses = runNodesAndAddToSetStrategy.execute(tag, count,
|
||||||
template, nodes, badNodes);
|
template, nodes, badNodes);
|
||||||
Map<?, Exception> executionExceptions = awaitCompletion(responses, executor, null, logger,
|
Map<?, Exception> executionExceptions = awaitCompletion(responses, executor, null, logger,
|
||||||
|
@ -185,12 +182,11 @@ public class BaseComputeService implements ComputeService {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void destroyNode(Location location, String id) {
|
public void destroyNode(String handle) {
|
||||||
checkNotNull(location, "location");
|
checkNotNull(handle, "handle");
|
||||||
checkNotNull(id, "id");
|
logger.debug(">> destroying node(%s)", handle);
|
||||||
logger.debug(">> destroying node(%s/%s)", location.getId(), id);
|
boolean successful = destroyNodeStrategy.execute(handle);
|
||||||
boolean successful = destroyNodeStrategy.execute(location, id);
|
logger.debug("<< destroyed node(%s) success(%s)", handle, successful);
|
||||||
logger.debug("<< destroyed node(%s/%s) success(%s)", location.getId(), id, successful);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,7 +201,7 @@ public class BaseComputeService implements ComputeService {
|
||||||
responses.put(node, makeListenable(executor.submit(new Callable<Void>() {
|
responses.put(node, makeListenable(executor.submit(new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
destroyNode(node.getLocation(), node.getId());
|
destroyNode(node.getHandle());
|
||||||
destroyedNodes.add(node);
|
destroyedNodes.add(node);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -282,22 +278,20 @@ public class BaseComputeService implements ComputeService {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata getNodeMetadata(Location location, String id) {
|
public NodeMetadata getNodeMetadata(String handle) {
|
||||||
checkNotNull(location, "location");
|
checkNotNull(handle, "handle");
|
||||||
checkNotNull(id, "id");
|
return getNodeMetadataStrategy.execute(handle);
|
||||||
return getNodeMetadataStrategy.execute(location, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void rebootNode(Location location, String id) {
|
public void rebootNode(String handle) {
|
||||||
checkNotNull(location, "location");
|
checkNotNull(handle, "handle");
|
||||||
checkNotNull(id, "id");
|
logger.debug(">> rebooting node(%s)", handle);
|
||||||
logger.debug(">> rebooting node(%s/%s)", location.getId(), id);
|
boolean successful = rebootNodeStrategy.execute(handle);
|
||||||
boolean successful = rebootNodeStrategy.execute(location, id);
|
logger.debug("<< rebooted node(%s) success(%s)", handle, successful);
|
||||||
logger.debug("<< rebooted node(%s/%s) success(%s)", location.getId(), id, successful);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,7 +306,7 @@ public class BaseComputeService implements ComputeService {
|
||||||
responses.put(node, makeListenable(executor.submit(new Callable<Void>() {
|
responses.put(node, makeListenable(executor.submit(new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
rebootNode(node.getLocation(), node.getId());
|
rebootNode(node.getHandle());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}), executor));
|
}), executor));
|
||||||
|
@ -383,12 +377,8 @@ public class BaseComputeService implements ComputeService {
|
||||||
return execs;
|
return execs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Iterable<? extends NodeMetadata> verifyParametersAndListNodes(
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
private Iterable<? extends NodeMetadata> verifyParametersAndListNodes(
|
|
||||||
Predicate<NodeMetadata> filter, byte[] runScript, final RunScriptOptions options) {
|
Predicate<NodeMetadata> filter, byte[] runScript, final RunScriptOptions options) {
|
||||||
checkNotNull(filter, "Filter must be provided");
|
checkNotNull(filter, "Filter must be provided");
|
||||||
checkNotNull(runScript,
|
checkNotNull(runScript,
|
||||||
|
@ -423,28 +413,6 @@ public class BaseComputeService implements ComputeService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String loadBalanceNodesMatching(String loadBalancerName,
|
|
||||||
String protocol, Integer loadBalancerPort, Integer instancePort,
|
|
||||||
Predicate<NodeMetadata> filter)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void deleteLoadBalancer(String loadBalancerName,
|
|
||||||
Predicate<NodeMetadata> filter)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Iterable<? extends NodeMetadata> detailsOnAllNodes() {
|
private Iterable<? extends NodeMetadata> detailsOnAllNodes() {
|
||||||
return listNodesStrategy.listDetailsOnNodesMatching(NodePredicates.all());
|
return listNodesStrategy.listDetailsOnNodesMatching(NodePredicates.all());
|
||||||
}
|
}
|
||||||
|
@ -453,4 +421,16 @@ public class BaseComputeService implements ComputeService {
|
||||||
public TemplateOptions templateOptions() {
|
public TemplateOptions templateOptions() {
|
||||||
return templateOptionsProvider.get();
|
return templateOptionsProvider.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteLoadBalancer(String loadBalancerName, Predicate<NodeMetadata> filter) {
|
||||||
|
throw new UnsupportedOperationException("deleteLoadBalancer not supported in this cloud");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String loadBalanceNodesMatching(Predicate<NodeMetadata> filter, String loadBalancerName,
|
||||||
|
String protocol, int loadBalancerPort, int instancePort) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"loadBalanceNodesMatching not supported in this cloud");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.compute.strategy;
|
package org.jclouds.compute.strategy;
|
||||||
|
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* terminates the node and blocks until it is no longer visible or in the state TERMINATED. If this
|
* terminates the node and blocks until it is no longer visible or in the state TERMINATED. If this
|
||||||
|
@ -29,6 +28,6 @@ import org.jclouds.domain.Location;
|
||||||
*/
|
*/
|
||||||
public interface DestroyNodeStrategy {
|
public interface DestroyNodeStrategy {
|
||||||
|
|
||||||
boolean execute(Location location, String id);
|
boolean execute(String handle);
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,7 +20,6 @@
|
||||||
package org.jclouds.compute.strategy;
|
package org.jclouds.compute.strategy;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns all details associated to the node below.
|
* returns all details associated to the node below.
|
||||||
|
@ -29,6 +28,6 @@ import org.jclouds.domain.Location;
|
||||||
*/
|
*/
|
||||||
public interface GetNodeMetadataStrategy {
|
public interface GetNodeMetadataStrategy {
|
||||||
|
|
||||||
NodeMetadata execute(Location location, String id);
|
NodeMetadata execute(String handle);
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,11 +28,9 @@ import org.jclouds.domain.Location;
|
||||||
*
|
*
|
||||||
* @author Lili Nader
|
* @author Lili Nader
|
||||||
*/
|
*/
|
||||||
public interface LoadBalancerStrategy
|
public interface LoadBalancerStrategy {
|
||||||
{
|
|
||||||
|
|
||||||
String execute(Location loaction, String name, String protocol,
|
String execute(Location loaction, String name, String protocol, int loadBalancerPort,
|
||||||
Integer loadBalancerPort, Integer instancePort,
|
int instancePort, Set<String> instanceIds);
|
||||||
Set<String> instanceIds);
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.compute.strategy;
|
package org.jclouds.compute.strategy;
|
||||||
|
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reboots a node unless it is in the state TERMINATED.
|
* Reboots a node unless it is in the state TERMINATED.
|
||||||
|
@ -28,6 +27,6 @@ import org.jclouds.domain.Location;
|
||||||
*/
|
*/
|
||||||
public interface RebootNodeStrategy {
|
public interface RebootNodeStrategy {
|
||||||
|
|
||||||
boolean execute(Location location, String id);
|
boolean execute(String handle);
|
||||||
|
|
||||||
}
|
}
|
|
@ -465,10 +465,10 @@ public class ComputeUtils {
|
||||||
* returns a new instance of {@link NodeMetadata} that has new credentials
|
* returns a new instance of {@link NodeMetadata} that has new credentials
|
||||||
*/
|
*/
|
||||||
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
|
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
|
||||||
return new NodeMetadataImpl(node.getId(), node.getName(), node.getLocation(), node.getUri(),
|
return new NodeMetadataImpl(node.getId(), node.getName(), node.getHandle(), node
|
||||||
node.getUserMetadata(), node.getTag(), node.getImage(), node.getState(), node
|
.getLocation(), node.getUri(), node.getUserMetadata(), node.getTag(), node
|
||||||
.getPublicAddresses(), node.getPrivateAddresses(), node.getExtra(),
|
.getImage(), node.getState(), node.getPublicAddresses(), node.getPrivateAddresses(),
|
||||||
newCredentials);
|
node.getExtra(), newCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -324,7 +324,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
.withTag(tag), Predicates.not(NodePredicates.TERMINATED))));
|
.withTag(tag), Predicates.not(NodePredicates.TERMINATED))));
|
||||||
for (NodeMetadata node : nodes) {
|
for (NodeMetadata node : nodes) {
|
||||||
metadataSet.remove(node);
|
metadataSet.remove(node);
|
||||||
NodeMetadata metadata = client.getNodeMetadata(node.getLocation(), node.getId());
|
NodeMetadata metadata = client.getNodeMetadata(node.getHandle());
|
||||||
assertEquals(metadata.getId(), node.getId());
|
assertEquals(metadata.getId(), node.getId());
|
||||||
assertEquals(metadata.getTag(), node.getTag());
|
assertEquals(metadata.getTag(), node.getTag());
|
||||||
assertLocationSameOrChild(metadata.getLocation(), template.getLocation());
|
assertLocationSameOrChild(metadata.getLocation(), template.getLocation());
|
||||||
|
|
|
@ -138,9 +138,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
||||||
new Long(id)));
|
new Long(handle)));
|
||||||
client.getServerServices().power(server.getName(), PowerCommand.RESTART);
|
client.getServerServices().power(server.getName(), PowerCommand.RESTART);
|
||||||
serverLatestJobCompleted.apply(server);
|
serverLatestJobCompleted.apply(server);
|
||||||
client.getServerServices().power(server.getName(), PowerCommand.START);
|
client.getServerServices().power(server.getName(), PowerCommand.START);
|
||||||
|
@ -186,9 +186,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(Location location, String id) {
|
public NodeMetadata execute(String handle) {
|
||||||
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
||||||
new Long(checkNotNull(id, "id"))));
|
new Long(checkNotNull(handle, "handle"))));
|
||||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,9 +206,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
||||||
new Long(id)));
|
new Long(handle)));
|
||||||
client.getServerServices().deleteByName(server.getName());
|
client.getServerServices().deleteByName(server.getName());
|
||||||
return serverLatestJobCompleted.apply(server);
|
return serverLatestJobCompleted.apply(server);
|
||||||
}
|
}
|
||||||
|
@ -329,16 +329,22 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
final Set<Size> sizes = Sets.newHashSet();
|
final Set<Size> sizes = Sets.newHashSet();
|
||||||
holder.logger.debug(">> providing sizes");
|
holder.logger.debug(">> providing sizes");
|
||||||
|
|
||||||
sizes.add(new SizeImpl("1", "1", null, null, ImmutableMap.<String, String> of(), 0.5, 512,
|
sizes.add(new SizeImpl("1", "1", "1", null, null, ImmutableMap.<String, String> of(), 0.5,
|
||||||
30, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
512, 30, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
sizes.add(new SizeImpl("2", "2", null, null, ImmutableMap.<String, String> of(), 1, 1024, 60,
|
sizes.add(new SizeImpl("2", "2", "2", null, null, ImmutableMap.<String, String> of(), 1,
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
1024, 60, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
sizes.add(new SizeImpl("3", "3", null, null, ImmutableMap.<String, String> of(), 2, 2048,
|
sizes
|
||||||
120, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
.add(new SizeImpl("3", "3", "3", null, null, ImmutableMap.<String, String> of(), 2,
|
||||||
sizes.add(new SizeImpl("4", "4", null, null, ImmutableMap.<String, String> of(), 4, 4096,
|
2048, 120, ImmutableSet.<Architecture> of(Architecture.X86_32,
|
||||||
240, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
Architecture.X86_64)));
|
||||||
sizes.add(new SizeImpl("5", "5", null, null, ImmutableMap.<String, String> of(), 8, 8192,
|
sizes
|
||||||
480, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
.add(new SizeImpl("4", "4", "4", null, null, ImmutableMap.<String, String> of(), 4,
|
||||||
|
4096, 240, ImmutableSet.<Architecture> of(Architecture.X86_32,
|
||||||
|
Architecture.X86_64)));
|
||||||
|
sizes
|
||||||
|
.add(new SizeImpl("5", "5", "5", null, null, ImmutableMap.<String, String> of(), 8,
|
||||||
|
8192, 480, ImmutableSet.<Architecture> of(Architecture.X86_32,
|
||||||
|
Architecture.X86_64)));
|
||||||
holder.logger.debug("<< sizes(%d)", sizes.size());
|
holder.logger.debug("<< sizes(%d)", sizes.size());
|
||||||
return sizes;
|
return sizes;
|
||||||
}
|
}
|
||||||
|
@ -377,9 +383,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
||||||
}
|
}
|
||||||
Credentials defaultCredentials = authenticator.execute(from);
|
Credentials defaultCredentials = authenticator.execute(from);
|
||||||
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location, null,
|
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), from.getId() + "",
|
||||||
ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
location, null, ImmutableMap.<String, String> of(), from.getDescription(),
|
||||||
osDescription, arch, defaultCredentials));
|
version, os, osDescription, arch, defaultCredentials));
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< images(%d)", images.size());
|
holder.logger.debug("<< images(%d)", images.size());
|
||||||
return images;
|
return images;
|
||||||
|
|
|
@ -103,8 +103,8 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
.warn("could not find a matching image for server %s in location %s", from,
|
.warn("could not find a matching image for server %s in location %s", from,
|
||||||
location);
|
location);
|
||||||
}
|
}
|
||||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), location, null, ImmutableMap
|
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", location,
|
||||||
.<String, String> of(), tag, image, state, ipSet, ImmutableList.<InetAddress> of(),
|
null, ImmutableMap.<String, String> of(), tag, image, state, ipSet, ImmutableList
|
||||||
ImmutableMap.<String, String> of(), creds);
|
.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -142,8 +142,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
int serverId = Integer.parseInt(id);
|
int serverId = Integer.parseInt(handle);
|
||||||
// if false server wasn't around in the first place
|
// if false server wasn't around in the first place
|
||||||
client.rebootServer(serverId, RebootType.HARD);
|
client.rebootServer(serverId, RebootType.HARD);
|
||||||
Server server = client.getServer(serverId);
|
Server server = client.getServer(serverId);
|
||||||
|
@ -165,8 +165,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
int serverId = Integer.parseInt(id);
|
int serverId = Integer.parseInt(handle);
|
||||||
// if false server wasn't around in the first place
|
// if false server wasn't around in the first place
|
||||||
if (!client.deleteServer(serverId))
|
if (!client.deleteServer(serverId))
|
||||||
return false;
|
return false;
|
||||||
|
@ -193,12 +193,13 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
Server server = client.createServer(name, Integer.parseInt(template.getImage().getId()),
|
Server server = client.createServer(name, Integer.parseInt(template.getImage().getId()),
|
||||||
Integer.parseInt(template.getSize().getId()));
|
Integer.parseInt(template.getSize().getId()));
|
||||||
serverActive.apply(server);
|
serverActive.apply(server);
|
||||||
return new NodeMetadataImpl(server.getId() + "", name, new LocationImpl(
|
return new NodeMetadataImpl(server.getId() + "", name, server.getId() + "",
|
||||||
LocationScope.HOST, server.getHostId(), server.getHostId(), template
|
new LocationImpl(LocationScope.HOST, server.getHostId(), server.getHostId(),
|
||||||
.getLocation()), null, server.getMetadata(), tag, template.getImage(),
|
template.getLocation()), null, server.getMetadata(), tag, template
|
||||||
NodeState.RUNNING, server.getAddresses().getPublicAddresses(), server
|
.getImage(), NodeState.RUNNING, server.getAddresses()
|
||||||
.getAddresses().getPrivateAddresses(), ImmutableMap
|
.getPublicAddresses(), server.getAddresses().getPrivateAddresses(),
|
||||||
.<String, String> of(), new Credentials("root", server.getAdminPass()));
|
ImmutableMap.<String, String> of(),
|
||||||
|
new Credentials("root", server.getAdminPass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -242,8 +243,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(Location location, String id) {
|
public NodeMetadata execute(String handle) {
|
||||||
int serverId = Integer.parseInt(id);
|
int serverId = Integer.parseInt(handle);
|
||||||
Server server = client.getServer(serverId);
|
Server server = client.getServer(serverId);
|
||||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||||
}
|
}
|
||||||
|
@ -315,9 +316,10 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
final Set<Size> sizes = Sets.newHashSet();
|
final Set<Size> sizes = Sets.newHashSet();
|
||||||
holder.logger.debug(">> providing sizes");
|
holder.logger.debug(">> providing sizes");
|
||||||
for (final Flavor from : sync.listFlavors(ListOptions.Builder.withDetails())) {
|
for (final Flavor from : sync.listFlavors(ListOptions.Builder.withDetails())) {
|
||||||
sizes.add(new SizeImpl(from.getId() + "", from.getName(), location, null, ImmutableMap
|
sizes.add(new SizeImpl(from.getId() + "", from.getName(), from.getId() + "", location,
|
||||||
.<String, String> of(), from.getDisk() / 10, from.getRam(), from.getDisk(),
|
null, ImmutableMap.<String, String> of(), from.getDisk() / 10, from.getRam(),
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
from.getDisk(), ImmutableSet.<Architecture> of(Architecture.X86_32,
|
||||||
|
Architecture.X86_64)));
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< sizes(%d)", sizes.size());
|
holder.logger.debug("<< sizes(%d)", sizes.size());
|
||||||
return sizes;
|
return sizes;
|
||||||
|
@ -357,9 +359,9 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
holder.logger.debug("<< didn't match os(%s)", matcher.group(2));
|
holder.logger.debug("<< didn't match os(%s)", matcher.group(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
images.add(new ImageImpl(from.getId() + "", from.getName(), location, null, ImmutableMap
|
images.add(new ImageImpl(from.getId() + "", from.getName(), from.getId() + "", location,
|
||||||
.<String, String> of(), from.getName(), version, os, osDescription, arch,
|
null, ImmutableMap.<String, String> of(), from.getName(), version, os,
|
||||||
new Credentials("root", null)));
|
osDescription, arch, new Credentials("root", null)));
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< images(%d)", images.size());
|
holder.logger.debug("<< images(%d)", images.size());
|
||||||
return images;
|
return images;
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
.warn("could not find a matching image for server %s in location %s", from,
|
.warn("could not find a matching image for server %s in location %s", from,
|
||||||
location);
|
location);
|
||||||
}
|
}
|
||||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), host, null,
|
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", host, null,
|
||||||
from.getMetadata(), tag, image, serverToNodeState.get(from.getStatus()), from
|
from.getMetadata(), tag, image, serverToNodeState.get(from.getStatus()), from
|
||||||
.getAddresses().getPublicAddresses(), from.getAddresses()
|
.getAddresses().getPublicAddresses(), from.getAddresses()
|
||||||
.getPrivateAddresses(), ImmutableMap.<String, String> of(), null);
|
.getPrivateAddresses(), ImmutableMap.<String, String> of(), null);
|
||||||
|
|
|
@ -140,8 +140,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
Long serverId = Long.parseLong(id);
|
Long serverId = Long.parseLong(handle);
|
||||||
// if false server wasn't around in the first place
|
// if false server wasn't around in the first place
|
||||||
return client.restartServer(serverId).getState() == RunningState.RUNNING;
|
return client.restartServer(serverId).getState() == RunningState.RUNNING;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String handle) {
|
||||||
long serverId = Long.parseLong(id);
|
Long serverId = Long.parseLong(handle);
|
||||||
client.destroyServer(serverId);
|
client.destroyServer(serverId);
|
||||||
return serverDestroyed.apply(client.getServer(serverId));
|
return serverDestroyed.apply(client.getServer(serverId));
|
||||||
}
|
}
|
||||||
|
@ -196,12 +196,12 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
Server server = client.getServer(serverResponse.getServer().getId());
|
Server server = client.getServer(serverResponse.getServer().getId());
|
||||||
// we have to lookup the new details in order to retrieve the currently assigned ip
|
// we have to lookup the new details in order to retrieve the currently assigned ip
|
||||||
// address.
|
// address.
|
||||||
NodeMetadata node = new NodeMetadataImpl(server.getId().toString(), name, template
|
NodeMetadata node = new NodeMetadataImpl(server.getId().toString(), name, server.getId()
|
||||||
.getLocation(), null, ImmutableMap.<String, String> of(), tag, template
|
.toString(), template.getLocation(), null, ImmutableMap.<String, String> of(),
|
||||||
.getImage(), runningStateToNodeState.get(server.getState()), getPublicAddresses
|
tag, template.getImage(), runningStateToNodeState.get(server.getState()),
|
||||||
.apply(server), ImmutableList.<InetAddress> of(), ImmutableMap
|
getPublicAddresses.apply(server), ImmutableList.<InetAddress> of(), ImmutableMap
|
||||||
.<String, String> of(), new Credentials("root", serverResponse
|
.<String, String> of(), new Credentials("root", serverResponse
|
||||||
.getNewInstanceRequest().getCreateOptions().getPassword()));
|
.getNewInstanceRequest().getCreateOptions().getPassword()));
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,9 +247,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(Location location, String id) {
|
public NodeMetadata execute(String handle) {
|
||||||
// TODO location
|
long serverId = Long.parseLong(handle);
|
||||||
long serverId = Long.parseLong(id);
|
|
||||||
Server server = client.getServer(serverId);
|
Server server = client.getServer(serverId);
|
||||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||||
}
|
}
|
||||||
|
@ -322,9 +321,9 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
location);
|
location);
|
||||||
}
|
}
|
||||||
NodeState state = runningStateToNodeState.get(from.getState());
|
NodeState state = runningStateToNodeState.get(from.getState());
|
||||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), location, null,
|
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "",
|
||||||
ImmutableMap.<String, String> of(), tag, image, state, getPublicAddresses
|
location, null, ImmutableMap.<String, String> of(), tag, image, state,
|
||||||
.apply(from), ImmutableList.<InetAddress> of(), ImmutableMap
|
getPublicAddresses.apply(from), ImmutableList.<InetAddress> of(), ImmutableMap
|
||||||
.<String, String> of(), creds);
|
.<String, String> of(), creds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -432,9 +431,9 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
sizes.add(new SizeImpl(from.getId(), from.getId(), location, null, ImmutableMap
|
sizes.add(new SizeImpl(from.getId(), from.getId(), from.getId(), location, null,
|
||||||
.<String, String> of(), 1, from.getRam(), from.getDiskSize(), ImmutableSet
|
ImmutableMap.<String, String> of(), 1, from.getRam(), from.getDiskSize(),
|
||||||
.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
holder.logger.warn("datacenter not present in " + from.getId());
|
holder.logger.warn("datacenter not present in " + from.getId());
|
||||||
}
|
}
|
||||||
|
@ -476,9 +475,9 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
images.add(new ImageImpl(from.getId(), from.getDescription(), null, null, ImmutableMap
|
images.add(new ImageImpl(from.getId(), from.getDescription(), from.getId(), null, null,
|
||||||
.<String, String> of(), from.getDescription(), version, os, osDescription, arch,
|
ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
||||||
new Credentials("root", null)));
|
osDescription, arch, new Credentials("root", null)));
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< images(%d)", images.size());
|
holder.logger.debug("<< images(%d)", images.size());
|
||||||
return images;
|
return images;
|
||||||
|
|
|
@ -235,7 +235,7 @@ public class ComputeTask extends Task {
|
||||||
|
|
||||||
private void logDetails(ComputeService computeService, ComputeMetadata node) {
|
private void logDetails(ComputeService computeService, ComputeMetadata node) {
|
||||||
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node)
|
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node)
|
||||||
: computeService.getNodeMetadata(node.getLocation(), node.getId());
|
: computeService.getNodeMetadata(node.getHandle());
|
||||||
log(String
|
log(String
|
||||||
.format(
|
.format(
|
||||||
" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, extra=%s",
|
" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, extra=%s",
|
||||||
|
|
|
@ -162,8 +162,8 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String id) {
|
||||||
Task task = client.resetVApp(id);
|
Task task = client.resetVApp(checkNotNull(id, "node.id"));
|
||||||
return taskTester.apply(task.getId());
|
return taskTester.apply(task.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Location location, String id) {
|
public boolean execute(String id) {
|
||||||
computeClient.stop(checkNotNull(id, "node.id"));
|
computeClient.stop(checkNotNull(id, "node.id"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -214,9 +214,9 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
|
|
||||||
protected NodeMetadata newCreateNodeResponse(String tag, Template template,
|
protected NodeMetadata newCreateNodeResponse(String tag, Template template,
|
||||||
Map<String, String> metaMap, VApp vApp) {
|
Map<String, String> metaMap, VApp vApp) {
|
||||||
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), template.getLocation(), vApp
|
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(), template
|
||||||
.getLocation(), ImmutableMap.<String, String> of(), tag, template.getImage(),
|
.getLocation(), vApp.getLocation(), ImmutableMap.<String, String> of(), tag,
|
||||||
vAppStatusToNodeState.get(vApp.getStatus()), computeClient
|
template.getImage(), vAppStatusToNodeState.get(vApp.getStatus()), computeClient
|
||||||
.getPublicAddresses(vApp.getId()), computeClient
|
.getPublicAddresses(vApp.getId()), computeClient
|
||||||
.getPrivateAddresses(vApp.getId()), ImmutableMap.<String, String> of(),
|
.getPrivateAddresses(vApp.getId()), ImmutableMap.<String, String> of(),
|
||||||
new Credentials(metaMap.get("username"), metaMap.get("password")));
|
new Credentials(metaMap.get("username"), metaMap.get("password")));
|
||||||
|
@ -255,7 +255,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc, NamedResource resource) {
|
private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc, NamedResource resource) {
|
||||||
Location location = findLocationForResourceInVDC.apply(resource, vdc.getId());
|
Location location = findLocationForResourceInVDC.apply(resource, vdc.getId());
|
||||||
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId(), resource.getName(),
|
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId(), resource.getName(),
|
||||||
location, null, ImmutableMap.<String, String> of());
|
resource.getId(), location, null, ImmutableMap.<String, String> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -279,7 +279,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (node == null && i++ < 3) {
|
while (node == null && i++ < 3) {
|
||||||
try {
|
try {
|
||||||
node = getNodeMetadataByIdInVDC(vdc.getId(), resource.getId());
|
node = getNodeMetadataByIdInVDC(resource.getId());
|
||||||
nodes.add(node);
|
nodes.add(node);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
logger.warn("vApp %s not yet present in vdc %s", resource.getId(), vdc.getId());
|
logger.warn("vApp %s not yet present in vdc %s", resource.getId(), vdc.getId());
|
||||||
|
@ -303,9 +303,8 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(Location location, String id) {
|
public NodeMetadata execute(String id) {
|
||||||
return getNodeMetadataByIdInVDC(checkNotNull(location, "location").getId(), checkNotNull(
|
return getNodeMetadataByIdInVDC(checkNotNull(id, "node.id"));
|
||||||
id, "node.id"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -366,10 +365,10 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
.getId());
|
.getId());
|
||||||
|
|
||||||
images.add(new ImageImpl(resource.getId(), template.getName(),
|
images.add(new ImageImpl(resource.getId(), template.getName(),
|
||||||
location, template.getLocation(), ImmutableMap
|
resource.getId(), location, template.getLocation(),
|
||||||
.<String, String> of(), template.getDescription(),
|
ImmutableMap.<String, String> of(), template
|
||||||
"", myOs, template.getName(), arch, new Credentials("root",
|
.getDescription(), "", myOs, template.getName(),
|
||||||
null)));
|
arch, new Credentials("root", null)));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}), executor));
|
}), executor));
|
||||||
|
@ -431,10 +430,12 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
throws InterruptedException, TimeoutException, ExecutionException {
|
throws InterruptedException, TimeoutException, ExecutionException {
|
||||||
Set<Size> sizes = Sets.newHashSet();
|
Set<Size> sizes = Sets.newHashSet();
|
||||||
for (int cpus : new int[] { 1, 2, 4 })
|
for (int cpus : new int[] { 1, 2, 4 })
|
||||||
for (int ram : new int[] { 512, 1024, 2048, 4096, 8192, 16384 })
|
for (int ram : new int[] { 512, 1024, 2048, 4096, 8192, 16384 }) {
|
||||||
sizes.add(new SizeImpl(String.format("cpu=%d,ram=%s,disk=%d", cpus, ram, 10), null,
|
String id = String.format("cpu=%d,ram=%s,disk=%d", cpus, ram, 10);
|
||||||
null, null, ImmutableMap.<String, String> of(), cpus, ram, 10, ImmutableSet
|
sizes.add(new SizeImpl(id, null, id, null, null, ImmutableMap.<String, String> of(),
|
||||||
.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
cpus, ram, 10, ImmutableSet.<Architecture> of(Architecture.X86_32,
|
||||||
|
Architecture.X86_64)));
|
||||||
|
}
|
||||||
return sizes;
|
return sizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VCloudGetNodeMetadata {
|
public class VCloudGetNodeMetadata {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
@ -86,15 +86,15 @@ public class VCloudGetNodeMetadata {
|
||||||
this.computeClient = checkNotNull(computeClient, "computeClient");
|
this.computeClient = checkNotNull(computeClient, "computeClient");
|
||||||
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NodeMetadata getNodeMetadataByIdInVDC(String vDCId, String id) {
|
protected NodeMetadata getNodeMetadataByIdInVDC(String id) {
|
||||||
VApp vApp = client.getVApp(id);
|
VApp vApp = client.getVApp(id);
|
||||||
|
|
||||||
String tag = null;
|
String tag = null;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
Matcher matcher = TAG_PATTERN_WITH_TEMPLATE.matcher(vApp.getName());
|
Matcher matcher = TAG_PATTERN_WITH_TEMPLATE.matcher(vApp.getName());
|
||||||
|
|
||||||
final Location location = findLocationForResourceInVDC.apply(vApp, vDCId);
|
final Location location = findLocationForResourceInVDC.apply(vApp, vApp.getVDC().getId());
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
tag = matcher.group(1);
|
tag = matcher.group(1);
|
||||||
String templateIdInHexWithoutLeadingZeros = matcher.group(2).replaceAll("^[0]+", "");
|
String templateIdInHexWithoutLeadingZeros = matcher.group(2).replaceAll("^[0]+", "");
|
||||||
|
@ -121,9 +121,9 @@ public class VCloudGetNodeMetadata {
|
||||||
tag = "NOTAG-" + vApp.getName();
|
tag = "NOTAG-" + vApp.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), location, vApp.getLocation(),
|
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(), location, vApp
|
||||||
ImmutableMap.<String, String> of(), tag, image, vAppStatusToNodeState.get(vApp
|
.getLocation(), ImmutableMap.<String, String> of(), tag, image,
|
||||||
.getStatus()), computeClient.getPublicAddresses(id), computeClient
|
vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(id),
|
||||||
.getPrivateAddresses(id), getExtra.apply(vApp), null);
|
computeClient.getPrivateAddresses(id), getExtra.apply(vApp), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,7 +48,7 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assert node.getId() != null;
|
assert node.getId() != null;
|
||||||
assert node.getLocation() != null;
|
assert node.getLocation() != null;
|
||||||
assertEquals(node.getType(), ComputeType.NODE);
|
assertEquals(node.getType(), ComputeType.NODE);
|
||||||
NodeMetadata allData = client.getNodeMetadata(node.getLocation(), node.getId());
|
NodeMetadata allData = client.getNodeMetadata(node.getHandle());
|
||||||
assert allData.getExtra().get("processor/count") != null;
|
assert allData.getExtra().get("processor/count") != null;
|
||||||
assert allData.getExtra().get("disk_drive/1/kb") != null;
|
assert allData.getExtra().get("disk_drive/1/kb") != null;
|
||||||
assert allData.getExtra().get("memory/mb") != null;
|
assert allData.getExtra().get("memory/mb") != null;
|
||||||
|
|
|
@ -101,9 +101,9 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
||||||
private static class ComputeOptionsToSize implements Function<ComputeOptions, Size> {
|
private static class ComputeOptionsToSize implements Function<ComputeOptions, Size> {
|
||||||
@Override
|
@Override
|
||||||
public Size apply(ComputeOptions from) {
|
public Size apply(ComputeOptions from) {
|
||||||
return new SizeImpl(from.toString(), from.toString(), null, null, ImmutableMap
|
return new SizeImpl(from.toString(), from.toString(), from.toString(), null, null,
|
||||||
.<String, String> of(), from.getProcessorCount(), from.getMemory(), 10,
|
ImmutableMap.<String, String> of(), from.getProcessorCount(), from.getMemory(),
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64));
|
10, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
||||||
.getId());
|
.getId());
|
||||||
|
|
||||||
images.add(new ImageImpl(resource.getId(), template.getName(),
|
images.add(new ImageImpl(resource.getId(), template.getName(),
|
||||||
location, template.getLocation(), ImmutableMap
|
resource.getId(), location, template.getLocation(),
|
||||||
.<String, String> of(), template.getDescription(),
|
ImmutableMap.<String, String> of(), template
|
||||||
"", myOs, template.getName(), arch, credentialsProvider
|
.getDescription(), "", myOs, template.getName(),
|
||||||
.execute(template)));
|
arch, credentialsProvider.execute(template)));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}), executor));
|
}), executor));
|
||||||
|
|
Loading…
Reference in New Issue