+ *
+ * affected nodes may not resume with the same IP address(es)
*/
void resumeNode(String id);
@@ -155,6 +159,10 @@ public interface ComputeService {
* nodes matching the filter are treated as a logical set. Using the resume command, you can save
* time by resumeing the nodes in parallel.
*
+ *
note
+ *
+ * affected nodes may not resume with the same IP address(es)
+ *
* @throws UnsupportedOperationException
* if the underlying provider doesn't support suspend/resume
*/
@@ -164,6 +172,10 @@ public interface ComputeService {
* suspend the node, given its id. This will result in
* {@link org.jclouds.compute.domain.NodeState#SUSPENDED suspended} state.
*
+ *
note
+ *
+ * affected nodes may not resume with the same IP address(es)
+ *
* @throws UnsupportedOperationException
* if the underlying provider doesn't support suspend/resume
*/
@@ -173,6 +185,9 @@ public interface ComputeService {
* nodes matching the filter are treated as a logical set. Using the suspend command, you can
* save time by suspending the nodes in parallel.
*
+ *
note
+ *
+ * affected nodes may not resume with the same IP address(es)
*/
void suspendNodesMatching(Predicate filter);
@@ -224,7 +239,7 @@ public interface ComputeService {
* @see org.jclouds.compute.predicates.NodePredicates#runningWithTag(String)
*/
Map extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate filter, Payload runScript)
- throws RunScriptOnNodesException;
+ throws RunScriptOnNodesException;
/**
* Run the script on all nodes with the specific tag.
@@ -243,6 +258,6 @@ public interface ComputeService {
* @see org.jclouds.io.Payloads
*/
Map extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate filter,
- Payload runScript, RunScriptOptions options) throws RunScriptOnNodesException;
+ Payload runScript, RunScriptOptions options) throws RunScriptOnNodesException;
}
diff --git a/compute/src/main/java/org/jclouds/compute/Utils.java b/compute/src/main/java/org/jclouds/compute/Utils.java
index 3d25c26635..345fb6ee37 100644
--- a/compute/src/main/java/org/jclouds/compute/Utils.java
+++ b/compute/src/main/java/org/jclouds/compute/Utils.java
@@ -44,4 +44,5 @@ public interface Utils extends org.jclouds.rest.Utils {
* @return function that gets an ssh client for a node that is available via ssh.
*/
Function sshForNode();
+
}
diff --git a/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java b/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java
index 5eb304e647..c8826d6570 100644
--- a/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java
+++ b/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java
@@ -35,9 +35,12 @@ import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.functions.CreateSshClientOncePortIsListeningOnNode;
+import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
+import org.jclouds.json.Json;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import org.jclouds.ssh.SshClient;
@@ -70,13 +73,20 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
bind(LoadBalancerService.class).toProvider(Providers. of(null)).in(Scopes.SINGLETON);
}
+ @Provides
+ @Singleton
+ public Map> provideOsVersionMap(ComputeServiceConstants.ReferenceData data, Json json) {
+ return json.fromJson(data.osVersionMapJson, new TypeLiteral
+ *
+ *
NOTE: the order of invocation of configuration methods does not matter.
+ *
+ * @author Inderjeet Singh
+ * @author Joel Leitch
+ */
+public final class JcloudsGsonBuilder {
+ private static final InnerClassExclusionStrategy innerClassExclusionStrategy =
+ new InnerClassExclusionStrategy();
+ private static final ExposeAnnotationSerializationExclusionStrategy
+ exposeAnnotationSerializationExclusionStrategy =
+ new ExposeAnnotationSerializationExclusionStrategy();
+ private static final ExposeAnnotationDeserializationExclusionStrategy
+ exposeAnnotationDeserializationExclusionStrategy =
+ new ExposeAnnotationDeserializationExclusionStrategy();
+
+ private final Collection exclusionStrategies =
+ new HashSet();
+
+ private double ignoreVersionsAfter;
+ private ModifierBasedExclusionStrategy modifierBasedExclusionStrategy;
+ private boolean serializeInnerClasses;
+ private boolean excludeFieldsWithoutExposeAnnotation;
+ private LongSerializationPolicy longSerializationPolicy;
+ private FieldNamingStrategy2 fieldNamingPolicy;
+ private final ParameterizedTypeHandlerMap> instanceCreators;
+ private final ParameterizedTypeHandlerMap> serializers;
+ private final ParameterizedTypeHandlerMap> deserializers;
+ private boolean serializeNulls;
+ private String datePattern;
+ private int dateStyle;
+ private int timeStyle;
+ private boolean serializeSpecialFloatingPointValues;
+ private boolean escapeHtmlChars;
+ private boolean prettyPrinting;
+ private boolean generateNonExecutableJson;
+
+ /**
+ * Creates a JcloudsGsonBuilder instance that can be used to build Gson with various configuration
+ * settings. JcloudsGsonBuilder follows the builder pattern, and it is typically used by first
+ * invoking various configuration methods to set desired options, and finally calling
+ * {@link #create()}.
+ */
+ public JcloudsGsonBuilder() {
+ // add default exclusion strategies
+ exclusionStrategies.add(Gson.DEFAULT_ANON_LOCAL_CLASS_EXCLUSION_STRATEGY);
+ exclusionStrategies.add(Gson.DEFAULT_SYNTHETIC_FIELD_EXCLUSION_STRATEGY);
+
+ // setup default values
+ ignoreVersionsAfter = VersionConstants.IGNORE_VERSIONS;
+ serializeInnerClasses = true;
+ prettyPrinting = false;
+ escapeHtmlChars = true;
+ modifierBasedExclusionStrategy = Gson.DEFAULT_MODIFIER_BASED_EXCLUSION_STRATEGY;
+ excludeFieldsWithoutExposeAnnotation = false;
+ longSerializationPolicy = LongSerializationPolicy.DEFAULT;
+ fieldNamingPolicy = Gson.DEFAULT_NAMING_POLICY;
+ instanceCreators = new ParameterizedTypeHandlerMap>();
+ serializers = new ParameterizedTypeHandlerMap>();
+ deserializers = new ParameterizedTypeHandlerMap>();
+ serializeNulls = false;
+ dateStyle = DateFormat.DEFAULT;
+ timeStyle = DateFormat.DEFAULT;
+ serializeSpecialFloatingPointValues = false;
+ generateNonExecutableJson = false;
+ }
+
+ /**
+ * Configures Gson to enable versioning support.
+ *
+ * @param ignoreVersionsAfter any field or type marked with a version higher than this value
+ * are ignored during serialization or deserialization.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ public JcloudsGsonBuilder setVersion(double ignoreVersionsAfter) {
+ this.ignoreVersionsAfter = ignoreVersionsAfter;
+ return this;
+ }
+
+ /**
+ * Configures Gson to excludes all class fields that have the specified modifiers. By default,
+ * Gson will exclude all fields marked transient or static. This method will override that
+ * behavior.
+ *
+ * @param modifiers the field modifiers. You must use the modifiers specified in the
+ * {@link java.lang.reflect.Modifier} class. For example,
+ * {@link java.lang.reflect.Modifier#TRANSIENT},
+ * {@link java.lang.reflect.Modifier#STATIC}.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ public JcloudsGsonBuilder excludeFieldsWithModifiers(int... modifiers) {
+ modifierBasedExclusionStrategy = new ModifierBasedExclusionStrategy(modifiers);
+ return this;
+ }
+
+ /**
+ * Makes the output JSON non-executable in Javascript by prefixing the generated JSON with some
+ * special text. This prevents attacks from third-party sites through script sourcing. See
+ * Gson Issue 42
+ * for details.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.3
+ */
+ public JcloudsGsonBuilder generateNonExecutableJson() {
+ this.generateNonExecutableJson = true;
+ return this;
+ }
+
+ /**
+ * Configures Gson to exclude all fields from consideration for serialization or deserialization
+ * that do not have the {@link com.google.gson.annotations.Expose} annotation.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ public JcloudsGsonBuilder excludeFieldsWithoutExposeAnnotation() {
+ excludeFieldsWithoutExposeAnnotation = true;
+ return this;
+ }
+
+ /**
+ * Configure Gson to serialize null fields. By default, Gson omits all fields that are null
+ * during serialization.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.2
+ */
+ public JcloudsGsonBuilder serializeNulls() {
+ this.serializeNulls = true;
+ return this;
+ }
+
+ /**
+ * Configures Gson to exclude inner classes during serialization.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.3
+ */
+ public JcloudsGsonBuilder disableInnerClassSerialization() {
+ serializeInnerClasses = false;
+ return this;
+ }
+
+ /**
+ * Configures Gson to apply a specific serialization policy for {@code Long} and {@code long}
+ * objects.
+ *
+ * @param serializationPolicy the particular policy to use for serializing longs.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.3
+ */
+ public JcloudsGsonBuilder setLongSerializationPolicy(LongSerializationPolicy serializationPolicy) {
+ this.longSerializationPolicy = serializationPolicy;
+ return this;
+ }
+
+ /**
+ * Configures Gson to apply a specific naming policy to an object's field during serialization
+ * and deserialization.
+ *
+ * @param namingConvention the JSON field naming convention to use for serialization and
+ * deserialization.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ public JcloudsGsonBuilder setFieldNamingPolicy(FieldNamingPolicy namingConvention) {
+ return setFieldNamingStrategy(namingConvention.getFieldNamingPolicy());
+ }
+
+ /**
+ * Configures Gson to apply a specific naming policy strategy to an object's field during
+ * serialization and deserialization.
+ *
+ * @param fieldNamingStrategy the actual naming strategy to apply to the fields
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.3
+ */
+ public JcloudsGsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) {
+ return setFieldNamingStrategy(new FieldNamingStrategy2Adapter(fieldNamingStrategy));
+ }
+
+ /**
+ * Configures Gson to apply a specific naming policy strategy to an object's field during
+ * serialization and deserialization.
+ *
+ * @param fieldNamingStrategy the actual naming strategy to apply to the fields
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ JcloudsGsonBuilder setFieldNamingStrategy(FieldNamingStrategy2 fieldNamingStrategy) {
+ this.fieldNamingPolicy =
+ new SerializedNameAnnotationInterceptingNamingPolicy(fieldNamingStrategy);
+ return this;
+ }
+
+ /**
+ * Configures Gson to apply a set of exclusion strategies during both serialization and
+ * deserialization. Each of the {@code strategies} will be applied as a disjunction rule.
+ * This means that if one of the {@code strategies} suggests that a field (or class) should be
+ * skipped then that field (or object) is skipped during serializaiton/deserialization.
+ *
+ * @param strategies the set of strategy object to apply during object (de)serialization.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.4
+ */
+ public JcloudsGsonBuilder setExclusionStrategies(ExclusionStrategy... strategies) {
+ for (ExclusionStrategy strategy : strategies) {
+ exclusionStrategies.add(strategy);
+ }
+ return this;
+ }
+
+ /**
+ * Configures Gson to output Json that fits in a page for pretty printing. This option only
+ * affects Json serialization.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ public JcloudsGsonBuilder setPrettyPrinting() {
+ prettyPrinting = true;
+ return this;
+ }
+
+ /**
+ * By default, Gson escapes HTML characters such as < > etc. Use this option to configure
+ * Gson to pass-through HTML characters as is.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.3
+ */
+ public JcloudsGsonBuilder disableHtmlEscaping() {
+ this.escapeHtmlChars = false;
+ return this;
+ }
+
+ /**
+ * Configures Gson to serialize {@code Date} objects according to the pattern provided. You can
+ * call this method or {@link #setDateFormat(int)} multiple times, but only the last invocation
+ * will be used to decide the serialization format.
+ *
+ *
Note that this pattern must abide by the convention provided by {@code SimpleDateFormat}
+ * class. See the documentation in {@link java.text.SimpleDateFormat} for more information on
+ * valid date and time patterns.
+ *
+ * @param pattern the pattern that dates will be serialized/deserialized to/from
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.2
+ */
+ public JcloudsGsonBuilder setDateFormat(String pattern) {
+ // TODO(Joel): Make this fail fast if it is an invalid date format
+ this.datePattern = pattern;
+ return this;
+ }
+
+ /**
+ * Configures Gson to to serialize {@code Date} objects according to the style value provided.
+ * You can call this method or {@link #setDateFormat(String)} multiple times, but only the last
+ * invocation will be used to decide the serialization format.
+ *
+ *
Note that this style value should be one of the predefined constants in the
+ * {@code DateFormat} class. See the documentation in {@link java.text.DateFormat} for more
+ * information on the valid style constants.
+ *
+ * @param style the predefined date style that date objects will be serialized/deserialized
+ * to/from
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.2
+ */
+ public JcloudsGsonBuilder setDateFormat(int style) {
+ this.dateStyle = style;
+ this.datePattern = null;
+ return this;
+ }
+
+ /**
+ * Configures Gson to to serialize {@code Date} objects according to the style value provided.
+ * You can call this method or {@link #setDateFormat(String)} multiple times, but only the last
+ * invocation will be used to decide the serialization format.
+ *
+ *
Note that this style value should be one of the predefined constants in the
+ * {@code DateFormat} class. See the documentation in {@link java.text.DateFormat} for more
+ * information on the valid style constants.
+ *
+ * @param dateStyle the predefined date style that date objects will be serialized/deserialized
+ * to/from
+ * @param timeStyle the predefined style for the time portion of the date objects
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.2
+ */
+ public JcloudsGsonBuilder setDateFormat(int dateStyle, int timeStyle) {
+ this.dateStyle = dateStyle;
+ this.timeStyle = timeStyle;
+ this.datePattern = null;
+ return this;
+ }
+
+ /**
+ * Configures Gson for custom serialization or deserialization. This method combines the
+ * registration of an {@link InstanceCreator}, {@link JsonSerializer}, and a
+ * {@link JsonDeserializer}. It is best used when a single object {@code typeAdapter} implements
+ * all the required interfaces for custom serialization with Gson. If an instance creator,
+ * serializer or deserializer was previously registered for the specified {@code type}, it is
+ * overwritten.
+ *
+ * @param type the type definition for the type adapter being registered
+ * @param typeAdapter This object must implement at least one of the {@link InstanceCreator},
+ * {@link JsonSerializer}, and a {@link JsonDeserializer} interfaces.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ public JcloudsGsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
+ Preconditions.checkArgument(typeAdapter instanceof JsonSerializer>
+ || typeAdapter instanceof JsonDeserializer> || typeAdapter instanceof InstanceCreator>);
+ if (typeAdapter instanceof InstanceCreator>) {
+ registerInstanceCreator(type, (InstanceCreator>) typeAdapter);
+ }
+ if (typeAdapter instanceof JsonSerializer>) {
+ registerSerializer(type, (JsonSerializer>) typeAdapter);
+ }
+ if (typeAdapter instanceof JsonDeserializer>) {
+ registerDeserializer(type, (JsonDeserializer>) typeAdapter);
+ }
+ return this;
+ }
+
+ /**
+ * Configures Gson to use a custom {@link InstanceCreator} for the specified type. If an instance
+ * creator was previously registered for the specified class, it is overwritten. Since this method
+ * takes a type instead of a Class object, it can be used to register a specific handler for a
+ * generic type corresponding to a raw type.
+ *
+ * @param the type for which instance creator is being registered
+ * @param typeOfT The Type definition for T
+ * @param instanceCreator the instance creator for T
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ private JcloudsGsonBuilder registerInstanceCreator(Type typeOfT,
+ InstanceCreator extends T> instanceCreator) {
+ instanceCreators.register(typeOfT, instanceCreator);
+ return this;
+ }
+
+ /**
+ * Configures Gson to use a custom JSON serializer for the specified type. You should use this
+ * method if you want to register different serializers for different generic types corresponding
+ * to a raw type.
+ *
+ * @param the type for which the serializer is being registered
+ * @param typeOfT The type definition for T
+ * @param serializer the custom serializer
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ private JcloudsGsonBuilder registerSerializer(Type typeOfT, final JsonSerializer serializer) {
+ serializers.register(typeOfT, serializer);
+ return this;
+ }
+
+ /**
+ * Configures Gson to use a custom JSON deserializer for the specified type. You should use this
+ * method if you want to register different deserializers for different generic types
+ * corresponding to a raw type.
+ *
+ * @param the type for which the deserializer is being registered
+ * @param typeOfT The type definition for T
+ * @param deserializer the custom deserializer
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ */
+ private JcloudsGsonBuilder registerDeserializer(Type typeOfT, JsonDeserializer deserializer) {
+ deserializers.register(typeOfT, new JsonDeserializerExceptionWrapper(deserializer));
+ return this;
+ }
+
+ /**
+ * Configures Gson for custom serialization or deserialization for an inheritance type hierarchy.
+ * This method combines the registration of an {@link InstanceCreator}, {@link JsonSerializer},
+ * and a {@link JsonDeserializer}. It is best used when a single object {@code typeAdapter}
+ * implements all the required interfaces for custom serialization with Gson.
+ * If an instance creator, serializer or deserializer was previously registered for the specified
+ * type hierarchy, it is overwritten. If an instance creator, serializer or deserializer is
+ * registered for a specific type in the type hierarchy, it will be invoked instead of the one
+ * registered for the type hierarchy.
+ *
+ * @param baseType the class definition for the type adapter being registered for the base class
+ * or interface
+ * @param typeAdapter This object must implement at least one of the {@link InstanceCreator},
+ * {@link JsonSerializer}, and a {@link JsonDeserializer} interfaces.
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.5
+ */
+ JcloudsGsonBuilder registerTypeHierarchyAdapter(Class> baseType, Object typeAdapter) {
+ Preconditions.checkArgument(typeAdapter instanceof JsonSerializer>
+ || typeAdapter instanceof JsonDeserializer> || typeAdapter instanceof InstanceCreator>);
+ if (typeAdapter instanceof InstanceCreator>) {
+ registerInstanceCreatorForTypeHierarchy(baseType, (InstanceCreator>) typeAdapter);
+ }
+ if (typeAdapter instanceof JsonSerializer>) {
+ registerSerializerForTypeHierarchy(baseType, (JsonSerializer>) typeAdapter);
+ }
+ if (typeAdapter instanceof JsonDeserializer>) {
+ registerDeserializerForTypeHierarchy(baseType, (JsonDeserializer>) typeAdapter);
+ }
+ return this;
+ }
+
+ private JcloudsGsonBuilder registerInstanceCreatorForTypeHierarchy(Class> classOfT,
+ InstanceCreator extends T> instanceCreator) {
+ instanceCreators.registerForTypeHierarchy(classOfT, instanceCreator);
+ return this;
+ }
+
+ private JcloudsGsonBuilder registerSerializerForTypeHierarchy(Class> classOfT,
+ final JsonSerializer serializer) {
+ serializers.registerForTypeHierarchy(classOfT, serializer);
+ return this;
+ }
+
+ private JcloudsGsonBuilder registerDeserializerForTypeHierarchy(Class> classOfT,
+ JsonDeserializer deserializer) {
+ deserializers.registerForTypeHierarchy(classOfT,
+ new JsonDeserializerExceptionWrapper(deserializer));
+ return this;
+ }
+
+ /**
+ * Section 2.4 of JSON specification disallows
+ * special double values (NaN, Infinity, -Infinity). However,
+ * Javascript
+ * specification (see section 4.3.20, 4.3.22, 4.3.23) allows these values as valid Javascript
+ * values. Moreover, most JavaScript engines will accept these special values in JSON without
+ * problem. So, at a practical level, it makes sense to accept these values as valid JSON even
+ * though JSON specification disallows them.
+ *
+ *
Gson always accepts these special values during deserialization. However, it outputs
+ * strictly compliant JSON. Hence, if it encounters a float value {@link Float#NaN},
+ * {@link Float#POSITIVE_INFINITY}, {@link Float#NEGATIVE_INFINITY}, or a double value
+ * {@link Double#NaN}, {@link Double#POSITIVE_INFINITY}, {@link Double#NEGATIVE_INFINITY}, it
+ * will throw an {@link IllegalArgumentException}. This method provides a way to override the
+ * default behavior when you know that the JSON receiver will be able to handle these special
+ * values.
+ *
+ * @return a reference to this {@code JcloudsGsonBuilder} object to fulfill the "Builder" pattern
+ * @since 1.3
+ */
+ public JcloudsGsonBuilder serializeSpecialFloatingPointValues() {
+ this.serializeSpecialFloatingPointValues = true;
+ return this;
+ }
+
+ /**
+ * Creates a {@link Gson} instance based on the current configuration. This method is free of
+ * side-effects to this {@code JcloudsGsonBuilder} instance and hence can be called multiple times.
+ *
+ * @return an instance of Gson configured with the options currently set in this builder
+ */
+ public Gson create() {
+ List serializationStrategies =
+ new LinkedList(exclusionStrategies);
+ List deserializationStrategies =
+ new LinkedList(exclusionStrategies);
+
+ serializationStrategies.add(modifierBasedExclusionStrategy);
+ deserializationStrategies.add(modifierBasedExclusionStrategy);
+
+ if (!serializeInnerClasses) {
+ serializationStrategies.add(innerClassExclusionStrategy);
+ deserializationStrategies.add(innerClassExclusionStrategy);
+ }
+ if (ignoreVersionsAfter != VersionConstants.IGNORE_VERSIONS) {
+ serializationStrategies.add(new VersionExclusionStrategy(ignoreVersionsAfter));
+ deserializationStrategies.add(new VersionExclusionStrategy(ignoreVersionsAfter));
+ }
+ if (excludeFieldsWithoutExposeAnnotation) {
+ serializationStrategies.add(exposeAnnotationSerializationExclusionStrategy);
+ deserializationStrategies.add(exposeAnnotationDeserializationExclusionStrategy);
+ }
+ ExclusionStrategy serializationExclusionStrategy =
+ new DisjunctionExclusionStrategy(serializationStrategies);
+ ExclusionStrategy deserializationExclusionStrategy =
+ new DisjunctionExclusionStrategy(deserializationStrategies);
+
+ ParameterizedTypeHandlerMap> customSerializers = serializers.copyOf();
+ ParameterizedTypeHandlerMap> customDeserializers = deserializers.copyOf();
+ addTypeAdaptersForDate(datePattern, dateStyle, timeStyle, customSerializers,
+ customDeserializers);
+
+ customSerializers.registerIfAbsent(JcloudsDefaultTypeAdapters.getDefaultSerializers(
+ serializeSpecialFloatingPointValues, longSerializationPolicy));
+
+ customDeserializers.registerIfAbsent(JcloudsDefaultTypeAdapters.getDefaultDeserializers());
+
+ ParameterizedTypeHandlerMap> customInstanceCreators =
+ instanceCreators.copyOf();
+ customInstanceCreators.registerIfAbsent(JcloudsDefaultTypeAdapters.getDefaultInstanceCreators());
+
+ customSerializers.makeUnmodifiable();
+ customDeserializers.makeUnmodifiable();
+ instanceCreators.makeUnmodifiable();
+
+ MappedObjectConstructor objConstructor = new MappedObjectConstructor(customInstanceCreators);
+
+ JsonFormatter formatter = prettyPrinting ?
+ new JsonPrintFormatter(escapeHtmlChars) : new JsonCompactFormatter(escapeHtmlChars);
+ Gson gson = new Gson(serializationExclusionStrategy, deserializationExclusionStrategy,
+ fieldNamingPolicy, objConstructor, formatter, serializeNulls, customSerializers,
+ customDeserializers, generateNonExecutableJson);
+ return gson;
+ }
+
+ private static void addTypeAdaptersForDate(String datePattern, int dateStyle, int timeStyle,
+ ParameterizedTypeHandlerMap> serializers,
+ ParameterizedTypeHandlerMap> deserializers) {
+ DefaultDateTypeAdapter dateTypeAdapter = null;
+ if (datePattern != null && !"".equals(datePattern.trim())) {
+ dateTypeAdapter = new DefaultDateTypeAdapter(datePattern);
+ } else if (dateStyle != DateFormat.DEFAULT && timeStyle != DateFormat.DEFAULT) {
+ dateTypeAdapter = new DefaultDateTypeAdapter(dateStyle, timeStyle);
+ }
+
+ if (dateTypeAdapter != null) {
+ if (!serializers.hasSpecificHandlerFor(Date.class)) {
+ serializers.register(Date.class, dateTypeAdapter);
+ }
+ if (!deserializers.hasSpecificHandlerFor(Date.class)) {
+ deserializers.register(Date.class, dateTypeAdapter);
+ }
+ }
+ }
+}
diff --git a/core/src/main/java/org/jclouds/http/HttpResponseException.java b/core/src/main/java/org/jclouds/http/HttpResponseException.java
index f7e035657a..d938a8e2a9 100644
--- a/core/src/main/java/org/jclouds/http/HttpResponseException.java
+++ b/core/src/main/java/org/jclouds/http/HttpResponseException.java
@@ -19,8 +19,13 @@
package org.jclouds.http;
+import java.io.IOException;
+
import javax.annotation.Nullable;
+import org.jclouds.io.payloads.StringPayload;
+import org.jclouds.util.Utils;
+
/**
* Represents an error obtained from an HttpResponse.
*
@@ -34,15 +39,14 @@ public class HttpResponseException extends RuntimeException {
protected final HttpResponse response;
private String content;
- public HttpResponseException(String message, HttpCommand command,
- @Nullable HttpResponse response, Throwable cause) {
+ public HttpResponseException(String message, HttpCommand command, @Nullable HttpResponse response, Throwable cause) {
super(message, cause);
this.command = command;
this.response = response;
}
- public HttpResponseException(String message, HttpCommand command,
- @Nullable HttpResponse response, String content, Throwable cause) {
+ public HttpResponseException(String message, HttpCommand command, @Nullable HttpResponse response, String content,
+ Throwable cause) {
super(message, cause);
this.command = command;
this.response = response;
@@ -50,15 +54,13 @@ public class HttpResponseException extends RuntimeException {
}
public HttpResponseException(HttpCommand command, HttpResponse response, Throwable cause) {
- this(String.format("command: %1$s failed with response: %2$s", command.getRequest()
- .getRequestLine(), response.getStatusLine()), command, response, cause);
+ this(String.format("command: %1$s failed with response: %2$s", command.getRequest().getRequestLine(),
+ response.getStatusLine()), command, response, cause);
}
- public HttpResponseException(HttpCommand command, HttpResponse response, String content,
- Throwable cause) {
- this(String.format("command: %1$s failed with response: %2$s; content: [%3$s]", command
- .getRequest().getRequestLine(), response.getStatusLine()), command, response,
- content, cause);
+ public HttpResponseException(HttpCommand command, HttpResponse response, String content, Throwable cause) {
+ this(String.format("command: %1$s failed with response: %2$s; content: [%3$s]", command.getRequest()
+ .getRequestLine(), response.getStatusLine()), command, response, content, cause);
}
public HttpResponseException(String message, HttpCommand command, @Nullable HttpResponse response) {
@@ -67,8 +69,7 @@ public class HttpResponseException extends RuntimeException {
this.response = response;
}
- public HttpResponseException(String message, HttpCommand command,
- @Nullable HttpResponse response, String content) {
+ public HttpResponseException(String message, HttpCommand command, @Nullable HttpResponse response, String content) {
super(message);
this.command = command;
this.response = response;
@@ -76,14 +77,29 @@ public class HttpResponseException extends RuntimeException {
}
public HttpResponseException(HttpCommand command, HttpResponse response) {
- this(String.format("command: %1$s failed with response: %2$s", command.getRequest()
- .getRequestLine(), response.getStatusLine()), command, response);
+ this(String.format("request: %s %sfailed with response: %s", command.getRequest().getRequestLine(),
+ requestPayloadIfStringOrFormIfNotReturnEmptyString(command.getRequest()), response.getStatusLine()),
+ command, response);
+ }
+
+ static String requestPayloadIfStringOrFormIfNotReturnEmptyString(HttpRequest request) {
+ if (request.getPayload() != null
+ && ("application/x-www-form-urlencoded".equals(request.getPayload().getContentMetadata().getContentType()) || request
+ .getPayload() instanceof StringPayload)
+ && request.getPayload().getContentMetadata().getContentLength() != null
+ && request.getPayload().getContentMetadata().getContentLength() < 1024) {
+ try {
+ return String.format(" [%s] ", request.getPayload() instanceof StringPayload ? request.getPayload()
+ .getRawContent() : Utils.toStringAndClose(request.getPayload().getInput()));
+ } catch (IOException e) {
+ }
+ }
+ return "";
}
public HttpResponseException(HttpCommand command, HttpResponse response, String content) {
- this(String.format("command: %1$s failed with response: %2$s; content: [%3$s]", command
- .getRequest().getRequestLine(), response.getStatusLine(), content), command,
- response, content);
+ this(String.format("command: %s failed with response: %s; content: [%s]", command.getRequest().getRequestLine(),
+ response.getStatusLine(), content), command, response, content);
}
public HttpCommand getCommand() {
diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java
index 47bad3d042..58d016fe1b 100644
--- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java
+++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java
@@ -227,7 +227,7 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
connection.setRequestProperty(HttpHeaders.CONTENT_LENGTH, "0");
// for some reason POST/PUT undoes the content length header above.
if (connection.getRequestMethod().equals("POST") || connection.getRequestMethod().equals("PUT"))
- connection.setChunkedStreamingMode(0);
+ connection.setFixedLengthStreamingMode(0);
}
return connection;
diff --git a/core/src/main/java/org/jclouds/json/config/GsonModule.java b/core/src/main/java/org/jclouds/json/config/GsonModule.java
index 257171505a..55c3836b9b 100644
--- a/core/src/main/java/org/jclouds/json/config/GsonModule.java
+++ b/core/src/main/java/org/jclouds/json/config/GsonModule.java
@@ -38,8 +38,8 @@ import org.jclouds.json.internal.GsonWrapper;
import com.google.common.collect.Maps;
import com.google.common.primitives.Bytes;
import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import com.google.gson.JcloudsCompactFormatter;
+import com.google.gson.JcloudsGsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
@@ -64,9 +64,9 @@ public class GsonModule extends AbstractModule {
@Provides
@Singleton
Gson provideGson(JsonBallAdapter jsonObjectAdapter, DateAdapter adapter, ByteListAdapter byteListAdapter,
- ByteArrayAdapter byteArrayAdapter, JsonAdapterBindings bindings) throws SecurityException,
- NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
- GsonBuilder builder = new GsonBuilder();
+ ByteArrayAdapter byteArrayAdapter, JsonAdapterBindings bindings) throws ClassNotFoundException, Exception {
+ JcloudsGsonBuilder builder = new JcloudsGsonBuilder();
+
builder.registerTypeAdapter(JsonBall.class, jsonObjectAdapter);
builder.registerTypeAdapter(Date.class, adapter);
builder.registerTypeAdapter(new TypeToken>() {
@@ -105,7 +105,7 @@ public class GsonModule extends AbstractModule {
@Override
public List deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ throws JsonParseException {
return Bytes.asList(CryptoStreams.hex(json.getAsString()));
}
@@ -121,7 +121,7 @@ public class GsonModule extends AbstractModule {
@Override
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ throws JsonParseException {
return CryptoStreams.hex(json.getAsString());
}
@@ -145,7 +145,7 @@ public class GsonModule extends AbstractModule {
}
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ throws JsonParseException {
String toParse = json.getAsJsonPrimitive().getAsString();
try {
return dateService.iso8601DateParse(toParse);
@@ -170,7 +170,7 @@ public class GsonModule extends AbstractModule {
}
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ throws JsonParseException {
String toParse = json.getAsJsonPrimitive().getAsString();
Date toReturn = dateService.cDateParse(toParse);
return toReturn;
@@ -191,7 +191,7 @@ public class GsonModule extends AbstractModule {
}
public JsonBall deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ throws JsonParseException {
return new JsonBall(json.toString());
}
@@ -205,7 +205,7 @@ public class GsonModule extends AbstractModule {
}
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ throws JsonParseException {
long toParse = json.getAsJsonPrimitive().getAsLong();
if (toParse == -1)
return null;
diff --git a/core/src/test/java/org/jclouds/http/functions/ParseSaxTest.java b/core/src/test/java/org/jclouds/http/functions/ParseSaxTest.java
new file mode 100644
index 0000000000..c1df2737f9
--- /dev/null
+++ b/core/src/test/java/org/jclouds/http/functions/ParseSaxTest.java
@@ -0,0 +1,141 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.http.functions;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXParseException;
+
+public class ParseSaxTest extends BaseHandlerTest {
+ public static class TestHandler extends ParseSax.HandlerWithResult {
+ @Override
+ public String getResult() {
+ return "";
+ }
+ }
+
+ ParseSax createParser() {
+ return factory.create(injector.getInstance(TestHandler.class));
+ }
+
+ @Test
+ public void testAddDetailsAndPropagateOkWhenRequestWithNoDataAndRuntimeExceptionThrowsOriginalException()
+ throws ExecutionException, InterruptedException, TimeoutException, IOException {
+
+ ParseSax parser = createParser();
+ Exception input = new RuntimeException("foo");
+
+ try {
+ parser.addDetailsAndPropagate(null, input);
+ } catch (RuntimeException e) {
+ assertEquals(e, input);
+ }
+ }
+
+ @Test
+ public void testAddDetailsAndPropagateOkWhenRequestWithNoDataAndExceptionPropagates() throws ExecutionException,
+ InterruptedException, TimeoutException, IOException {
+
+ ParseSax parser = createParser();
+ Exception input = new Exception("foo");
+
+ try {
+ parser.addDetailsAndPropagate(null, input);
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(), "java.lang.Exception: foo");
+ assertEquals(e.getCause(), input);
+ }
+ }
+
+ @Test
+ public void testAddDetailsAndPropagateOkWhenRequestIsNotNullAndResponseIsNull() throws ExecutionException,
+ InterruptedException, TimeoutException, IOException {
+
+ ParseSax parser = createParser();
+ HttpRequest request = new HttpRequest("GET", URI.create("http://foohost"));
+ Exception input = new Exception("foo");
+
+ try {
+ parser.setContext(request);
+ parser.addDetailsAndPropagate(null, input);
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(), "request: GET http://foohost HTTP/1.1; cause: java.lang.Exception: foo");
+ assertEquals(e.getCause(), input);
+ }
+ }
+
+ @Test
+ public void testAddDetailsAndPropagateOkWithValidRequestResponse() throws ExecutionException, InterruptedException,
+ TimeoutException, IOException {
+
+ ParseSax parser = createParser();
+ HttpRequest request = new HttpRequest("GET", URI.create("http://foohost"));
+ HttpResponse response = new HttpResponse(304, "Not Modified", null);
+ Exception input = new Exception("foo");
+
+ try {
+ parser.setContext(request);
+ parser.addDetailsAndPropagate(response, input);
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(), "request: GET http://foohost HTTP/1.1; response: HTTP/1.1 304 Not Modified; cause: java.lang.Exception: foo");
+ assertEquals(e.getCause(), input);
+ }
+ }
+
+ @Test
+ public void testAddDetailsAndPropagateOkWithValidRequestResponseWithSAXParseException() throws ExecutionException,
+ InterruptedException, TimeoutException, IOException {
+
+ ParseSax parser = createParser();
+ HttpRequest request = new HttpRequest("GET", URI.create("http://foohost"));
+ HttpResponse response = new HttpResponse(304, "Not Modified", null);
+ Locator locator = createMock(Locator.class);
+ expect(locator.getColumnNumber()).andReturn(1);
+ expect(locator.getLineNumber()).andReturn(1);
+ expect(locator.getPublicId()).andReturn("publicId");
+ expect(locator.getSystemId()).andReturn("systemId");
+ replay(locator);
+ Exception input = new SAXParseException("foo", locator);
+ verify(locator);
+
+ try {
+ parser.setContext(request);
+ parser.addDetailsAndPropagate(response, input);
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(),
+ "request: GET http://foohost HTTP/1.1; response: HTTP/1.1 304 Not Modified; error at 1:1 in document systemId; cause: org.xml.sax.SAXParseException: foo");
+ assertEquals(e.getCause(), input);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/test/java/org/jclouds/json/JsonTest.java b/core/src/test/java/org/jclouds/json/JsonTest.java
new file mode 100644
index 0000000000..16f7e1eeee
--- /dev/null
+++ b/core/src/test/java/org/jclouds/json/JsonTest.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.json;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.json.config.GsonModule;
+import org.testng.annotations.Test;
+
+import com.google.gson.JsonParseException;
+import com.google.inject.Guice;
+
+@Test
+public class JsonTest {
+ private Json json = Guice.createInjector(new GsonModule()).getInstance(Json.class);
+
+ private static class EnumInside {
+ private static enum Test {
+ FOO, BAR;
+ }
+
+ private Test enumValue;
+ }
+
+ public void testDeserializeEnum() {
+ assertEquals(json.fromJson("{enumValue : \"FOO\"}", EnumInside.class).enumValue, EnumInside.Test.FOO);
+ }
+
+ @Test(expectedExceptions = JsonParseException.class)
+ public void testDeserializeEnumWhenBadValue() {
+ assertEquals(json.fromJson("{enumValue : \"s\"}", EnumInside.class).enumValue, EnumInside.Test.FOO);
+ }
+
+ private static class EnumInsideWithParser {
+ private static enum Test {
+ FOO, BAR, UNRECOGNIZED;
+
+ @SuppressWarnings("unused")
+ public static Test fromValue(String state) {
+ try {
+ return valueOf(state);
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+ }
+
+ private Test enumValue;
+ }
+
+ public void testDeserializeEnumWithParser() {
+ assertEquals(json.fromJson("{enumValue : \"FOO\"}", EnumInsideWithParser.class).enumValue,
+ EnumInsideWithParser.Test.FOO);
+ }
+
+ public void testDeserializeEnumWithParserAndBadValue() {
+ assertEquals(json.fromJson("{enumValue : \"sd\"}", EnumInsideWithParser.class).enumValue,
+ EnumInsideWithParser.Test.UNRECOGNIZED);
+ }
+
+}
diff --git a/demos/gae-tweetstore-spring/pom.xml b/demos/gae-tweetstore-spring/pom.xml
index 33825908e0..bc2fa22aa5 100644
--- a/demos/gae-tweetstore-spring/pom.xml
+++ b/demos/gae-tweetstore-spring/pom.xml
@@ -255,44 +255,44 @@
- twitter.identity
- ${jclouds.twitter.user}
+ test.twitter.identity
+ ${test.twitter.identity}
- twitter.credential
- ${jclouds.twitter.password}
+ test.twitter.credential
+ ${test.twitter.credential}
- azureblob.identity
- ${jclouds.azure.storage.account}
+ test.azureblob.identity
+ ${test.azureblob.identity}
- azureblob.credential
- ${jclouds.azure.storage.key}
+ test.azureblob.credential
+ ${test.azureblob.credential}
- cloudfiles.identity
- ${jclouds.rackspace.user}
+ test.cloudfiles.identity
+ ${test.cloudfiles.identity}
- cloudfiles.credential
- ${jclouds.rackspace.key}
+ test.cloudfiles.credential
+ ${test.cloudfiles.credential}
- googlestorage.identity
- ${jclouds.googlestorage.accesskeyid}
+ test.googlestorage.identity
+ ${test.googlestorage.identity}
- googlestorage.credential
- ${jclouds.googlestorage.secretaccesskey}
+ test.googlestorage.credential
+ ${test.googlestorage.credential}
- s3.identity
- ${jclouds.aws.accesskeyid}
+ test.s3.identity
+ ${test.s3.identity}
- s3.credential
- ${jclouds.aws.secretaccesskey}
+ test.s3.credential
+ ${test.s3.credential}appengine.home
diff --git a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java
index cdfebf94a3..fb11dccccd 100644
--- a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java
+++ b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java
@@ -89,8 +89,8 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
Set modules = ImmutableSet. of(googleModule);
// shared across all blobstores and used to retrieve tweets
try {
- twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
- .getProperty("credential"));
+ twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
+ props.getProperty("twitter.credential"));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
}
@@ -100,7 +100,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
// instantiate and store references to all blobstores by provider name
providerTypeToBlobStoreMap = Maps.newHashMap();
for (String hint : Splitter.on(',').split(
- checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) {
+ checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) {
providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props));
}
@@ -111,7 +111,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
queue.add(url("/store/do").header("context", name).method(Method.GET));
}
logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient,
- container, providerTypeToBlobStoreMap.keySet());
+ container, providerTypeToBlobStoreMap.keySet());
}
private Properties loadJCloudsProperties() {
@@ -139,7 +139,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
@Bean
public AddTweetsController addTweetsController() {
AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap,
- serviceToStoredTweetStatuses());
+ serviceToStoredTweetStatuses());
injectServletConfig(controller);
return controller;
}
diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java
index 79c9a43a4a..77a693d46c 100644
--- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java
+++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java
@@ -27,9 +27,9 @@ import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@@ -70,16 +70,17 @@ public class TweetStoreLiveTest {
private String container;
private static final String blobs = System.getProperty("jclouds.tweetstore.blobstores",
- "cloudfiles,googlestorage,s3,azureblob");
+ "cloudfiles,googlestorage,s3,azureblob");
private static final Iterable blobstores = Splitter.on(',').split(blobs);
private static final Properties props = new Properties();
@BeforeTest
- void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException {
+ void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
+ TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
- props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER),
- PROPERTY_TWEETSTORE_CONTAINER));
+ props.setProperty(PROPERTY_TWEETSTORE_CONTAINER,
+ checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores));
@@ -98,8 +99,8 @@ public class TweetStoreLiveTest {
contexts.put(provider, factory.createContext(provider, wiring, props));
}
- Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
- .getProperty("twitter.credential"));
+ Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
+ props.getProperty("twitter.credential"));
StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
ResponseList statuses = client.getMentions();
@@ -108,7 +109,7 @@ public class TweetStoreLiveTest {
for (BlobStoreContext context : contexts.values()) {
if (context.getBlobStore().containerExists(container)) {
System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext()
- .getEndpoint());
+ .getEndpoint());
context.getBlobStore().deleteContainer(container);
deleted = true;
}
@@ -119,7 +120,7 @@ public class TweetStoreLiveTest {
}
for (BlobStoreContext context : contexts.values()) {
System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext()
- .getEndpoint());
+ .getEndpoint());
context.getBlobStore().createContainerInLocation(null, container);
}
if (deleted) {
@@ -134,22 +135,23 @@ public class TweetStoreLiveTest {
}
private void addConfigurationForTwitter(Properties props) {
- props.setProperty("twitter.identity", checkNotNull(System.getProperty("twitter.identity"), "twitter.identity"));
- props.setProperty("twitter.credential", checkNotNull(System.getProperty("twitter.credential"),
- "twitter.credential"));
+ props.setProperty("twitter.identity",
+ checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity"));
+ props.setProperty("twitter.credential",
+ checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential"));
}
private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) {
- props.setProperty(provider + ".identity", checkNotNull(System.getProperty(provider + ".identity"), provider
- + ".identity"));
- props.setProperty(provider + ".credential", checkNotNull(System.getProperty(provider + ".credential"),
- provider + ".credential"));
+ props.setProperty(provider + ".identity",
+ checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"));
+ props.setProperty(provider + ".credential",
+ checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential"));
}
}
@BeforeTest
- @Parameters( { "warfile", "devappserver.address", "devappserver.port" })
+ @Parameters({ "warfile", "devappserver.address", "devappserver.port" })
public void startDevAppServer(final String warfile, final String address, final String port) throws Exception {
url = new URL(String.format("http://%s:%s", address, port));
server = new GoogleDevServer();
diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java
index cbd5dd0538..5c06ae6ee8 100755
--- a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java
+++ b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java
@@ -79,7 +79,7 @@ public class GuiceServletConfig extends GuiceServletContextListener {
// shared across all blobstores and used to retrieve tweets
try {
twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
- .getProperty("credential"));
+ .getProperty("twitter.credential"));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
}
diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java
index a6e0700e32..1ac1f1d10f 100755
--- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java
+++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java
@@ -27,9 +27,9 @@ import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@@ -57,8 +57,8 @@ import com.google.common.collect.Maps;
import com.google.inject.Module;
/**
- * Starts up the Google App Engine for Java Development environment and deploys
- * an application which tests accesses twitter and blobstores.
+ * Starts up the Google App Engine for Java Development environment and deploys an application which
+ * tests accesses twitter and blobstores.
*
* @author Adrian Cole
*/
@@ -75,11 +75,12 @@ public class TweetStoreLiveTest {
private static final Properties props = new Properties();
@BeforeTest
- void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException {
+ void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
+ TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
- props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER),
- PROPERTY_TWEETSTORE_CONTAINER));
+ props.setProperty(PROPERTY_TWEETSTORE_CONTAINER,
+ checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores));
@@ -98,8 +99,8 @@ public class TweetStoreLiveTest {
contexts.put(provider, factory.createContext(provider, wiring, props));
}
- Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
- .getProperty("twitter.credential"));
+ Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
+ props.getProperty("twitter.credential"));
StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
ResponseList statuses = client.getMentions();
@@ -139,7 +140,7 @@ public class TweetStoreLiveTest {
}
@BeforeTest(dependsOnMethods = "clearAndCreateContainers")
- @Parameters( { "warfile", "devappserver.address", "devappserver.port" })
+ @Parameters({ "warfile", "devappserver.address", "devappserver.port" })
public void startDevAppServer(final String warfile, final String address, final String port) throws Exception {
url = new URL(String.format("http://%s:%s", address, port));
@@ -148,17 +149,17 @@ public class TweetStoreLiveTest {
}
private void addConfigurationForTwitter(Properties props) {
- props.setProperty("twitter.identity", checkNotNull(System.getProperty("twitter.identity"), "twitter.identity"));
- props.setProperty("twitter.credential", checkNotNull(System.getProperty("twitter.credential"),
- "twitter.credential"));
+ props.setProperty("twitter.identity", checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity"));
+ props.setProperty("twitter.credential",
+ checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential"));
}
private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) {
- props.setProperty(provider + ".identity", checkNotNull(System.getProperty(provider + ".identity"), provider
- + ".identity"));
- props.setProperty(provider + ".credential", checkNotNull(System.getProperty(provider + ".credential"),
- provider + ".credential"));
+ props.setProperty(provider + ".identity",
+ checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"));
+ props.setProperty(provider + ".credential",
+ checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential"));
}
}
diff --git a/filesystem/src/main/java/org/jclouds/filesystem/reference/FilesystemConstants.java b/filesystem/src/main/java/org/jclouds/filesystem/reference/FilesystemConstants.java
index c8afc9ae05..cab89f5bf2 100644
--- a/filesystem/src/main/java/org/jclouds/filesystem/reference/FilesystemConstants.java
+++ b/filesystem/src/main/java/org/jclouds/filesystem/reference/FilesystemConstants.java
@@ -27,6 +27,6 @@ package org.jclouds.filesystem.reference;
public class FilesystemConstants {
/** Specify the base directory where provider starts its file operations - must exists */
- public static final String PROPERTY_BASEDIR = "FileSystemAsyncBlobStore-basedir";
-
+ public static final String PROPERTY_BASEDIR = "jclouds.filesystem.basedir";
+
}
diff --git a/gogrid/pom.xml b/gogrid/pom.xml
index 24bf36665d..bcd69c7262 100644
--- a/gogrid/pom.xml
+++ b/gogrid/pom.xml
@@ -40,7 +40,7 @@
- trmkrun-ccc,test.trmk-924
+ trmkrun-ccc,test.trmk-924https://api.gogrid.com/api1.5FIXME
@@ -119,8 +119,8 @@
${test.gogrid.credential}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java b/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java
index 7d8f2fc9f9..b715f25771 100644
--- a/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java
+++ b/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java
@@ -19,6 +19,7 @@
package org.jclouds.gogrid.compute.suppliers;
+import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -34,6 +35,7 @@ import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
+import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.gogrid.GoGridClient;
import org.jclouds.gogrid.domain.ServerImage;
import org.jclouds.logging.Logger;
@@ -56,9 +58,12 @@ public class GoGridImageSupplier implements Supplier> {
private final GoGridClient sync;
private final PopulateDefaultLoginCredentialsForImageStrategy authenticator;
+ private final Map> osVersionMap;
@Inject
- GoGridImageSupplier(final GoGridClient sync, PopulateDefaultLoginCredentialsForImageStrategy authenticator) {
+ GoGridImageSupplier(GoGridClient sync, PopulateDefaultLoginCredentialsForImageStrategy authenticator,
+ Map> osVersionMap) {
+ this.osVersionMap = osVersionMap;
this.sync = sync;
this.authenticator = authenticator;
}
@@ -85,29 +90,28 @@ public class GoGridImageSupplier implements Supplier> {
OsFamily osFamily = null;
String osName = from.getOs().getName();
String osArch = from.getArchitecture().getDescription();
- String osVersion = parseVersion(osName);
+ String osVersion = null;
String osDescription = from.getOs().getDescription();
boolean is64Bit = (from.getOs().getName().indexOf("64") != -1 || from.getDescription().indexOf("64") != -1);
- Matcher matcher = GOGRID_OS_PATTERN.matcher(from.getName());
- if (matcher.find()) {
- try {
- osFamily = OsFamily.fromValue(matcher.group(1).toLowerCase());
- } catch (IllegalArgumentException e) {
- logger.debug("<< didn't match os(%s)", from.getName());
+ if (osName.startsWith("Windows")) {
+ osFamily = OsFamily.WINDOWS;
+ } else {
+ Matcher matcher = GOGRID_OS_PATTERN.matcher(from.getName());
+ if (matcher.find()) {
+ try {
+ osFamily = OsFamily.fromValue(matcher.group(1).toLowerCase());
+ } catch (IllegalArgumentException e) {
+ logger.debug("<< didn't match os(%s)", from.getName());
+ }
}
}
-
- // TODO determine DC images are in
- OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
- return os;
- }
-
- static String parseVersion(String name) {
- Matcher matcher = GOGRID_VERSION_PATTERN.matcher(name);
+ Matcher matcher = GOGRID_VERSION_PATTERN.matcher(osName);
if (matcher.find()) {
- return matcher.group(1);
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap);
}
- return null;
+ // TODO determine DC images are in
+ return new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
}
+
}
\ No newline at end of file
diff --git a/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java
new file mode 100644
index 0000000000..ab09cf3337
--- /dev/null
+++ b/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.gogrid.compute;
+
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.compute.BaseTemplateBuilderLiveTest;
+import org.jclouds.compute.OsFamilyVersion64Bit;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "gogrid.GoGridTemplateBuilderLiveTest")
+public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+
+ public GoGridTemplateBuilderLiveTest() {
+ provider = "gogrid";
+ }
+
+ @Override
+ protected Predicate defineUnsupportedOperatingSystems() {
+ return new Predicate() {
+
+ @Override
+ public boolean apply(OsFamilyVersion64Bit input) {
+ return ((input.family == OsFamily.RHEL && !input.version.equals("5.4")) || //
+ (input.family == OsFamily.CENTOS && input.version.matches("5.[54]")) || //
+ (input.family == OsFamily.CENTOS && input.is64Bit && input.version.equals("5.4")) || //
+ (input.family == OsFamily.UBUNTU) || //
+ (input.family == OsFamily.WINDOWS && input.version.equals("2008 SP2") || //
+ (input.family == OsFamily.WINDOWS && input.version.equals("2008 R2"))));
+ }
+
+ };
+ }
+
+ @Test
+ public void testDefaultTemplateBuilder() throws IOException {
+ Template defaultTemplate = context.getComputeService().templateBuilder().build();
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.3");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
+ assertEquals(getCores(defaultTemplate.getHardware()), 0.5d);
+ }
+
+}
\ No newline at end of file
diff --git a/rackspace/pom.xml b/rackspace/pom.xml
index b59c1b321d..2e5dcd08d6 100644
--- a/rackspace/pom.xml
+++ b/rackspace/pom.xml
@@ -38,7 +38,7 @@
FIXMEorg.jclouds.rackspace.cloudfiles.blobstore.integration.CloudFilesTestInitializer
- trmkrun-ccc,test.trmk-924
+ trmkrun-ccc,test.trmk-924${test.rackspace.endpoint}${test.rackspace.apiversion}${test.rackspace.identity}
@@ -151,8 +151,8 @@
${test.cloudservers.credential}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}test.initializer
diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java
index 96e02eb531..91be884115 100755
--- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java
+++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java
@@ -19,14 +19,9 @@
package org.jclouds.rackspace.cloudservers.compute.config;
-import static org.jclouds.compute.domain.OsFamily.UBUNTU;
-
import org.jclouds.compute.config.BaseComputeServiceContextModule;
-import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.BaseComputeService;
-import com.google.inject.Injector;
-
/**
* Configures the {@link CloudServersComputeServiceContext}; requires {@link BaseComputeService}
* bound.
@@ -43,8 +38,4 @@ public class CloudServersComputeServiceContextModule extends BaseComputeServiceC
super.configure();
}
- @Override
- protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
- return template.osFamily(UBUNTU).imageNameMatches(".*10\\.?04.*");
- }
}
diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToOperatingSystem.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToOperatingSystem.java
index be3f50fb84..0ec8016fed 100644
--- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToOperatingSystem.java
+++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToOperatingSystem.java
@@ -19,16 +19,19 @@
package org.jclouds.rackspace.cloudservers.compute.functions;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
+import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
@@ -40,11 +43,20 @@ import com.google.common.base.Function;
@Singleton
public class CloudServersImageToOperatingSystem implements
Function {
- public static final Pattern RACKSPACE_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
+ public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
+ // Windows Server 2008 R2 x64
+ public static final Pattern WINDOWS_PATTERN = Pattern.compile("Windows (.*) (x[86][64])");
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
+
+ private final Map> osVersionMap;
+
+ @Inject
+ public CloudServersImageToOperatingSystem(Map> osVersionMap) {
+ this.osVersionMap = osVersionMap;
+ }
public OperatingSystem apply(final org.jclouds.rackspace.cloudservers.domain.Image from) {
OsFamily osFamily = null;
@@ -53,21 +65,28 @@ public class CloudServersImageToOperatingSystem implements
String osVersion = null;
String osDescription = from.getName();
boolean is64Bit = true;
- Matcher matcher = RACKSPACE_PATTERN.matcher(from.getName());
if (from.getName().indexOf("Red Hat EL") != -1) {
osFamily = OsFamily.RHEL;
} else if (from.getName().indexOf("Oracle EL") != -1) {
osFamily = OsFamily.OEL;
- }
- if (matcher.find()) {
- try {
- osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
- } catch (IllegalArgumentException e) {
- logger.debug("<< didn't match os(%s)", matcher.group(2));
+ } else if (from.getName().indexOf("Windows") != -1) {
+ osFamily = OsFamily.WINDOWS;
+ Matcher matcher = WINDOWS_PATTERN.matcher(from.getName());
+ if (matcher.find()) {
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap);
+ is64Bit = matcher.group(2).equals("x64");
+ }
+ } else {
+ Matcher matcher = DEFAULT_PATTERN.matcher(from.getName());
+ if (matcher.find()) {
+ try {
+ osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
+ } catch (IllegalArgumentException e) {
+ logger.debug("<< didn't match os(%s)", matcher.group(2));
+ }
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap);
}
- osVersion = matcher.group(3);
}
- OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
- return os;
+ return new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
}
}
\ No newline at end of file
diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java
index 6c669adf78..ad757b5826 100644
--- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java
+++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java
@@ -52,7 +52,7 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "9.10");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DFW1");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
@@ -66,7 +66,7 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext tmContext = new ComputeServiceContextFactory()
- .createContext(provider, identity, credential).getProviderSpecificContext();
+ .createContext(provider, identity, credential).getProviderSpecificContext();
}
@Override
@@ -82,4 +82,21 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
super.testSuspendResume();
}
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testGetNodesWithDetails() throws Exception {
+ super.testGetNodesWithDetails();
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testListNodes() throws Exception {
+ super.testListNodes();
+ }
+
+ @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" })
+ @Override
+ public void testDestroyNodes() {
+ super.testDestroyNodes();
+ }
}
\ No newline at end of file
diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java
new file mode 100644
index 0000000000..0eb104d29a
--- /dev/null
+++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.rackspace.cloudservers.compute;
+
+import org.jclouds.compute.BaseTemplateBuilderLiveTest;
+import org.jclouds.compute.OsFamilyVersion64Bit;
+import org.jclouds.compute.domain.OsFamily;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "cloudservers.CloudServersTemplateBuilderLiveTest")
+public class CloudServersTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+
+ public CloudServersTemplateBuilderLiveTest() {
+ provider = "cloudservers";
+ }
+
+ @Override
+ protected Predicate defineUnsupportedOperatingSystems() {
+ return new Predicate() {
+
+ @Override
+ public boolean apply(OsFamilyVersion64Bit input) {
+ return (input.family != OsFamily.WINDOWS && !input.is64Bit) || //
+ input.family == OsFamily.RHEL || //
+ (input.family == OsFamily.UBUNTU && input.version.equals("11.04")) || //
+ (input.family == OsFamily.CENTOS && input.version.matches("5.[23]")) || //
+ (input.family == OsFamily.WINDOWS && input.version.equals("2008")) || //
+ (input.family == OsFamily.WINDOWS && input.version.equals("2008 R2") && !input.is64Bit);
+ }
+
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToImageTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToImageTest.java
index 3b2ab4c81d..99c4fb9bd5 100644
--- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToImageTest.java
+++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/CloudServersImageToImageTest.java
@@ -23,14 +23,20 @@ import static org.testng.Assert.assertEquals;
import java.net.UnknownHostException;
+import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials;
+import org.jclouds.json.Json;
+import org.jclouds.json.config.GsonModule;
import org.jclouds.rackspace.cloudservers.functions.ParseImageFromJsonResponseTest;
import org.testng.annotations.Test;
+import com.google.inject.Guice;
+
/**
* @author Adrian Cole
*/
@@ -52,7 +58,9 @@ public class CloudServersImageToImageTest {
public static Image convertImage() {
org.jclouds.rackspace.cloudservers.domain.Image image = ParseImageFromJsonResponseTest.parseImage();
- CloudServersImageToImage parser = new CloudServersImageToImage(new CloudServersImageToOperatingSystem());
+ CloudServersImageToImage parser = new CloudServersImageToImage(new CloudServersImageToOperatingSystem(new BaseComputeServiceContextModule() {
+ }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
+ .getInstance(Json.class))));
return parser.apply(image);
}
diff --git a/rimuhosting/pom.xml b/rimuhosting/pom.xml
index ed70bcad8d..8915c0eed5 100644
--- a/rimuhosting/pom.xml
+++ b/rimuhosting/pom.xml
@@ -40,8 +40,8 @@
- trmkrun-ccc,test.trmk-924
- https://rimuhosting.com/r
+ trmkrun-ccc,test.trmk-924
+ https://api.rimuhosting.com/r1.0FIXME
@@ -114,8 +114,8 @@
${test.rimuhosting.identity}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java
index 57bf048d9a..3d6a451c00 100644
--- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java
+++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java
@@ -39,6 +39,7 @@ import org.jclouds.rest.annotations.MatrixParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.Unwrap;
+import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rimuhosting.miro.binder.CreateServerOptions;
import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder;
import org.jclouds.rimuhosting.miro.domain.Image;
@@ -66,6 +67,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see
*/
@RequestFilters(RimuHostingAuthentication.class)
+@VirtualHost
public interface RimuHostingAsyncClient {
/**
@@ -74,7 +76,6 @@ public interface RimuHostingAsyncClient {
@GET
@Path("/distributions")
@ResponseParser(ParseImagesFromJsonResponse.class)
- @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ParseRimuHostingException.class)
ListenableFuture> getImageList();
@@ -86,7 +87,6 @@ public interface RimuHostingAsyncClient {
@Path("/orders")
@ResponseParser(ParseServersFromJsonResponse.class)
@MatrixParams(keys = "include_inactive", values = "N")
- @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ParseRimuHostingException.class)
ListenableFuture> getServerList();
diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java
index acf507980a..36a395af2e 100644
--- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java
+++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java
@@ -37,7 +37,7 @@ public class RimuHostingPropertiesBuilder extends PropertiesBuilder {
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, "TODO");
- properties.setProperty(PROPERTY_ENDPOINT, "https://rimuhosting.com/r");
+ properties.setProperty(PROPERTY_ENDPOINT, "https://api.rimuhosting.com/r");
properties.setProperty(PROPERTY_RIMUHOSTING_DEFAULT_DC, "DCDALLAS");
return properties;
}
diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java
index 5421e5511f..02020e68c2 100755
--- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java
+++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java
@@ -19,9 +19,6 @@
package org.jclouds.rimuhosting.miro.compute.config;
-import static org.jclouds.compute.domain.OsFamily.UBUNTU;
-
-
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.TemplateBuilder;
@@ -45,7 +42,7 @@ public class RimuHostingComputeServiceContextModule extends BaseComputeServiceCo
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
- return template.hardwareId("MIRO1B").osFamily(UBUNTU).os64Bit(false).osVersionMatches("9.10");
+ return super.provideTemplate(injector, template).hardwareId("MIRO4B");
}
}
diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java
index 919e2fe870..7d25b9d32e 100644
--- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java
+++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java
@@ -51,13 +51,13 @@ public class RimuHostingAsyncClientTest extends RestClientTest httpRequest = processor.createRequest(method, "test.ivan.api.com",
- "lenny", "MIRO1B");
+ "lenny", "MIRO4B");
- assertRequestLineEquals(httpRequest, "POST https://rimuhosting.com/r/orders/new-vps HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertRequestLineEquals(httpRequest, "POST https://api.rimuhosting.com/r/orders/new-vps HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nHost: api.rimuhosting.com\n");
assertPayloadEquals(
httpRequest,
- "{\"request\":{\"instantiation_options\":{\"distro\":\"lenny\",\"domain_name\":\"test.ivan.api.com\"},\"pricing_plan_code\":\"MIRO1B\",\"meta_data\":[]}}",
+ "{\"request\":{\"instantiation_options\":{\"distro\":\"lenny\",\"domain_name\":\"test.ivan.api.com\"},\"pricing_plan_code\":\"MIRO4B\",\"meta_data\":[]}}",
"application/json", false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java
index 7c7a0ea22d..45fc4a4fb5 100644
--- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java
+++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java
@@ -115,7 +115,7 @@ public class RimuHostingClientLiveTest {
@Test
public void testLifeCycle() {
// Get the first image, we dont really care what it is in this test.
- NewServerResponse serverResponse = connection.createServer("test.ivan.api.com", "lenny", "MIRO1B");
+ NewServerResponse serverResponse = connection.createServer("test.ivan.api.com", "lenny", "MIRO4B");
Server server = serverResponse.getServer();
// Now we have the server, lets restart it
assertNotNull(server.getId());
diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java
index 2116ea9e87..49e6ed4b70 100755
--- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java
+++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java
@@ -48,10 +48,10 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "9.10");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DCDALLAS");
- assertEquals(defaultTemplate.getHardware().getProviderId(), "MIRO1B");
+ assertEquals(defaultTemplate.getHardware().getProviderId(), "MIRO4B");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
@@ -60,4 +60,4 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes
return new JschSshClientModule();
}
-}
\ No newline at end of file
+}
diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java
new file mode 100644
index 0000000000..4206b962db
--- /dev/null
+++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.rimuhosting.miro.compute;
+
+import org.jclouds.compute.BaseTemplateBuilderLiveTest;
+import org.jclouds.compute.OsFamilyVersion64Bit;
+import org.jclouds.compute.domain.OsFamily;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "rimuhosting.RimuHostingTemplateBuilderLiveTest")
+public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+
+ public RimuHostingTemplateBuilderLiveTest() {
+ provider = "rimuhosting";
+ }
+
+ @Override
+ protected Predicate defineUnsupportedOperatingSystems() {
+ return new Predicate() {
+
+ @Override
+ public boolean apply(OsFamilyVersion64Bit input) {
+ return input.family != OsFamily.UBUNTU || //
+ Float.parseFloat(input.version) > 10.04 || //
+ (!(input.is64Bit) && Float.parseFloat(input.version) < 8.10);
+ }
+
+ };
+ }
+}
\ No newline at end of file
diff --git a/skeletons/standalone-compute/pom.xml b/skeletons/standalone-compute/pom.xml
index d65f9ef182..c255c52cdc 100644
--- a/skeletons/standalone-compute/pom.xml
+++ b/skeletons/standalone-compute/pom.xml
@@ -32,7 +32,7 @@
jclouds example components for a standalone compute provider
- trmkrun-ccc,test.trmk-924
+ trmkrun-ccc,test.trmk-924FIXMEhttps://servermanager.com1.0
@@ -108,8 +108,8 @@
${test.servermanager.identity}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/slicehost/pom.xml b/slicehost/pom.xml
index 4105e0a851..b048dd7c46 100644
--- a/slicehost/pom.xml
+++ b/slicehost/pom.xml
@@ -32,7 +32,7 @@
jclouds slicehost components
- trmkrun-ccc,test.trmk-924
+ trmkrun-ccc,test.trmk-924https://api.slicehost.com1.4.1.1FIXME
@@ -107,8 +107,8 @@
${test.slicehost.identity}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java b/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java
index 15ff8b0d15..ca21e49616 100644
--- a/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java
+++ b/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java
@@ -19,14 +19,11 @@
package org.jclouds.slicehost.compute.config;
-import static org.jclouds.compute.domain.OsFamily.UBUNTU;
-
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
-import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.BaseComputeService;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
@@ -34,7 +31,6 @@ import org.jclouds.domain.internal.LocationImpl;
import org.jclouds.rest.annotations.Provider;
import com.google.common.collect.ImmutableSet;
-import com.google.inject.Injector;
import com.google.inject.Provides;
/**
@@ -51,11 +47,6 @@ public class SlicehostComputeServiceContextModule extends BaseComputeServiceCont
return new LocationImpl(LocationScope.ZONE, "DFW1", "Dallas, TX", provider);
}
- @Override
- protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
- return template.osFamily(UBUNTU).os64Bit(true);
- }
-
@Provides
@Singleton
Set extends Location> provideLocations(Location location) {
diff --git a/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java b/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java
index a9486f752e..543fda05aa 100644
--- a/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java
+++ b/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SlicehostImageToOperatingSystem.java
@@ -19,16 +19,19 @@
package org.jclouds.slicehost.compute.functions;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
+import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
@@ -38,14 +41,22 @@ import com.google.common.base.Function;
* @author Adrian Cole
*/
@Singleton
-public class SlicehostImageToOperatingSystem implements
- Function {
- public static final Pattern SLICEHOST_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
+public class SlicehostImageToOperatingSystem implements Function {
+ public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
+ // Windows Server 2008 R2 x64
+ public static final Pattern WINDOWS_PATTERN = Pattern.compile("Windows (.*) (x[86][64])");
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
+ private final Map> osVersionMap;
+
+ @Inject
+ public SlicehostImageToOperatingSystem(Map> osVersionMap) {
+ this.osVersionMap = osVersionMap;
+ }
+
public OperatingSystem apply(final org.jclouds.slicehost.domain.Image from) {
OsFamily osFamily = null;
String osName = null;
@@ -57,17 +68,24 @@ public class SlicehostImageToOperatingSystem implements
osFamily = OsFamily.RHEL;
} else if (from.getName().indexOf("Oracle EL") != -1) {
osFamily = OsFamily.OEL;
- }
- Matcher matcher = SLICEHOST_PATTERN.matcher(from.getName());
- if (matcher.find()) {
- try {
- osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
- } catch (IllegalArgumentException e) {
- logger.debug("<< didn't match os(%s)", matcher.group(2));
+ } else if (from.getName().indexOf("Windows") != -1) {
+ osFamily = OsFamily.WINDOWS;
+ Matcher matcher = WINDOWS_PATTERN.matcher(from.getName());
+ if (matcher.find()) {
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap);
+ is64Bit = matcher.group(2).equals("x64");
+ }
+ } else {
+ Matcher matcher = DEFAULT_PATTERN.matcher(from.getName());
+ if (matcher.find()) {
+ try {
+ osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
+ } catch (IllegalArgumentException e) {
+ logger.debug("<< didn't match os(%s)", matcher.group(2));
+ }
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap);
}
- osVersion = matcher.group(3);
}
- OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
- return os;
+ return new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
}
}
\ No newline at end of file
diff --git a/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java
index a120662bff..aa9de7cb58 100644
--- a/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java
+++ b/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java
@@ -32,6 +32,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.Constants;
+import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payloads;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@@ -77,7 +78,7 @@ public class SlicehostClientLiveTest {
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
- + ".apiversion");
+ + ".apiversion");
}
protected Properties setupProperties() {
@@ -96,8 +97,7 @@ public class SlicehostClientLiveTest {
Properties overrides = setupProperties();
Injector injector = new RestContextFactory().createContextBuilder(provider,
- ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides)
- .buildInjector();
+ ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector();
client = injector.getInstance(SlicehostClient.class);
sshFactory = injector.getInstance(SshClient.Factory.class);
@@ -252,7 +252,7 @@ public class SlicehostClientLiveTest {
private void blockUntilSliceActive(int sliceId) throws InterruptedException {
Slice currentDetails = null;
for (currentDetails = client.getSlice(sliceId); currentDetails.getStatus() != Slice.Status.ACTIVE; currentDetails = client
- .getSlice(sliceId)) {
+ .getSlice(sliceId)) {
System.out.printf("blocking on status active%n%s%n", currentDetails);
Thread.sleep(5 * 1000);
}
@@ -286,7 +286,7 @@ public class SlicehostClientLiveTest {
IPSocket socket = new IPSocket(ip, 22);
socketTester.apply(socket);
- SshClient client = sshFactory.create(socket, "root", pass);
+ SshClient client = sshFactory.create(socket, new Credentials("root", pass));
try {
client.connect();
client.put("/etc/jclouds.txt", Payloads.newStringPayload("slicehost"));
diff --git a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java
index 05ebe60d0b..bc635d579d 100644
--- a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java
+++ b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java
@@ -48,7 +48,7 @@ public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "9.10");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DFW1");
assertEquals(getCores(defaultTemplate.getHardware()), 0.25d);
@@ -62,6 +62,29 @@ public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext tmContext = new ComputeServiceContextFactory().createContext(
- provider, identity, credential).getProviderSpecificContext();
+ provider, identity, credential).getProviderSpecificContext();
+ }
+
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void testSuspendResume() throws Exception {
+ super.testSuspendResume();
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testGetNodesWithDetails() throws Exception {
+ super.testGetNodesWithDetails();
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testListNodes() throws Exception {
+ super.testListNodes();
+ }
+
+ @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" })
+ @Override
+ public void testDestroyNodes() {
+ super.testDestroyNodes();
}
}
diff --git a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java
new file mode 100644
index 0000000000..cf88d5ac72
--- /dev/null
+++ b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java
@@ -0,0 +1,70 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.slicehost.compute;
+
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.compute.BaseTemplateBuilderLiveTest;
+import org.jclouds.compute.OsFamilyVersion64Bit;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "slicehost.SlicehostTemplateBuilderLiveTest")
+public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+
+ public SlicehostTemplateBuilderLiveTest() {
+ provider = "slicehost";
+ }
+
+ @Override
+ protected Predicate defineUnsupportedOperatingSystems() {
+ return new Predicate() {
+
+ @Override
+ public boolean apply(OsFamilyVersion64Bit input) {
+ return (input.family == OsFamily.RHEL || //
+ (input.family == OsFamily.UBUNTU && input.version.equals("11.04")) || //
+ (input.family == OsFamily.CENTOS && input.version.matches("5.[23]")) || //
+ (input.family == OsFamily.WINDOWS && !(input.is64Bit && input.version.equals("2008 R2"))//
+ && !(!input.is64Bit && input.version.equals("2008 SP2"))));
+ }
+
+ };
+ }
+
+ @Test
+ public void testDefaultTemplateBuilder() throws IOException {
+ Template defaultTemplate = context.getComputeService().templateBuilder().build();
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+ assertEquals(getCores(defaultTemplate.getHardware()), 0.25d);
+ }
+}
\ No newline at end of file
diff --git a/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java b/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java
index a02238bcef..60e327be7e 100644
--- a/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java
+++ b/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java
@@ -23,17 +23,23 @@ import static org.testng.Assert.assertEquals;
import java.net.UnknownHostException;
+import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl;
+import org.jclouds.json.Json;
+import org.jclouds.json.config.GsonModule;
import org.jclouds.slicehost.xml.ImageHandlerTest;
import org.testng.annotations.Test;
+import com.google.inject.Guice;
+
/**
* @author Adrian Cole
*/
@@ -43,20 +49,27 @@ public class SlicehostImageToImageTest {
@Test
public void test() throws UnknownHostException {
- assertEquals(convertImage(), new ImageBuilder().name("CentOS 5.2").operatingSystem(
- new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(
- true).build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null)).ids(
- "2").build());
+ assertEquals(
+ convertImage(),
+ new ImageBuilder()
+ .name("CentOS 5.2")
+ .operatingSystem(
+ new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2")
+ .is64Bit(true).build()).description("CentOS 5.2")
+ .defaultCredentials(new Credentials("root", null)).ids("2").build());
}
@Test
public void test32() throws UnknownHostException {
- assertEquals(convertImage("/test_get_image32.xml"), new ImageBuilder().name("Ubuntu 10.10 (maverick) 32-bit")
- .operatingSystem(
- new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("10.10").description(
- "Ubuntu 10.10 (maverick) 32-bit").build()).description(
- "Ubuntu 10.10 (maverick) 32-bit").defaultCredentials(new Credentials("root", null)).ids("70")
- .build());
+ assertEquals(
+ convertImage("/test_get_image32.xml"),
+ new ImageBuilder()
+ .name("Ubuntu 10.10 (maverick) 32-bit")
+ .operatingSystem(
+ new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("10.10")
+ .description("Ubuntu 10.10 (maverick) 32-bit").build())
+ .description("Ubuntu 10.10 (maverick) 32-bit").defaultCredentials(new Credentials("root", null))
+ .ids("70").build());
}
public static Image convertImage() {
@@ -66,7 +79,10 @@ public class SlicehostImageToImageTest {
public static Image convertImage(String resource) {
org.jclouds.slicehost.domain.Image image = ImageHandlerTest.parseImage(resource);
- SlicehostImageToImage parser = new SlicehostImageToImage(new SlicehostImageToOperatingSystem());
+ SlicehostImageToImage parser = new SlicehostImageToImage(new SlicehostImageToOperatingSystem(
+ new BaseComputeServiceContextModule() {
+ }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
+ .getInstance(Json.class))));
return parser.apply(image);
}
diff --git a/vcloud/bluelock/pom.xml b/vcloud/bluelock/pom.xml
index 7a978a21c6..75c49003af 100644
--- a/vcloud/bluelock/pom.xml
+++ b/vcloud/bluelock/pom.xml
@@ -34,7 +34,7 @@
-
+ https://vcenterprise.bluelock.com/api1.0FIXME
@@ -95,8 +95,8 @@
${test.bluelock-vcdirector.credential}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java
index 5a216d0ead..6eebfa0a8e 100644
--- a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java
+++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java
@@ -49,10 +49,10 @@ public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeS
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
- assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem());
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (32-bit)");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (64-bit)");
assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation();
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
System.out.println(defaultTemplate.getHardware());
diff --git a/vcloud/core/pom.xml b/vcloud/core/pom.xml
index 3abc2e44cd..2a2b87a308 100644
--- a/vcloud/core/pom.xml
+++ b/vcloud/core/pom.xml
@@ -32,7 +32,7 @@
jclouds Core components to access vcloud
- trmkrun-ccc,test.trmk-924
+ trmkrun-ccc,test.trmk-924https://66.45.200.97/api1.0FIXME
@@ -91,8 +91,8 @@
${test.vcloud.credential}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java
index 16a2ba0a81..8d9ba099b6 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java
@@ -20,6 +20,8 @@
package org.jclouds.vcloud.compute.config;
+import static org.jclouds.compute.domain.OsFamily.UBUNTU;
+
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.config.BindComputeStrategiesByClass;
import org.jclouds.compute.config.BindComputeSuppliersByClass;
@@ -44,6 +46,7 @@ import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.VApp;
import com.google.common.base.Function;
+import com.google.inject.Injector;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
@@ -79,7 +82,13 @@ public class VCloudComputeServiceContextModule extends CommonVCloudComputeServic
});
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(GetLoginCredentialsFromGuestConfiguration.class);
}
-
+
+ //CIM ostype does not include version info
+ @Override
+ protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
+ return template.osFamily(UBUNTU).os64Bit(true);
+ }
+
@Override
public BindComputeStrategiesByClass defineComputeStrategyModule() {
return new VCloudBindComputeStrategiesByClass();
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVCloudExpressVAppTemplate.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVCloudExpressVAppTemplate.java
index b6e6dd8ad7..1895b2cef5 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVCloudExpressVAppTemplate.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVCloudExpressVAppTemplate.java
@@ -22,6 +22,7 @@ package org.jclouds.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrNull;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -31,7 +32,9 @@ import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystemBuilder;
+import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
+import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
@@ -45,9 +48,13 @@ public class ImageForVCloudExpressVAppTemplate implements Function> osVersionMap;
+
@Inject
protected ImageForVCloudExpressVAppTemplate(FindLocationForResource findLocationForResource,
- PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) {
+ PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
+ Map> osVersionMap) {
+ this.osVersionMap = osVersionMap;
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
}
@@ -74,12 +81,13 @@ public class ImageForVCloudExpressVAppTemplate implements Function of(new Log4JLoggingModule()), overrides).getComputeService();
+ ImmutableSet. of(new Log4JLoggingModule()), overrides).getComputeService();
socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 60, 1, TimeUnit.SECONDS);
sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class);
}
@@ -128,7 +129,7 @@ public class VCloudGuestCustomizationLiveTest {
try {
ssh.connect();
- assertEquals(ssh.exec(PARSE_VMTOOLSD).getOutput(), script);
+ assertEquals(ssh.exec(PARSE_VMTOOLSD).getOutput(), script.replaceAll("\n", "\r\n"));
assertEquals(ssh.exec("cat /root/foo.txt").getOutput().trim(), "I love candy");
} finally {
diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java
index 0908cf7c86..6ed6f83234 100644
--- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java
+++ b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java
@@ -71,4 +71,15 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}
}
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testGetNodesWithDetails() throws Exception {
+ super.testGetNodesWithDetails();
+ }
+
+ @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" })
+ @Override
+ public void testDestroyNodes() {
+ super.testDestroyNodes();
+ }
}
\ No newline at end of file
diff --git a/vcloud/terremark/pom.xml b/vcloud/terremark/pom.xml
index 613d21b536..fe0ca133a4 100644
--- a/vcloud/terremark/pom.xml
+++ b/vcloud/terremark/pom.xml
@@ -32,7 +32,7 @@
jclouds Core components to access terremark
- trmkrun-ccc,test.trmk-924
+ trmkrun-ccc,test.trmk-924https://services.vcloudexpress.terremark.com/api0.8a-ext1.6FIXME
@@ -114,8 +114,8 @@
${test.trmk-ecloud.credential}
- jclouds.compute.blacklist.nodes
- ${jclouds.compute.blacklist.nodes}
+ jclouds.compute.blacklist-nodes
+ ${jclouds.compute.blacklist-nodes}
diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClient.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClient.java
index a812be12d8..d2d6658990 100644
--- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClient.java
+++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClient.java
@@ -217,7 +217,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
try {
client.deletePublicIp(address.getId());
logger.debug("<< deleted PublicIpAddress(%s)", address.getId());
- } catch (UnsupportedOperationException e) {
+ } catch (Exception e) {
logger.trace("cannot delete PublicIpAddress(%s) as it is unsupported", address.getId());
}
continue IPADDRESS;
diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java
index 017c798f46..1afcc45c64 100644
--- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java
+++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java
@@ -29,7 +29,11 @@ import com.google.inject.Injector;
* @author Adrian Cole
*/
public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudComputeServiceContextModule {
+
+ // as of 6-nov-2010 only centos has ssh key injection in the images.
+ // ssh key injection in ubuntu is targeted for dec-2010 or sooner
+ @Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
- return template.osFamily(CENTOS);
+ return template.osFamily(CENTOS).os64Bit(true);
}
}
diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java
index 0d84ab905c..3f8397589b 100755
--- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java
+++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java
@@ -19,6 +19,8 @@
package org.jclouds.vcloud.terremark.compute.config;
+import static org.jclouds.compute.domain.OsFamily.UBUNTU;
+
import java.security.SecureRandom;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -30,6 +32,7 @@ import org.jclouds.compute.ComputeService;
import org.jclouds.compute.config.BindComputeStrategiesByClass;
import org.jclouds.compute.config.BindComputeSuppliersByClass;
import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
@@ -46,6 +49,7 @@ import org.jclouds.vcloud.terremark.compute.strategy.ParseVAppTemplateDescriptio
import com.google.common.base.Function;
import com.google.common.base.Supplier;
+import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
@@ -69,6 +73,12 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudExpressCom
}
+ // prefer jeos as the copy time is much shorter
+ @Override
+ protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
+ return template.osFamily(UBUNTU).osDescriptionMatches(".*JeOS.*").os64Bit(true);
+ }
+
@Override
protected void configure() {
super.configure();
@@ -79,7 +89,7 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudExpressCom
bind(ComputeService.class).to(TerremarkVCloudComputeService.class);
bind(VCloudExpressComputeClient.class).to(TerremarkVCloudComputeClient.class);
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(
- ParseVAppTemplateDescriptionToGetDefaultLoginCredentials.class);
+ ParseVAppTemplateDescriptionToGetDefaultLoginCredentials.class);
bind(SecureRandom.class).toInstance(new SecureRandom());
}
diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java
index 40017c27b8..aac93990c8 100644
--- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java
+++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java
@@ -57,8 +57,7 @@ public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandl
if (response.getMessage() != null
&& ((response.getMessage().indexOf("because there is a pending task running") != -1)
|| (response.getMessage().indexOf("because it is already powered off") != -1)
- || (response.getMessage().indexOf("already exists") != -1) || (response.getMessage()
- .indexOf("same name exists") != -1)))
+ || (response.getMessage().indexOf("exists") != -1)))
exception = new IllegalStateException(response.getMessage(), exception);
else
switch (response.getStatusCode()) {
diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java
index 87b66edba2..738ba14e27 100644
--- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java
+++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java
@@ -90,8 +90,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
super.testCatalog();
}
- protected String expectedOs = "Ubuntu Linux (32-bit)";
- protected String itemName = "Ubuntu JeOS 9.10 (32-bit)";
+ protected String expectedOs = "Ubuntu Linux (64-bit)";
+ protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
protected TerremarkVCloudClient tmClient;
protected Factory sshFactory;
@@ -154,8 +154,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
long hardDisk = 4194304;
// long hardDisk = 4194304 / 4 * 10;
- // String catalogOs = "CentOS 5.3 (32-bit)";
- // String expectedOs = "Red Hat Enterprise Linux 5 (32-bit)";
+ // String catalogOs = "CentOS 5.3 (64-bit)";
+ // String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)";
// lookup the datacenter you are deploying into
vdc = tmClient.findVDCInOrgNamed(null, null);
diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java
index 3be000c4c8..ea30431be5 100644
--- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java
+++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java
@@ -59,8 +59,8 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assert defaultTemplate.getLocation().getDescription() != null;// different per org
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
@@ -68,7 +68,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext tmContext = new ComputeServiceContextFactory()
- .createContext(provider, identity, credential).getProviderSpecificContext();
+ .createContext(provider, identity, credential).getProviderSpecificContext();
}
@Override
@@ -84,7 +84,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
@Override
protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null)
- assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED);
+ assertEquals(node.getOperatingSystem().getFamily(), null);
}
@Override
@@ -94,7 +94,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
// image.getLocationId() can be null, if it is a location-free image
assertEquals(image.getType(), ComputeType.IMAGE);
if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS
- && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) {
+ && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) {
assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image;
assert image.getDefaultCredentials().credential != null : image;
}
@@ -110,7 +110,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
NodeMetadata allData = client.getNodeMetadata(node.getId());
System.out.println(allData.getHardware());
RestContext tmContext = new ComputeServiceContextFactory()
- .createContext(provider, identity, credential).getProviderSpecificContext();
+ .createContext(provider, identity, credential).getProviderSpecificContext();
VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName());
assertEquals(vApp.getName(), allData.getName());
}
diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java
new file mode 100644
index 0000000000..95845f31a0
--- /dev/null
+++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.vcloud.terremark.compute;
+
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.compute.BaseTemplateBuilderLiveTest;
+import org.jclouds.compute.OsFamilyVersion64Bit;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "terremark.TerremarkECloudTemplateBuilderLiveTest")
+public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+
+ public TerremarkECloudTemplateBuilderLiveTest() {
+ provider = "trmk-ecloud";
+ }
+
+ @Override
+ protected Predicate defineUnsupportedOperatingSystems() {
+ return new Predicate() {
+
+ @Override
+ public boolean apply(OsFamilyVersion64Bit input) {
+ return ((input.family == OsFamily.RHEL) || //
+ (input.family == OsFamily.CENTOS && !input.version.equals("5.5")) || //
+ (input.family == OsFamily.UBUNTU &&( !input.version.equals("10.04")&&!input.version.equals("8.04"))) || //
+ (input.family == OsFamily.WINDOWS && (input.version.equals("2008 SP2") || input.version.equals("2008 R2"))));
+ }
+
+ };
+ }
+
+ @Test
+ public void testDefaultTemplateBuilder() throws IOException {
+ Template defaultTemplate = context.getComputeService().templateBuilder().build();
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
+ assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
+
+ }
+
+}
\ No newline at end of file
diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java
index e138e298d2..514b15fac3 100644
--- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java
+++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java
@@ -19,95 +19,52 @@
package org.jclouds.vcloud.terremark.compute;
-import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
-import java.util.Properties;
-import org.jclouds.Constants;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.ComputeServiceContextFactory;
+import org.jclouds.compute.BaseTemplateBuilderLiveTest;
+import org.jclouds.compute.OsFamilyVersion64Bit;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
-import org.jclouds.logging.log4j.config.Log4JLoggingModule;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
+import com.google.common.base.Predicate;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", testName = "terremark.TerremarkVCloudExpressTemplateBuilderLiveTest")
-public class TerremarkVCloudExpressTemplateBuilderLiveTest {
- protected String provider = "trmk-vcloudexpress";
- protected String identity;
- protected String credential;
- protected String endpoint;
- protected String apiversion;
+public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
- @BeforeClass
- protected void setupCredentials() {
- identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
- credential = System.getProperty("test." + provider + ".credential");
- endpoint = System.getProperty("test." + provider + ".endpoint");
- apiversion = System.getProperty("test." + provider + ".apiversion");
+ public TerremarkVCloudExpressTemplateBuilderLiveTest() {
+ provider = "trmk-vcloudexpress";
}
- protected Properties setupProperties() {
- Properties overrides = new Properties();
- overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
- overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
- overrides.setProperty(provider + ".identity", identity);
- if (credential != null)
- overrides.setProperty(provider + ".credential", credential);
- if (endpoint != null)
- overrides.setProperty(provider + ".endpoint", endpoint);
- if (apiversion != null)
- overrides.setProperty(provider + ".apiversion", apiversion);
- return overrides;
- }
+ @Override
+ protected Predicate defineUnsupportedOperatingSystems() {
+ return new Predicate() {
- @Test
- public void testTemplateBuilderCanUseImageId() {
- ComputeServiceContext newContext = null;
- try {
- newContext = new ComputeServiceContextFactory().createContext(provider, ImmutableSet
- . of(new Log4JLoggingModule()), setupProperties());
+ @Override
+ public boolean apply(OsFamilyVersion64Bit input) {
+ return ((input.family == OsFamily.RHEL || input.family == OsFamily.CENTOS) || //
+ (input.family == OsFamily.UBUNTU && !input.version.equals("9.10")) || //
+ (input.family == OsFamily.WINDOWS && (input.version.equals("2008 SP2") || input.version.equals("2008 R2"))));
+ }
- Template defaultTemplate = newContext.getComputeService().templateBuilder().build();
-
- Template template = newContext.getComputeService().templateBuilder().imageId(
- defaultTemplate.getImage().getId()).build();
- assertEquals(template, defaultTemplate);
-
- } finally {
- if (newContext != null)
- newContext.close();
- }
+ };
}
@Test
public void testDefaultTemplateBuilder() throws IOException {
- ComputeServiceContext newContext = null;
- try {
- newContext = new ComputeServiceContextFactory().createContext(provider, ImmutableSet
- . of(new Log4JLoggingModule()), setupProperties());
+ Template defaultTemplate = context.getComputeService().templateBuilder().build();
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "9.10");
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
+ assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+ assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
- Template defaultTemplate = newContext.getComputeService().templateBuilder().build();
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), null);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
- assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
- assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
-
- } finally {
- if (newContext != null)
- newContext.close();
- }
}
}
\ No newline at end of file
diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java
index 19062050d9..1c1365a1cc 100644
--- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java
+++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java
@@ -85,6 +85,13 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError
IllegalStateException.class);
}
+ @Test
+ public void testKeyAlreadyExistsSetsIllegalStateException() {
+ assertCodeMakes("POST", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/org/48/keys"), 400,
+ "Security key with name livetest exists.", "Security key with name livetest exists.",
+ IllegalStateException.class);
+ }
+
@Override
protected Class extends HttpErrorHandler> getHandlerClass() {
return ParseTerremarkVCloudErrorFromHttpResponse.class;