mirror of https://github.com/apache/jclouds.git
Issue 204: add template description, Issue 162: update to correct image and location details
This commit is contained in:
parent
b36d68417c
commit
79c54e9f45
|
@ -40,6 +40,11 @@ public interface Image extends ComputeMetadata {
|
||||||
*/
|
*/
|
||||||
String getVersion();
|
String getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the image.
|
||||||
|
*/
|
||||||
|
String getDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operating System
|
* Operating System
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -98,15 +98,20 @@ public interface TemplateBuilder {
|
||||||
*/
|
*/
|
||||||
TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
|
TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure this template to have an image name that matches the regular expression
|
||||||
|
*/
|
||||||
|
TemplateBuilder imageNameMatches(String imageNameRegex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to have an image version that matches the regular expression
|
* Configure this template to have an image version that matches the regular expression
|
||||||
*/
|
*/
|
||||||
TemplateBuilder imageVersionMatches(String imageVersionRegex);
|
TemplateBuilder imageVersionMatches(String imageVersionRegex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to have a description that matches the regular expression
|
* Configure this template to have an image description that matches the regular expression
|
||||||
*/
|
*/
|
||||||
TemplateBuilder imageDescriptionMatches(String descriptionRegex);
|
TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to require the minimum cores below
|
* Configure this template to require the minimum cores below
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
private static final long serialVersionUID = 7856744554191025307L;
|
private static final long serialVersionUID = 7856744554191025307L;
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
private final String description;
|
||||||
private final OsFamily osFamily;
|
private final OsFamily osFamily;
|
||||||
private final String osDescription;
|
private final String osDescription;
|
||||||
private final Architecture architecture;
|
private final Architecture architecture;
|
||||||
|
@ -54,6 +55,7 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
super(ComputeType.IMAGE, id, name, locationId, uri, userMetadata);
|
super(ComputeType.IMAGE, id, name, locationId, uri, userMetadata);
|
||||||
this.version = checkNotNull(version, "version");
|
this.version = checkNotNull(version, "version");
|
||||||
this.osFamily = osFamily;
|
this.osFamily = osFamily;
|
||||||
|
this.description = checkNotNull(description, "description");
|
||||||
this.osDescription = checkNotNull(osDescription, "osDescription");
|
this.osDescription = checkNotNull(osDescription, "osDescription");
|
||||||
this.architecture = checkNotNull(architecture, "architecture");
|
this.architecture = checkNotNull(architecture, "architecture");
|
||||||
}
|
}
|
||||||
|
@ -66,6 +68,14 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -93,8 +103,9 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", name=" + getName() + ", locationId=" + getLocationId()
|
return "[id=" + getId() + ", name=" + getName() + ", locationId=" + getLocationId()
|
||||||
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
+ ", architecture=" + architecture + ", description=" + description
|
||||||
+ ", osFamily=" + osFamily + ", version=" + version + "]";
|
+ ", osDescription=" + osDescription + ", osFamily=" + osFamily + ", version="
|
||||||
|
+ version + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,6 +113,7 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
|
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + ((osDescription == null) ? 0 : osDescription.hashCode());
|
result = prime * result + ((osDescription == null) ? 0 : osDescription.hashCode());
|
||||||
result = prime * result + ((osFamily == null) ? 0 : osFamily.hashCode());
|
result = prime * result + ((osFamily == null) ? 0 : osFamily.hashCode());
|
||||||
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
||||||
|
@ -122,6 +134,11 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
return false;
|
return false;
|
||||||
} else if (!architecture.equals(other.architecture))
|
} else if (!architecture.equals(other.architecture))
|
||||||
return false;
|
return false;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
if (osDescription == null) {
|
if (osDescription == null) {
|
||||||
if (other.osDescription != null)
|
if (other.osDescription != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
private String osDescription;
|
private String osDescription;
|
||||||
private String imageVersion;
|
private String imageVersion;
|
||||||
private String imageName;
|
private String imageName;
|
||||||
|
private String imageDescription;
|
||||||
|
|
||||||
private double minCores;
|
private double minCores;
|
||||||
private int minRam;
|
private int minRam;
|
||||||
|
@ -127,8 +128,11 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
if (input.getOsDescription() == null)
|
if (input.getOsDescription() == null)
|
||||||
returnVal = false;
|
returnVal = false;
|
||||||
else
|
else
|
||||||
returnVal = input.getOsDescription().contains(osDescription) ||
|
returnVal = input.getOsDescription().contains(osDescription)
|
||||||
input.getOsDescription().matches(osDescription); /*note: matches() expects a regex!*/
|
|| input.getOsDescription().matches(osDescription); /*
|
||||||
|
* note: matches()
|
||||||
|
* expects a regex!
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +163,19 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private final Predicate<Image> imageDescriptionPredicate = new Predicate<Image>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Image input) {
|
||||||
|
boolean returnVal = true;
|
||||||
|
if (imageDescription != null) {
|
||||||
|
if (input.getName() == null)
|
||||||
|
returnVal = false;
|
||||||
|
else
|
||||||
|
returnVal = input.getName().matches(imageDescription);
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
};
|
||||||
private final Predicate<Size> sizeIdPredicate = new Predicate<Size>() {
|
private final Predicate<Size> sizeIdPredicate = new Predicate<Size>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Size input) {
|
public boolean apply(Size input) {
|
||||||
|
@ -177,7 +193,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
|
|
||||||
private final Predicate<Image> imagePredicate = Predicates.and(idPredicate, locationPredicate,
|
private final Predicate<Image> imagePredicate = Predicates.and(idPredicate, locationPredicate,
|
||||||
osPredicate, imageArchPredicate, osDescriptionPredicate, imageVersionPredicate,
|
osPredicate, imageArchPredicate, osDescriptionPredicate, imageVersionPredicate,
|
||||||
imageNamePredicate);
|
imageNamePredicate, imageDescriptionPredicate);
|
||||||
|
|
||||||
private final Predicate<Size> sizeArchPredicate = new Predicate<Size>() {
|
private final Predicate<Size> sizeArchPredicate = new Predicate<Size>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -221,9 +237,10 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return ComparisonChain.start().compare(left.getName(), right.getName(),
|
return ComparisonChain.start().compare(left.getName(), right.getName(),
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getVersion(),
|
Ordering.<String> natural().nullsLast()).compare(left.getVersion(),
|
||||||
right.getVersion(), Ordering.<String> natural().nullsLast()).compare(
|
right.getVersion(), Ordering.<String> natural().nullsLast()).compare(
|
||||||
left.getOsDescription(), right.getOsDescription(),
|
left.getDescription(), right.getDescription(),
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getArchitecture(),
|
Ordering.<String> natural().nullsLast()).compare(left.getOsDescription(),
|
||||||
right.getArchitecture()).result();
|
right.getOsDescription(), Ordering.<String> natural().nullsLast()).compare(
|
||||||
|
left.getArchitecture(), right.getArchitecture()).result();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -258,6 +275,10 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
this.locationId = image.getLocationId();
|
this.locationId = image.getLocationId();
|
||||||
if (image.getOsFamily() != null)
|
if (image.getOsFamily() != null)
|
||||||
this.os = image.getOsFamily();
|
this.os = image.getOsFamily();
|
||||||
|
if (image.getName() != null)
|
||||||
|
this.imageName = image.getName();
|
||||||
|
if (image.getDescription() != null)
|
||||||
|
this.imageDescription = image.getDescription();
|
||||||
if (image.getOsDescription() != null)
|
if (image.getOsDescription() != null)
|
||||||
this.osDescription = image.getOsDescription();
|
this.osDescription = image.getOsDescription();
|
||||||
if (image.getVersion() != null)
|
if (image.getVersion() != null)
|
||||||
|
@ -365,12 +386,21 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder imageNameMatches(String nameRegex) {
|
||||||
|
this.imageName = nameRegex;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TemplateBuilder imageDescriptionMatches(String descriptionRegex) {
|
public TemplateBuilder imageDescriptionMatches(String descriptionRegex) {
|
||||||
this.imageName = descriptionRegex;
|
this.imageDescription = descriptionRegex;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,11 +460,11 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[arch=" + arch + ", biggest=" + biggest + ", fastest=" + fastest
|
return "[arch=" + arch + ", biggest=" + biggest + ", fastest=" + fastest + ", imageName="
|
||||||
+ ", imageDescription=" + imageName + ", imageId=" + imageId + ", imageVersion="
|
+ imageName + ", imageDescription=" + imageDescription + ", imageId=" + imageId
|
||||||
+ imageVersion + ", location=" + locationId + ", minCores=" + minCores + ", minRam="
|
+ ", imageVersion=" + imageVersion + ", location=" + locationId + ", minCores="
|
||||||
+ minRam + ", os=" + os + ", osDescription=" + osDescription + ", sizeId=" + sizeId
|
+ minCores + ", minRam=" + minRam + ", os=" + os + ", osDescription="
|
||||||
+ "]";
|
+ osDescription + ", sizeId=" + sizeId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,39 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.config;
|
package org.jclouds.gogrid.config;
|
||||||
|
|
||||||
import com.google.common.base.*;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.google.common.collect.*;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
import org.jclouds.compute.ComputeService;
|
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
|
||||||
import org.jclouds.compute.domain.*;
|
|
||||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
|
||||||
import org.jclouds.compute.strategy.*;
|
|
||||||
import org.jclouds.domain.Credentials;
|
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.domain.LocationScope;
|
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
|
||||||
import org.jclouds.gogrid.GoGridAsyncClient;
|
|
||||||
import org.jclouds.gogrid.GoGridClient;
|
|
||||||
import org.jclouds.gogrid.domain.*;
|
|
||||||
import org.jclouds.gogrid.options.GetIpListOptions;
|
|
||||||
import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
|
|
||||||
import org.jclouds.gogrid.util.GoGridUtils;
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
@ -59,10 +28,66 @@ import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
import org.jclouds.compute.domain.Architecture;
|
||||||
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.Size;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||||
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||||
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
|
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
|
import org.jclouds.gogrid.GoGridAsyncClient;
|
||||||
|
import org.jclouds.gogrid.GoGridClient;
|
||||||
|
import org.jclouds.gogrid.domain.Ip;
|
||||||
|
import org.jclouds.gogrid.domain.IpType;
|
||||||
|
import org.jclouds.gogrid.domain.PowerCommand;
|
||||||
|
import org.jclouds.gogrid.domain.Server;
|
||||||
|
import org.jclouds.gogrid.domain.ServerImage;
|
||||||
|
import org.jclouds.gogrid.options.GetIpListOptions;
|
||||||
|
import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
|
||||||
|
import org.jclouds.gogrid.util.GoGridUtils;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.ssh.SshClient;
|
||||||
|
|
||||||
|
import com.google.common.base.CharMatcher;
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
|
@ -98,17 +123,14 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected GoGridAddNodeWithTagStrategy(GoGridClient client,
|
protected GoGridAddNodeWithTagStrategy(GoGridClient client,
|
||||||
Function<Server, NodeMetadata> serverToNodeMetadata,
|
Function<Server, NodeMetadata> serverToNodeMetadata, Function<Size, String> sizeToRam) {
|
||||||
Function<Size, String> sizeToRam) {
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.serverToNodeMetadata = serverToNodeMetadata;
|
this.serverToNodeMetadata = serverToNodeMetadata;
|
||||||
this.sizeToRam = sizeToRam;
|
this.sizeToRam = sizeToRam;
|
||||||
this.serverLatestJobCompleted = new RetryablePredicate<Server>(
|
this.serverLatestJobCompleted = new RetryablePredicate<Server>(
|
||||||
new ServerLatestJobCompleted(client.getJobServices()),
|
new ServerLatestJobCompleted(client.getJobServices()), 800, 20, TimeUnit.SECONDS);
|
||||||
800, 20, TimeUnit.SECONDS);
|
|
||||||
this.serverLatestJobCompletedShort = new RetryablePredicate<Server>(
|
this.serverLatestJobCompletedShort = new RetryablePredicate<Server>(
|
||||||
new ServerLatestJobCompleted(client.getJobServices()),
|
new ServerLatestJobCompleted(client.getJobServices()), 60, 20, TimeUnit.SECONDS);
|
||||||
60, 20, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,18 +139,22 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
boolean notStarted = true;
|
boolean notStarted = true;
|
||||||
int numOfRetries = 20;
|
int numOfRetries = 20;
|
||||||
// lock-free consumption of a shared resource: IP address pool
|
// lock-free consumption of a shared resource: IP address pool
|
||||||
while(notStarted) { // TODO: replace with Predicate-based thread collision avoidance for simplicity
|
while (notStarted) { // TODO: replace with Predicate-based thread collision avoidance for
|
||||||
Set<Ip> availableIps =
|
// simplicity
|
||||||
client.getIpServices().getIpList(new GetIpListOptions().onlyUnassigned().onlyWithType(IpType.PUBLIC));
|
Set<Ip> availableIps = client.getIpServices().getIpList(
|
||||||
if(availableIps.size() == 0) throw new RuntimeException("No public IPs available on this account.");
|
new GetIpListOptions().onlyUnassigned().onlyWithType(IpType.PUBLIC));
|
||||||
|
if (availableIps.size() == 0)
|
||||||
|
throw new RuntimeException("No public IPs available on this account.");
|
||||||
int ipIndex = new SecureRandom().nextInt(availableIps.size());
|
int ipIndex = new SecureRandom().nextInt(availableIps.size());
|
||||||
Ip availableIp = Iterables.get(availableIps, ipIndex);
|
Ip availableIp = Iterables.get(availableIps, ipIndex);
|
||||||
try {
|
try {
|
||||||
addedServer = client.getServerServices().addServer(name, checkNotNull(template.getImage().getId()),
|
addedServer = client.getServerServices().addServer(name,
|
||||||
|
checkNotNull(template.getImage().getId()),
|
||||||
sizeToRam.apply(template.getSize()), availableIp.getIp());
|
sizeToRam.apply(template.getSize()), availableIp.getIp());
|
||||||
notStarted = false;
|
notStarted = false;
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
if(--numOfRetries == 0) Throwables.propagate(e);
|
if (--numOfRetries == 0)
|
||||||
|
Throwables.propagate(e);
|
||||||
notStarted = true;
|
notStarted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,9 +163,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
client.getServerServices().power(addedServer.getName(), PowerCommand.START);
|
client.getServerServices().power(addedServer.getName(), PowerCommand.START);
|
||||||
serverLatestJobCompletedShort.apply(addedServer);
|
serverLatestJobCompletedShort.apply(addedServer);
|
||||||
|
|
||||||
addedServer = Iterables.getOnlyElement(
|
addedServer = Iterables.getOnlyElement(client.getServerServices().getServersByName(
|
||||||
client.getServerServices().getServersByName(addedServer.getName())
|
addedServer.getName()));
|
||||||
);
|
|
||||||
return serverToNodeMetadata.apply(addedServer);
|
return serverToNodeMetadata.apply(addedServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,17 +179,15 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
protected GoGridRebootNodeStrategy(GoGridClient client) {
|
protected GoGridRebootNodeStrategy(GoGridClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.serverLatestJobCompleted = new RetryablePredicate<Server>(
|
this.serverLatestJobCompleted = new RetryablePredicate<Server>(
|
||||||
new ServerLatestJobCompleted(client.getJobServices()),
|
new ServerLatestJobCompleted(client.getJobServices()), 800, 20, TimeUnit.SECONDS);
|
||||||
800, 20, TimeUnit.SECONDS);
|
|
||||||
this.serverLatestJobCompletedShort = new RetryablePredicate<Server>(
|
this.serverLatestJobCompletedShort = new RetryablePredicate<Server>(
|
||||||
new ServerLatestJobCompleted(client.getJobServices()),
|
new ServerLatestJobCompleted(client.getJobServices()), 60, 20, TimeUnit.SECONDS);
|
||||||
60, 20, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ComputeMetadata node) {
|
public boolean execute(ComputeMetadata node) {
|
||||||
Server server =
|
Server server = Iterables.getOnlyElement(client.getServerServices().getServersByName(
|
||||||
Iterables.getOnlyElement(client.getServerServices().getServersByName(node.getName()));
|
node.getName()));
|
||||||
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,7 +209,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends ComputeMetadata> execute() {
|
public Iterable<? extends ComputeMetadata> execute() {
|
||||||
return Iterables.transform(client.getServerServices().getServerList(), serverToNodeMetadata);
|
return Iterables.transform(client.getServerServices().getServerList(),
|
||||||
|
serverToNodeMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -205,9 +229,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(ComputeMetadata node) {
|
public NodeMetadata execute(ComputeMetadata node) {
|
||||||
Server server = Iterables.getOnlyElement(
|
Server server = Iterables.getOnlyElement(client.getServerServices().getServersByName(
|
||||||
client.getServerServices().getServersByName(node.getName())
|
node.getName()));
|
||||||
);
|
|
||||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,14 +244,13 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
protected GoGridDestroyNodeStrategy(GoGridClient client) {
|
protected GoGridDestroyNodeStrategy(GoGridClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.serverLatestJobCompleted = new RetryablePredicate<Server>(
|
this.serverLatestJobCompleted = new RetryablePredicate<Server>(
|
||||||
new ServerLatestJobCompleted(client.getJobServices()),
|
new ServerLatestJobCompleted(client.getJobServices()), 800, 20, TimeUnit.SECONDS);
|
||||||
800, 20, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ComputeMetadata node) {
|
public boolean execute(ComputeMetadata node) {
|
||||||
Server server = Iterables.getOnlyElement(
|
Server server = Iterables.getOnlyElement(client.getServerServices().getServersByName(
|
||||||
client.getServerServices().getServersByName(node.getName()));
|
node.getName()));
|
||||||
client.getServerServices().deleteByName(server.getName());
|
client.getServerServices().deleteByName(server.getName());
|
||||||
return serverLatestJobCompleted.apply(server);
|
return serverLatestJobCompleted.apply(server);
|
||||||
}
|
}
|
||||||
|
@ -238,14 +260,10 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<String, NodeState> provideServerToNodeState() {
|
Map<String, NodeState> provideServerToNodeState() {
|
||||||
return ImmutableMap.<String, NodeState> builder()
|
return ImmutableMap.<String, NodeState> builder().put("On", NodeState.RUNNING).put(
|
||||||
.put("On", NodeState.RUNNING)
|
"Starting", NodeState.PENDING).put("Off", NodeState.SUSPENDED).put("Saving",
|
||||||
.put("Starting", NodeState.PENDING)
|
NodeState.PENDING).put("Restarting", NodeState.PENDING).put("Stopping",
|
||||||
.put("Off", NodeState.SUSPENDED)
|
NodeState.PENDING).build();
|
||||||
.put("Saving", NodeState.PENDING)
|
|
||||||
.put("Restarting", NodeState.PENDING)
|
|
||||||
.put("Stopping", NodeState.PENDING)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -265,16 +283,12 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds matches to required configurations.
|
* Finds matches to required configurations. GoGrid's documentation only specifies how much RAM
|
||||||
* GoGrid's documentation only specifies how much RAM one can get with
|
* one can get with different instance types. The # of cores and disk sizes are purely empyrical
|
||||||
* different instance types. The # of cores and disk sizes are purely
|
* and aren't guaranteed. However, these are the matches found: Ram: 512MB, CPU: 1 core, HDD: 28
|
||||||
* empyrical and aren't guaranteed.
|
* GB Ram: 1GB, CPU: 1 core, HDD: 57 GB Ram: 2GB, CPU: 1 core, HDD: 113 GB Ram: 4GB, CPU: 3
|
||||||
* However, these are the matches found:
|
* cores, HDD: 233 GB Ram: 8GB, CPU: 6 cores, HDD: 462 GB
|
||||||
* Ram: 512MB, CPU: 1 core, HDD: 28 GB
|
*
|
||||||
* Ram: 1GB, CPU: 1 core, HDD: 57 GB
|
|
||||||
* Ram: 2GB, CPU: 1 core, HDD: 113 GB
|
|
||||||
* Ram: 4GB, CPU: 3 cores, HDD: 233 GB
|
|
||||||
* Ram: 8GB, CPU: 6 cores, HDD: 462 GB
|
|
||||||
* @return matched size
|
* @return matched size
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -283,11 +297,15 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
return new Function<Size, String>() {
|
return new Function<Size, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(Size size) {
|
public String apply(Size size) {
|
||||||
if(size.getRam() >= 8 * 1024 || size.getCores() >= 6 || size.getDisk() >= 450) return "8GB";
|
if (size.getRam() >= 8 * 1024 || size.getCores() >= 6 || size.getDisk() >= 450)
|
||||||
if(size.getRam() >= 4 * 1024 || size.getCores() >= 3 || size.getDisk() >= 230) return "4GB";
|
return "8GB";
|
||||||
if(size.getRam() >= 2 * 1024 || size.getDisk() >= 110) return "2GB";
|
if (size.getRam() >= 4 * 1024 || size.getCores() >= 3 || size.getDisk() >= 230)
|
||||||
if(size.getRam() >= 1024 || size.getDisk() >= 55) return "1GB";
|
return "4GB";
|
||||||
return "512MB"; /*smallest*/
|
if (size.getRam() >= 2 * 1024 || size.getDisk() >= 110)
|
||||||
|
return "2GB";
|
||||||
|
if (size.getRam() >= 1024 || size.getDisk() >= 55)
|
||||||
|
return "1GB";
|
||||||
|
return "512MB"; /* smallest */
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -300,8 +318,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerToNodeMetadata(Map<String, NodeState> serverStateToNodeState,
|
ServerToNodeMetadata(Map<String, NodeState> serverStateToNodeState,
|
||||||
Function<String, InetAddress> stringIpToInetAddress,
|
Function<String, InetAddress> stringIpToInetAddress, GoGridClient client) {
|
||||||
GoGridClient client) {
|
|
||||||
this.serverStateToNodeState = serverStateToNodeState;
|
this.serverStateToNodeState = serverStateToNodeState;
|
||||||
this.stringIpToInetAddress = stringIpToInetAddress;
|
this.stringIpToInetAddress = stringIpToInetAddress;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
@ -311,15 +328,15 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
public NodeMetadata apply(Server from) {
|
public NodeMetadata apply(Server from) {
|
||||||
String locationId = "Unavailable";
|
String locationId = "Unavailable";
|
||||||
String tag = CharMatcher.JAVA_LETTER.retainFrom(from.getName());
|
String tag = CharMatcher.JAVA_LETTER.retainFrom(from.getName());
|
||||||
Credentials creds = client.getServerServices().getServerCredentialsList().get(from.getName());
|
Credentials creds = client.getServerServices().getServerCredentialsList().get(
|
||||||
Set<InetAddress> ipSet =
|
from.getName());
|
||||||
ImmutableSet.of(stringIpToInetAddress.apply(from.getIp().getIp()));
|
Set<InetAddress> ipSet = ImmutableSet
|
||||||
|
.of(stringIpToInetAddress.apply(from.getIp().getIp()));
|
||||||
NodeState state = serverStateToNodeState.get(from.getState().getName());
|
NodeState state = serverStateToNodeState.get(from.getState().getName());
|
||||||
|
|
||||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), locationId, null,
|
return new NodeMetadataImpl(from.getId() + "", from.getName(), locationId, null,
|
||||||
ImmutableMap.<String, String> of(), tag, state,
|
ImmutableMap.<String, String> of(), tag, state, ipSet, ImmutableList
|
||||||
ipSet,
|
.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
||||||
ImmutableList.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,8 +345,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
@Singleton
|
@Singleton
|
||||||
ComputeServiceContext provideContext(ComputeService computeService,
|
ComputeServiceContext provideContext(ComputeService computeService,
|
||||||
RestContext<GoGridAsyncClient, GoGridClient> context) {
|
RestContext<GoGridAsyncClient, GoGridClient> context) {
|
||||||
return new ComputeServiceContextImpl<GoGridAsyncClient, GoGridClient>(
|
return new ComputeServiceContextImpl<GoGridAsyncClient, GoGridClient>(computeService, context);
|
||||||
computeService, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -343,7 +359,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
Location getDefaultLocation(Map<String, ? extends Location> locations) {
|
Location getDefaultLocation(Map<String, ? extends Location> locations) {
|
||||||
return locations.get("SANJOSE");
|
return locations.get("SANFRANCISCO");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -351,9 +367,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
Map<String, ? extends Location> getDefaultLocations(GoGridClient sync, LogHolder holder,
|
Map<String, ? extends Location> getDefaultLocations(GoGridClient sync, LogHolder holder,
|
||||||
Function<ComputeMetadata, String> indexer) {
|
Function<ComputeMetadata, String> indexer) {
|
||||||
final Set<Location> locations = Sets.newHashSet();
|
final Set<Location> locations = Sets.newHashSet();
|
||||||
holder.logger.debug(">> providing empty locations because gogrid doesnt have any");
|
holder.logger.debug(">> providing locations");
|
||||||
locations.add(new LocationImpl(LocationScope.REGION, "SANJOSE", "GoGrid doesnt support locations so using " +
|
locations.add(new LocationImpl(LocationScope.ZONE, "SANFRANCISCO", "San Francisco, CA", null,
|
||||||
"a made up one to comply with API", "Santa Clara County", true));
|
true));
|
||||||
holder.logger.debug("<< locations(%d)", locations.size());
|
holder.logger.debug("<< locations(%d)", locations.size());
|
||||||
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
||||||
|
|
||||||
|
@ -384,26 +400,16 @@ 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,
|
sizes.add(new SizeImpl("1", "1", null, null, ImmutableMap.<String, String> of(), 1, 512, 28,
|
||||||
ImmutableMap.<String, String> of(), 1, 512, 28,
|
ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32,
|
sizes.add(new SizeImpl("2", "2", null, null, ImmutableMap.<String, String> of(), 1, 1024, 57,
|
||||||
Architecture.X86_64)));
|
ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
sizes.add(new SizeImpl("2", "2", null, null,
|
sizes.add(new SizeImpl("3", "3", null, null, ImmutableMap.<String, String> of(), 1, 2048,
|
||||||
ImmutableMap.<String, String> of(), 1, 1024, 57,
|
113, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32,
|
sizes.add(new SizeImpl("4", "4", null, null, ImmutableMap.<String, String> of(), 3, 4096,
|
||||||
Architecture.X86_64)));
|
233, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
sizes.add(new SizeImpl("3", "3", null, null,
|
sizes.add(new SizeImpl("5", "5", null, null, ImmutableMap.<String, String> of(), 6, 8192,
|
||||||
ImmutableMap.<String, String> of(), 1, 2048, 113,
|
462, ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64)));
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32,
|
|
||||||
Architecture.X86_64)));
|
|
||||||
sizes.add(new SizeImpl("4", "4", null, null,
|
|
||||||
ImmutableMap.<String, String> of(), 3, 4096, 233,
|
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32,
|
|
||||||
Architecture.X86_64)));
|
|
||||||
sizes.add(new SizeImpl("5", "5", null, null,
|
|
||||||
ImmutableMap.<String, String> of(), 6, 8192, 462,
|
|
||||||
ImmutableSet.<Architecture> of(Architecture.X86_32,
|
|
||||||
Architecture.X86_64)));
|
|
||||||
holder.logger.debug("<< sizes(%d)", sizes.size());
|
holder.logger.debug("<< sizes(%d)", sizes.size());
|
||||||
return Maps.uniqueIndex(sizes, indexer);
|
return Maps.uniqueIndex(sizes, indexer);
|
||||||
}
|
}
|
||||||
|
@ -415,39 +421,35 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Pattern GOGRID_OS_NAME_PATTERN = Pattern.compile("([a-zA-Z]*)(.*)");
|
public static final Pattern GOGRID_OS_NAME_PATTERN = Pattern.compile("([a-zA-Z]*)(.*)");
|
||||||
public static final Pattern GOGRID_OS_VERSION_PATTERN = Pattern.compile("([a-zA-Z\\s]*)(\\d(\\.)*\\d+)");
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<String, ? extends Image> provideImages(final GoGridClient sync,
|
protected Map<String, ? extends Image> provideImages(final GoGridClient sync, LogHolder holder,
|
||||||
LogHolder holder, Function<ComputeMetadata, String> indexer)
|
Function<ComputeMetadata, String> indexer, Location location)
|
||||||
throws InterruptedException, ExecutionException, TimeoutException {
|
throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
final Set<Image> images = Sets.newHashSet();
|
final Set<Image> images = Sets.newHashSet();
|
||||||
holder.logger.debug(">> providing images");
|
holder.logger.debug(">> providing images");
|
||||||
Set<ServerImage> allImages = sync.getImageServices().getImageList();
|
Set<ServerImage> allImages = sync.getImageServices().getImageList();
|
||||||
for (ServerImage from : allImages) {
|
for (ServerImage from : allImages) {
|
||||||
OsFamily os = null;
|
OsFamily os = null;
|
||||||
Architecture arch = (from.getOs().getName().indexOf("64") == -1 &&
|
Architecture arch = (from.getOs().getName().indexOf("64") == -1 && from.getDescription()
|
||||||
from.getDescription().indexOf("64") == -1) ?
|
.indexOf("64") == -1) ? Architecture.X86_32 : Architecture.X86_64;
|
||||||
Architecture.X86_32 : Architecture.X86_64;
|
|
||||||
String osDescription;
|
String osDescription;
|
||||||
String version = "";
|
String version = "";
|
||||||
|
|
||||||
osDescription = from.getOs().getName();
|
osDescription = from.getOs().getName();
|
||||||
|
|
||||||
String matchedOs = GoGridUtils.parseStringByPatternAndGetNthMatchGroup(from.getOs().getName(),
|
String matchedOs = GoGridUtils.parseStringByPatternAndGetNthMatchGroup(from.getOs()
|
||||||
GOGRID_OS_NAME_PATTERN, 1);
|
.getName(), GOGRID_OS_NAME_PATTERN, 1);
|
||||||
try {
|
try {
|
||||||
os = OsFamily.fromValue(matchedOs.toLowerCase());
|
os = OsFamily.fromValue(matchedOs.toLowerCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
version = GoGridUtils.parseStringByPatternAndGetNthMatchGroup(from.getOs().getName(),
|
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location.getId(), null,
|
||||||
GOGRID_OS_VERSION_PATTERN, 2);
|
ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
||||||
|
osDescription, arch));
|
||||||
images.add(new ImageImpl(from.getName(), from.getDescription(), null, null, ImmutableMap
|
|
||||||
.<String, String> of(), from.getDescription(), version, os, osDescription, arch));
|
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< images(%d)", images.size());
|
holder.logger.debug("<< images(%d)", images.size());
|
||||||
return Maps.uniqueIndex(images, indexer);
|
return Maps.uniqueIndex(images, indexer);
|
||||||
|
|
|
@ -21,9 +21,9 @@ package org.jclouds.gogrid;
|
||||||
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
@ -34,14 +34,12 @@ import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
|
@ -56,20 +54,24 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String buildScript() {
|
public String buildScript() {
|
||||||
return
|
return new StringBuilder()
|
||||||
new StringBuilder()//
|
//
|
||||||
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")
|
||||||
|
//
|
||||||
.append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
.append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
||||||
.append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
.append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
||||||
.append("echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
.append(
|
||||||
|
"echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
||||||
.append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
.append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
||||||
.append("yum -y install java-1.6.0-openjdk\n")
|
.append("yum -y install java-1.6.0-openjdk\n")
|
||||||
.append("echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")
|
.append(
|
||||||
|
"echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
||||||
return templateBuilder.osFamily(CENTOS).imageId("centos5.3_32_base").smallest().build();
|
return templateBuilder.osFamily(CENTOS).imageDescriptionMatches(".*w/ None.*").smallest()
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,19 +88,19 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
public void endToEndComputeServiceTest() {
|
public void endToEndComputeServiceTest() {
|
||||||
ComputeService service = context.getComputeService();
|
ComputeService service = context.getComputeService();
|
||||||
Template t = service.templateBuilder().minRam(1024).imageId(
|
Template t = service.templateBuilder().minRam(1024).imageId("1532").build();
|
||||||
"GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2").build();
|
|
||||||
|
|
||||||
int originalSize = service.getNodes().size();
|
int originalSize = service.getNodes().size();
|
||||||
|
|
||||||
assertEquals(t.getImage().getId(), "GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2");
|
assertEquals(t.getImage().getId(), "1532");
|
||||||
service.runNodesWithTag(this.service, 1, t);
|
service.runNodesWithTag(this.service, 1, t);
|
||||||
|
|
||||||
Map<String, ? extends ComputeMetadata> nodes = service.getNodes();
|
Map<String, ? extends ComputeMetadata> nodes = service.getNodes();
|
||||||
assertEquals(nodes.size(), originalSize + 1, "size should've been larger by 1");
|
assertEquals(nodes.size(), originalSize + 1, "size should've been larger by 1");
|
||||||
|
|
||||||
ComputeMetadata node = Iterables.find(nodes.values(), new Predicate<ComputeMetadata>() {
|
ComputeMetadata node = Iterables.find(nodes.values(), new Predicate<ComputeMetadata>() {
|
||||||
@Override public boolean apply(ComputeMetadata computeMetadata) {
|
@Override
|
||||||
|
public boolean apply(ComputeMetadata computeMetadata) {
|
||||||
return computeMetadata.getName().startsWith(GoGridComputeServiceLiveTest.this.service);
|
return computeMetadata.getName().startsWith(GoGridComputeServiceLiveTest.this.service);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -149,9 +149,12 @@ public class ComputeTask extends Task {
|
||||||
private void listImages(ComputeService computeService) {
|
private void listImages(ComputeService computeService) {
|
||||||
log("list images");
|
log("list images");
|
||||||
for (Image image : computeService.getImages().values()) {// TODO
|
for (Image image : computeService.getImages().values()) {// TODO
|
||||||
log(String.format(" image location=%s, id=%s, version=%s, arch=%s, osfam=%s, desc=%s",
|
log(String
|
||||||
image.getLocationId(), image.getId(), image.getVersion(),
|
.format(
|
||||||
image.getArchitecture(), image.getOsFamily(), image.getOsDescription()));
|
" image location=%s, id=%s, name=%s, version=%s, arch=%s, osfam=%s, osdesc=%s, desc=%s",
|
||||||
|
image.getLocationId(), image.getId(), image.getName(), image
|
||||||
|
.getVersion(), image.getArchitecture(), image.getOsFamily(),
|
||||||
|
image.getOsDescription(), image.getDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue