mirror of https://github.com/apache/jclouds.git
Issue 938:TemplateBuilderSpec
This commit is contained in:
parent
c6a65df48d
commit
5c647df129
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudsigma;
|
package org.jclouds.cloudsigma;
|
||||||
|
|
||||||
import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
|
import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -67,6 +68,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
|
||||||
// from a race condition applying the password set script
|
// from a race condition applying the password set script
|
||||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
properties.setProperty("jclouds.ssh.max-retries", "7");
|
||||||
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,imageNameMatches=.*[Aa]utomated SSH Access.*,os64Bit=true");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
@ -59,7 +58,6 @@ import com.google.common.base.Predicates;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -70,11 +68,6 @@ import com.google.inject.TypeLiteral;
|
||||||
public class CloudSigmaComputeServiceContextModule extends
|
public class CloudSigmaComputeServiceContextModule extends
|
||||||
ComputeServiceAdapterContextModule<ServerInfo, Hardware, DriveInfo, Location> {
|
ComputeServiceAdapterContextModule<ServerInfo, Hardware, DriveInfo, Location> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(OsFamily.UBUNTU).imageNameMatches(".*[Aa]utomated SSH Access.*").os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.vcloud;
|
package org.jclouds.vcloud;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
|
||||||
|
@ -82,6 +83,8 @@ public class VCloudApiMetadata extends BaseRestApiMetadata {
|
||||||
// everything.
|
// everything.
|
||||||
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 1200l * 1000l + "");
|
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 1200l * 1000l + "");
|
||||||
properties.setProperty(PROPERTY_SESSION_INTERVAL, 300 + "");
|
properties.setProperty(PROPERTY_SESSION_INTERVAL, 300 + "");
|
||||||
|
// CIM ostype does not include version info
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,os64Bit=true");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.config;
|
package org.jclouds.vcloud.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
|
|
||||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
|
* Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
|
||||||
* bound.
|
* bound.
|
||||||
|
@ -43,10 +38,4 @@ public class VCloudComputeServiceContextModule extends
|
||||||
install(new VCloudComputeServiceDependenciesModule());
|
install(new VCloudComputeServiceDependenciesModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
// CIM ostype does not include version info
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(UBUNTU).os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.compute.config;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_ID;
|
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_ID;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -174,7 +175,14 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
|
||||||
@Named("DEFAULT")
|
@Named("DEFAULT")
|
||||||
protected TemplateBuilder provideTemplateOptionallyFromProperties(Injector injector, TemplateBuilder template,
|
protected TemplateBuilder provideTemplateOptionallyFromProperties(Injector injector, TemplateBuilder template,
|
||||||
@Provider String provider, ValueOfConfigurationKeyOrNull config) {
|
@Provider String provider, ValueOfConfigurationKeyOrNull config) {
|
||||||
template = provideTemplate(injector, template);
|
String templateString = config.apply(provider + ".template");
|
||||||
|
if (templateString == null)
|
||||||
|
templateString = config.apply(TEMPLATE);
|
||||||
|
if (templateString != null) {
|
||||||
|
template.from(templateString);
|
||||||
|
} else {
|
||||||
|
template.osFamily(UBUNTU).osVersionMatches("1[012].[01][04]").os64Bit(true);
|
||||||
|
}
|
||||||
String imageId = config.apply(provider + ".image-id");
|
String imageId = config.apply(provider + ".image-id");
|
||||||
if (imageId == null)
|
if (imageId == null)
|
||||||
imageId = config.apply(IMAGE_ID);
|
imageId = config.apply(IMAGE_ID);
|
||||||
|
@ -183,10 +191,6 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(UBUNTU).osVersionMatches("1[012].[01][04]").os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
|
protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.config;
|
package org.jclouds.compute.config;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilderSpec;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -36,6 +38,12 @@ public interface ComputeServiceProperties {
|
||||||
public static final String INIT_STATUS_INITIAL_PERIOD = "jclouds.compute.init-status.initial-period";
|
public static final String INIT_STATUS_INITIAL_PERIOD = "jclouds.compute.init-status.initial-period";
|
||||||
public static final String INIT_STATUS_MAX_PERIOD = "jclouds.compute.init-status.max-period";
|
public static final String INIT_STATUS_MAX_PERIOD = "jclouds.compute.init-status.max-period";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* overrides the default specified in the subclass of {@link BaseComputeServiceContextModule#provideTemplate}
|
||||||
|
* @see TemplateBuilderSpec
|
||||||
|
*/
|
||||||
|
public static final String TEMPLATE = "jclouds.template";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* overrides the image specified in the subclass of {@link BaseComputeServiceContextModule#provideTemplate}
|
* overrides the image specified in the subclass of {@link BaseComputeServiceContextModule#provideTemplate}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.NoSuchElementException;
|
||||||
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
|
@ -54,6 +55,24 @@ public interface TemplateBuilder {
|
||||||
*/
|
*/
|
||||||
TemplateBuilder fromTemplate(Template image);
|
TemplateBuilder fromTemplate(Template image);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new {@code TemplateBuilderSpec} instance with the settings specified in {@code spec}.
|
||||||
|
*
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
@Beta
|
||||||
|
TemplateBuilder from(TemplateBuilderSpec spec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new {@code TemplateBuilder} instance with the settings specified in {@code spec}.
|
||||||
|
* This is especially useful for command-line configuration of a {@code TemplateBuilder}.
|
||||||
|
*
|
||||||
|
* @param spec a String in the format specified by {@link TemplateBuilderSpec}
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
@Beta
|
||||||
|
TemplateBuilder from(String spec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* configure this template to the smallest hardware, based on cores, ram, then disk
|
* configure this template to the smallest hardware, based on cores, ram, then disk
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,550 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you 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.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
|
import static com.google.common.base.Objects.toStringHelper;
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
import org.jclouds.domain.LoginCredentials.Builder;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.cache.CacheBuilderSpec;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specification of a {@link TemplateBuilder} configuration.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* {@code TemplateBuilderSpec} supports parsing configuration off of a string,
|
||||||
|
* which makes it especially useful for command-line configuration of a
|
||||||
|
* {@code TemplateBuilder}.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The string syntax is a series of comma-separated keys or key-value pairs,
|
||||||
|
* each corresponding to a {@code TemplateBuilder} method.
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code hardwareId=[String]}: sets {@link TemplateBuilder#hardwareId}.
|
||||||
|
* <li>{@code minCores=[double]}: sets {@link TemplateBuilder#minCores}.
|
||||||
|
* <li>{@code minRam=[integer]}: sets {@link TemplateBuilder#minRam}.
|
||||||
|
* <li>{@code hypervisorMatches=[String]}: sets
|
||||||
|
* {@link TemplateBuilder#hypervisorMatches}.
|
||||||
|
* <li>{@code imageId=[String]}: sets {@link TemplateBuilder#imageId}.
|
||||||
|
* <li>{@code imageNameMatches=[String]}: sets
|
||||||
|
* {@link TemplateBuilder#imageNameMatches}.
|
||||||
|
* <li>{@code osFamily=[OsFamily]}: sets {@link TemplateBuilder#osFamily}.
|
||||||
|
* <li>{@code osVersionMatches=[String]}: sets
|
||||||
|
* {@link TemplateBuilder#osVersionMatches}.
|
||||||
|
* <li>{@code os64Bit=[boolean]}: sets {@link TemplateBuilder#os64Bit}.
|
||||||
|
* <li>{@code osArchMatches=[String]}: sets
|
||||||
|
* {@link TemplateBuilder#osArchMatches}.
|
||||||
|
* <li>{@code osDescriptionMatches=[String]}: sets
|
||||||
|
* {@link TemplateBuilder#osDescriptionMatches}.
|
||||||
|
* <li>{@code loginUser=[String]}: sets
|
||||||
|
* {@link TemplateOptions#overrideLoginCredentials} parsing password, if colon
|
||||||
|
* delimited.
|
||||||
|
* <li>{@code authenticateSudo=[Boolean]}: sets
|
||||||
|
* {@link TemplateOptions#overrideLoginCredentials}, but only if
|
||||||
|
* {@code loginUser} is set.
|
||||||
|
* <li>{@code locationId=[String]}: sets {@link TemplateBuilder#locationId}.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* The set of supported keys will grow as {@code TemplateBuilder} evolves, but
|
||||||
|
* existing keys will never be removed.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Whitespace before and after commas and equal signs is ignored. Keys may not
|
||||||
|
* be repeated.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* It is also illegal to use the following combination of keys
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code hardwareId} and any of
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code minCores}
|
||||||
|
* <li>{@code minRam}
|
||||||
|
* <li>{@code hypervisorMatches}
|
||||||
|
* </ul>
|
||||||
|
* <li>{@code imageId} and any of
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code imageNameMatches}
|
||||||
|
* <li>{@code osFamily}
|
||||||
|
* <li>{@code osVersionMatches}
|
||||||
|
* <li>{@code os64Bit}
|
||||||
|
* <li>{@code osArchMatches}
|
||||||
|
* <li>{@code osDescriptionMatches}
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* {@code TemplateBuilderSpec} does not support configuring
|
||||||
|
* {@code TemplateBuilder} methods with non-value parameters. These must be
|
||||||
|
* configured in code.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* A new {@code TemplateBuilder} can be instantiated from a
|
||||||
|
* {@code TemplateBuilderSpec} using
|
||||||
|
* {@link TemplateBuilder#from(TemplateBuilderSpec)} or
|
||||||
|
* {@link TemplateBuilder#from(String)}.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Design inspired by {@link CacheBuilderSpec}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
@Beta
|
||||||
|
public class TemplateBuilderSpec implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -379469670373111569L;
|
||||||
|
|
||||||
|
/** Parses a single value. */
|
||||||
|
protected static interface ValueParser {
|
||||||
|
void parse(TemplateBuilderSpec spec, String key, @Nullable String value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Splits each key-value pair. */
|
||||||
|
protected static final Splitter KEYS_SPLITTER = Splitter.on(',').trimResults();
|
||||||
|
|
||||||
|
/** Splits the key from the value. */
|
||||||
|
protected static final Splitter KEY_VALUE_SPLITTER = Splitter.on('=').trimResults();
|
||||||
|
|
||||||
|
/** Map of names to ValueParser. */
|
||||||
|
protected static final ImmutableMap<String, ValueParser> VALUE_PARSERS = ImmutableMap.<String, ValueParser> builder()
|
||||||
|
.put("hardwareId", new HardwareIdParser())
|
||||||
|
.put("minCores", new MinCoresParser())
|
||||||
|
.put("minRam", new MinRamParser())
|
||||||
|
.put("hypervisorMatches", new HypervisorMatchesMatchesParser())
|
||||||
|
.put("imageId", new ImageIdParser())
|
||||||
|
.put("imageNameMatches", new ImageNameMatchesParser())
|
||||||
|
.put("osFamily", new OsFamilyParser())
|
||||||
|
.put("osVersionMatches", new OsVersionMatchesParser())
|
||||||
|
.put("os64Bit", new Os64BitParser())
|
||||||
|
.put("osArchMatches", new OsArchMatchesParser())
|
||||||
|
.put("osDescriptionMatches", new OsDescriptionMatchesParser())
|
||||||
|
.put("loginUser", new LoginUserParser())
|
||||||
|
.put("authenticateSudo", new AuthenticateSudoParser())
|
||||||
|
.put("locationId", new LocationIdParser())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
String hardwareId;
|
||||||
|
@VisibleForTesting
|
||||||
|
Double minCores;
|
||||||
|
@VisibleForTesting
|
||||||
|
Integer minRam;
|
||||||
|
@VisibleForTesting
|
||||||
|
String hypervisorMatches;
|
||||||
|
@VisibleForTesting
|
||||||
|
String imageId;
|
||||||
|
@VisibleForTesting
|
||||||
|
String imageNameMatches;
|
||||||
|
@VisibleForTesting
|
||||||
|
OsFamily osFamily;
|
||||||
|
@VisibleForTesting
|
||||||
|
String osVersionMatches;
|
||||||
|
@VisibleForTesting
|
||||||
|
Boolean os64Bit;
|
||||||
|
@VisibleForTesting
|
||||||
|
String osArchMatches;
|
||||||
|
@VisibleForTesting
|
||||||
|
String osDescriptionMatches;
|
||||||
|
@VisibleForTesting
|
||||||
|
String loginUser;
|
||||||
|
@VisibleForTesting
|
||||||
|
Boolean authenticateSudo;
|
||||||
|
@VisibleForTesting
|
||||||
|
String locationId;
|
||||||
|
|
||||||
|
/** Specification; used for toParseableString(). */
|
||||||
|
// transient in case people using serializers don't want this to show up
|
||||||
|
protected transient final String specification;
|
||||||
|
|
||||||
|
protected TemplateBuilderSpec(String specification) {
|
||||||
|
this.specification = specification;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a TemplateBuilderSpec from a string.
|
||||||
|
*
|
||||||
|
* @param templateBuilderSpecification
|
||||||
|
* the string form
|
||||||
|
*/
|
||||||
|
public static TemplateBuilderSpec parse(String templateBuilderSpecification) {
|
||||||
|
TemplateBuilderSpec spec = new TemplateBuilderSpec(templateBuilderSpecification);
|
||||||
|
if (!templateBuilderSpecification.isEmpty()) {
|
||||||
|
for (String keyValuePair : KEYS_SPLITTER.split(templateBuilderSpecification)) {
|
||||||
|
List<String> keyAndValue = ImmutableList.copyOf(KEY_VALUE_SPLITTER.split(keyValuePair));
|
||||||
|
checkArgument(!keyAndValue.isEmpty(), "blank key-value pair");
|
||||||
|
checkArgument(keyAndValue.size() <= 2, "key-value pair %s with more than one equals sign", keyValuePair);
|
||||||
|
|
||||||
|
// Find the ValueParser for the current key.
|
||||||
|
String key = keyAndValue.get(0);
|
||||||
|
ValueParser valueParser = VALUE_PARSERS.get(key);
|
||||||
|
checkArgument(valueParser != null, "unknown key %s", key);
|
||||||
|
|
||||||
|
String value = keyAndValue.size() == 1 ? null : keyAndValue.get(1);
|
||||||
|
valueParser.parse(spec, key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a TemplateBuilder configured according to this instance's
|
||||||
|
* specification.
|
||||||
|
* @param templateOptions
|
||||||
|
*/
|
||||||
|
public TemplateBuilder copyTo(TemplateBuilder builder, TemplateOptions templateOptions) {
|
||||||
|
if (hardwareId != null) {
|
||||||
|
builder.hardwareId(hardwareId);
|
||||||
|
}
|
||||||
|
if (minCores != null) {
|
||||||
|
builder.minCores(minCores);
|
||||||
|
}
|
||||||
|
if (minRam != null) {
|
||||||
|
builder.minRam(minRam);
|
||||||
|
}
|
||||||
|
if (hypervisorMatches != null) {
|
||||||
|
builder.hypervisorMatches(hypervisorMatches);
|
||||||
|
}
|
||||||
|
if (imageId != null) {
|
||||||
|
builder.imageId(imageId);
|
||||||
|
}
|
||||||
|
if (imageNameMatches != null) {
|
||||||
|
builder.imageNameMatches(imageNameMatches);
|
||||||
|
}
|
||||||
|
if (osFamily != null) {
|
||||||
|
builder.osFamily(osFamily);
|
||||||
|
}
|
||||||
|
if (osVersionMatches != null) {
|
||||||
|
builder.osVersionMatches(osVersionMatches);
|
||||||
|
}
|
||||||
|
if (os64Bit != null) {
|
||||||
|
builder.os64Bit(os64Bit);
|
||||||
|
}
|
||||||
|
if (osArchMatches != null) {
|
||||||
|
builder.osArchMatches(osArchMatches);
|
||||||
|
}
|
||||||
|
if (osDescriptionMatches != null) {
|
||||||
|
builder.osArchMatches(osDescriptionMatches);
|
||||||
|
}
|
||||||
|
if (loginUser != null) {
|
||||||
|
Builder loginBuilder = LoginCredentials.builder();
|
||||||
|
|
||||||
|
int pos = loginUser.indexOf(':');
|
||||||
|
if (pos != -1) {
|
||||||
|
loginBuilder.user(loginUser.substring(0, pos)).password(loginUser.substring(pos + 1));
|
||||||
|
} else
|
||||||
|
loginBuilder.user(loginUser);
|
||||||
|
|
||||||
|
if (authenticateSudo != null) {
|
||||||
|
loginBuilder.authenticateSudo(authenticateSudo);
|
||||||
|
}
|
||||||
|
LoginCredentials creds = loginBuilder.build();
|
||||||
|
templateOptions.overrideLoginCredentials(creds);
|
||||||
|
}
|
||||||
|
if (locationId != null) {
|
||||||
|
builder.locationId(locationId);
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string that can be used to parse an equivalent
|
||||||
|
* {@code TemplateBuilderSpec}. The order and form of this representation is
|
||||||
|
* not guaranteed, except that reparsing its output will produce a
|
||||||
|
* {@code TemplateBuilderSpec} equal to this instance.
|
||||||
|
*/
|
||||||
|
public String toParsableString() {
|
||||||
|
return specification;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation for this TemplateBuilderSpec instance. The
|
||||||
|
* form of this representation is not guaranteed.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return toStringHelper(this).addValue(toParsableString()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(hardwareId, minCores, minRam, hypervisorMatches, imageId, imageNameMatches, osFamily,
|
||||||
|
osVersionMatches, os64Bit, osArchMatches, osDescriptionMatches, loginUser, authenticateSudo, locationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof TemplateBuilderSpec)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TemplateBuilderSpec that = (TemplateBuilderSpec) obj;
|
||||||
|
return equal(hardwareId, that.hardwareId) && equal(minCores, that.minCores) && equal(minRam, that.minRam)
|
||||||
|
&& equal(hypervisorMatches, that.hypervisorMatches) && equal(imageId, that.imageId)
|
||||||
|
&& equal(imageNameMatches, that.imageNameMatches) && equal(osFamily, that.osFamily)
|
||||||
|
&& equal(osVersionMatches, that.osVersionMatches) && equal(os64Bit, that.os64Bit)
|
||||||
|
&& equal(osArchMatches, that.osArchMatches) && equal(osDescriptionMatches, that.osDescriptionMatches)
|
||||||
|
&& equal(loginUser, that.loginUser) && equal(authenticateSudo, that.authenticateSudo)
|
||||||
|
&& equal(locationId, that.locationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Base class for parsing doubles. */
|
||||||
|
abstract static class DoubleParser implements ValueParser {
|
||||||
|
protected abstract void parseDouble(TemplateBuilderSpec spec, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parse(TemplateBuilderSpec spec, String key, String value) {
|
||||||
|
checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
|
||||||
|
try {
|
||||||
|
parseDouble(spec, Double.parseDouble(value));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException(String.format("key %s value set to %s, must be double", key, value), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Base class for parsing ints. */
|
||||||
|
abstract static class IntegerParser implements ValueParser {
|
||||||
|
protected abstract void parseInteger(TemplateBuilderSpec spec, int value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parse(TemplateBuilderSpec spec, String key, String value) {
|
||||||
|
checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
|
||||||
|
try {
|
||||||
|
parseInteger(spec, Integer.parseInt(value));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException(String.format("key %s value set to %s, must be integer", key, value), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Base class for parsing enums. */
|
||||||
|
abstract static class EnumParser<E extends Enum<E>> implements ValueParser {
|
||||||
|
private final Class<E> type;
|
||||||
|
|
||||||
|
protected EnumParser(Class<E> type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void parseEnum(TemplateBuilderSpec spec, E value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parse(TemplateBuilderSpec spec, String key, String value) {
|
||||||
|
checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
|
||||||
|
try {
|
||||||
|
parseEnum(spec, Enum.valueOf(type, value));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new IllegalArgumentException(String.format("key %s value set to %s, must be a name in enum %s", key,
|
||||||
|
value, type), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Base class for parsing strings. */
|
||||||
|
abstract static class StringParser implements ValueParser {
|
||||||
|
protected abstract void set(TemplateBuilderSpec spec, String value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parse(TemplateBuilderSpec spec, String key, String value) {
|
||||||
|
checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
|
||||||
|
set(spec, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Base class for parsing booleans. */
|
||||||
|
abstract static class BooleanParser implements ValueParser {
|
||||||
|
protected abstract void parseBoolean(TemplateBuilderSpec spec, boolean value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parse(TemplateBuilderSpec spec, String key, String value) {
|
||||||
|
checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
|
||||||
|
try {
|
||||||
|
parseBoolean(spec, Boolean.parseBoolean(value));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException(String.format("key %s value set to %s, must be booleans", key, value), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse hardwareId */
|
||||||
|
static class HardwareIdParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.hardwareId == null, "hardware id was already set to ", spec.hardwareId);
|
||||||
|
checkArgument(spec.minCores == null, "min cores was already set to ", spec.minCores);
|
||||||
|
checkArgument(spec.minRam == null, "min ram was already set to ", spec.minRam);
|
||||||
|
checkArgument(spec.hypervisorMatches == null, "hypervisor matches was already set to ", spec.hypervisorMatches);
|
||||||
|
spec.hardwareId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse minCores */
|
||||||
|
static class MinCoresParser extends DoubleParser {
|
||||||
|
@Override
|
||||||
|
protected void parseDouble(TemplateBuilderSpec spec, double value) {
|
||||||
|
checkArgument(spec.minCores == null, "min cores was already set to ", spec.minCores);
|
||||||
|
checkArgument(spec.hardwareId == null, "hardware id was already set to ", spec.hardwareId);
|
||||||
|
spec.minCores = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse minRam */
|
||||||
|
static class MinRamParser extends IntegerParser {
|
||||||
|
@Override
|
||||||
|
protected void parseInteger(TemplateBuilderSpec spec, int value) {
|
||||||
|
checkArgument(spec.minRam == null, "min ram was already set to ", spec.minRam);
|
||||||
|
checkArgument(spec.hardwareId == null, "hardware id was already set to ", spec.hardwareId);
|
||||||
|
spec.minRam = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse hypervisorMatches */
|
||||||
|
static class HypervisorMatchesMatchesParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.hypervisorMatches == null, "hypervisor matches was already set to ", spec.hypervisorMatches);
|
||||||
|
checkArgument(spec.hardwareId == null, "hardware id was already set to ", spec.hardwareId);
|
||||||
|
spec.hypervisorMatches = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse imageId */
|
||||||
|
static class ImageIdParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
checkArgument(spec.imageNameMatches == null, "image name matches was already set to ", spec.imageNameMatches);
|
||||||
|
checkArgument(spec.osFamily == null, "operating system family was already set to ", spec.osFamily);
|
||||||
|
checkArgument(spec.osVersionMatches == null, "os version matches was already set to ", spec.osVersionMatches);
|
||||||
|
checkArgument(spec.os64Bit == null, "os 64 bit was already set to ", spec.os64Bit);
|
||||||
|
checkArgument(spec.osArchMatches == null, "os arch matches was already set to ", spec.osArchMatches);
|
||||||
|
checkArgument(spec.osDescriptionMatches == null, "os description matches was already set to ", spec.osDescriptionMatches);
|
||||||
|
spec.imageId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse imageNameMatches */
|
||||||
|
static class ImageNameMatchesParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.imageNameMatches == null, "image name matches was already set to ", spec.imageNameMatches);
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
spec.imageNameMatches = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse osFamily */
|
||||||
|
static class OsFamilyParser extends EnumParser<OsFamily> {
|
||||||
|
|
||||||
|
protected OsFamilyParser() {
|
||||||
|
super(OsFamily.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void parseEnum(TemplateBuilderSpec spec, OsFamily value) {
|
||||||
|
checkArgument(spec.osFamily == null, "operating system family was already set to ", spec.osFamily);
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
spec.osFamily = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse osVersionMatches */
|
||||||
|
static class OsVersionMatchesParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.osVersionMatches == null, "os version matches was already set to ", spec.osVersionMatches);
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
spec.osVersionMatches = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse os64Bit */
|
||||||
|
static class Os64BitParser extends BooleanParser {
|
||||||
|
@Override
|
||||||
|
protected void parseBoolean(TemplateBuilderSpec spec, boolean value) {
|
||||||
|
checkArgument(spec.os64Bit == null, "os 64 bit was already set to ", spec.os64Bit);
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
spec.os64Bit = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse osArchMatches */
|
||||||
|
static class OsArchMatchesParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.osArchMatches == null, "os arch matches was already set to ", spec.osArchMatches);
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
spec.osArchMatches = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse osDescriptionMatches */
|
||||||
|
static class OsDescriptionMatchesParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.osDescriptionMatches == null, "os description matches was already set to ", spec.osDescriptionMatches);
|
||||||
|
checkArgument(spec.imageId == null, "image id was already set to ", spec.imageId);
|
||||||
|
spec.osDescriptionMatches = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** Parse loginUser */
|
||||||
|
static class LoginUserParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.loginUser == null, "login user was already set to ", spec.loginUser);
|
||||||
|
spec.loginUser = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse authenticateSudo */
|
||||||
|
static class AuthenticateSudoParser extends BooleanParser {
|
||||||
|
@Override
|
||||||
|
protected void parseBoolean(TemplateBuilderSpec spec, boolean value) {
|
||||||
|
checkArgument(spec.loginUser != null, "login user must be set to use authenticateSudo");
|
||||||
|
checkArgument(spec.authenticateSudo == null, "authenticate sudo was already set to ", spec.authenticateSudo);
|
||||||
|
spec.authenticateSudo = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse locationId */
|
||||||
|
static class LocationIdParser extends StringParser {
|
||||||
|
@Override
|
||||||
|
protected void set(TemplateBuilderSpec spec, String value) {
|
||||||
|
checkArgument(spec.locationId == null, "location id was already set to ", spec.locationId);
|
||||||
|
spec.locationId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -48,6 +48,7 @@ import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilderSpec;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -970,4 +971,14 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder from(TemplateBuilderSpec spec) {
|
||||||
|
return spec.copyTo(this, options != null ? options : optionsProvider.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder from(String spec) {
|
||||||
|
return from(TemplateBuilderSpec.parse(spec));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,630 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you 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.compute.domain;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.domain.TemplateBuilderSpec.parse;
|
||||||
|
import static org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials;
|
||||||
|
import static org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginUser;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNull;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import javax.inject.Provider;
|
||||||
|
|
||||||
|
import org.jclouds.ContextBuilder;
|
||||||
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* <p/>
|
||||||
|
* inspired by guava {@code CacheBuilderSpecTest}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(testName = "TemplateBuilderSpecTest")
|
||||||
|
public class TemplateBuilderSpecTest {
|
||||||
|
Provider<TemplateBuilder> templateBuilders = ContextBuilder.newBuilder("stub").buildInjector()
|
||||||
|
.getProvider(TemplateBuilder.class);
|
||||||
|
|
||||||
|
public void testParse_empty() {
|
||||||
|
TemplateBuilderSpec spec = parse("");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get(), templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_hardwareId() {
|
||||||
|
TemplateBuilderSpec spec = parse("hardwareId=m1.small");
|
||||||
|
assertEquals(spec.hardwareId, "m1.small");
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().hardwareId("m1.small"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_hardwareIdRepeated() {
|
||||||
|
try {
|
||||||
|
parse("hardwareId=m1.small, hardwareId=t1.micro");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_hardwareIdNotCompatibleWithHardwareValues() {
|
||||||
|
try {
|
||||||
|
parse("hardwareId=m1.small,minCores=1");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("hardwareId=m1.small,minRam=512");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("hardwareId=m1.small,hypervisorMatches=OpenVZ");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_minCores() {
|
||||||
|
TemplateBuilderSpec spec = parse("minCores=32");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertEquals(32, spec.minCores.intValue());
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().minCores(32), templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_minCoresRepeated() {
|
||||||
|
try {
|
||||||
|
parse("minCores=10, minCores=20");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_minRam() {
|
||||||
|
TemplateBuilderSpec spec = parse("minRam=10");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertEquals(spec.minRam.intValue(), 10);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().minRam(10), templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_minRamRepeated() {
|
||||||
|
try {
|
||||||
|
parse("minRam=10, minRam=20");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_hypervisorMatches() {
|
||||||
|
TemplateBuilderSpec spec = parse("hypervisorMatches=OpenVZ");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertEquals(spec.hypervisorMatches, "OpenVZ");
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().hypervisorMatches("OpenVZ"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_hypervisorMatchesRepeated() {
|
||||||
|
try {
|
||||||
|
parse("hypervisorMatches=VSphere, hypervisorMatches=OpenVZ");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_imageId() {
|
||||||
|
TemplateBuilderSpec spec = parse("imageId=us-east-1/ami-fffffff");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertEquals(spec.imageId, "us-east-1/ami-fffffff");
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().imageId("us-east-1/ami-fffffff"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_imageIdRepeated() {
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff, imageId=ami-eeeeeee");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_imageIdNotCompatibleWithImageValues() {
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff,imageNameMatches=foo");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff,osFamily=UBUNTU");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff,osVersionMatches=10.04");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff,os64Bit=true");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff,osArchMatches=x86");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parse("imageId=us-east-1/ami-fffffff,osDescriptionMatches=^((?!MGC).)*$");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testParse_imageNameMatches() {
|
||||||
|
TemplateBuilderSpec spec = parse("imageNameMatches=.*w/ None.*");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertEquals(spec.imageNameMatches, ".*w/ None.*");
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().imageNameMatches(".*w/ None.*"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_imageNameMatchesRepeated() {
|
||||||
|
try {
|
||||||
|
parse("imageNameMatches=hello, imageNameMatches=.*w/ None.*");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osFamily() {
|
||||||
|
TemplateBuilderSpec spec = parse("osFamily=UBUNTU");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertEquals(spec.osFamily, OsFamily.UBUNTU);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().osFamily(OsFamily.UBUNTU),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osFamilyRepeated() {
|
||||||
|
try {
|
||||||
|
parse("osFamily=UBUNTU, osFamily=LINUX");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osVersionMatches() {
|
||||||
|
TemplateBuilderSpec spec = parse("osVersionMatches=.*[Aa]utomated SSH Access.*");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertEquals(spec.osVersionMatches, ".*[Aa]utomated SSH Access.*");
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().osVersionMatches(".*[Aa]utomated SSH Access.*"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osVersionMatchesRepeated() {
|
||||||
|
try {
|
||||||
|
parse("osVersionMatches=11.04, osVersionMatches=.*[Aa]utomated SSH Access.*");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_os64Bit() {
|
||||||
|
TemplateBuilderSpec spec = parse("os64Bit=true");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertEquals(spec.os64Bit.booleanValue(), true);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().os64Bit(true),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_os64BitRepeated() {
|
||||||
|
try {
|
||||||
|
parse("os64Bit=false, os64Bit=true");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osArchMatches() {
|
||||||
|
TemplateBuilderSpec spec = parse("osArchMatches=x86");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertEquals(spec.osArchMatches, "x86");
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().osArchMatches("x86"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osArchMatchesRepeated() {
|
||||||
|
try {
|
||||||
|
parse("osArchMatches=x86, osArchMatches=foo");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osDescriptionMatches() {
|
||||||
|
TemplateBuilderSpec spec = parse("osDescriptionMatches=^((?!MGC).)*$");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertEquals(spec.osDescriptionMatches, "^((?!MGC).)*$");
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().osDescriptionMatches("^((?!MGC).)*$"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_osDescriptionMatchesRepeated() {
|
||||||
|
try {
|
||||||
|
parse("osDescriptionMatches=^((?!MGC).)*$, osDescriptionMatches=.*[Aa]utomated SSH Access.*");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_loginUser() {
|
||||||
|
TemplateBuilderSpec spec = parse("loginUser=ubuntu");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertEquals(spec.loginUser, "ubuntu");
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(
|
||||||
|
templateBuilders.get().options(overrideLoginUser("ubuntu")), templateBuilders
|
||||||
|
.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_loginUserRepeated() {
|
||||||
|
try {
|
||||||
|
parse("loginUser=aws-user,loginUser=ubuntu");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_loginUserWithPassword() {
|
||||||
|
TemplateBuilderSpec spec = parse("loginUser=root:toor");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertEquals(spec.loginUser, "root:toor");
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(
|
||||||
|
templateBuilders.get().options(
|
||||||
|
overrideLoginCredentials(LoginCredentials.builder().user("root").password("toor").build())),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_authenticateSudoWithoutLoginUser() {
|
||||||
|
try {
|
||||||
|
parse("authenticateSudo=true");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_authenticateSudo() {
|
||||||
|
TemplateBuilderSpec spec = parse("loginUser=root:toor,authenticateSudo=true");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertEquals(spec.loginUser, "root:toor");
|
||||||
|
assertEquals(spec.authenticateSudo.booleanValue(), true);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
assertTemplateBuilderEquivalence(
|
||||||
|
templateBuilders.get().options(
|
||||||
|
overrideLoginCredentials(LoginCredentials.builder().user("root").password("toor")
|
||||||
|
.authenticateSudo(true).build())), templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_authenticateSudoRepeated() {
|
||||||
|
try {
|
||||||
|
parse("loginUser=root:toor,authenticateSudo=true,authenticateSudo=false");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_locationId() {
|
||||||
|
TemplateBuilderSpec spec = parse("locationId=stub");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertNull(spec.osFamily);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertEquals(spec.locationId, "stub");
|
||||||
|
assertTemplateBuilderEquivalence(templateBuilders.get().locationId("stub"),
|
||||||
|
templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_locationIdRepeated() {
|
||||||
|
try {
|
||||||
|
parse("locationId=stub, locationId=stub");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_multipleKeys() {
|
||||||
|
TemplateBuilderSpec spec = parse("osFamily=UBUNTU,osVersionMatches=1[012].[01][04],imageNameMatches=.*w/ None.*");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertNull(spec.minRam);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertEquals(spec.imageNameMatches, ".*w/ None.*");
|
||||||
|
assertEquals(spec.osFamily, OsFamily.UBUNTU);
|
||||||
|
assertEquals(spec.osVersionMatches, "1[012].[01][04]");
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
TemplateBuilder expected = templateBuilders.get().osVersionMatches("1[012].[01][04]").imageNameMatches(".*w/ None.*").osFamily(OsFamily.UBUNTU);
|
||||||
|
assertTemplateBuilderEquivalence(expected, templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_whitespaceAllowed() {
|
||||||
|
TemplateBuilderSpec spec = parse(" minRam=10,\nosFamily=UBUNTU");
|
||||||
|
assertNull(spec.hardwareId);
|
||||||
|
assertNull(spec.minCores);
|
||||||
|
assertEquals(spec.minRam.intValue(), 10);
|
||||||
|
assertNull(spec.hypervisorMatches);
|
||||||
|
assertNull(spec.imageId);
|
||||||
|
assertNull(spec.imageNameMatches);
|
||||||
|
assertEquals(spec.osFamily, OsFamily.UBUNTU);
|
||||||
|
assertNull(spec.osVersionMatches);
|
||||||
|
assertNull(spec.os64Bit);
|
||||||
|
assertNull(spec.osArchMatches);
|
||||||
|
assertNull(spec.osDescriptionMatches);
|
||||||
|
assertNull(spec.loginUser);
|
||||||
|
assertNull(spec.authenticateSudo);
|
||||||
|
assertNull(spec.locationId);
|
||||||
|
TemplateBuilder expected = templateBuilders.get().minRam(10).osFamily(OsFamily.UBUNTU);
|
||||||
|
assertTemplateBuilderEquivalence(expected, templateBuilders.get().from(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse_unknownKey() {
|
||||||
|
try {
|
||||||
|
parse("foo=17");
|
||||||
|
fail("Expected exception");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testTemplateBuilderFrom_string() {
|
||||||
|
TemplateBuilder fromString = templateBuilders.get().from("minRam=10,osFamily=UBUNTU");
|
||||||
|
TemplateBuilder expected = templateBuilders.get().minCores(30).minRam(10).osFamily(OsFamily.UBUNTU);
|
||||||
|
assertTemplateBuilderEquivalence(expected, fromString);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertTemplateBuilderEquivalence(TemplateBuilder a, TemplateBuilder b) {
|
||||||
|
// Labs hack: dig into the TemplateBuilder instances, verifying all fields
|
||||||
|
// are equal.
|
||||||
|
for (Field f : TemplateBuilder.class.getFields()) {
|
||||||
|
f.setAccessible(true);
|
||||||
|
try {
|
||||||
|
assertEquals(f.get(a), f.get(b), "Field " + f.getName() + " not equal");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new AssertionError(e.getMessage());
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new AssertionError(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.util;
|
package org.jclouds.util;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General utilities used in jclouds code for {@link Iterable Iterables}.
|
* General utilities used in jclouds code for {@link Iterable Iterables}.
|
||||||
|
@ -34,7 +34,8 @@ public class Iterables2 {
|
||||||
* @return concrete-typed copy of the source
|
* @return concrete-typed copy of the source
|
||||||
*/
|
*/
|
||||||
public static <T> Iterable<T> concreteCopy(Iterable<? extends T> unboundedValues) {
|
public static <T> Iterable<T> concreteCopy(Iterable<? extends T> unboundedValues) {
|
||||||
return ImmutableSortedSet.copyOf(unboundedValues);
|
// Please do not attempt to sort, as this is wasteful
|
||||||
|
return ImmutableSet.copyOf(unboundedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.glesys;
|
package org.jclouds.glesys;
|
||||||
|
|
||||||
import static org.jclouds.glesys.reference.GleSYSConstants.PROPERTY_GLESYS_DEFAULT_DC;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||||
|
@ -62,7 +62,7 @@ public class GleSYSProviderMetadata extends BaseProviderMetadata {
|
||||||
properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N");
|
properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY");
|
properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".Stockholm." + ISO3166_CODES, "SE-AB");
|
properties.setProperty(PROPERTY_ZONE + ".Stockholm." + ISO3166_CODES, "SE-AB");
|
||||||
properties.setProperty(PROPERTY_GLESYS_DEFAULT_DC, "Falkenberg");
|
properties.setProperty(TEMPLATE, "minRam=512,osFamily=UBUNTU,hypervisorMatches=OpenVZ,osVersionMatches=1[012].[01][04],os64Bit=true,locationId=Falkenberg");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,7 @@ import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -44,7 +42,6 @@ import org.jclouds.glesys.domain.OSTemplate;
|
||||||
import org.jclouds.glesys.domain.ServerDetails;
|
import org.jclouds.glesys.domain.ServerDetails;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
@ -78,12 +75,6 @@ public class GleSYSComputeServiceContextModule extends
|
||||||
install(new LocationsFromComputeServiceAdapterModule<ServerDetails, Hardware, OSTemplate, String>(){});
|
install(new LocationsFromComputeServiceAdapterModule<ServerDetails, Hardware, OSTemplate, String>(){});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 128MB is perhaps too little ram
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.minRam(512).osFamily(OsFamily.UBUNTU).hypervisorMatches("OpenVZ").osVersionMatches("1[10].[10][04]").os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Named("PASSWORD")
|
@Named("PASSWORD")
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class PasswordProvider implements Provider<String> {
|
public static class PasswordProvider implements Provider<String> {
|
||||||
|
|
|
@ -13,9 +13,6 @@ import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
public class GleSYSConstants {
|
public class GleSYSConstants {
|
||||||
public static final String PROPERTY_GLESYS_DEFAULT_DC = "jclouds.glesys.defaultdc";
|
|
||||||
public static final String PROPERTY_GLESYS_MIN_DISK = "jclouds.glesys.mindisk";
|
|
||||||
public static final String PROPERTY_GLESYS_MIN_RAM = "jclouds.glesys.minram";
|
|
||||||
|
|
||||||
public static final Pattern JCLOUDS_ID_TO_PLATFORM = Pattern.compile("([a-zA-Z]+) .*");
|
public static final Pattern JCLOUDS_ID_TO_PLATFORM = Pattern.compile("([a-zA-Z]+) .*");
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
case UBUNTU:
|
case UBUNTU:
|
||||||
return input.version.equals("")
|
return input.version.equals("")
|
||||||
|| input.version.equals("10.04")
|
|| input.version.equals("10.04")
|
||||||
|
|| input.version.equals("12.04")
|
||||||
|| ((input.version.equals("8.04") || input.version.equals("11.04") || input.version
|
|| ((input.version.equals("8.04") || input.version.equals("11.04") || input.version
|
||||||
.equals("10.10")) && input.is64Bit);
|
.equals("10.10")) && input.is64Bit);
|
||||||
case DEBIAN:
|
case DEBIAN:
|
||||||
|
@ -82,8 +83,8 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultTemplateBuilder() throws IOException {
|
public void testDefaultTemplateBuilder() throws IOException {
|
||||||
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
assertEquals(defaultTemplate.getImage().getId(), "Ubuntu 11.04 64-bit");
|
assertEquals(defaultTemplate.getImage().getId(), "Ubuntu 12.04 LTS 64-bit");
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04");
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04");
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||||
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.savvis.vpdc;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -53,6 +55,7 @@ public class VPDCProviderMetadata extends BaseProviderMetadata {
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=RHEL,os64Bit=true");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.savvis.vpdc.compute.config;
|
package org.jclouds.savvis.vpdc.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.RHEL;
|
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.CIMOperatingSystem;
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.savvis.vpdc.compute.functions.CIMOperatingSystemToImage;
|
import org.jclouds.savvis.vpdc.compute.functions.CIMOperatingSystemToImage;
|
||||||
import org.jclouds.savvis.vpdc.compute.functions.NetworkToLocation;
|
import org.jclouds.savvis.vpdc.compute.functions.NetworkToLocation;
|
||||||
|
@ -36,7 +33,6 @@ import org.jclouds.savvis.vpdc.domain.VM;
|
||||||
import org.jclouds.savvis.vpdc.domain.VMSpec;
|
import org.jclouds.savvis.vpdc.domain.VMSpec;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,11 +42,6 @@ import com.google.inject.TypeLiteral;
|
||||||
public class VPDCComputeServiceContextModule extends
|
public class VPDCComputeServiceContextModule extends
|
||||||
ComputeServiceAdapterContextModule<VM, VMSpec, CIMOperatingSystem, Network> {
|
ComputeServiceAdapterContextModule<VM, VMSpec, CIMOperatingSystem, Network> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(RHEL).os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.virtualbox;
|
package org.jclouds.virtualbox;
|
||||||
|
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_AUTHENTICATE_SUDO;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_LOGIN_USER;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR;
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
||||||
|
@ -65,10 +64,6 @@ public class VirtualBoxApiMetadata extends BaseApiMetadata {
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = BaseApiMetadata.defaultProperties();
|
Properties properties = BaseApiMetadata.defaultProperties();
|
||||||
|
|
||||||
properties.put(IMAGE_LOGIN_USER, "toor:password");
|
|
||||||
properties.put(IMAGE_AUTHENTICATE_SUDO, "true");
|
|
||||||
|
|
||||||
|
|
||||||
properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, "<Esc><Esc><Enter> "
|
properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, "<Esc><Esc><Enter> "
|
||||||
+ "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL "
|
+ "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL "
|
||||||
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME "
|
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME "
|
||||||
|
@ -86,6 +81,7 @@ public class VirtualBoxApiMetadata extends BaseApiMetadata {
|
||||||
properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor);
|
properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor);
|
||||||
|
|
||||||
properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/preseed.cfg");
|
properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/preseed.cfg");
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=11.10,os64Bit=true,osArchMatches=x86,loginUser=toor:password,authenticateSudo=true");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.config;
|
package org.jclouds.virtualbox.config;
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_ARCH;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_OS;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_VERSION;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -32,14 +28,13 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.ImageExtension;
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||||
|
import org.jclouds.compute.ImageExtension;
|
||||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -173,12 +168,6 @@ public class VirtualBoxComputeServiceContextModule extends
|
||||||
return new RetryablePredicate<SshClient>(sshResponds, timeouts.nodeRunning, 500l, TimeUnit.MILLISECONDS);
|
return new RetryablePredicate<SshClient>(sshResponds, timeouts.nodeRunning, 500l, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(VIRTUALBOX_DEFAULT_IMAGE_OS).osVersionMatches(VIRTUALBOX_DEFAULT_IMAGE_VERSION)
|
|
||||||
.osArchMatches(VIRTUALBOX_DEFAULT_IMAGE_ARCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Optional<ImageExtension> provideImageExtension(Injector i) {
|
protected Optional<ImageExtension> provideImageExtension(Injector i) {
|
||||||
return Optional.of(i.getInstance(ImageExtension.class));
|
return Optional.of(i.getInstance(ImageExtension.class));
|
||||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.virtualbox.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties used for interacting with VirtualBox instances.
|
* Configuration properties used for interacting with VirtualBox instances.
|
||||||
*
|
*
|
||||||
|
@ -62,12 +60,6 @@ public interface VirtualBoxConstants {
|
||||||
public static final String VIRTUALBOX_DEFAULT_DIR = System.getProperty("user.home") + File.separator
|
public static final String VIRTUALBOX_DEFAULT_DIR = System.getProperty("user.home") + File.separator
|
||||||
+ ".jclouds-vbox";
|
+ ".jclouds-vbox";
|
||||||
|
|
||||||
public static final OsFamily VIRTUALBOX_DEFAULT_IMAGE_OS = OsFamily.UBUNTU;
|
|
||||||
|
|
||||||
public static final String VIRTUALBOX_DEFAULT_IMAGE_VERSION = "11.10";
|
|
||||||
|
|
||||||
public static final String VIRTUALBOX_DEFAULT_IMAGE_ARCH = "x86";
|
|
||||||
|
|
||||||
public static final String VIRTUALBOX_PROVIDER = "virtualbox";
|
public static final String VIRTUALBOX_PROVIDER = "virtualbox";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you 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.virtualbox.predicates;
|
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_ARCH;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_OS;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_VERSION;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
|
|
||||||
public class DefaultImagePredicate implements Predicate<Image> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Image input) {
|
|
||||||
return input.getOperatingSystem().getFamily() == VIRTUALBOX_DEFAULT_IMAGE_OS
|
|
||||||
&& input.getOperatingSystem().getVersion().equals(VIRTUALBOX_DEFAULT_IMAGE_VERSION)
|
|
||||||
&& input.getOperatingSystem().getArch().equals(VIRTUALBOX_DEFAULT_IMAGE_ARCH);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,7 +24,6 @@ import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -50,12 +49,8 @@ import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
||||||
import org.jclouds.virtualbox.domain.NetworkSpec;
|
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||||
import org.jclouds.virtualbox.domain.StorageController;
|
import org.jclouds.virtualbox.domain.StorageController;
|
||||||
import org.jclouds.virtualbox.domain.VmSpec;
|
import org.jclouds.virtualbox.domain.VmSpec;
|
||||||
import org.jclouds.virtualbox.domain.YamlImage;
|
|
||||||
import org.jclouds.virtualbox.functions.IMachineToVmSpec;
|
import org.jclouds.virtualbox.functions.IMachineToVmSpec;
|
||||||
import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
|
|
||||||
import org.jclouds.virtualbox.functions.admin.ImagesToYamlImagesFromYamlDescriptor;
|
|
||||||
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
|
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
|
||||||
import org.jclouds.virtualbox.predicates.DefaultImagePredicate;
|
|
||||||
import org.jclouds.virtualbox.util.MachineController;
|
import org.jclouds.virtualbox.util.MachineController;
|
||||||
import org.jclouds.virtualbox.util.MachineUtils;
|
import org.jclouds.virtualbox.util.MachineUtils;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
|
@ -139,20 +134,18 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
view.utils().injector().injectMembers(this);
|
view.utils().injector().injectMembers(this);
|
||||||
|
|
||||||
YamlImage image = getDefaultImage();
|
|
||||||
|
|
||||||
imageId = image.id;
|
|
||||||
masterVmName = VIRTUALBOX_IMAGE_PREFIX + image.id;
|
|
||||||
isosDir = workingDir + File.separator + "isos";
|
|
||||||
|
|
||||||
hostVersion = Iterables.get(Splitter.on('r').split(view.utils().injector().getInstance(Key.get(String.class, BuildVersion.class))), 0);
|
|
||||||
operatingSystemIso = String.format("%s/%s.iso", isosDir, image.name);
|
|
||||||
guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", isosDir, hostVersion);
|
|
||||||
|
|
||||||
// try and get a master from the cache, this will initialize the config/download isos and
|
// try and get a master from the cache, this will initialize the config/download isos and
|
||||||
// prepare everything IF a master is not available, subsequent calls should be pretty fast
|
// prepare everything IF a master is not available, subsequent calls should be pretty fast
|
||||||
Template template = view.getComputeService().templateBuilder().build();
|
Template template = view.getComputeService().templateBuilder().build();
|
||||||
checkNotNull(mastersCache.apply(template.getImage()));
|
checkNotNull(mastersCache.apply(template.getImage()));
|
||||||
|
|
||||||
|
imageId = template.getImage().getId();
|
||||||
|
masterVmName = VIRTUALBOX_IMAGE_PREFIX + imageId;
|
||||||
|
isosDir = workingDir + File.separator + "isos";
|
||||||
|
|
||||||
|
hostVersion = Iterables.get(Splitter.on('r').split(view.utils().injector().getInstance(Key.get(String.class, BuildVersion.class))), 0);
|
||||||
|
operatingSystemIso = String.format("%s/%s.iso", isosDir, template.getImage().getName());
|
||||||
|
guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", isosDir, hostVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void undoVm(String vmNameOrId) {
|
protected void undoVm(String vmNameOrId) {
|
||||||
|
@ -213,12 +206,6 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT
|
||||||
return MasterSpec.builder().iso(isoSpec).vm(sourceVmSpec).network(networkSpec).build();
|
return MasterSpec.builder().iso(isoSpec).vm(sourceVmSpec).network(networkSpec).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YamlImage getDefaultImage() {
|
|
||||||
Map<Image, YamlImage> images = new ImagesToYamlImagesFromYamlDescriptor(new YamlImagesFromFileConfig(
|
|
||||||
"/default-images.yaml")).get();
|
|
||||||
return images.get(Iterables.getOnlyElement(Iterables.filter(images.keySet(), new DefaultImagePredicate())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Module getSshModule() {
|
protected Module getSshModule() {
|
||||||
return new SshjSshClientModule();
|
return new SshjSshClientModule();
|
||||||
|
|
|
@ -22,16 +22,24 @@ import static junit.framework.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||||
|
import org.jclouds.virtualbox.domain.YamlImage;
|
||||||
|
import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
|
||||||
|
import org.jclouds.virtualbox.functions.admin.ImagesToYamlImagesFromYamlDescriptor;
|
||||||
import org.jclouds.virtualbox.functions.admin.PreseedCfgServer;
|
import org.jclouds.virtualbox.functions.admin.PreseedCfgServer;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that jetty is able to serve the preseed.cfg from the provided yaml image. This test is here
|
* Tests that jetty is able to serve the preseed.cfg from the provided yaml
|
||||||
* to have access to the defaultProperties() method in {@link VirtualBoxPropertiesBuilder}.
|
* image. This test is here to have access to the defaultProperties() method in
|
||||||
|
* {@link VirtualBoxPropertiesBuilder}.
|
||||||
*
|
*
|
||||||
* @author dralves
|
* @author dralves
|
||||||
*
|
*
|
||||||
|
@ -49,12 +57,18 @@ public class PreseedCfgServerTest {
|
||||||
|
|
||||||
PreseedCfgServer starter = new PreseedCfgServer();
|
PreseedCfgServer starter = new PreseedCfgServer();
|
||||||
|
|
||||||
starter.start(preconfigurationUrl, BaseVirtualBoxClientLiveTest.getDefaultImage().preseed_cfg);
|
starter.start(preconfigurationUrl, getDefaultImage().preseed_cfg);
|
||||||
|
|
||||||
String preseedFileFromJetty = IOUtils.toString(new URL("http://127.0.0.1:" + port + "/preseed.cfg").openStream());
|
String preseedFileFromJetty = IOUtils.toString(new URL("http://127.0.0.1:" + port + "/preseed.cfg").openStream());
|
||||||
String preseedFileFromFile = BaseVirtualBoxClientLiveTest.getDefaultImage().preseed_cfg + "\n";
|
String preseedFileFromFile = getDefaultImage().preseed_cfg + "\n";
|
||||||
assertEquals(preseedFileFromFile, preseedFileFromJetty);
|
assertEquals(preseedFileFromFile, preseedFileFromJetty);
|
||||||
|
|
||||||
starter.stop();
|
starter.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static YamlImage getDefaultImage() {
|
||||||
|
Map<Image, YamlImage> images = new ImagesToYamlImagesFromYamlDescriptor(new YamlImagesFromFileConfig(
|
||||||
|
"/default-images.yaml")).get();
|
||||||
|
return Iterables.get(images.values(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -30,7 +29,6 @@ import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.virtualbox.domain.YamlImage;
|
import org.jclouds.virtualbox.domain.YamlImage;
|
||||||
import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
|
import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
|
||||||
import org.jclouds.virtualbox.predicates.DefaultImagePredicate;
|
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -61,13 +59,4 @@ public class ImageFromYamlStringTest {
|
||||||
public void testNodesParse() {
|
public void testNodesParse() {
|
||||||
assertEquals(Iterables.getFirst(images.keySet(), null), TEST1);
|
assertEquals(Iterables.getFirst(images.keySet(), null), TEST1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultImagePresent() {
|
|
||||||
|
|
||||||
Iterable<Image> defaultImage = Iterables.filter(images.keySet(), new DefaultImagePredicate());
|
|
||||||
|
|
||||||
assertTrue(!Iterables.isEmpty(defaultImage));
|
|
||||||
assertEquals(1, Iterables.size(defaultImage));
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,64 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you 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.virtualbox.predicates;
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_ARCH;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_OS;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_IMAGE_VERSION;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple test for {@link DefaultImagePredicate} that makes sure the predicate returns true when
|
|
||||||
* an image built with the defaults is passed and false when it's not.
|
|
||||||
*
|
|
||||||
* @author dralves
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DefaultImagePredicateTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFindDefaultImage() {
|
|
||||||
Image image = new ImageBuilder()
|
|
||||||
.id("test-id")
|
|
||||||
.description("test-image")
|
|
||||||
.operatingSystem(
|
|
||||||
OperatingSystem.builder().arch(VIRTUALBOX_DEFAULT_IMAGE_ARCH)
|
|
||||||
.version(VIRTUALBOX_DEFAULT_IMAGE_VERSION).description("test-os")
|
|
||||||
.family(VIRTUALBOX_DEFAULT_IMAGE_OS).build()).build();
|
|
||||||
assertTrue(new DefaultImagePredicate().apply(image));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNotFindDefaultImage() {
|
|
||||||
Image image = new ImageBuilder()
|
|
||||||
.id("test-id")
|
|
||||||
.description("test-image")
|
|
||||||
.operatingSystem(
|
|
||||||
OperatingSystem.builder().arch(VIRTUALBOX_DEFAULT_IMAGE_ARCH)
|
|
||||||
.version(VIRTUALBOX_DEFAULT_IMAGE_VERSION).description("test-os")
|
|
||||||
.family(OsFamily.UNRECOGNIZED).build()).build();
|
|
||||||
assertTrue(!new DefaultImagePredicate().apply(image));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,10 +17,10 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2;
|
package org.jclouds.aws.ec2;
|
||||||
|
|
||||||
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
|
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
|
||||||
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
|
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
|
||||||
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS;
|
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -74,6 +74,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
||||||
.setProperty(
|
.setProperty(
|
||||||
PROPERTY_EC2_CC_AMI_QUERY,
|
PROPERTY_EC2_CC_AMI_QUERY,
|
||||||
"virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen;state=available;image-type=machine;root-device-type=ebs");
|
"virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen;state=available;image-type=machine;root-device-type=ebs");
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=AMZN_LINUX,os64Bit=true");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.jclouds.aws.ec2.compute.config;
|
package org.jclouds.aws.ec2.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -42,7 +41,6 @@ import org.jclouds.aws.ec2.compute.suppliers.AWSEC2HardwareSupplier;
|
||||||
import org.jclouds.compute.ImageExtension;
|
import org.jclouds.compute.ImageExtension;
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionSupplier;
|
import org.jclouds.concurrent.RetryOnTimeOutExceptionSupplier;
|
||||||
import org.jclouds.ec2.compute.config.EC2BindComputeStrategiesByClass;
|
import org.jclouds.ec2.compute.config.EC2BindComputeStrategiesByClass;
|
||||||
|
@ -166,11 +164,6 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext
|
||||||
return supplier;
|
return supplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(AMZN_LINUX).os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* With amazon linux 2011.09, ssh starts after package updates, which slows the boot process and
|
* With amazon linux 2011.09, ssh starts after package updates, which slows the boot process and
|
||||||
* runs us out of ssh retries (context property {@code "jclouds.ssh.max-retries"}).
|
* runs us out of ssh retries (context property {@code "jclouds.ssh.max-retries"}).
|
||||||
|
|
|
@ -55,8 +55,6 @@ public class BluelockVCloudZone01TemplateBuilderLiveTest extends BaseTemplateBui
|
||||||
return !input.version.equals("") || !input.is64Bit;
|
return !input.version.equals("") || !input.is64Bit;
|
||||||
case RHEL:
|
case RHEL:
|
||||||
return !input.version.equals("");
|
return !input.version.equals("");
|
||||||
case WINDOWS:
|
|
||||||
return !input.version.equals("");
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.epc;
|
package org.jclouds.epc;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||||
|
@ -67,6 +68,7 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad
|
||||||
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
|
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
|
||||||
properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA");
|
properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA");
|
||||||
properties.setProperty("eucalyptus-partnercloud-ec2.virtualization-type", "kvm");
|
properties.setProperty("eucalyptus-partnercloud-ec2.virtualization-type", "kvm");
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,locationId=${eucalyptus-partnercloud-ec2.virtualization-type}-cluster");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,30 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.epc.config;
|
package org.jclouds.epc.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
|
import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
|
||||||
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
|
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
|
||||||
import org.jclouds.epc.strategy.EucalyptusPartnerCloudReviseParsedImage;
|
import org.jclouds.epc.strategy.EucalyptusPartnerCloudReviseParsedImage;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.name.Names;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class EucalyptusPartnerCloudComputeServiceContextModule extends EC2ComputeServiceContextModule {
|
public class EucalyptusPartnerCloudComputeServiceContextModule extends EC2ComputeServiceContextModule {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
String virt = injector.getInstance(Key.get(String.class, Names
|
|
||||||
.named("eucalyptus-partnercloud-ec2.virtualization-type")));
|
|
||||||
return template.osFamily(UBUNTU).locationId(virt + "-cluster");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.gogrid;
|
package org.jclouds.gogrid;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.gogrid.reference.GoGridConstants.PROPERTY_GOGRID_DEFAULT_DC;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||||
|
@ -63,7 +63,7 @@ public class GoGridProviderMetadata extends BaseProviderMetadata {
|
||||||
properties.setProperty(PROPERTY_ZONE + ".2." + ISO3166_CODES, "US-VA");
|
properties.setProperty(PROPERTY_ZONE + ".2." + ISO3166_CODES, "US-VA");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".3." + ISO3166_CODES, "NL-NH");
|
properties.setProperty(PROPERTY_ZONE + ".3." + ISO3166_CODES, "NL-NH");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, GoGridAsyncClient.VERSION);
|
properties.setProperty(PROPERTY_API_VERSION, GoGridAsyncClient.VERSION);
|
||||||
properties.setProperty(PROPERTY_GOGRID_DEFAULT_DC, "1");
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[012].[01][04],imageNameMatches=.*w/ None.*,locationId=1");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.compute.config;
|
package org.jclouds.gogrid.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
|
import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
|
||||||
|
|
||||||
|
@ -32,7 +31,6 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -49,7 +47,6 @@ import org.jclouds.gogrid.domain.ServerState;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -61,11 +58,6 @@ import com.google.inject.TypeLiteral;
|
||||||
public class GoGridComputeServiceContextModule extends
|
public class GoGridComputeServiceContextModule extends
|
||||||
ComputeServiceAdapterContextModule<Server, Hardware, ServerImage, Option> {
|
ComputeServiceAdapterContextModule<Server, Hardware, ServerImage, Option> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").imageNameMatches(".*w/ None.*");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.location;
|
package org.jclouds.gogrid.location;
|
||||||
|
|
||||||
import static org.jclouds.gogrid.reference.GoGridConstants.PROPERTY_GOGRID_DEFAULT_DC;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -31,6 +33,7 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@ -44,10 +47,11 @@ public class GoGridDefaultLocationSupplier implements ImplicitLocationSupplier {
|
||||||
private final String defaultDC;
|
private final String defaultDC;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GoGridDefaultLocationSupplier(@Memoized Supplier<Set<? extends Location>> locations,
|
GoGridDefaultLocationSupplier(@Memoized Supplier<Set<? extends Location>> locations, @Named(TEMPLATE) String template) {
|
||||||
@Named(PROPERTY_GOGRID_DEFAULT_DC) String defaultDC) {
|
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
this.defaultDC = defaultDC;
|
Map<String, String> map = Splitter.on(',').trimResults().withKeyValueSeparator("=").split(template);
|
||||||
|
//TODO: move to real ImplicitLocationSupplier
|
||||||
|
this.defaultDC = checkNotNull(map.get("locationId"), "locationId not in % value: %s", TEMPLATE, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you 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.reference;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration properties and constants used in GoGrid connections.
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public interface GoGridConstants {
|
|
||||||
|
|
||||||
public static final String PROPERTY_GOGRID_DEFAULT_DC = "jclouds.gogrid.defaultdc";
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.hpcloud.compute;
|
package org.jclouds.hpcloud.compute;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
|
||||||
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
|
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
|
||||||
import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
|
import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
|
||||||
|
@ -70,6 +71,7 @@ public class HPCloudComputeProviderMetadata extends BaseProviderMetadata {
|
||||||
properties.setProperty(CREDENTIAL_TYPE, "apiAccessKeyCredentials");
|
properties.setProperty(CREDENTIAL_TYPE, "apiAccessKeyCredentials");
|
||||||
properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true");
|
properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true");
|
||||||
properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true");
|
properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true");
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[012].[01][04],os64Bit=true,locationId=az-2.region-a.geo-1");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.hpcloud.compute.config;
|
package org.jclouds.hpcloud.compute.config;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.hpcloud.compute.HPCloudComputeServiceAdapter;
|
import org.jclouds.hpcloud.compute.HPCloudComputeServiceAdapter;
|
||||||
import org.jclouds.openstack.nova.v1_1.compute.NovaComputeServiceAdapter;
|
import org.jclouds.openstack.nova.v1_1.compute.NovaComputeServiceAdapter;
|
||||||
import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule;
|
import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -37,10 +34,4 @@ public class HPCloudComputeServiceContextModule extends NovaComputeServiceContex
|
||||||
bind(NovaComputeServiceAdapter.class).to(HPCloudComputeServiceAdapter.class);
|
bind(NovaComputeServiceAdapter.class).to(HPCloudComputeServiceAdapter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
// account on az-1.region-a.geo-1 hosed
|
|
||||||
return super.provideTemplate(injector, template).locationId("az-2.region-a.geo-1");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,10 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro;
|
package org.jclouds.rimuhosting.miro;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||||
import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_DEFAULT_DC;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -62,7 +62,7 @@ public class RimuHostingProviderMetadata extends BaseProviderMetadata {
|
||||||
properties.setProperty(PROPERTY_ZONE + ".DCLONDON." + ISO3166_CODES, "GB-LND");
|
properties.setProperty(PROPERTY_ZONE + ".DCLONDON." + ISO3166_CODES, "GB-LND");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".DCDALLAS." + ISO3166_CODES, "US-TX");
|
properties.setProperty(PROPERTY_ZONE + ".DCDALLAS." + ISO3166_CODES, "US-TX");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".DCSYDNEY." + ISO3166_CODES, "AU-NSW");
|
properties.setProperty(PROPERTY_ZONE + ".DCSYDNEY." + ISO3166_CODES, "AU-NSW");
|
||||||
properties.setProperty(PROPERTY_RIMUHOSTING_DEFAULT_DC, "DCDALLAS");
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[012].[01][04],os64Bit=true,hardwareId=MIRO4B,locationId=DCDALLAS");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
package org.jclouds.rimuhosting.miro.compute.config;
|
package org.jclouds.rimuhosting.miro.compute.config;
|
||||||
|
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the {@link RimuHostingComputeServiceContext}; requires
|
* Configures the {@link RimuHostingComputeServiceContext}; requires
|
||||||
|
@ -39,9 +36,4 @@ public class RimuHostingComputeServiceContextModule extends BaseComputeServiceCo
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return super.provideTemplate(injector, template).hardwareId("MIRO4B");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.location;
|
package org.jclouds.rimuhosting.miro.location;
|
||||||
|
|
||||||
import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_DEFAULT_DC;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -31,6 +33,7 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@ -45,9 +48,11 @@ public class RimuHostingDefaultLocationSupplier implements ImplicitLocationSuppl
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RimuHostingDefaultLocationSupplier(@Memoized Supplier<Set<? extends Location>> locations,
|
RimuHostingDefaultLocationSupplier(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Named(PROPERTY_RIMUHOSTING_DEFAULT_DC) String defaultDC) {
|
@Named(TEMPLATE) String template) {
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
this.defaultDC = defaultDC;
|
Map<String, String> map = Splitter.on(',').trimResults().withKeyValueSeparator("=").split(template);
|
||||||
|
// TODO: move to real ImplicitLocationSupplier
|
||||||
|
this.defaultDC = checkNotNull(map.get("locationId"), "locationId not in % value: %s", TEMPLATE, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you 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.reference;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration properties and constants used in RimuHosting connections.
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public interface RimuHostingConstants {
|
|
||||||
|
|
||||||
public static final String PROPERTY_RIMUHOSTING_DEFAULT_DC = "jclouds.rimuhosting.defaultdc";
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.jclouds.slicehost;
|
package org.jclouds.slicehost;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ public class SlicehostProviderMetadata extends BaseProviderMetadata {
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[012].[01][04],os64Bit=true,osDescriptionMatches=^((?!MGC).)*$");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.slicehost.compute.config;
|
package org.jclouds.slicehost.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -31,7 +29,6 @@ import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -46,7 +43,6 @@ import org.jclouds.slicehost.domain.Slice;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -82,12 +78,6 @@ public class SlicehostComputeServiceContextModule extends
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").osDescriptionMatches("^((?!MGC).)*$")
|
|
||||||
.os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<Slice.Status, NodeState> sliceStatusToNodeState = ImmutableMap
|
public static final Map<Slice.Status, NodeState> sliceStatusToNodeState = ImmutableMap
|
||||||
.<Slice.Status, NodeState> builder().put(Slice.Status.ACTIVE, NodeState.RUNNING)//
|
.<Slice.Status, NodeState> builder().put(Slice.Status.ACTIVE, NodeState.RUNNING)//
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.softlayer;
|
package org.jclouds.softlayer;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX;
|
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX;
|
||||||
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE;
|
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE;
|
||||||
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY;
|
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY;
|
||||||
|
@ -83,7 +84,7 @@ public class SoftLayerProviderMetadata extends BaseProviderMetadata {
|
||||||
prices.add("420"); // Unlimited SSL VPN Users & 1 PPTP VPN User per account: categoryCode:
|
prices.add("420"); // Unlimited SSL VPN Users & 1 PPTP VPN User per account: categoryCode:
|
||||||
// vpn_management
|
// vpn_management
|
||||||
properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES, Joiner.on(',').join(prices.build()));
|
properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES, Joiner.on(',').join(prices.build()));
|
||||||
|
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[012].[01][04],os64Bit=true,osDescriptionMatches=.*Minimal Install.*");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
|
@ -59,7 +57,6 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -88,11 +85,6 @@ public class SoftLayerComputeServiceContextModule extends
|
||||||
install(new LocationsFromComputeServiceAdapterModule<VirtualGuest, Iterable<ProductItem>, ProductItem, Datacenter>(){});
|
install(new LocationsFromComputeServiceAdapterModule<VirtualGuest, Iterable<ProductItem>, ProductItem, Datacenter>(){});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(OsFamily.UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true).osDescriptionMatches(
|
|
||||||
".*Minimal Install.*");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Many requests need the same productPackage, which is in this case the package for virtual
|
* Many requests need the same productPackage, which is in this case the package for virtual
|
||||||
* guests. We may at some point need to make an annotation qualifying it as such. ex. @VirtualGuest
|
* guests. We may at some point need to make an annotation qualifying it as such. ex. @VirtualGuest
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.stratogen.vcloud.mycloud;
|
package org.jclouds.stratogen.vcloud.mycloud;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -62,6 +63,7 @@ public class StratoGenVCloudMyCloudProviderMetadata extends BaseProviderMetadata
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "Direct Internet");
|
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "Direct Internet");
|
||||||
|
properties.setProperty(TEMPLATE, "imageNameMatches=Ubuntu server 11.04 64bit no GUI (base)");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.stratogen.vcloud.mycloud.config;
|
package org.jclouds.stratogen.vcloud.mycloud.config;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
||||||
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
||||||
|
@ -33,11 +32,6 @@ import com.google.inject.Injector;
|
||||||
*/
|
*/
|
||||||
public class StratoGenVCloudMyCloudComputeServiceContextModule extends VCloudComputeServiceContextModule {
|
public class StratoGenVCloudMyCloudComputeServiceContextModule extends VCloudComputeServiceContextModule {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.imageNameMatches("Ubuntu server 11.04 64bit no GUI (base)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
|
protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
|
||||||
return options.as(VCloudTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL);
|
return options.as(VCloudTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL);
|
||||||
|
|
|
@ -18,17 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.trmk.ecloud.compute.config;
|
package org.jclouds.trmk.ecloud.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.trmk.ecloud.compute.functions.TerremarkECloudParseOsFromVAppTemplateName;
|
import org.jclouds.trmk.ecloud.compute.functions.TerremarkECloudParseOsFromVAppTemplateName;
|
||||||
import org.jclouds.trmk.ecloud.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier;
|
import org.jclouds.trmk.ecloud.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier;
|
||||||
import org.jclouds.trmk.vcloud_0_8.compute.config.TerremarkVCloudComputeServiceContextModule;
|
import org.jclouds.trmk.vcloud_0_8.compute.config.TerremarkVCloudComputeServiceContextModule;
|
||||||
import org.jclouds.trmk.vcloud_0_8.compute.functions.ParseOsFromVAppTemplateName;
|
import org.jclouds.trmk.vcloud_0_8.compute.functions.ParseOsFromVAppTemplateName;
|
||||||
import org.jclouds.trmk.vcloud_0_8.suppliers.InternetServiceAndPublicIpAddressSupplier;
|
import org.jclouds.trmk.vcloud_0_8.suppliers.InternetServiceAndPublicIpAddressSupplier;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -42,9 +37,4 @@ public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudC
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue