Issue 355: initial cut of nova support

This commit is contained in:
Adrian Cole 2010-09-15 19:12:21 -07:00
parent ccbe1c56f1
commit 6f3b20d9c9
21 changed files with 725 additions and 52 deletions

View File

@ -0,0 +1,47 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
import java.util.Properties;
/**
* Builds properties used in Eucalyptus Clients
*
* @author Adrian Cole
*/
public class NovaPropertiesBuilder extends EC2PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ENDPOINT, "YOU_MUST_SET_" + PROPERTY_ENDPOINT);
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*");
properties.setProperty(PROPERTY_EC2_CC_AMIs, "");
return properties;
}
public NovaPropertiesBuilder(Properties properties) {
super(properties);
}
}

View File

@ -26,6 +26,7 @@ import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs; import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX; import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
import static org.jclouds.compute.domain.OsFamily.CENTOS; import static org.jclouds.compute.domain.OsFamily.CENTOS;
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Map; import java.util.Map;
@ -36,7 +37,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.aws.Region;
import org.jclouds.aws.ec2.EC2AsyncClient; import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.compute.EC2ComputeService; import org.jclouds.aws.ec2.compute.EC2ComputeService;
@ -83,6 +83,7 @@ import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.annotations.Provider;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
@ -164,9 +165,13 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
@Override @Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
String region = injector.getInstance(Key.get(String.class, Region.class)); String provider = injector.getInstance(Key.get(String.class, Provider.class));
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest() : template.osFamily(AMZN_LINUX) if ("eucalyptus".equals(provider))
.os64Bit(true); return template.osFamily(CENTOS);
else if ("nova".equals(provider))
return template.osFamily(UBUNTU);
else
return template.osFamily(AMZN_LINUX).os64Bit(true);
} }
@Provides @Provides

View File

@ -110,11 +110,11 @@ public class EC2Hardware extends HardwareImpl {
1.0, 1.0)), 1740, ImmutableList.of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f, 1.0, 1.0)), 1740, ImmutableList.of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f,
"/dev/sda2", false, false)), false); "/dev/sda2", false, false)), false);
/** /**
* In Eucalyptus, m1.small can run 64bit images. * In Nova, m1.small can run 64bit images.
* *
* @see InstanceType#M1_SMALL * @see InstanceType#M1_SMALL
*/ */
public static final EC2Hardware M1_SMALL_EUCALYPTUS = new EC2Hardware(null, InstanceType.M1_SMALL, ImmutableList public static final EC2Hardware M1_SMALL_NOVA = new EC2Hardware(null, InstanceType.M1_SMALL, ImmutableList
.of(new Processor(1.0, 1.0)), 1740, ImmutableList.of(new VolumeImpl(10.0f, "/dev/sda1", true, false), .of(new Processor(1.0, 1.0)), 1740, ImmutableList.of(new VolumeImpl(10.0f, "/dev/sda1", true, false),
new VolumeImpl(150.0f, "/dev/sda2", false, false)), any()); new VolumeImpl(150.0f, "/dev/sda2", false, false)), any());

View File

@ -46,6 +46,7 @@ import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope; import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl; import org.jclouds.domain.internal.LocationImpl;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rest.annotations.Provider;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -61,11 +62,17 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
@Resource @Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER) @Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
// nebula/ubuntu-karmic
// nebula/karmic-large
public static final Pattern NEBULA_PATTERN = Pattern.compile("nebula/(ubuntu-)?(.*)(-.*)?");
// 137112412989/amzn-ami-0.9.7-beta.i386-ebs // 137112412989/amzn-ami-0.9.7-beta.i386-ebs
// 137112412989/amzn-ami-0.9.7-beta.x86_64-ebs // 137112412989/amzn-ami-0.9.7-beta.x86_64-ebs
// amzn-ami-us-east-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml // amzn-ami-us-east-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml
// amzn-ami-us-east-1/amzn-ami-0.9.7-beta.i386.manifest.xml // amzn-ami-us-east-1/amzn-ami-0.9.7-beta.i386.manifest.xml
public static final Pattern AMZN_PATTERN = Pattern.compile(".*/amzn-ami-(.*)\\.(i386|x86_64)(-ebs|\\.manifest.xml)?"); public static final Pattern AMZN_PATTERN = Pattern
.compile(".*/amzn-ami-(.*)\\.(i386|x86_64)(-ebs|\\.manifest.xml)?");
public static final Pattern CANONICAL_PATTERN = Pattern.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?"); public static final Pattern CANONICAL_PATTERN = Pattern.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?");
@ -81,22 +88,19 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
private final Supplier<Set<? extends Location>> locations; private final Supplier<Set<? extends Location>> locations;
private final Supplier<Location> defaultLocation; private final Supplier<Location> defaultLocation;
private final String provider;
@Inject @Inject
ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider, ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
Supplier<Set<? extends Location>> locations, Supplier<Location> defaultLocation) { Supplier<Set<? extends Location>> locations, Supplier<Location> defaultLocation, @Provider String provider) {
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider"); this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
this.locations = checkNotNull(locations, "locations"); this.locations = checkNotNull(locations, "locations");
this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation"); this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
this.provider = checkNotNull(provider, "provider");
} }
@Override @Override
public Image apply(final org.jclouds.aws.ec2.domain.Image from) { public Image apply(final org.jclouds.aws.ec2.domain.Image from) {
if (from.getImageLocation().indexOf("test") != -1) {
logger.trace("skipping test image(%s)", from.getId());
return null;
}
if (from.getImageType() != ImageType.MACHINE) { if (from.getImageType() != ImageType.MACHINE) {
logger.trace("skipping as not a machine image(%s)", from.getId()); logger.trace("skipping as not a machine image(%s)", from.getId());
return null; return null;
@ -105,7 +109,7 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
String description = from.getDescription() != null ? from.getDescription() : from.getImageLocation(); String description = from.getDescription() != null ? from.getDescription() : from.getImageLocation();
String version = null; String version = null;
OsFamily osFamily = parseOsFamilyOrNull(from.getImageLocation()); OsFamily osFamily = parseOsFamilyOrNull(provider, from.getImageLocation());
String osName = null; String osName = null;
String osArch = from.getVirtualizationType(); String osArch = from.getVirtualizationType();
String osVersion = parseVersionOrReturnEmptyString(osFamily, from.getImageLocation()); String osVersion = parseVersionOrReturnEmptyString(osFamily, from.getImageLocation());
@ -116,6 +120,8 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
if (matcher.pattern() == AMZN_PATTERN) { if (matcher.pattern() == AMZN_PATTERN) {
osFamily = OsFamily.AMZN_LINUX; osFamily = OsFamily.AMZN_LINUX;
version = osVersion = matcher.group(1); version = osVersion = matcher.group(1);
} else if (matcher.pattern() == NEBULA_PATTERN) {
osVersion = parseVersionOrReturnEmptyString(osFamily, matcher.group(2));
} else { } else {
osFamily = OsFamily.fromValue(matcher.group(1)); osFamily = OsFamily.fromValue(matcher.group(1));
osVersion = parseVersionOrReturnEmptyString(osFamily, matcher.group(2)); osVersion = parseVersionOrReturnEmptyString(osFamily, matcher.group(2));
@ -157,7 +163,8 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
* if no configured matcher matches the manifest. * if no configured matcher matches the manifest.
*/ */
private Matcher getMatcherAndFind(String manifest) { private Matcher getMatcherAndFind(String manifest) {
for (Pattern pattern : new Pattern[] { AMZN_PATTERN, CANONICAL_PATTERN, RIGHTIMAGE_PATTERN, RIGHTSCALE_PATTERN }) { for (Pattern pattern : new Pattern[] { AMZN_PATTERN, NEBULA_PATTERN, CANONICAL_PATTERN, RIGHTIMAGE_PATTERN,
RIGHTSCALE_PATTERN }) {
Matcher matcher = pattern.matcher(manifest); Matcher matcher = pattern.matcher(manifest);
if (matcher.find()) if (matcher.find())
return matcher; return matcher;

View File

@ -58,6 +58,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ComputationException;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -239,6 +240,8 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
image = imageMap.get(key); image = imageMap.get(key);
} catch (NullPointerException nex) { } catch (NullPointerException nex) {
logger.debug("could not find a matching image for instance %s in location %s", instance, location); logger.debug("could not find a matching image for instance %s in location %s", instance, location);
} catch (ComputationException nex) {
logger.debug("could not find a matching image for instance %s in location %s", instance, location);
} }
return image; return image;
} }

View File

@ -31,14 +31,15 @@ import javax.inject.Provider;
import org.jclouds.aws.ec2.compute.domain.RegionAndName; import org.jclouds.aws.ec2.compute.domain.RegionAndName;
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions; import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
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 org.jclouds.domain.Location; import org.jclouds.domain.Location;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ComputationException;
/** /**
* *
@ -91,6 +92,8 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
return imageMap.get(key); return imageMap.get(key);
} catch (NullPointerException nex) { } catch (NullPointerException nex) {
throw new NoSuchElementException(String.format("image %s/%s not found", key.getRegion(), key.getName())); throw new NoSuchElementException(String.format("image %s/%s not found", key.getRegion(), key.getName()));
} catch (ComputationException nex) {
throw new NoSuchElementException(String.format("image %s/%s not found", key.getRegion(), key.getName()));
} }
} }
return null; return null;

View File

@ -86,9 +86,8 @@ public class EC2HardwareSupplier implements Supplier<Set<? extends Hardware>> {
new VolumeImpl(840.0f, "/dev/sdc", false, false)), ccAmis)); new VolumeImpl(840.0f, "/dev/sdc", false, false)), ccAmis));
} }
sizes.addAll(ImmutableSet.<Hardware> of(EC2Hardware.T1_MICRO, EC2Hardware.C1_MEDIUM, EC2Hardware.C1_XLARGE, sizes.addAll(ImmutableSet.<Hardware> of(EC2Hardware.T1_MICRO, EC2Hardware.C1_MEDIUM, EC2Hardware.C1_XLARGE,
EC2Hardware.M1_LARGE, "eucalyptus".equals(providerName) ? EC2Hardware.M1_SMALL_EUCALYPTUS EC2Hardware.M1_LARGE, "nova".equals(providerName) ? EC2Hardware.M1_SMALL_NOVA : EC2Hardware.M1_SMALL,
: EC2Hardware.M1_SMALL, EC2Hardware.M1_XLARGE, EC2Hardware.M2_XLARGE, EC2Hardware.M2_2XLARGE, EC2Hardware.M1_XLARGE, EC2Hardware.M2_XLARGE, EC2Hardware.M2_2XLARGE, EC2Hardware.M2_4XLARGE));
EC2Hardware.M2_4XLARGE));
return sizes; return sizes;
} }
} }

View File

@ -186,11 +186,11 @@ public class RunningInstance implements Comparable<RunningInstance> {
this.keyName = keyName; this.keyName = keyName;
this.launchTime = checkNotNull(launchTime, "launchTime"); this.launchTime = checkNotNull(launchTime, "launchTime");
this.monitoringState = monitoringState; this.monitoringState = monitoringState;
this.availabilityZone = availabilityZone; // nullable on Eucalyptus. this.availabilityZone = availabilityZone; // nullable on Nova.
this.placementGroup = placementGroup; this.placementGroup = placementGroup;
this.virtualizationType = virtualizationType; this.virtualizationType = virtualizationType;
this.platform = platform; this.platform = platform;
this.privateDnsName = privateDnsName; // nullable on runinstances. this.privateDnsName = privateDnsName; // nullable on Nova.
this.privateIpAddress = privateIpAddress; this.privateIpAddress = privateIpAddress;
Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes")); Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes"));
this.ramdiskId = ramdiskId; this.ramdiskId = ramdiskId;

View File

@ -147,7 +147,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
} else if (qName.equals("name")) { } else if (qName.equals("name")) {
String state = currentOrNull(); String state = currentOrNull();
if (state != null) { if (state != null) {
// Eucalyptus // Nova
if ("shutdown".equalsIgnoreCase(state)) if ("shutdown".equalsIgnoreCase(state))
instanceState = InstanceState.TERMINATED; instanceState = InstanceState.TERMINATED;
else else

View File

@ -121,7 +121,8 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerForGeneratedR
imageOwnerId = currentText.toString().trim(); imageOwnerId = currentText.toString().trim();
} else if (qName.equals("imageState")) { } else if (qName.equals("imageState")) {
imageState = ImageState.fromValue(currentText.toString().trim()); imageState = ImageState.fromValue(currentText.toString().trim());
} else if (qName.equals("imageType")) { // eucalyptus
} else if (qName.equals("imageType") || qName.equals("type")) {
imageType = ImageType.fromValue(currentText.toString().trim()); imageType = ImageType.fromValue(currentText.toString().trim());
} else if (qName.equals("isPublic")) { } else if (qName.equals("isPublic")) {
isPublic = Boolean.parseBoolean(currentText.toString().trim()); isPublic = Boolean.parseBoolean(currentText.toString().trim());

View File

@ -51,7 +51,7 @@ public class DescribeRegionsResponseHandler extends ParseSax.HandlerWithResult<M
String pending = currentText.toString().trim(); String pending = currentText.toString().trim();
if (pending.indexOf("Walrus") == -1) if (pending.indexOf("Walrus") == -1)
region = pending; region = pending;
// Eucalyptus uses regionUrl // Nova uses regionUrl
} else if (qName.equals("regionEndpoint") || qName.equals("regionUrl")) { } else if (qName.equals("regionEndpoint") || qName.equals("regionUrl")) {
String pending = currentText.toString().trim(); String pending = currentText.toString().trim();
if (pending.indexOf("Walrus") == -1) if (pending.indexOf("Walrus") == -1)

View File

@ -97,7 +97,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
exception = new IllegalStateException(message, exception); exception = new IllegalStateException(message, exception);
else if (error != null && error.getCode() != null && error.getCode().equals("AuthFailure")) else if (error != null && error.getCode() != null && error.getCode().equals("AuthFailure"))
exception = new AuthorizationException(command.getRequest(), message); exception = new AuthorizationException(command.getRequest(), message);
else if (message != null && message.indexOf("Failed to bind the following fields") != -1)// Eucalyptus else if (message != null && message.indexOf("Failed to bind the following fields") != -1)// Nova
exception = new IllegalArgumentException(message, exception); exception = new IllegalArgumentException(message, exception);
break; break;
case 401: case 401:

View File

@ -43,6 +43,7 @@ public class ProvidersInPropertiesTest {
assert !Iterables.contains(providers, "walrus") : providers; assert !Iterables.contains(providers, "walrus") : providers;
assert !Iterables.contains(providers, "googlestorage") : providers; assert !Iterables.contains(providers, "googlestorage") : providers;
assert Iterables.contains(providers, "ec2") : providers; assert Iterables.contains(providers, "ec2") : providers;
assert Iterables.contains(providers, "nebula") : providers;
assert Iterables.contains(providers, "eucalyptus") : providers; assert Iterables.contains(providers, "eucalyptus") : providers;
} }
@ -55,6 +56,7 @@ public class ProvidersInPropertiesTest {
assert Iterables.contains(providers, "walrus") : providers; assert Iterables.contains(providers, "walrus") : providers;
assert Iterables.contains(providers, "googlestorage") : providers; assert Iterables.contains(providers, "googlestorage") : providers;
assert Iterables.contains(providers, "ec2") : providers; assert Iterables.contains(providers, "ec2") : providers;
assert Iterables.contains(providers, "nebula") : providers;
assert Iterables.contains(providers, "eucalyptus") : providers; assert Iterables.contains(providers, "eucalyptus") : providers;
} }
@ -67,6 +69,7 @@ public class ProvidersInPropertiesTest {
assert Iterables.contains(providers, "walrus") : providers; assert Iterables.contains(providers, "walrus") : providers;
assert Iterables.contains(providers, "googlestorage") : providers; assert Iterables.contains(providers, "googlestorage") : providers;
assert !Iterables.contains(providers, "ec2") : providers; assert !Iterables.contains(providers, "ec2") : providers;
assert !Iterables.contains(providers, "nebula") : providers;
assert !Iterables.contains(providers, "eucalyptus") : providers; assert !Iterables.contains(providers, "eucalyptus") : providers;
} }

View File

@ -0,0 +1,54 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.compute;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", sequential = true, testName = "ec2.NebulaComputeServiceLiveTest")
public class NovaComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
@BeforeClass
@Override
public void setServiceDefaults() {
provider = "nova";
}
@Override
protected void assertDefaultWorks() {
Template defaultTemplate = client.templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(defaultTemplate.getLocation().getId(), "nova");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
}

View File

@ -0,0 +1,110 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.compute;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.jclouds.aws.ec2.reference.EC2Constants;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", testName = "ec2.NebulaTemplateBuilderLiveTest")
public class NovaTemplateBuilderLiveTest {
private String password;
private String user;
@BeforeGroups(groups = { "live" })
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
user = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
password = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
}
@Test
public void testDefaultTemplateBuilder() throws IOException {
ComputeServiceContext newContext = null;
try {
newContext = new ComputeServiceContextFactory().createContext("nova", user, password, ImmutableSet
.of(new Log4JLoggingModule()));
Template defaultTemplate = newContext.getComputeService().templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "9.10");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(defaultTemplate.getLocation().getId(), "nova");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
} finally {
if (newContext != null)
newContext.close();
}
}
@Test
public void testTemplateBuilderWithNoOwnersParsesImageOnDemand() throws IOException {
ComputeServiceContext newContext = null;
try {
Properties overrides = new Properties();
// set owners to nothing
overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
newContext = new ComputeServiceContextFactory().createContext("nova", user, password, ImmutableSet
.of(new Log4JLoggingModule()), overrides);
assertEquals(newContext.getComputeService().listImages().size(), 0);
Template template = newContext.getComputeService().templateBuilder().imageId("nova/ami-6CD61336").build();
assert (template.getImage().getProviderId().startsWith("ami-")) : template;
assertEquals(template.getImage().getOperatingSystem().getVersion(), "");
assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(template.getImage().getOperatingSystem().getFamily(), null);
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(template.getLocation().getId(), "nova");
assertEquals(getCores(template.getHardware()), 1.0d);
// ensure we cache the new image for next time
assertEquals(newContext.getComputeService().listImages().size(), 1);
} finally {
if (newContext != null)
newContext.close();
}
}
}

View File

@ -58,7 +58,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation)); .ofInstance(defaultLocation), "ec2");
org.jclouds.compute.domain.Image ubuntuHardy = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image ubuntuHardy = parser.apply(Iterables.get(result, 0));
assertEquals(ubuntuHardy.getDescription(), "ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml"); assertEquals(ubuntuHardy.getDescription(), "ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
@ -114,8 +114,24 @@ public class ImageParserTest extends BaseEC2HandlerTest {
"rootDeviceType", "instance-store")); "rootDeviceType", "instance-store"));
assertEquals(ubuntuKarmic.getVersion(), "20100121"); assertEquals(ubuntuKarmic.getVersion(), "20100121");
// should skip testing image org.jclouds.compute.domain.Image testing = parser.apply(Iterables.get(result, 3));
assert parser.apply(Iterables.get(result, 3)) == null;
assertEquals(testing.getOperatingSystem().is64Bit(), true);
assertEquals(testing.getDescription(),
"ubuntu-images-testing-us/ubuntu-lucid-daily-amd64-desktop-20100317.manifest.xml");
assertEquals(testing.getId(), "us-east-1/ami-190fe070");
assertEquals(testing.getProviderId(), "ami-190fe070");
assertEquals(testing.getLocation(), defaultLocation);
assertEquals(testing.getName(), null);
assertEquals(testing.getOperatingSystem().getName(), null);
assertEquals(testing.getOperatingSystem().getVersion(), "10.04");
assertEquals(testing.getOperatingSystem().getArch(), "paravirtual");
assertEquals(testing.getOperatingSystem().getDescription(),
"ubuntu-images-testing-us/ubuntu-lucid-daily-amd64-desktop-20100317.manifest.xml");
assertEquals(testing.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(testing.getUserMetadata(), ImmutableMap.<String, String> of("owner", "099720109477",
"rootDeviceType", "instance-store"));
assertEquals(testing.getVersion(), "20100317");
org.jclouds.compute.domain.Image alesticHardy = parser.apply(Iterables.get(result, 4)); org.jclouds.compute.domain.Image alesticHardy = parser.apply(Iterables.get(result, 4));
@ -186,7 +202,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation)); .ofInstance(defaultLocation), "ec2");
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
@ -215,7 +231,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation)); .ofInstance(defaultLocation), "ec2");
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
@ -243,7 +259,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation)); .ofInstance(defaultLocation), "ec2");
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
@ -289,7 +305,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
assertEquals(result.size(), 4); assertEquals(result.size(), 4);
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation)); .ofInstance(defaultLocation), "ec2");
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
@ -308,10 +324,6 @@ public class ImageParserTest extends BaseEC2HandlerTest {
"instance-store")); "instance-store"));
assertEquals(image.getVersion(), null); assertEquals(image.getVersion(), null);
// should skip test images
image = parser.apply(Iterables.get(result, 3));
assertEquals(image, null);
} }
public void testParseAmznmage() { public void testParseAmznmage() {
@ -321,7 +333,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
assertEquals(result.size(), 4); assertEquals(result.size(), 4);
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers .<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation)); .ofInstance(defaultLocation), "ec2");
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
@ -368,7 +380,8 @@ public class ImageParserTest extends BaseEC2HandlerTest {
assertEquals(image.getOperatingSystem().getName(), null); assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "0.9.7-beta"); assertEquals(image.getOperatingSystem().getVersion(), "0.9.7-beta");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual"); assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "amzn-ami-us-west-1/amzn-ami-0.9.7-beta.i386.manifest.xml"); assertEquals(image.getOperatingSystem().getDescription(),
"amzn-ami-us-west-1/amzn-ami-0.9.7-beta.i386.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX); assertEquals(image.getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "137112412989", "rootDeviceType", assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "137112412989", "rootDeviceType",
"instance-store")); "instance-store"));
@ -386,12 +399,254 @@ public class ImageParserTest extends BaseEC2HandlerTest {
assertEquals(image.getOperatingSystem().getName(), null); assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "0.9.7-beta"); assertEquals(image.getOperatingSystem().getVersion(), "0.9.7-beta");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual"); assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml"); assertEquals(image.getOperatingSystem().getDescription(),
"amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX); assertEquals(image.getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "137112412989", "rootDeviceType", assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "137112412989", "rootDeviceType",
"instance-store")); "instance-store"));
assertEquals(image.getVersion(), "0.9.7-beta"); assertEquals(image.getVersion(), "0.9.7-beta");
}
public void testParseNovaImage() {
InputStream is = getClass().getResourceAsStream("/ec2/nova_images.xml");
Set<Image> result = parseImages(is);
assertEquals(result.size(), 19);
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation), "nebula");
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "nasacms/image.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-h30p5im0");
assertEquals(image.getProviderId(), "ami-h30p5im0");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "nasacms/image.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "foo", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
assertEquals(parser.apply(Iterables.get(result, 1)), null);
image = parser.apply(Iterables.get(result, 2));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "nebula/tiny");
assertEquals(image.getId(), "us-east-1/ami-tiny");
assertEquals(image.getProviderId(), "ami-tiny");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "nebula/tiny");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "vishvananda", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 3));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "demos/mediawiki");
assertEquals(image.getId(), "us-east-1/ami-630A130F");
assertEquals(image.getProviderId(), "ami-630A130F");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "demos/mediawiki");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "admin", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
assertEquals(parser.apply(Iterables.get(result, 4)), null);
assertEquals(parser.apply(Iterables.get(result, 5)), null);
assertEquals(parser.apply(Iterables.get(result, 6)), null);
image = parser.apply(Iterables.get(result, 7));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "pinglet/instances");
assertEquals(image.getId(), "us-east-1/ami-pinginst");
assertEquals(image.getProviderId(), "ami-pinginst");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "pinglet/instances");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "admin", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 8));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "bucket/testbuntu.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-alqbihe2");
assertEquals(image.getProviderId(), "ami-alqbihe2");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "bucket/testbuntu.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "rkumar2", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 9));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "gfortran-bucket/gfortran.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-i0aemtfp");
assertEquals(image.getProviderId(), "ami-i0aemtfp");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "gfortran-bucket/gfortran.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "ykliu", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
assertEquals(parser.apply(Iterables.get(result, 10)), null);
image = parser.apply(Iterables.get(result, 11));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "grinder/grinder-analyzer.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-2ig7w1bh");
assertEquals(image.getProviderId(), "ami-2ig7w1bh");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "grinder/grinder-analyzer.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "foo", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
assertEquals(parser.apply(Iterables.get(result, 12)), null);
image = parser.apply(Iterables.get(result, 13));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "nebula/lucid");
assertEquals(image.getId(), "us-east-1/ami-lucid");
assertEquals(image.getProviderId(), "ami-lucid");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "10.04");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "nebula/lucid");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "vishvananda", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 14));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "nebula/karmic-large");
assertEquals(image.getId(), "us-east-1/ami-karmiclg");
assertEquals(image.getProviderId(), "ami-karmiclg");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "9.10");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "nebula/karmic-large");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "admin", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 15));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "jo/qa-grinder.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-8jen8kdn");
assertEquals(image.getProviderId(), "ami-8jen8kdn");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "jo/qa-grinder.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "jyothi", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 16));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "nebula/lucid-large");
assertEquals(image.getId(), "us-east-1/ami-lucidlg");
assertEquals(image.getProviderId(), "ami-lucidlg");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "10.04");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "nebula/lucid-large");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "vishvananda", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 17));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "demos/wordpress");
assertEquals(image.getId(), "us-east-1/ami-6CD61336");
assertEquals(image.getProviderId(), "ami-6CD61336");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "demos/wordpress");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "admin", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
image = parser.apply(Iterables.get(result, 18));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "nebula/ubuntu-karmic");
assertEquals(image.getId(), "us-east-1/ami-25CB1213");
assertEquals(image.getProviderId(), "ami-25CB1213");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "9.10");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "nebula/ubuntu-karmic");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "admin", "rootDeviceType",
"instance-store"));
assertEquals(image.getVersion(), null);
} }

View File

@ -132,8 +132,8 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
assertEquals(result, contents); assertEquals(result, contents);
} }
public void testApplyInputStreamEucNoAvailabilityZone() { public void testApplyInputStreamNovaNoAvailabilityZone() {
InputStream is = getClass().getResourceAsStream("/ec2/describe_instances_euc1.xml"); InputStream is = getClass().getResourceAsStream("/ec2/describe_instances_nova.xml");
Set<Reservation<? extends RunningInstance>> contents = Sets.newLinkedHashSet(); Set<Reservation<? extends RunningInstance>> contents = Sets.newLinkedHashSet();
contents.add(new Reservation<RunningInstance>(defaultRegion, ImmutableSet.of("default"), ImmutableSet contents.add(new Reservation<RunningInstance>(defaultRegion, ImmutableSet.of("default"), ImmutableSet

View File

@ -0,0 +1,179 @@
<?xml version="1.0" ?>
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
<requestId>RX9NL9IWKIR11XL8ZLFR</requestId>
<imagesSet>
<item>
<imageOwnerId>foo</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-h30p5im0</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nasacms/image.manifest.xml</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ari-lucid</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid-ramdisk</imageLocation>
<type>ramdisk</type>
</item>
<item>
<imageOwnerId>vishvananda</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-tiny</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/tiny</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-630A130F</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>demos/mediawiki</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>aki-edge</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/bleeding-edge-kernel</imageLocation>
<type>kernel</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ari-edge</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/bleeding-edge-ramdisk</imageLocation>
<type>ramdisk</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>aki-lucid</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid-kernel</imageLocation>
<type>kernel</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-pinginst</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>pinglet/instances</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>rkumar2</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-alqbihe2</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>bucket/testbuntu.manifest.xml</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>ykliu</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-i0aemtfp</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>gfortran-bucket/gfortran.manifest.xml
</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ari-22F211EF</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/ramdisk</imageLocation>
<type>ramdisk</type>
</item>
<item>
<imageOwnerId>foo</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-2ig7w1bh</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>grinder/grinder-analyzer.manifest.xml
</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>aki-EAB510D9</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/kernel</imageLocation>
<type>kernel</type>
</item>
<item>
<imageOwnerId>vishvananda</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-lucid</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-karmiclg</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/karmic-large</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>jyothi</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-8jen8kdn</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>jo/qa-grinder.manifest.xml</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>vishvananda</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-lucidlg</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid-large</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-6CD61336</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>demos/wordpress</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-25CB1213</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/ubuntu-karmic</imageLocation>
<type>machine</type>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -37,6 +37,7 @@ import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeMetadata;
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.Processor; import org.jclouds.compute.domain.Processor;
import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.Volume;
import org.jclouds.compute.domain.internal.HardwareImpl; import org.jclouds.compute.domain.internal.HardwareImpl;
@ -78,7 +79,8 @@ public class ComputeServiceUtils {
* @return a shell script that will invoke the http request * @return a shell script that will invoke the http request
*/ */
public static Statement extractTargzIntoDirectory(HttpRequest targz, String directory) { public static Statement extractTargzIntoDirectory(HttpRequest targz, String directory) {
return Statements.extractTargzIntoDirectory(targz.getMethod(), targz.getEndpoint(), targz.getHeaders(), directory); return Statements
.extractTargzIntoDirectory(targz.getMethod(), targz.getEndpoint(), targz.getHeaders(), directory);
} }
public static Statement extractTargzIntoDirectory(URI targz, String directory) { public static Statement extractTargzIntoDirectory(URI targz, String directory) {
@ -119,7 +121,7 @@ public class ComputeServiceUtils {
.build(), org.jclouds.compute.domain.OsFamily.UBUNTU, ImmutableMap .build(), org.jclouds.compute.domain.OsFamily.UBUNTU, ImmutableMap
.<String, String> builder().put("hardy", "8.04").put("intrepid", "8.10").put("jaunty", .<String, String> builder().put("hardy", "8.04").put("intrepid", "8.10").put("jaunty",
"9.04").put("karmic", "9.10").put("lucid", "10.04").put("maverick", "10.10") "9.04").put("karmic", "9.10").put("lucid", "10.04").put("maverick", "10.10")
.build()); .put("natty", "11.04").build());
public static String parseVersionOrReturnEmptyString(org.jclouds.compute.domain.OsFamily family, final String in) { public static String parseVersionOrReturnEmptyString(org.jclouds.compute.domain.OsFamily family, final String in) {
if (NAME_VERSION_MAP.containsKey(family)) { if (NAME_VERSION_MAP.containsKey(family)) {
@ -137,13 +139,16 @@ public class ComputeServiceUtils {
return ""; return "";
} }
public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrNull(String in) { public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrNull(String provider, String in) {
org.jclouds.compute.domain.OsFamily myOs = null; org.jclouds.compute.domain.OsFamily myOs = null;
for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) { for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) { if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
myOs = os; myOs = os;
} }
} }
if (myOs == null && provider.indexOf("nebula") != -1) {
myOs = OsFamily.UBUNTU;
}
return myOs; return myOs;
} }

View File

@ -77,6 +77,9 @@ vcloudexpress.propertiesbuilder=org.jclouds.vcloud.VCloudExpressPropertiesBuilde
eucalyptus.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder eucalyptus.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
eucalyptus.propertiesbuilder=org.jclouds.aws.ec2.EucalyptusPropertiesBuilder eucalyptus.propertiesbuilder=org.jclouds.aws.ec2.EucalyptusPropertiesBuilder
nova.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
nova.propertiesbuilder=org.jclouds.aws.ec2.NovaPropertiesBuilder
cloudservers.contextbuilder=org.jclouds.rackspace.cloudservers.CloudServersContextBuilder cloudservers.contextbuilder=org.jclouds.rackspace.cloudservers.CloudServersContextBuilder
cloudservers.propertiesbuilder=org.jclouds.rackspace.RackspacePropertiesBuilder cloudservers.propertiesbuilder=org.jclouds.rackspace.RackspacePropertiesBuilder
@ -94,7 +97,6 @@ stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder
# example of where to change your endpoint # example of where to change your endpoint
# bluelock.endpoint=https://express3.bluelock.com/api # bluelock.endpoint=https://express3.bluelock.com/api
atmosonline.contextbuilder=org.jclouds.atmosonline.saas.AtmosStorageContextBuilder atmosonline.contextbuilder=org.jclouds.atmosonline.saas.AtmosStorageContextBuilder
atmosonline.endpoint=https://accesspoint.atmosonline.com atmosonline.endpoint=https://accesspoint.atmosonline.com
atmosonline.apiversion=1.3.0 atmosonline.apiversion=1.3.0