Issue 333: added operatingsystem to nodemetatdata; Issue 327: completed vcloud conversion to ids; Issue 306; completed vcloud lookup by id; Issue 338: got rid architecture object

This commit is contained in:
Adrian Cole 2010-08-18 21:04:17 -07:00
parent 8efea1b42d
commit f895756c65
78 changed files with 961 additions and 1159 deletions

View File

@ -51,7 +51,7 @@ public class ${providerName}ComputeServiceLiveTest extends BaseComputeServiceLiv
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DFW1");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
}

View File

@ -69,7 +69,6 @@ import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.Size;
import org.jclouds.compute.domain.TemplateBuilder;
@ -170,9 +169,8 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
String region = injector.getInstance(Key.get(String.class, Region.class));
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest() : template.architecture(
Architecture.X86_32).osFamily(UBUNTU).imageNameMatches(".*10\\.?04.*").osDescriptionMatches(
"^ubuntu-images.*");
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest() : template.os64Bit(false).osFamily(
UBUNTU).imageNameMatches(".*10\\.?04.*").osDescriptionMatches("^ubuntu-images.*");
}
@Provides

View File

@ -33,9 +33,10 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.aws.ec2.domain.Image.Architecture;
import org.jclouds.aws.ec2.domain.Image.ImageType;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.compute.reference.ComputeServiceConstants;
@ -95,16 +96,20 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
logger.trace("skipping as not a machine image(%s)", from.getId());
return null;
}
OsFamily os = parseOsFamilyOrNull(from.getImageLocation());
String name = parseVersionOrReturnEmptyString(os, from.getImageLocation());
String name = null;
String description = from.getDescription() != null ? from.getDescription() : from.getImageLocation();
String osDescription = from.getImageLocation();
String version = "";
String version = null;
OsFamily osFamily = parseOsFamilyOrNull(from.getImageLocation());
String osName = null;
String osArch = from.getVirtualizationType();
String osVersion = parseVersionOrReturnEmptyString(osFamily, from.getImageLocation());
String osDescription = from.getImageLocation();
boolean is64Bit = from.getArchitecture() == Architecture.X86_64;
try {
Matcher matcher = getMatcherAndFind(from.getImageLocation());
os = OsFamily.fromValue(matcher.group(1));
name = parseVersionOrReturnEmptyString(os, matcher.group(2));
osFamily = OsFamily.fromValue(matcher.group(1));
osVersion = parseVersionOrReturnEmptyString(osFamily, matcher.group(2));
version = matcher.group(3).replace(".manifest.xml", "");
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", from.getImageLocation());
@ -129,10 +134,9 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
location = new LocationImpl(LocationScope.REGION, from.getRegion(), from.getRegion(), defaultLocation.get()
.getParent());
}
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
return new ImageImpl(from.getId(), name, from.getRegion() + "/" + from.getId(), location, null, ImmutableMap
.<String, String> of("owner", from.getImageOwnerId()), description, version, os, osDescription, from
.getArchitecture() == org.jclouds.aws.ec2.domain.Image.Architecture.I386 ? Architecture.X86_32
: Architecture.X86_64, defaultCredentials);
.<String, String> of("owner", from.getImageOwnerId()), os, description, version, defaultCredentials);
}

View File

@ -117,7 +117,8 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
Image image = resolveImageForInstanceInLocation(instance, location);
return new NodeMetadataImpl(id, name, instance.getRegion() + "/" + instance.getId(), location, uri, userMetadata,
tag, image, state, publicAddresses, privateAddresses, extra, credentials);
tag, instance.getRegion() + "/" + instance.getImageId(), image != null ? image.getOperatingSystem()
: null, state, publicAddresses, privateAddresses, extra, credentials);
}
private Credentials getCredentialsForInstanceWithTag(final RunningInstance instance, String tag) {

View File

@ -47,6 +47,13 @@ public enum MonitoringState {
}
public static MonitoringState fromValue(String state) {
/**
* Eucalyptus
*/
if ("false".endsWith(state))
return DISABLED;
if ("true".endsWith(state))
return ENABLED;
return valueOf(checkNotNull(state, "state").toUpperCase());
}
}

View File

@ -38,7 +38,6 @@ import org.jclouds.aws.ec2.services.InstanceClient;
import org.jclouds.aws.ec2.services.KeyPairClient;
import org.jclouds.aws.ec2.services.SecurityGroupClient;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
@ -91,7 +90,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
protected void assertDefaultWorks() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
}
@ -151,8 +150,8 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
assert group.getIpPermissions().size() == 0 : group;
// try to run a script with the original keyPair
runScriptWithCreds(tag, first.getImage().getOperatingSystem().getFamily(), new Credentials(first
.getCredentials().identity, result.getKeyMaterial()));
runScriptWithCreds(tag, first.getOperatingSystem(), new Credentials(first.getCredentials().identity, result
.getKeyMaterial()));
} finally {
client.destroyNodesMatching(NodePredicates.withTag(tag));

View File

@ -30,9 +30,10 @@ import javax.inject.Provider;
import org.jclouds.aws.ec2.compute.domain.EC2Size;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Size;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
@ -75,8 +76,7 @@ public class EC2ComputeServiceTest {
*/
@Test
public void testTemplateChoiceForInstanceBySizeId() throws Exception {
Template template = newTemplateBuilder().architecture(Architecture.X86_64).sizeId("m2.xlarge").locationId(
"us-east-1").build();
Template template = newTemplateBuilder().os64Bit(true).sizeId("m2.xlarge").locationId("us-east-1").build();
assert template != null : "The returned template was null, but it should have a value.";
assert EC2Size.M2_XLARGE.equals(template.getSize()) : format(
@ -102,8 +102,8 @@ public class EC2ComputeServiceTest {
*/
@Test
public void testTemplateChoiceForInstanceByAttributes() throws Exception {
Template template = newTemplateBuilder().architecture(Architecture.X86_64).minRam(17510).minCores(6.5).smallest()
.locationId("us-east-1").build();
Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.5).smallest().locationId(
"us-east-1").build();
assert template != null : "The returned template was null, but it should have a value.";
assert EC2Size.M2_XLARGE.equals(template.getSize()) : format(
@ -121,8 +121,8 @@ public class EC2ComputeServiceTest {
*/
@Test
public void testNegativeTemplateChoiceForInstanceByAttributes() throws Exception {
Template template = newTemplateBuilder().architecture(Architecture.X86_64).minRam(17510).minCores(6.7).smallest()
.locationId("us-east-1").build();
Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.7).smallest().locationId(
"us-east-1").build();
assert template != null : "The returned template was null, but it should have a value.";
assert !EC2Size.M2_XLARGE.equals(template.getSize()) : format(
@ -140,8 +140,8 @@ public class EC2ComputeServiceTest {
expect(optionsProvider.get()).andReturn(defaultOptions);
Image image = new ImageImpl("cc-image", "image", "us-east-1/cc-image", location, null, Maps
.<String, String> newHashMap(), "description", "1.0", null, "ubuntu", Architecture.X86_64,
new Credentials("root", null));
.<String, String> newHashMap(), new OperatingSystem(OsFamily.UBUNTU, null, "1.0", null, "ubuntu", true),
"description", "1.0", new Credentials("root", null));
replay(optionsProvider);
replay(templateBuilderProvider);
Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet

View File

@ -30,7 +30,6 @@ 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.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -50,36 +49,36 @@ public class EC2TemplateBuilderLiveTest {
private String user;
@BeforeGroups(groups = { "live" })
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException,
IOException {
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 testTemplateBuilderCanUseImageId() {
// TODO
}
@Test
public void testTemplateBuilder() throws IOException {
ComputeServiceContext newContext = null;
try {
newContext = new ComputeServiceContextFactory().createContext("ec2", user, password,
ImmutableSet.of(new Log4JLoggingModule()));
newContext = new ComputeServiceContextFactory().createContext("ec2", user, password, ImmutableSet
.of(new Log4JLoggingModule()));
Template defaultTemplate = newContext.getComputeService().templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getName(), "10.04");
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "us-east-1");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
newContext.getComputeService().templateBuilder().imageId(
Iterables.get(newContext.getComputeService().listImages(), 0).getProviderId()).build();
newContext.getComputeService().templateBuilder().osFamily(OsFamily.UBUNTU).smallest()
.architecture(Architecture.X86_32).imageId("ami-7e28ca17").build();
newContext.getComputeService().templateBuilder().osFamily(OsFamily.UBUNTU).smallest()
.architecture(Architecture.X86_32).imageId("ami-bb709dd2").build();
newContext.getComputeService().templateBuilder().osFamily(OsFamily.UBUNTU).smallest().os64Bit(false).imageId(
"ami-7e28ca17").build();
newContext.getComputeService().templateBuilder().osFamily(OsFamily.UBUNTU).smallest().os64Bit(false).imageId(
"ami-bb709dd2").build();
} finally {
if (newContext != null)
newContext.close();
@ -94,18 +93,17 @@ public class EC2TemplateBuilderLiveTest {
// set owners to nothing
overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
newContext = new ComputeServiceContextFactory().createContext("ec2", user, password,
ImmutableSet.of(new Log4JLoggingModule()), overrides);
newContext = new ComputeServiceContextFactory().createContext("ec2", user, password, ImmutableSet
.of(new Log4JLoggingModule()), overrides);
assertEquals(newContext.getComputeService().listImages().size(), 0);
Template template = newContext.getComputeService().templateBuilder().imageId(
"ami-ccb35ea5").build();
Template template = newContext.getComputeService().templateBuilder().imageId("ami-ccb35ea5").build();
System.out.println(template.getImage());
assert (template.getImage().getProviderId().startsWith("ami-")) : template;
assertEquals(template.getImage().getName(), "5.4");
assertEquals(template.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(template.getImage().getOsFamily(), OsFamily.CENTOS);
assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(template.getImage().getVersion(), "4.4.10");
assertEquals(template.getLocation().getId(), "us-east-1");
assertEquals(template.getSize().getCores(), 4.0d); // because it is 64bit

View File

@ -21,7 +21,6 @@ package org.jclouds.aws.ec2.compute;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.testng.annotations.BeforeClass;
@ -44,8 +43,8 @@ public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest
@Override
protected void assertDefaultWorks() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
// 64 bit implied 4 ecus
assertEquals(defaultTemplate.getSize().getCores(), 4.0d);
}

View File

@ -61,40 +61,53 @@ public class ImageParserTest extends BaseEC2HandlerTest {
.ofInstance(defaultLocation));
org.jclouds.compute.domain.Image ubuntuHardy = parser.apply(Iterables.get(result, 0));
assertEquals(ubuntuHardy.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(ubuntuHardy.getDescription(), "ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
assertEquals(ubuntuHardy.getId(), "us-east-1/ami-7e28ca17");
assertEquals(ubuntuHardy.getProviderId(), "ami-7e28ca17");
assertEquals(ubuntuHardy.getLocation(), defaultLocation);
assertEquals(ubuntuHardy.getName(), "8.04");
assertEquals(ubuntuHardy.getOsDescription(),
assertEquals(ubuntuHardy.getName(), null);
assertEquals(ubuntuHardy.getOperatingSystem().getName(), null);
assertEquals(ubuntuHardy.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(ubuntuHardy.getOperatingSystem().getVersion(), "8.04");
assertEquals(ubuntuHardy.getOperatingSystem().getArch(), "paravirtual");
assertEquals(ubuntuHardy.getOperatingSystem().getDescription(),
"ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
assertEquals(ubuntuHardy.getOsFamily(), OsFamily.UBUNTU);
assertEquals(ubuntuHardy.getOperatingSystem().is64Bit(), false);
assertEquals(ubuntuHardy.getUserMetadata(), ImmutableMap.<String, String> of("owner", "099720109477"));
assertEquals(ubuntuHardy.getVersion(), "20091130");
org.jclouds.compute.domain.Image alesticKarmic = parser.apply(Iterables.get(result, 1));
assertEquals(alesticKarmic.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(alesticKarmic.getOperatingSystem().is64Bit(), false);
assertEquals(alesticKarmic.getDescription(), "alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
assertEquals(alesticKarmic.getId(), "us-east-1/ami-19a34270");
assertEquals(alesticKarmic.getProviderId(), "ami-19a34270");
assertEquals(alesticKarmic.getLocation(), defaultLocation);
assertEquals(alesticKarmic.getName(), "9.10");
assertEquals(alesticKarmic.getOsDescription(), "alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
assertEquals(alesticKarmic.getOsFamily(), OsFamily.UBUNTU);
assertEquals(alesticKarmic.getName(), null);
assertEquals(alesticKarmic.getOperatingSystem().getName(), null);
assertEquals(alesticKarmic.getOperatingSystem().getVersion(), "9.10");
assertEquals(alesticKarmic.getOperatingSystem().getArch(), "paravirtual");
assertEquals(alesticKarmic.getOperatingSystem().getDescription(),
"alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
assertEquals(alesticKarmic.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(alesticKarmic.getUserMetadata(), ImmutableMap.<String, String> of("owner", "063491364108"));
assertEquals(alesticKarmic.getVersion(), "20090623");
org.jclouds.compute.domain.Image ubuntuKarmic = parser.apply(Iterables.get(result, 2));
assertEquals(ubuntuKarmic.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(ubuntuKarmic.getOperatingSystem().is64Bit(), false);
assertEquals(ubuntuKarmic.getDescription(),
"ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml");
assertEquals(ubuntuKarmic.getId(), "us-east-1/ami-bb709dd2");
assertEquals(ubuntuKarmic.getProviderId(), "ami-bb709dd2");
assertEquals(ubuntuKarmic.getLocation(), defaultLocation);
assertEquals(ubuntuKarmic.getName(), "9.10");
assertEquals(ubuntuKarmic.getOsDescription(),
assertEquals(ubuntuKarmic.getName(), null);
assertEquals(ubuntuKarmic.getOperatingSystem().getName(), null);
assertEquals(ubuntuKarmic.getOperatingSystem().getVersion(), "9.10");
assertEquals(ubuntuKarmic.getOperatingSystem().getArch(), "paravirtual");
assertEquals(ubuntuKarmic.getOperatingSystem().getDescription(),
"ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml");
assertEquals(ubuntuKarmic.getOsFamily(), OsFamily.UBUNTU);
assertEquals(ubuntuKarmic.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(ubuntuKarmic.getUserMetadata(), ImmutableMap.<String, String> of("owner", "099720109477"));
assertEquals(ubuntuKarmic.getVersion(), "20100121");
@ -103,27 +116,36 @@ public class ImageParserTest extends BaseEC2HandlerTest {
org.jclouds.compute.domain.Image alesticHardy = parser.apply(Iterables.get(result, 4));
assertEquals(alesticHardy.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(alesticHardy.getOperatingSystem().is64Bit(), false);
assertEquals(alesticHardy.getDescription(), "alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
assertEquals(alesticHardy.getId(), "us-east-1/ami-c0fa1ea9");
assertEquals(alesticHardy.getProviderId(), "ami-c0fa1ea9");
assertEquals(alesticHardy.getLocation(), defaultLocation);
assertEquals(alesticHardy.getName(), "8.04");
assertEquals(alesticHardy.getOsDescription(), "alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
assertEquals(alesticHardy.getOsFamily(), OsFamily.UBUNTU);
assertEquals(alesticHardy.getName(), null);
assertEquals(alesticHardy.getOperatingSystem().getName(), null);
assertEquals(alesticHardy.getOperatingSystem().getVersion(), "8.04");
assertEquals(alesticHardy.getOperatingSystem().getArch(), "paravirtual");
assertEquals(alesticHardy.getOperatingSystem().getDescription(),
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
assertEquals(alesticHardy.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(alesticHardy.getUserMetadata(), ImmutableMap.<String, String> of("owner", "063491364108"));
assertEquals(alesticHardy.getVersion(), "20080905");
org.jclouds.compute.domain.Image ubuntuLucid = parser.apply(Iterables.get(result, 5));
assertEquals(ubuntuLucid.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(ubuntuLucid.getOperatingSystem().is64Bit(), false);
assertEquals(ubuntuLucid.getDescription(),
"ubuntu-images-us-west-1/ubuntu-lucid-10.04-i386-server-20100427.1.manifest.xml");
assertEquals(ubuntuLucid.getId(), "us-east-1/ami-c597c680");
assertEquals(ubuntuLucid.getProviderId(), "ami-c597c680");
assertEquals(ubuntuLucid.getLocation(), defaultLocation);
assertEquals(ubuntuLucid.getName(), "10.04");
assertEquals(ubuntuLucid.getOsDescription(),
assertEquals(ubuntuLucid.getName(), null);
assertEquals(ubuntuLucid.getOperatingSystem().getName(), null);
assertEquals(ubuntuLucid.getOperatingSystem().getVersion(), "10.04");
assertEquals(ubuntuLucid.getOperatingSystem().getArch(), "paravirtual");
assertEquals(ubuntuLucid.getOperatingSystem().getDescription(),
"ubuntu-images-us-west-1/ubuntu-lucid-10.04-i386-server-20100427.1.manifest.xml");
assertEquals(ubuntuLucid.getOsFamily(), OsFamily.UBUNTU);
assertEquals(ubuntuLucid.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(ubuntuLucid.getUserMetadata(), ImmutableMap.<String, String> of("owner", "099720109477"));
assertEquals(ubuntuLucid.getVersion(), "20100427.1");
@ -144,18 +166,50 @@ public class ImageParserTest extends BaseEC2HandlerTest {
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
assertEquals(image.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(image.getOperatingSystem().is64Bit(), false);
assertEquals(image.getDescription(), "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-870de2ee");
assertEquals(image.getProviderId(), "ami-870de2ee");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), "");
assertEquals(image.getOsDescription(), "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
assertEquals(image.getOsFamily(), OsFamily.UNKNOWN);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(),
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNKNOWN);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "133804938231"));
assertEquals(image.getVersion(), "5622");
}
public void testParseCCImage() {
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_cc.xml");
Set<Image> result = parseImages(is);
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation));
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "EC2 CentOS 5.4 HVM AMI");
assertEquals(image.getId(), "us-east-1/ami-7ea24a17");
assertEquals(image.getProviderId(), "ami-7ea24a17");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "5.4");
assertEquals(image.getOperatingSystem().getArch(), "hvm");
assertEquals(image.getOperatingSystem().getDescription(), "amazon/EC2 CentOS 5.4 HVM AMI");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "206029621532"));
assertEquals(image.getVersion(), null);
}
public void testParseRightScaleImage() {
InputStream is = getClass().getResourceAsStream("/ec2/rightscale_images.xml");
@ -167,25 +221,34 @@ public class ImageParserTest extends BaseEC2HandlerTest {
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
assertEquals(image.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_64);
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml");
assertEquals(image.getId(), "us-east-1/ami-ccb35ea5");
assertEquals(image.getProviderId(), "ami-ccb35ea5");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), "5.4");
assertEquals(image.getOsDescription(), "rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml");
assertEquals(image.getOsFamily(), OsFamily.CENTOS);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "5.4");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(),
"rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "411009282317"));
assertEquals(image.getVersion(), "4.4.10");
image = parser.apply(Iterables.get(result, 1));
assertEquals(image.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_64);
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha");
assertEquals(image.getId(), "us-east-1/ami-c19db6b5");
assertEquals(image.getProviderId(), "ami-c19db6b5");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), "9.10");
assertEquals(image.getOsDescription(), "411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha");
assertEquals(image.getOsFamily(), OsFamily.UBUNTU);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "9.10");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(),
"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "411009282317"));
assertEquals(image.getVersion(), "4.5.3_EBS_Alpha");
@ -202,15 +265,19 @@ public class ImageParserTest extends BaseEC2HandlerTest {
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
assertEquals(image.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_64);
assertEquals(image.getOperatingSystem().is64Bit(), true);
assertEquals(image.getDescription(), "centos-5.3-x86_64/centos.5-3.x86-64.img.manifest.xml");
assertEquals(image.getId(), "us-east-1/emi-9ACB1363");
assertEquals(image.getProviderId(), "emi-9ACB1363");
assertEquals(image.getLocation(), defaultLocation);
assertEquals(image.getName(), "5.3");
assertEquals(image.getOsDescription(), "centos-5.3-x86_64/centos.5-3.x86-64.img.manifest.xml");
assertEquals(image.getOsFamily(), OsFamily.CENTOS);
assertEquals(image.getName(), null);
assertEquals(image.getOperatingSystem().getName(), null);
assertEquals(image.getOperatingSystem().getVersion(), "5.3");
assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), "centos-5.3-x86_64/centos.5-3.x86-64.img.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "admin"));
assertEquals(image.getVersion(), "");
assertEquals(image.getVersion(), null);
// should skip test images
image = parser.apply(Iterables.get(result, 3));

View File

@ -43,6 +43,7 @@ import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.functions.RunningInstanceToStorageMappingUnix;
import org.jclouds.aws.ec2.services.AMIClient;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
@ -118,7 +119,7 @@ public class RunningInstanceToNodeMetadataTest {
NodeMetadata metadata = parser.apply(instance);
assertEquals(metadata.getLocation(), locations.get().iterator().next());
assertEquals(metadata.getImage(), null);
assertEquals(metadata.getImageId(), "us-east-1/imageId");
assertEquals(metadata.getTag(), "NOTAG-id");
assertEquals(metadata.getCredentials(), null);
@ -133,7 +134,7 @@ public class RunningInstanceToNodeMetadataTest {
@SuppressWarnings("unchecked")
@Test
public void testImageNotFoundAndLazyFailsWithNPE() throws UnknownHostException {
public void testImageNotFoundStillSetsImageId() throws UnknownHostException {
EC2Client client = createMock(EC2Client.class);
AMIClient amiClient = createMock(AMIClient.class);
Map<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
@ -181,7 +182,7 @@ public class RunningInstanceToNodeMetadataTest {
NodeMetadata metadata = parser.apply(instance);
assertEquals(metadata.getLocation(), locations.get().iterator().next());
assertEquals(metadata.getImage(), null);
assertEquals(metadata.getImageId(), "us-east-1/imageId");
assertEquals(metadata.getTag(), "NOTAG-id");
assertEquals(metadata.getCredentials(), null);
@ -229,6 +230,8 @@ public class RunningInstanceToNodeMetadataTest {
org.jclouds.compute.domain.Image lateImage = createMock(org.jclouds.compute.domain.Image.class);
expect(imageMap.get(new RegionAndName("us-east-1", "imageId"))).andReturn(lateImage).atLeastOnce();
expect(lateImage.getId()).andReturn("us-east-1/imageId").atLeastOnce();
expect(lateImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce();
@ -246,7 +249,7 @@ public class RunningInstanceToNodeMetadataTest {
NodeMetadata metadata = parser.apply(instance);
assertEquals(metadata.getLocation(), locations.get().iterator().next());
assertEquals(metadata.getImage(), lateImage);
assertEquals(metadata.getImageId(), lateImage.getId());
assertEquals(metadata.getTag(), "NOTAG-id");
assertEquals(metadata.getCredentials(), null);
@ -290,6 +293,8 @@ public class RunningInstanceToNodeMetadataTest {
expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce();
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
expect(instance.getImageId()).andReturn("imageId").atLeastOnce();
expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage);
@ -308,7 +313,7 @@ public class RunningInstanceToNodeMetadataTest {
NodeMetadata metadata = parser.apply(instance);
assertEquals(metadata.getLocation(), locations.get().iterator().next());
assertEquals(metadata.getImage(), jcImage);
assertEquals(metadata.getImageId(), "us-east-1/imageId");
assertEquals(metadata.getTag(), "NOTAG-id");
assertEquals(metadata.getCredentials(), null);
@ -350,6 +355,8 @@ public class RunningInstanceToNodeMetadataTest {
expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce();
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
expect(instance.getImageId()).andReturn("imageId").atLeastOnce();
expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage);
@ -368,7 +375,7 @@ public class RunningInstanceToNodeMetadataTest {
NodeMetadata metadata = parser.apply(instance);
assertEquals(metadata.getLocation(), locations.get().iterator().next());
assertEquals(metadata.getImage(), jcImage);
assertEquals(metadata.getImageId(), "us-east-1/imageId");
assertEquals(metadata.getTag(), "tag");
assertEquals(metadata.getCredentials(), null);
@ -412,6 +419,8 @@ public class RunningInstanceToNodeMetadataTest {
expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce();
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
expect(instance.getImageId()).andReturn("imageId").atLeastOnce();
expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage);
@ -441,7 +450,7 @@ public class RunningInstanceToNodeMetadataTest {
assertEquals(metadata.getTag(), "tag");
assertEquals(metadata.getLocation(), location);
assertEquals(metadata.getImage(), jcImage);
assertEquals(metadata.getImageId(), "us-east-1/imageId");
assertEquals(metadata.getCredentials(), new Credentials("user", "pass"));
@ -486,6 +495,8 @@ public class RunningInstanceToNodeMetadataTest {
expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce();
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
expect(instance.getImageId()).andReturn("imageId").atLeastOnce();
expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "imageId"))).andReturn(jcImage);
@ -516,7 +527,7 @@ public class RunningInstanceToNodeMetadataTest {
assertEquals(metadata.getTag(), "NOTAG-id");
assertEquals(metadata.getLocation(), location);
assertEquals(metadata.getImage(), jcImage);
assertEquals(metadata.getImageId(), "us-east-1/imageId");
assertEquals(metadata.getCredentials(), new Credentials("user", "pass"));

View File

@ -33,7 +33,6 @@ import javax.inject.Provider;
import org.jclouds.aws.ec2.compute.domain.RegionAndName;
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.Size;
@ -96,8 +95,8 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
.<Location> of(location));
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1, 1,
ImagePredicates.any())));
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1,
1, ImagePredicates.any())));
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
@ -112,7 +111,6 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
expect(knownImage.getName()).andReturn(null).atLeastOnce();
expect(knownImage.getDescription()).andReturn(null).atLeastOnce();
expect(knownImage.getVersion()).andReturn(null).atLeastOnce();
expect(knownImage.getArchitecture()).andReturn(Architecture.X86_32).atLeastOnce();
expect(knownImage.getOperatingSystem()).andReturn(os).atLeastOnce();
@ -150,8 +148,8 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
.<Location> of(location));
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1, 1,
ImagePredicates.any())));
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1,
1, ImagePredicates.any())));
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
@ -188,8 +186,8 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
.<Location> of(location));
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1, 1,
ImagePredicates.any())));
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1,
1, ImagePredicates.any())));
Location defaultLocation = createMock(Location.class);
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
@ -199,7 +197,6 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
expect(defaultLocation.getId()).andReturn("region");
expect(optionsProvider.get()).andReturn(defaultOptions);
expect(knownImage.getArchitecture()).andReturn(Architecture.X86_32).atLeastOnce();
replay(knownImage);
replay(defaultOptions);

View File

@ -167,7 +167,7 @@ public class PlacementGroupClientLiveTest {
template.getOptions().installPrivateKey(newStringPayload(keyPair.get("private"))).authorizePublicKey(
newStringPayload(keyPair.get("public"))).runScript(
newStringPayload(BaseComputeServiceLiveTest.buildScript(template.getImage().getOsFamily())));
newStringPayload(BaseComputeServiceLiveTest.buildScript(template.getImage().getOperatingSystem())));
String tag = PREFIX + "cccluster";
context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag));

View File

@ -61,7 +61,7 @@ See http://code.google.com/p/jclouds for details."
ComputeService ComputeServiceContext ComputeServiceContextFactory]
[org.jclouds.compute.domain
Template TemplateBuilder ComputeMetadata NodeMetadata Size OsFamily
Image Architecture]
Image]
[org.jclouds.compute.options TemplateOptions]
[org.jclouds.compute.predicates
NodePredicates]
@ -356,11 +356,8 @@ See http://code.google.com/p/jclouds for details."
(defn os-families []
(. OsFamily values))
(defn architectures []
(. Architecture values))
(def enum-map {:os-family (os-families)
:architecture (architectures)})
(def enum-map {:os-family (os-families)})
(defn add-option-with-value-if [builder kword]
(loop [enums (sequence enum-map)]

View File

@ -1,41 +0,0 @@
/**
*
* 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.compute.domain;
/**
* Architecture of a node
*
* <p/>
* Please transition to {@link OperatingSystem}
*
* @author Adrian Cole
*/
@Deprecated
public enum Architecture {
/**
* 32-bit platform
*/
X86_32,
/**
* 64-bit platform
*/
X86_64;
}

View File

@ -19,8 +19,6 @@
package org.jclouds.compute.domain;
import javax.annotation.Nullable;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.domain.Credentials;
@ -50,31 +48,6 @@ public interface Image extends ComputeMetadata {
*/
String getDescription();
/**
* please use {#link {@link #getOperatingSystem()}
*
* @see OperatingSystem#getFamily()
*/
@Deprecated
OsFamily getOsFamily();
/**
* please use {#link {@link #getOperatingSystem()}
*
* @see OperatingSystem#getDescription()
*/
@Deprecated
String getOsDescription();
/**
* please use {#link {@link #getOperatingSystem()}
*
* @see OperatingSystem#getDescription()
*/
@Nullable
@Deprecated
Architecture getArchitecture();
/**
* Default credentials for the current image
*/

View File

@ -24,17 +24,21 @@ import java.util.Set;
import javax.annotation.Nullable;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.domain.Credentials;
import com.google.inject.ImplementedBy;
/**
* @author Adrian Cole
* @author Ivan Meredith
*/
@ImplementedBy(NodeMetadataImpl.class)
public interface NodeMetadata extends ComputeMetadata {
/**
* Tag used for all resources that belong to the same logical group. run,
* destroy commands are scoped to tag.
* Tag used for all resources that belong to the same logical group. run, destroy commands are
* scoped to tag.
*
* @return tag for this node, or null, if not a part of a group
*
@ -42,10 +46,18 @@ public interface NodeMetadata extends ComputeMetadata {
String getTag();
/**
* The image this node was created from, if possible to correlate.
*
* The id of the image this node was created from, if possible to correlate.
*/
@Nullable
Image getImage();
String getImageId();
/**
*
* The operating system this node is running, if possible to determine.
*/
@Nullable
OperatingSystem getOperatingSystem();
/**
* Current State of the node
@ -63,8 +75,8 @@ public interface NodeMetadata extends ComputeMetadata {
Set<String> getPrivateAddresses();
/**
* If possible, these are returned upon all detail requests. However, it is
* often the case that credentials are only available at "run" time.
* If possible, these are returned upon all detail requests. However, it is often the case that
* credentials are only available at "run" time.
*/
Credentials getCredentials();

View File

@ -35,8 +35,7 @@ import com.google.inject.ImplementedBy;
public interface TemplateBuilder {
/**
* prime this builder with parameters known to work on the current compute
* provider.
* prime this builder with parameters known to work on the current compute provider.
*/
TemplateBuilder any();
@ -83,14 +82,6 @@ public interface TemplateBuilder {
*/
TemplateBuilder locationId(String locationId);
/**
* Configure this template to require a specific architecture
*
* Please switch to either architecture as a string, or {@link #is64bit()}
*/
@Deprecated
TemplateBuilder architecture(Architecture architecture);
/**
* Configure this template to require a specific imageId.
* <p/>
@ -104,26 +95,23 @@ public interface TemplateBuilder {
TemplateBuilder sizeId(String sizeId);
/**
* Configure this template to have an operating system name that matches the
* regular expression
* Configure this template to have an operating system name that matches the regular expression
*/
TemplateBuilder osNameMatches(String osNameRegex);
/**
* Configure this template to have an operating system description that
* matches the regular expression
* Configure this template to have an operating system description that matches the regular
* expression
*/
TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
/**
* Configure this template to have an os version that matches the regular
* expression
* Configure this template to have an os version that matches the regular expression
*/
TemplateBuilder osVersionMatches(String osVersionRegex);
/**
* Configure this template to require a specific architecture. ex.
* virtualizationType or
* Configure this template to require a specific architecture. ex. virtualizationType or
*
*/
TemplateBuilder osArchMatches(String architecture);
@ -131,23 +119,20 @@ public interface TemplateBuilder {
/**
* Configure this template to require a 64 bit operating system.
*/
TemplateBuilder os64bit(boolean is64bit);
TemplateBuilder os64Bit(boolean is64bit);
/**
* Configure this template to have an image name that matches the regular
* expression
* Configure this template to have an image name that matches the regular expression
*/
TemplateBuilder imageNameMatches(String imageNameRegex);
/**
* Configure this template to have an image version that matches the regular
* expression
* Configure this template to have an image version that matches the regular expression
*/
TemplateBuilder imageVersionMatches(String imageVersionRegex);
/**
* Configure this template to have an image description that matches the
* regular expression
* Configure this template to have an image description that matches the regular expression
*/
TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex);

View File

@ -26,11 +26,9 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
@ -46,30 +44,18 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
private final String version;
private final String description;
@Nullable
private final Architecture architecture;
private final Credentials defaultCredentials;
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
Map<String, String> userMetadata, OperatingSystem operatingSystem, String description, String version,
@Nullable Architecture architecture, Credentials defaultCredentials) {
Map<String, String> userMetadata, OperatingSystem operatingSystem, String description,
@Nullable String version, @Nullable Credentials defaultCredentials) {
super(ComputeType.IMAGE, providerId, name, id, location, uri, userMetadata);
this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem");
this.version = checkNotNull(version, "version");
this.version = version;
this.description = checkNotNull(description, "description");
this.architecture = architecture;
this.defaultCredentials = defaultCredentials;
}
@Deprecated
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
Map<String, String> userMetadata, String description, String version, @Nullable OsFamily osFamily,
String osDescription, @Nullable Architecture architecture, Credentials defaultCredentials) {
this(providerId, name, id, location, uri, userMetadata, new OperatingSystem(osFamily, null, null,
architecture != null ? architecture.toString() : null, osDescription, architecture != null ? architecture
.equals(Architecture.X86_64) : false), description, version, architecture, defaultCredentials);
}
/**
* {@inheritDoc}
*/
@ -94,33 +80,6 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
return description;
}
/**
* {@inheritDoc}
*/
@Override
public OsFamily getOsFamily() {
return operatingSystem.getFamily();
}
/**
* {@inheritDoc}
*/
@Deprecated
@Override
public String getOsDescription() {
return operatingSystem.getDescription();
}
/**
* {@inheritDoc}
*/
@Deprecated
@Override
@Nullable
public Architecture getArchitecture() {
return architecture;
}
/**
* {@inheritDoc}
*/
@ -139,7 +98,6 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
result = prime * result + ((defaultCredentials == null) ? 0 : defaultCredentials.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
@ -156,11 +114,6 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
if (getClass() != obj.getClass())
return false;
ImageImpl other = (ImageImpl) obj;
if (architecture == null) {
if (other.architecture != null)
return false;
} else if (!architecture.equals(other.architecture))
return false;
if (defaultCredentials == null) {
if (other.defaultCredentials != null)
return false;

View File

@ -28,9 +28,9 @@ import java.util.Set;
import javax.annotation.Nullable;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
@ -42,8 +42,7 @@ import com.google.common.collect.Sets;
* @author Adrian Cole
* @author Ivan Meredith
*/
public class NodeMetadataImpl extends ComputeMetadataImpl implements
NodeMetadata {
public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 7924307572338157887L;
@ -53,21 +52,20 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements
private final Map<String, String> extra = Maps.newLinkedHashMap();
private final Credentials credentials;
private final String tag;
private final Image image;
private final String imageId;
private final OperatingSystem os;
public NodeMetadataImpl(String providerId, String name, String id,
Location location, URI uri, Map<String, String> userMetadata,
@Nullable String tag, @Nullable Image image, NodeState state,
Iterable<String> publicAddresses, Iterable<String> privateAddresses,
Map<String, String> extra, @Nullable Credentials credentials) {
public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
Map<String, String> userMetadata, @Nullable String tag, @Nullable String imageId,
@Nullable OperatingSystem os, NodeState state, Iterable<String> publicAddresses,
Iterable<String> privateAddresses, Map<String, String> extra, @Nullable Credentials credentials) {
super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata);
this.tag = tag;
this.image = image;
this.imageId = imageId;
this.os = os;
this.state = checkNotNull(state, "state");
Iterables.addAll(this.publicAddresses, checkNotNull(publicAddresses,
"publicAddresses"));
Iterables.addAll(this.privateAddresses, checkNotNull(privateAddresses,
"privateAddresses"));
Iterables.addAll(this.publicAddresses, checkNotNull(publicAddresses, "publicAddresses"));
Iterables.addAll(this.privateAddresses, checkNotNull(privateAddresses, "privateAddresses"));
this.extra.putAll(checkNotNull(extra, "extra"));
this.credentials = credentials;
}
@ -88,15 +86,6 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements
return credentials;
}
/**
* {@inheritDoc}
*/
@Override
@Nullable
public Image getImage() {
return image;
}
/**
* {@inheritDoc}
*/
@ -131,24 +120,22 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements
@Override
public String toString() {
return "[id=" + getId() + ", providerId=" + getProviderId() + ", tag="
+ getTag() + ", name=" + getName() + ", location=" + getLocation()
+ ", uri=" + getUri() + ", image=" + getImage() + ", userMetadata="
+ getUserMetadata() + ", state=" + getState()
+ ", privateAddresses=" + privateAddresses + ", publicAddresses="
+ publicAddresses + ", extra=" + getExtra() + "]";
return "[id=" + getId() + ", providerId=" + getProviderId() + ", tag=" + getTag() + ", name=" + getName()
+ ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
+ getOperatingSystem() + ", userMetadata=" + getUserMetadata() + ", state=" + getState()
+ ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + ", extra="
+ getExtra() + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((privateAddresses == null) ? 0 : privateAddresses.hashCode());
result = prime * result
+ ((publicAddresses == null) ? 0 : publicAddresses.hashCode());
result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode());
result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode());
result = prime * result + ((tag == null) ? 0 : tag.hashCode());
result = prime * result + ((image == null) ? 0 : image.hashCode());
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
result = prime * result + ((os == null) ? 0 : os.hashCode());
return result;
}
@ -176,12 +163,27 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements
return false;
} else if (!tag.equals(other.tag))
return false;
if (image == null) {
if (other.image != null)
if (imageId == null) {
if (other.imageId != null)
return false;
} else if (!image.equals(other.image))
} else if (!imageId.equals(other.imageId))
return false;
if (os == null) {
if (other.os != null)
return false;
} else if (!os.equals(other.os))
return false;
return true;
}
@Override
public String getImageId() {
return imageId;
}
@Override
public OperatingSystem getOperatingSystem() {
return os;
}
}

View File

@ -35,7 +35,6 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
@ -54,7 +53,6 @@ import com.google.common.base.Predicates;
import com.google.common.base.Supplier;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Doubles;
@ -77,8 +75,6 @@ public class TemplateBuilderImpl implements TemplateBuilder {
protected final Provider<TemplateOptions> optionsProvider;
protected final Provider<TemplateBuilder> defaultTemplateProvider;
@VisibleForTesting
protected Architecture arch;
@VisibleForTesting
protected Location location;
@VisibleForTesting
@ -117,7 +113,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
@Inject
protected TemplateBuilderImpl(Supplier<Set<? extends Location>> locations, Supplier<Set<? extends Image>> images,
Supplier<Set<? extends Size>> sizes, Supplier<Location> defaultLocation2,
Provider<TemplateOptions> optionsProvider, @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
Provider<TemplateOptions> optionsProvider,
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
this.locations = locations;
this.images = images;
this.sizes = sizes;
@ -127,13 +124,11 @@ public class TemplateBuilderImpl implements TemplateBuilder {
}
/**
* If the current location id is null, then we don't care where to launch a
* node.
* If the current location id is null, then we don't care where to launch a node.
*
* If the input location is null, then the data isn't location sensitive
*
* If the input location is a parent of the specified location, then we are
* ok.
* If the input location is a parent of the specified location, then we are ok.
*/
private final Predicate<ComputeMetadata> locationPredicate = new Predicate<ComputeMetadata>() {
@Override
@ -172,17 +167,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
}
};
private final Predicate<Image> imageArchPredicate = new Predicate<Image>() {
@Override
public boolean apply(Image input) {
boolean returnVal = true;
if (arch != null)
returnVal = arch.equals(input.getArchitecture());
return returnVal;
}
};
private final Predicate<OperatingSystem> osNamePredicate = new Predicate<OperatingSystem>() {
@Override
public boolean apply(OperatingSystem input) {
@ -399,8 +384,6 @@ public class TemplateBuilderImpl implements TemplateBuilder {
this.os64Bit = image.getOperatingSystem().is64Bit();
if (image.getOperatingSystem().getArch() != null)
this.osArch = image.getOperatingSystem().getArch();
if (image.getArchitecture() != null)
this.arch = image.getArchitecture();
return this;
}
@ -456,15 +439,6 @@ public class TemplateBuilderImpl implements TemplateBuilder {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public TemplateBuilder architecture(Architecture architecture) {
this.arch = architecture;
return this;
}
/**
* {@inheritDoc}
*/
@ -487,8 +461,6 @@ public class TemplateBuilderImpl implements TemplateBuilder {
Image image = resolveImage(size, supportedImages);
logger.debug("<< matched image(%s)", image);
// ensure we have an architecture matching
this.arch = image.getArchitecture();
return new TemplateImpl(image, size, location, options);
}
@ -566,6 +538,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
if (imageId != null) {
predicates.add(idPredicate);
} else {
if (location != null)
predicates.add(new Predicate<Image>() {
@Override
@ -574,19 +547,33 @@ public class TemplateBuilderImpl implements TemplateBuilder {
}
});
final List<Predicate<OperatingSystem>> osPredicates = newArrayList();
if (osFamily != null)
osPredicates.add(osFamilyPredicate);
if (osName != null)
osPredicates.add(osNamePredicate);
if (osDescription != null)
osPredicates.add(osDescriptionPredicate);
if (osVersion != null)
osPredicates.add(osVersionPredicate);
if (os64Bit != null)
osPredicates.add(os64BitPredicate);
if (osArch != null)
osPredicates.add(osArchPredicate);
predicates.add(new Predicate<Image>() {
@Override
public boolean apply(Image input) {
return Predicates.and(
ImmutableSet.of(osFamilyPredicate, osNamePredicate, osDescriptionPredicate, osVersionPredicate,
os64BitPredicate, osArchPredicate)).apply(input.getOperatingSystem());
return Predicates.and(osPredicates).apply(input.getOperatingSystem());
}
});
predicates.add(imageArchPredicate);
if (imageVersion != null)
predicates.add(imageVersionPredicate);
if (imageName != null)
predicates.add(imageNamePredicate);
if (imageDescription != null)
predicates.add(imageDescriptionPredicate);
}
@ -603,7 +590,6 @@ public class TemplateBuilderImpl implements TemplateBuilder {
this.imageName = null;
this.imageDescription = null;
this.imageVersion = null;
this.arch = null;
this.osFamily = null;
this.osName = null;
this.osDescription = null;
@ -732,8 +718,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
@VisibleForTesting
boolean nothingChangedExceptOptions() {
return osFamily == null && arch == null && location == null && imageId == null && sizeId == null
&& osName == null && osDescription == null && imageVersion == null && osVersion == null && osArch == null
return osFamily == null && location == null && imageId == null && sizeId == null && osName == null
&& osDescription == null && imageVersion == null && osVersion == null && osArch == null
&& os64Bit == null && imageName == null && imageDescription == null && minCores == 0 && minRam == 0
&& !biggest && !fastest;
}
@ -748,15 +734,15 @@ public class TemplateBuilderImpl implements TemplateBuilder {
@Override
public String toString() {
return "[arch=" + arch + ", biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName
+ ", imageDescription=" + imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion
+ ", location=" + location + ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily
+ ", osName=" + osName + ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch + ", os64Bit="
+ os64Bit + ", sizeId=" + sizeId + "]";
return "[biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName + ", imageDescription="
+ imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion + ", location="
+ location + ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily + ", osName="
+ osName + ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch
+ ", os64Bit=" + os64Bit + ", sizeId=" + sizeId + "]";
}
@Override
public TemplateBuilder os64bit(boolean is64Bit) {
public TemplateBuilder os64Bit(boolean is64Bit) {
this.os64Bit = is64Bit;
return this;
}

View File

@ -253,7 +253,6 @@ public class CIMOperatingSystem extends OperatingSystem {
super(osType.getFamily(), osType.getValue(), version, arch, description, osType.is64Bit());
this.osType = osType;
}
/**
* CIM OSType of the image
*/

View File

@ -23,6 +23,7 @@ import org.jclouds.compute.domain.OperatingSystem;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
/**
* Container for operating system filters (predicates).
@ -48,8 +49,11 @@ public class OperatingSystemPredicates {
return true;
}
}
String toMatch = os.getName() != null ? os.getName() : os.getDescription();
return (toMatch.toLowerCase().indexOf("ubuntu") != -1 || toMatch.toLowerCase().indexOf("debian") != -1);
for (String toMatch : ImmutableSet.of(os.getName(), os.getDescription()))
if (toMatch != null && toMatch.toLowerCase().indexOf("ubuntu") != -1
|| toMatch.toLowerCase().indexOf("debian") != -1)
return true;
return false;
}
@Override
@ -75,10 +79,13 @@ public class OperatingSystemPredicates {
return true;
}
}
String toMatch = os.getName() != null ? os.getName() : os.getDescription();
return (toMatch.toLowerCase().indexOf("centos") != -1 || toMatch.toLowerCase().indexOf("rhel") != -1
|| toMatch.toLowerCase().replace(" ", "").indexOf("redhate") != -1 || toMatch.toLowerCase().indexOf(
"fedora") != -1);
for (String toMatch : ImmutableSet.of(os.getName(), os.getDescription()))
if (toMatch.toLowerCase().indexOf("centos") != -1 || toMatch.toLowerCase().indexOf("rhel") != -1
|| toMatch.toLowerCase().replace(" ", "").indexOf("redhate") != -1
|| toMatch.toLowerCase().indexOf("fedora") != -1)
return true;
return false;
}
@Override
@ -88,6 +95,33 @@ public class OperatingSystemPredicates {
};
}
/**
* evaluates true if the OperatingSystem supports the zypper installer
*
*/
public static Predicate<OperatingSystem> supportsZypper() {
return new Predicate<OperatingSystem>() {
@Override
public boolean apply(OperatingSystem os) {
if (os.getFamily() != null) {
switch (os.getFamily()) {
case SUSE:
return true;
}
}
for (String toMatch : ImmutableSet.of(os.getName(), os.getDescription()))
if (toMatch != null && toMatch.toLowerCase().indexOf("suse") != -1)
return true;
return false;
}
@Override
public String toString() {
return "supportsZypper()";
}
};
}
/**
* return everything.
*/

View File

@ -178,11 +178,11 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo
private final ExecutorService service;
public StubNodeMetadata(String providerId, String name, String id, Location location, URI uri,
Map<String, String> userMetadata, String tag, Image image, NodeState state,
Iterable<String> publicAddresses, Iterable<String> privateAddresses, Map<String, String> extra,
Credentials credentials, ExecutorService service) {
super(providerId, name, id, location, uri, userMetadata, tag, image, state, publicAddresses, privateAddresses,
extra, credentials);
Map<String, String> userMetadata, String tag, String imageId, Image image, OperatingSystem os,
NodeState state, Iterable<String> publicAddresses, Iterable<String> privateAddresses,
Map<String, String> extra, Credentials credentials, ExecutorService service) {
super(providerId, name, id, location, uri, userMetadata, tag, imageId, os, state, publicAddresses,
privateAddresses, extra, credentials);
this.setState(state, 0);
this.service = service;
}
@ -242,9 +242,10 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo
checkArgument(location.get().equals(template.getLocation()), "invalid location: " + template.getLocation());
int id = idProvider.get();
StubNodeMetadata node = new StubNodeMetadata(id + "", name, id + "", location.get(), null, ImmutableMap
.<String, String> of(), tag, template.getImage(), NodeState.PENDING, ImmutableSet
.<String> of(publicIpPrefix + id), ImmutableSet.<String> of(privateIpPrefix + id), ImmutableMap
.<String, String> of(), new Credentials("root", passwordPrefix + id), service);
.<String, String> of(), tag, template.getImage().getId(), template.getImage(), template.getImage()
.getOperatingSystem(), NodeState.PENDING, ImmutableSet.<String> of(publicIpPrefix + id), ImmutableSet
.<String> of(privateIpPrefix + id), ImmutableMap.<String, String> of(), new Credentials("root",
passwordPrefix + id), service);
nodes.put(id, node);
node.setState(NodeState.RUNNING, 100);
return node;
@ -355,15 +356,15 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo
new ImageImpl("1", OsFamily.UBUNTU.name(), parentId + "/1", zone, null,
ImmutableMap.<String, String> of(), //
new OperatingSystem(OsFamily.UBUNTU, "ubuntu 32", null, "X86_32", "ubuntu 32", false),
"stub ubuntu 32", "", null, new Credentials("root", null)), //
"stub ubuntu 32", "", new Credentials("root", null)), //
new ImageImpl("2", OsFamily.UBUNTU.name(), parentId + "/2", zone, null,
ImmutableMap.<String, String> of(),//
new OperatingSystem(OsFamily.UBUNTU, "ubuntu 64", null, "X86_64", "ubuntu 64", true),
"stub ubuntu 64", "", null, new Credentials("root", null)),//
"stub ubuntu 64", "", new Credentials("root", null)),//
new ImageImpl("3", OsFamily.CENTOS.name(), parentId + "/3", zone, null,
ImmutableMap.<String, String> of(), //
new OperatingSystem(OsFamily.CENTOS, "centos 64", null, "X86_64", "centos 64", true),
"stub centos 64", "", null, new Credentials("root", null))));
"stub centos 64", "", new Credentials("root", null))));
}
@Provides

View File

@ -28,7 +28,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
@ -90,10 +89,6 @@ public class ComputeServiceUtils {
return myOs;
}
public static Architecture parseArchitectureOrNull(String in) {
return in.indexOf("64") == -1 ? Architecture.X86_32 : Architecture.X86_64;
}
public static String createExecutionErrorMessage(Map<?, Exception> executionExceptions) {
Formatter fmt = new Formatter().format("Execution failures:%n%n");
int index = 1;
@ -154,8 +149,9 @@ public class ComputeServiceUtils {
*/
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
return new NodeMetadataImpl(node.getProviderId(), node.getName(), node.getId(), node.getLocation(),
node.getUri(), node.getUserMetadata(), node.getTag(), node.getImage(), node.getState(), node
.getPublicAddresses(), node.getPrivateAddresses(), node.getExtra(), newCredentials);
node.getUri(), node.getUserMetadata(), node.getTag(), node.getImageId(), node.getOperatingSystem(), node
.getState(), node.getPublicAddresses(), node.getPrivateAddresses(), node.getExtra(),
newCredentials);
}
public static Iterable<String> getSupportedProviders() {

View File

@ -55,11 +55,12 @@ import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.Size;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.predicates.OperatingSystemPredicates;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
@ -92,6 +93,34 @@ import com.google.inject.Module;
*/
@Test(groups = { "integration", "live" }, sequential = true, testName = "compute.ComputeServiceLiveTest")
public abstract class BaseComputeServiceLiveTest {
public static final String APT_RUN_SCRIPT = new StringBuilder()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
.append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")//
.append(
"sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")//
.append("apt-get update\n")//
.append("apt-get install -f -y --force-yes openjdk-6-jdk\n")//
.toString();
public static final String YUM_RUN_SCRIPT = new StringBuilder()
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")
//
.append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
//
.append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
//
.append(
"echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")//
.append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")//
.append("yum --nogpgcheck -y install java-1.6.0-openjdk\n")//
.append("echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")//
.toString();
public static final String ZYPPER_RUN_SCRIPT = new StringBuilder()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
.append("sudo zypper install java-1.6.0-openjdk-devl\n")//
.toString();
@BeforeClass
abstract public void setServiceDefaults();
@ -209,16 +238,16 @@ public abstract class BaseComputeServiceLiveTest {
assert good.identity != null : nodes;
assert good.credential != null : nodes;
Image image = get(nodes, 0).getImage();
OperatingSystem os = get(nodes, 0).getOperatingSystem();
try {
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(tag, image.getOsFamily(),
new Credentials(good.identity, "romeo"));
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(tag, os, new Credentials(
good.identity, "romeo"));
assert false : "shouldn't pass with a bad password\n" + responses;
} catch (RunScriptOnNodesException e) {
assert getRootCause(e).getMessage().contains("Auth fail") : e;
}
runScriptWithCreds(tag, image.getOsFamily(), good);
runScriptWithCreds(tag, os, good);
checkNodes(nodes, tag);
@ -247,7 +276,7 @@ public abstract class BaseComputeServiceLiveTest {
template.getOptions().installPrivateKey(newStringPayload(keyPair.get("private"))).authorizePublicKey(
newStringPayload(keyPair.get("public"))).runScript(
newStringPayload(buildScript(template.getImage().getOsFamily())));
newStringPayload(buildScript(template.getImage().getOperatingSystem())));
try {
nodes = newTreeSet(client.runNodesWithTag(tag, 2, template));
} catch (RunNodesException e) {
@ -263,11 +292,20 @@ public abstract class BaseComputeServiceLiveTest {
assertLocationSameOrChild(node1.getLocation(), template.getLocation());
assertLocationSameOrChild(node2.getLocation(), template.getLocation());
if (node1.getImage() != null)
assertEquals(node1.getImage(), template.getImage());
if (node2.getImage() != null)
assertEquals(node2.getImage(), template.getImage());
checkImageIdMatchesTemplate(node1);
checkImageIdMatchesTemplate(node2);
checkOsMatchesTemplate(node1);
checkOsMatchesTemplate(node2);
}
protected void checkImageIdMatchesTemplate(NodeMetadata node) {
if (node.getImageId() != null)
assertEquals(node.getImageId(), template.getImage().getId());
}
protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null)
assertEquals(node.getOperatingSystem().getFamily(), template.getImage().getOperatingSystem().getFamily());
}
void assertLocationSameOrChild(Location test, Location expected) {
@ -287,13 +325,13 @@ public abstract class BaseComputeServiceLiveTest {
this.nodes.add(node);
assertEquals(nodes.size(), 1);
assertLocationSameOrChild(node.getLocation(), template.getLocation());
assertEquals(node.getImage(), template.getImage());
assertEquals(node.getOperatingSystem().getFamily(), template.getImage().getOperatingSystem().getFamily());
}
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OsFamily osFamily,
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os,
Credentials creds) throws RunScriptOnNodesException {
try {
return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(osFamily)),
return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)),
overrideCredentialsWith(creds));
} catch (SshException e) {
if (getRootCause(e).getMessage().contains("Auth fail")) {
@ -325,35 +363,15 @@ public abstract class BaseComputeServiceLiveTest {
return templateBuilder.build();
}
public static String buildScript(OsFamily osFamily) {
switch (osFamily) {
case UBUNTU:
return new StringBuilder()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
.append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")//
.append(
"sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")//
.append("apt-get update\n")//
.append("apt-get install -f -y --force-yes openjdk-6-jdk\n")//
.append("wget -qO/usr/bin/runurl run.alestic.com/runurl\n")//
.append("chmod 755 /usr/bin/runurl\n")//
.toString();
case CENTOS:
case RHEL:
return new StringBuilder()
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")
.append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
.append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
.append(
"echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
.append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
.append("yum --nogpgcheck -y install java-1.6.0-openjdk\n")
.append(
"echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")
.toString();
default:
throw new IllegalArgumentException(osFamily.toString());
}
public static String buildScript(OperatingSystem os) {
if (OperatingSystemPredicates.supportsApt().apply(os))
return APT_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsYum().apply(os))
return YUM_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsZypper().apply(os))
return ZYPPER_RUN_SCRIPT;
else
throw new IllegalArgumentException("don't know how to handle" + os.toString());
}
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired")
@ -366,7 +384,8 @@ public abstract class BaseComputeServiceLiveTest {
assertEquals(metadata.getProviderId(), node.getProviderId());
assertEquals(metadata.getTag(), node.getTag());
assertLocationSameOrChild(metadata.getLocation(), template.getLocation());
assertEquals(metadata.getImage(), template.getImage());
checkImageIdMatchesTemplate(metadata);
checkOsMatchesTemplate(metadata);
assertEquals(metadata.getState(), NodeState.RUNNING);
assertEquals(metadata.getPrivateAddresses(), node.getPrivateAddresses());
assertEquals(metadata.getPublicAddresses(), node.getPublicAddresses());

View File

@ -213,8 +213,8 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
}
private void runScript(SshClient client, String scriptName, int nodeId) {
client.put(eq("" + scriptName + ""), payloadEq(initScript(scriptName, buildScript(OsFamily.UBUNTU))));
client.put(eq("" + scriptName + ""), payloadEq(initScript(scriptName,
BaseComputeServiceLiveTest.APT_RUN_SCRIPT)));
expect(client.exec("chmod 755 " + scriptName + "")).andReturn(EXEC_GOOD);
expect(client.getUsername()).andReturn("root").atLeastOnce();
expect(client.getHostAddress()).andReturn(nodeId + "").atLeastOnce();

View File

@ -30,7 +30,6 @@ import java.util.Set;
import javax.inject.Provider;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
@ -137,13 +136,13 @@ public class TemplateBuilderImplTest {
expect(optionsProvider.get()).andReturn(new TemplateOptions());
expect(image.getLocation()).andReturn(defaultLocation).atLeastOnce();
expect(image.getArchitecture()).andReturn(Architecture.X86_32).atLeastOnce();
expect(image2.getLocation()).andReturn(defaultLocation).atLeastOnce();
expect(image2.getArchitecture()).andReturn(Architecture.X86_64).atLeastOnce();
expect(image.getOperatingSystem()).andReturn(os).atLeastOnce();
expect(image2.getOperatingSystem()).andReturn(os2).atLeastOnce();
expect(os.getArch()).andReturn("X86_32").atLeastOnce();
expect(os2.getArch()).andReturn("X86_64").atLeastOnce();
replay(image);
replay(image2);
replay(os);
@ -156,7 +155,7 @@ public class TemplateBuilderImplTest {
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
optionsProvider, templateBuilderProvider);
assertEquals(template.smallest().architecture(Architecture.X86_32).build().getImage(), image);
assertEquals(template.smallest().osArchMatches("X86_32").build().getImage(), image);
verify(image);
verify(image2);
@ -193,7 +192,6 @@ public class TemplateBuilderImplTest {
expect(image.getName()).andReturn(null).atLeastOnce();
expect(image.getDescription()).andReturn(null).atLeastOnce();
expect(image.getVersion()).andReturn(null).atLeastOnce();
expect(image.getArchitecture()).andReturn(null).atLeastOnce();
expect(image.getOperatingSystem()).andReturn(os).atLeastOnce();
expect(os.getName()).andReturn(null).atLeastOnce();
@ -249,7 +247,6 @@ public class TemplateBuilderImplTest {
expect(image.getName()).andReturn(null).atLeastOnce();
expect(image.getDescription()).andReturn(null).atLeastOnce();
expect(image.getVersion()).andReturn(null).atLeastOnce();
expect(image.getArchitecture()).andReturn(null).atLeastOnce();
expect(os.getName()).andReturn(null).atLeastOnce();
expect(os.getVersion()).andReturn(null).atLeastOnce();
@ -516,14 +513,14 @@ public class TemplateBuilderImplTest {
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
optionsProvider, templateBuilderProvider);
template.architecture(Architecture.X86_32);
template.imageDescriptionMatches("imageDescriptionMatches");
template.imageNameMatches("imageNameMatches");
template.imageVersionMatches("imageVersionMatches");
template.osDescriptionMatches("osDescriptionMatches");
template.osFamily(OsFamily.CENTOS);
template.osArchMatches("osArchMatches");
assertEquals(template.arch, Architecture.X86_32);
assertEquals(template.osArch, "osArchMatches");
assertEquals(template.imageDescription, "imageDescriptionMatches");
assertEquals(template.imageName, "imageNameMatches");
assertEquals(template.imageVersion, "imageVersionMatches");
@ -532,7 +529,7 @@ public class TemplateBuilderImplTest {
assertEquals(template.imageId, null);
template.imageId("myid");
assertEquals(template.arch, null);
assertEquals(template.osArch, null);
assertEquals(template.imageDescription, null);
assertEquals(template.imageName, null);
assertEquals(template.imageVersion, null);

View File

@ -21,6 +21,7 @@ package org.jclouds.compute.predicates;
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsApt;
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsYum;
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsZypper;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
@ -37,91 +38,102 @@ import org.testng.annotations.Test;
public class OperatingSystemPredicatesTest {
public void testCIMCENTOSDoesntSupportApt() {
assert !supportsApt().apply(new CIMOperatingSystem(OSType.CENTOS, null, null, "description"));
assert !supportsApt().apply(new CIMOperatingSystem(OSType.CENTOS_64, null, null, "description"));
assert !supportsApt().apply(new CIMOperatingSystem(OSType.CENTOS, "", null, "description"));
assert !supportsApt().apply(new CIMOperatingSystem(OSType.CENTOS_64, "", null, "description"));
}
public void testCIMRHELDoesntSupportApt() {
assert !supportsApt().apply(new CIMOperatingSystem(OSType.RHEL, null, null, "description"));
assert !supportsApt().apply(new CIMOperatingSystem(OSType.RHEL_64, null, null, "description"));
assert !supportsApt().apply(new CIMOperatingSystem(OSType.RHEL, "", null, "description"));
assert !supportsApt().apply(new CIMOperatingSystem(OSType.RHEL_64, "", null, "description"));
}
public void testCIMDEBIANSupportsApt() {
assert supportsApt().apply(new CIMOperatingSystem(OSType.DEBIAN, null, null, "description"));
assert supportsApt().apply(new CIMOperatingSystem(OSType.DEBIAN_64, null, null, "description"));
assert supportsApt().apply(new CIMOperatingSystem(OSType.DEBIAN, "", null, "description"));
assert supportsApt().apply(new CIMOperatingSystem(OSType.DEBIAN_64, "", null, "description"));
}
public void testCIMUBUNTUSupportsApt() {
assert supportsApt().apply(new CIMOperatingSystem(OSType.UBUNTU, null, null, "description"));
assert supportsApt().apply(new CIMOperatingSystem(OSType.UBUNTU_64, null, null, "description"));
assert supportsApt().apply(new CIMOperatingSystem(OSType.UBUNTU, "", null, "description"));
assert supportsApt().apply(new CIMOperatingSystem(OSType.UBUNTU_64, "", null, "description"));
}
public void testUbuntuNameSupportsApt() {
assert supportsApt().apply(new OperatingSystem(null, "Ubuntu", null, null, "description", false));
assert supportsApt().apply(new OperatingSystem(null, "Ubuntu", "", null, "description", false));
}
public void testCIMCENTOSSupportsYum() {
assert supportsYum().apply(new CIMOperatingSystem(OSType.CENTOS, null, null, "description"));
assert supportsYum().apply(new CIMOperatingSystem(OSType.CENTOS_64, null, null, "description"));
assert supportsYum().apply(new CIMOperatingSystem(OSType.CENTOS, "", null, "description"));
assert supportsYum().apply(new CIMOperatingSystem(OSType.CENTOS_64, "", null, "description"));
}
public void testCIMRHELSupportsYum() {
assert supportsYum().apply(new CIMOperatingSystem(OSType.RHEL, null, null, "description"));
assert supportsYum().apply(new CIMOperatingSystem(OSType.RHEL_64, null, null, "description"));
assert supportsYum().apply(new CIMOperatingSystem(OSType.RHEL, "", null, "description"));
assert supportsYum().apply(new CIMOperatingSystem(OSType.RHEL_64, "", null, "description"));
}
public void testCIMDEBIANDoesntSupportYum() {
assert !supportsYum().apply(new CIMOperatingSystem(OSType.DEBIAN, null, null, "description"));
assert !supportsYum().apply(new CIMOperatingSystem(OSType.DEBIAN_64, null, null, "description"));
assert !supportsYum().apply(new CIMOperatingSystem(OSType.DEBIAN, "", null, "description"));
assert !supportsYum().apply(new CIMOperatingSystem(OSType.DEBIAN_64, "", null, "description"));
}
public void testCIMUBUNTUDoesntSupportYum() {
assert !supportsYum().apply(new CIMOperatingSystem(OSType.UBUNTU, null, null, "description"));
assert !supportsYum().apply(new CIMOperatingSystem(OSType.UBUNTU_64, null, null, "description"));
assert !supportsYum().apply(new CIMOperatingSystem(OSType.UBUNTU, "", null, "description"));
assert !supportsYum().apply(new CIMOperatingSystem(OSType.UBUNTU_64, "", null, "description"));
}
public void testSuseTypeSupportsZypper() {
assert supportsZypper().apply(new OperatingSystem(OsFamily.SUSE, null, "", null, "description", false));
}
public void testSuseDescriptionSupportsZypper() {
assert supportsZypper().apply(new OperatingSystem(null, "", null, null, "Suse", false));
}
public void testSuseNameSupportsZypper() {
assert supportsZypper().apply(new OperatingSystem(null, "Suse", "", null, "description", false));
}
public void testCentosTypeSupportsYum() {
assert supportsYum().apply(new OperatingSystem(OsFamily.CENTOS, null, null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(OsFamily.CENTOS, null, "", null, "description", false));
}
public void testRhelTypeSupportsYum() {
assert supportsYum().apply(new OperatingSystem(OsFamily.RHEL, null, null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(OsFamily.RHEL, null, "", null, "description", false));
}
public void testFedoraTypeSupportsYum() {
assert supportsYum().apply(new OperatingSystem(OsFamily.FEDORA, null, null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(OsFamily.FEDORA, null, "", null, "description", false));
}
public void testCentosNameSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, "Centos", null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(null, "Centos", "", null, "description", false));
}
public void testRhelNameSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, "RHEL", null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(null, "RHEL", "", null, "description", false));
}
public void testFedoraNameSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, "Fedora", null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(null, "Fedora", "", null, "description", false));
}
public void testRedHatEnterpriseLinuxNameSupportsYum() {
assert supportsYum().apply(
new OperatingSystem(null, "Red Hat Enterprise Linux", null, null, "description", false));
assert supportsYum().apply(new OperatingSystem(null, "Red Hat Enterprise Linux", "", null, "description", false));
}
public void testCentosDescriptionSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "Centos", false));
assert supportsYum().apply(new OperatingSystem(null, "", null, null, "Centos", false));
}
public void testRhelDescriptionSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "RHEL", false));
assert supportsYum().apply(new OperatingSystem(null, "", null, null, "RHEL", false));
}
public void testFedoraDescriptionSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "Fedora", false));
assert supportsYum().apply(new OperatingSystem(null, "", null, null, "Fedora", false));
}
public void testRedHatEnterpriseLinuxDescriptionSupportsYum() {
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "Red Hat Enterprise Linux", false));
assert supportsYum().apply(new OperatingSystem(null, "", null, null, "Red Hat Enterprise Linux", false));
}
}

View File

@ -100,7 +100,9 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
logger.warn("could not find a matching image for server %s", from);
}
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", locations.get().get(
from.getDatacenter().getId() + ""), null, ImmutableMap.<String, String> of(), tag, image, state, ipSet,
ImmutableList.<String> of(), ImmutableMap.<String, String> of(), creds);
from.getDatacenter().getId() + ""), null, ImmutableMap.<String, String> of(), tag, from.getImage()
.getId()
+ "", image != null ? image.getOperatingSystem() : null, state, ipSet, ImmutableList.<String> of(),
ImmutableMap.<String, String> of(), creds);
}
}

View File

@ -27,8 +27,8 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.compute.reference.ComputeServiceConstants;
@ -70,26 +70,28 @@ public class GoGridImageSupplier implements Supplier<Set<? extends Image>> {
logger.debug(">> providing images");
Set<ServerImage> allImages = sync.getImageServices().getImageList();
for (ServerImage from : allImages) {
OsFamily os = null;
Architecture arch = (from.getOs().getName().indexOf("64") == -1 && from.getDescription().indexOf("64") == -1) ? Architecture.X86_32
: Architecture.X86_64;
String osDescription;
OsFamily osFamily = null;
String osName = from.getOs().getName();
String osArch = from.getArchitecture().getDescription();
String osVersion = null;// TODO
String osDescription = from.getOs().getDescription();
boolean is64Bit = (from.getOs().getName().indexOf("64") != -1 || from.getDescription().indexOf("64") != -1);
String description = from.getDescription();
String version = "";
osDescription = from.getOs().getName();
String matchedOs = GoGridUtils.parseStringByPatternAndGetNthMatchGroup(from.getOs().getName(),
GOGRID_OS_NAME_PATTERN, 1);
String matchedOs = GoGridUtils.parseStringByPatternAndGetNthMatchGroup(osName, GOGRID_OS_NAME_PATTERN, 1);
try {
os = OsFamily.fromValue(matchedOs.toLowerCase());
osFamily = OsFamily.fromValue(matchedOs.toLowerCase());
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", matchedOs);
}
Credentials defaultCredentials = authenticator.execute(from);
// TODO determine DC images are in
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), from.getId() + "", null, null,
ImmutableMap.<String, String> of(), from.getDescription(), version, os, osDescription, arch,
defaultCredentials));
ImmutableMap.<String, String> of(), os, description, version, defaultCredentials));
}
logger.debug("<< images(%d)", images.size());
return images;

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.gogrid.GoGridAsyncClient;
@ -48,8 +47,8 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getLocation().getId(), "1");
assertEquals(defaultTemplate.getSize().getCores(), 0.5d);
}

View File

@ -32,6 +32,7 @@ import java.util.Set;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
@ -88,6 +89,7 @@ public class ServerToNodeMetadataTest {
expect(image.getId()).andReturn(2000l).atLeastOnce();
expect(jcImage.getProviderId()).andReturn("2000").atLeastOnce();
expect(jcImage.getLocation()).andReturn(location).atLeastOnce();
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
replay(caller);
replay(client);
@ -103,7 +105,7 @@ public class ServerToNodeMetadataTest {
NodeMetadata metadata = parser.apply(server);
assertEquals(metadata.getLocation(), location);
assertEquals(metadata.getImage(), jcImage);
assertEquals(metadata.getImageId(), "2000");
assertEquals(metadata.getTag(), "tag");
assertEquals(metadata.getCredentials(), new Credentials("user", "pass"));

View File

@ -19,7 +19,7 @@
package org.jclouds.ibmdev.compute.config;
import static org.jclouds.compute.domain.OsFamily.RHEL;
import static org.jclouds.compute.domain.OsFamily.SUSE;
import java.util.Map;
import java.util.Set;
@ -98,7 +98,7 @@ public class IBMDeveloperCloudComputeServiceContextModule extends BaseComputeSer
*/
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
return template.osFamily(RHEL);
return template.osFamily(SUSE);
}
@Provides

View File

@ -19,7 +19,7 @@
package org.jclouds.ibmdev.compute.domain;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.domain.Credentials;
@ -42,11 +42,12 @@ public class IBMImage extends ImageImpl {
// TODO manifest fails to parse due to encoding issues in the path
// TODO get correct default credentials
// http://www-180.ibm.com/cloud/enterprise/beta/ram/community/_rlvid.jsp.faces?_rap=pc_DiscussionForum.doDiscussionTopic&_rvip=/community/discussionForum.jsp&guid={DA689AEE-783C-6FE7-6F9F-DFEE9763F806}&v=1&submission=false&fid=1068&tid=1527
super(in.getId(), in.getName(), in.getId(), location, null, ImmutableMap.<String, String> of(), in
.getDescription(), in.getCreatedTime().getTime() + "",
(in.getPlatform().indexOf("Red Hat") != -1) ? OsFamily.RHEL : OsFamily.SUSE, in.getPlatform(), (in
.getPlatform().indexOf("32") != -1) ? Architecture.X86_32 : Architecture.X86_64,
new Credentials("idcuser", null));
super(in.getId(), in.getName(), in.getId(), location, null, ImmutableMap.<String, String> of(),
new OperatingSystem((in.getPlatform().indexOf("Red Hat") != -1) ? OsFamily.RHEL : OsFamily.SUSE, null,
null, null, in.getPlatform(), (in.getPlatform().indexOf("32") == -1)), in.getDescription(), in
.getCreatedTime().getTime()
+ "", new Credentials("idcuser", null));
this.rawImage = in;
}

View File

@ -76,8 +76,8 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
Image image = images.get().get(from.getImageId());
String key = tag != null ? credentialsMap.get(tag) : null;
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", locations.get().get(
image.getLocation()), null, ImmutableMap.<String, String> of(), tag, image, state, ipSet, ImmutableList
.<String> of(), ImmutableMap.<String, String> of(), new Credentials(
image.getDefaultCredentials().identity, key));
image.getLocation()), null, ImmutableMap.<String, String> of(), tag, from.getImageId(),
image != null ? image.getOperatingSystem() : null, state, ipSet, ImmutableList.<String> of(),
ImmutableMap.<String, String> of(), new Credentials(image.getDefaultCredentials().identity, key));
}
}

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.OsFamily;
@ -50,8 +49,8 @@ public class IBMDeveloperCloudComputeServiceLiveTestDisabled extends BaseCompute
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.RHEL);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.SUSE);
assertEquals(defaultTemplate.getLocation().getId(), "1");
assertEquals(defaultTemplate.getSize().getCores(), 2.0d);
}

View File

@ -94,8 +94,9 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
logger.warn("could not find a matching image for server %s in location %s", from, location);
}
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", host, null, from.getMetadata(),
tag, image, serverToNodeState.get(from.getStatus()), from.getAddresses().getPublicAddresses(), from
.getAddresses().getPrivateAddresses(), ImmutableMap.<String, String> of(), null);
tag, from.getImageId() + "", image != null ? image.getOperatingSystem() : null, serverToNodeState
.get(from.getStatus()), from.getAddresses().getPublicAddresses(), from.getAddresses()
.getPrivateAddresses(), ImmutableMap.<String, String> of(), null);
}
}

View File

@ -53,10 +53,10 @@ public class CloudServersAddNodeWithTagStrategy implements AddNodeWithTagStrateg
public NodeMetadata execute(String tag, String name, Template template) {
Server server = client.createServer(name, Integer.parseInt(template.getImage().getProviderId()), Integer
.parseInt(template.getSize().getProviderId()));
return new NodeMetadataImpl(server.getId() + "", name, server.getId() + "", new LocationImpl(
LocationScope.HOST, server.getHostId(), server.getHostId(), template.getLocation()), null, server
.getMetadata(), tag, template.getImage(), NodeState.PENDING, server.getAddresses()
.getPublicAddresses(), server.getAddresses().getPrivateAddresses(), ImmutableMap
return new NodeMetadataImpl(server.getId() + "", name, server.getId() + "", new LocationImpl(LocationScope.HOST,
server.getHostId(), server.getHostId(), template.getLocation()), null, server.getMetadata(), tag,
template.getImage().getId(), template.getImage().getOperatingSystem(), NodeState.PENDING, server
.getAddresses().getPublicAddresses(), server.getAddresses().getPrivateAddresses(), ImmutableMap
.<String, String> of(), new Credentials("root", server.getAdminPass()));
}

View File

@ -28,8 +28,8 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.compute.reference.ComputeServiceConstants;
@ -69,26 +69,31 @@ public class CloudServersImageSupplier implements Supplier<Set<? extends Image>>
logger.debug(">> providing images");
for (final org.jclouds.rackspace.cloudservers.domain.Image from : sync.listImages(ListOptions.Builder
.withDetails())) {
OsFamily os = null;
Architecture arch = Architecture.X86_64;
String osDescription = "";
String version = "";
String version = from.getUpdated().getTime() + "";
Matcher matcher = RACKSPACE_PATTERN.matcher(from.getName());
osDescription = from.getName();
OsFamily osFamily = null;
String osName = null;
String osArch = null;
String osVersion = null;
String osDescription = from.getName();
boolean is64Bit = true;
if (from.getName().indexOf("Red Hat EL") != -1) {
os = OsFamily.RHEL;
osFamily = OsFamily.RHEL;
} else if (from.getName().indexOf("Oracle EL") != -1) {
os = OsFamily.OEL;
osFamily = OsFamily.OEL;
} else if (matcher.find()) {
try {
os = OsFamily.fromValue(matcher.group(2).toLowerCase());
osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", matcher.group(2));
}
}
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
images.add(new ImageImpl(from.getId() + "", from.getName(), from.getId() + "", location.get(), null,
ImmutableMap.<String, String> of(), from.getName(), version, os, osDescription, arch,
new Credentials("root", null)));
ImmutableMap.<String, String> of(), os, from.getName(), version, new Credentials("root", null)));
}
logger.debug("<< images(%d)", images.size());
return images;

View File

@ -25,7 +25,6 @@ import java.io.IOException;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
@ -55,8 +54,8 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DFW1");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
}

View File

@ -32,6 +32,7 @@ import java.util.Set;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl;
@ -82,6 +83,7 @@ public class ServerToNodeMetadataTest {
expect(server.getImageId()).andReturn(2000).atLeastOnce();
expect(jcImage.getProviderId()).andReturn("2000").atLeastOnce();
expect(jcImage.getLocation()).andReturn(provider).atLeastOnce();
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
replay(addresses);
replay(jcImage);
@ -93,7 +95,7 @@ public class ServerToNodeMetadataTest {
NodeMetadata metadata = parser.apply(server);
assertEquals(metadata.getLocation(), location);
assertEquals(metadata.getImage(), jcImage);
assertEquals(metadata.getImageId(), "2000");
assert metadata.getUserMetadata() != null;
assertEquals(metadata.getTag(), "cloudservers");
assertEquals(metadata.getCredentials(), null);

View File

@ -161,13 +161,12 @@
<category name="jclouds.ssh">
<priority value="DEBUG" />
<appender-ref ref="ASYNCSSH" />
</category><!--
</category>
<category name="jclouds.wire">
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
--><category name="jclouds.blobstore">
<category name="jclouds.blobstore">
<priority value="DEBUG" />
<appender-ref ref="ASYNCBLOBSTORE" />
</category>

View File

@ -31,7 +31,6 @@ import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
@ -108,8 +107,7 @@ public class RimuHostingComputeServiceContextModule extends BaseComputeServiceCo
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
return template.sizeId("MIRO1B").osFamily(UBUNTU).architecture(Architecture.X86_32).imageNameMatches(
".*10\\.?04.*");
return template.sizeId("MIRO1B").osFamily(UBUNTU).os64Bit(false).imageNameMatches(".*10\\.?04.*");
}
@VisibleForTesting

View File

@ -107,8 +107,9 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
}
NodeState state = runningStateToNodeState.get(from.getState());
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", location, null, ImmutableMap
.<String, String> of(), tag, image, state, getPublicAddresses.apply(from), ImmutableList.<String> of(),
ImmutableMap.<String, String> of(), creds);
.<String, String> of(), tag, from.getImageId(), image != null ? image.getOperatingSystem() : null,
state, getPublicAddresses.apply(from), ImmutableList.<String> of(), ImmutableMap.<String, String> of(),
creds);
}
}

View File

@ -65,10 +65,10 @@ public class RimuHostingAddNodeWithTagStrategy implements AddNodeWithTagStrategy
"imageId"), checkNotNull(template.getSize().getProviderId(), "sizeId"));
Server server = client.getServer(serverResponse.getServer().getId());
NodeMetadata node = new NodeMetadataImpl(server.getId().toString(), name, server.getId().toString(), template
.getLocation(), null, ImmutableMap.<String, String> of(), tag, template.getImage(),
runningStateToNodeState.get(server.getState()), getPublicAddresses.apply(server), ImmutableList
.<String> of(), ImmutableMap.<String, String> of(), new Credentials("root", serverResponse
.getNewInstanceRequest().getCreateOptions().getPassword()));
.getLocation(), null, ImmutableMap.<String, String> of(), tag, template.getImage().getId(), template
.getImage().getOperatingSystem(), runningStateToNodeState.get(server.getState()), getPublicAddresses
.apply(server), ImmutableList.<String> of(), ImmutableMap.<String, String> of(), new Credentials("root",
serverResponse.getNewInstanceRequest().getCreateOptions().getPassword()));
return node;
}

View File

@ -28,8 +28,8 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.compute.reference.ComputeServiceConstants;
@ -64,25 +64,29 @@ public class RimuHostingImageSupplier implements Supplier<Set<? extends Image>>
final Set<Image> images = Sets.newHashSet();
logger.debug(">> providing images");
for (final org.jclouds.rimuhosting.miro.domain.Image from : sync.getImageList()) {
OsFamily os = null;
Architecture arch = from.getId().indexOf("64") == -1 ? Architecture.X86_32 : Architecture.X86_64;
String osDescription = "";
String version = "";
String version = null;
OsFamily osFamily = null;
String osName = null;
String osArch = null;
String osVersion = null;
String osDescription = from.getId();
boolean is64Bit = from.getId().indexOf("64") != -1;
osDescription = from.getId();
Matcher matcher = RIMU_PATTERN.matcher(from.getId());
if (matcher.find()) {
try {
os = OsFamily.fromValue(matcher.group(1).toLowerCase());
osFamily = OsFamily.fromValue(matcher.group(1).toLowerCase());
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", matcher.group(2));
}
}
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
images.add(new ImageImpl(from.getId(), from.getDescription(), from.getId(), null, null, ImmutableMap
.<String, String> of(), from.getDescription(), version, os, osDescription, arch, new Credentials(
"root", null)));
.<String, String> of(), os, from.getDescription(), version, new Credentials("root", null)));
}
logger.debug("<< images(%d)", images.size());
return images;

View File

@ -22,7 +22,6 @@ package org.jclouds.rimuhosting.miro.compute;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
@ -44,8 +43,8 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DCDALLAS");
assertEquals(defaultTemplate.getSize().getProviderId(), "MIRO1B");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);

View File

@ -38,7 +38,6 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.slicehost.binders.BindCreateBackupToXmlPayload;
import org.jclouds.slicehost.binders.BindCreateSliceToXmlPayload;
import org.jclouds.slicehost.domain.Backup;
import org.jclouds.slicehost.domain.Flavor;
@ -59,9 +58,9 @@ import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to Slicehost via their REST API.
* <p/>
* All commands return a ListenableFuture of the result from Slicehost. Any
* exceptions incurred during processing will be wrapped in an
* {@link ExecutionException} as documented in {@link ListenableFuture#get()}.
* All commands return a ListenableFuture of the result from Slicehost. Any exceptions incurred
* during processing will be wrapped in an {@link ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @see SlicehostClient
* @see <a href="http://www.slicehost.com/docs/Slicehost_API.pdf" />
@ -107,7 +106,7 @@ public interface SlicehostAsyncClient {
* @see SlicehostClient#hardRebootSlice
*/
@PUT
@Path("/slices/{id}/hardReboot.xml")
@Path("/slices/{id}/hard_reboot.xml")
ListenableFuture<Void> hardRebootSlice(@PathParam("id") int id);
/**
@ -170,13 +169,6 @@ public interface SlicehostAsyncClient {
@XMLResponseParser(ImageHandler.class)
ListenableFuture<Image> getImage(@PathParam("id") int id);
/**
* @see SlicehostClient#destroyBackup
*/
@DELETE
@Path("/backups/{id}/destroy.xml")
ListenableFuture<Void> destroyBackup(@PathParam("id") int id);
/**
* @see SlicehostClient#listBackups
*/
@ -195,13 +187,4 @@ public interface SlicehostAsyncClient {
@XMLResponseParser(BackupHandler.class)
ListenableFuture<Backup> getBackup(@PathParam("id") int id);
/**
* @see BackuphostClient#createBackup
*/
@POST
@Path("/slices.xml")
@MapBinder(BindCreateBackupToXmlPayload.class)
@XMLResponseParser(BackupHandler.class)
ListenableFuture<Backup> createBackup(@MapPayloadParam("name") String name, @MapPayloadParam("slice_id") int sliceId);
}

View File

@ -34,9 +34,9 @@ import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides access to Slicehost via their REST API.
* <p/>
* All commands return a ListenableFuture of the result from Slicehost. Any
* exceptions incurred during processing will be wrapped in an
* {@link ExecutionException} as documented in {@link ListenableFuture#get()}.
* All commands return a ListenableFuture of the result from Slicehost. Any exceptions incurred
* during processing will be wrapped in an {@link ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @see SlicehostAsyncClient
* @see <a href="http://www.slicehost.com/docs/Slicehost_API.pdf" />
@ -68,12 +68,8 @@ public interface SlicehostClient {
Image getImage(int id);
Void destroyBackup(int id);
Set<Backup> listBackups();
Backup getBackup(int id);
Backup createBackup(String name, int sliceId);
}

View File

@ -86,8 +86,9 @@ public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
}
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", location.get(), null,
ImmutableMap.<String, String> of(), tag, image, sliceToNodeState.get(from.getStatus()), Iterables
.filter(from.getAddresses(), new Predicate<String>() {
ImmutableMap.<String, String> of(), tag, from.getImageId() + "", image != null ? image
.getOperatingSystem() : null, sliceToNodeState.get(from.getStatus()), Iterables.filter(from
.getAddresses(), new Predicate<String>() {
@Override
public boolean apply(String input) {

View File

@ -55,8 +55,9 @@ public class SlicehostAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
Slice slice = client.createSlice(name, Integer.parseInt(template.getImage().getProviderId()), Integer
.parseInt(template.getSize().getProviderId()));
return new NodeMetadataImpl(slice.getId() + "", name, slice.getId() + "", template.getLocation(), null,
ImmutableMap.<String, String> of(), tag, template.getImage(), NodeState.PENDING, Iterables.filter(slice
.getAddresses(), new Predicate<String>() {
ImmutableMap.<String, String> of(), tag, template.getImage().getId(), template.getImage()
.getOperatingSystem(), NodeState.PENDING, Iterables.filter(slice.getAddresses(),
new Predicate<String>() {
@Override
public boolean apply(String input) {

View File

@ -28,8 +28,8 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.compute.reference.ComputeServiceConstants;
@ -67,22 +67,31 @@ public class SlicehostImageSupplier implements Supplier<Set<? extends Image>> {
final Set<Image> images = Sets.newHashSet();
logger.debug(">> providing images");
for (final org.jclouds.slicehost.domain.Image from : sync.listImages()) {
OsFamily os = null;
Architecture arch = Architecture.X86_64;
String osDescription = "";
String version = "";
String version = null;
Matcher matcher = SLICEHOST_PATTERN.matcher(from.getName());
osDescription = from.getName();
if (matcher.find()) {
OsFamily osFamily = null;
String osName = null;
String osArch = null;
String osVersion = null;
String osDescription = from.getName();
boolean is64Bit = true;
if (from.getName().indexOf("Red Hat EL") != -1) {
osFamily = OsFamily.RHEL;
} else if (from.getName().indexOf("Oracle EL") != -1) {
osFamily = OsFamily.OEL;
} else if (matcher.find()) {
try {
os = OsFamily.fromValue(matcher.group(2).toLowerCase());
osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", matcher.group(2));
}
}
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
images.add(new ImageImpl(from.getId() + "", from.getName(), from.getId() + "", location.get(), null,
ImmutableMap.<String, String> of(), from.getName(), version, os, osDescription, arch,
new Credentials("root", null)));
ImmutableMap.<String, String> of(), os, from.getName(), version, new Credentials("root", null)));
}
logger.debug("<< images(%d)", images.size());
return images;

View File

@ -35,7 +35,6 @@ import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.slicehost.filters.SlicehostBasic;
import org.jclouds.slicehost.xml.BackupHandler;
import org.jclouds.slicehost.xml.FlavorHandler;
import org.jclouds.slicehost.xml.FlavorsHandler;
import org.jclouds.slicehost.xml.ImageHandler;
@ -178,20 +177,6 @@ public class SlicehostAsyncClientTest extends RestClientTest<SlicehostAsyncClien
checkFilters(request);
}
public void testDestroyBackup() throws IOException, SecurityException, NoSuchMethodException {
Method method = SlicehostAsyncClient.class.getMethod("destroyBackup", int.class);
HttpRequest request = processor.createRequest(method, 2);
assertRequestLineEquals(request, "DELETE https://api.slicehost.com/backups/2/destroy.xml HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testRebuildSliceFromImage() throws IOException, SecurityException, NoSuchMethodException {
Method method = SlicehostAsyncClient.class.getMethod("rebuildSliceFromImage", int.class, int.class);
@ -242,7 +227,7 @@ public class SlicehostAsyncClientTest extends RestClientTest<SlicehostAsyncClien
Method method = SlicehostAsyncClient.class.getMethod("hardRebootSlice", int.class);
HttpRequest request = processor.createRequest(method, 2);
assertRequestLineEquals(request, "PUT https://api.slicehost.com/slices/2/hardReboot.xml HTTP/1.1");
assertRequestLineEquals(request, "PUT https://api.slicehost.com/slices/2/hard_reboot.xml HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
@ -253,25 +238,6 @@ public class SlicehostAsyncClientTest extends RestClientTest<SlicehostAsyncClien
checkFilters(request);
}
public void testCreateBackup() throws IOException, SecurityException, NoSuchMethodException {
Method method = SlicehostAsyncClient.class.getMethod("createBackup", String.class, int.class);
HttpRequest request = processor.createRequest(method, "ralphie", 2);
assertRequestLineEquals(request, "POST https://api.slicehost.com/slices.xml HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(
request,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><backup><slice-id type=\"integer\">2</slice-id><name>ralphie</name></backup>",
"application/xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, BackupHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<SlicehostAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<SlicehostAsyncClient>>() {

View File

@ -38,7 +38,6 @@ import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.slicehost.domain.Backup;
import org.jclouds.slicehost.domain.Flavor;
import org.jclouds.slicehost.domain.Image;
import org.jclouds.slicehost.domain.Slice;
@ -202,7 +201,6 @@ public class SlicehostClientLiveTest {
private String slicePrefix = System.getProperty("user.name") + ".sh";
private int sliceId;
private String rootPassword;
private int backupId;
@Test(enabled = true)
public void testCreateSlice() throws Exception {
@ -287,25 +285,6 @@ public class SlicehostClientLiveTest {
}
@Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testSliceDetails")
public void testCreateBackup() throws Exception {
Backup backup = client.createBackup("hoofie", sliceId);
// TODO validate our request, as the above returns <nil-classes
// type="array"/>
assertEquals("hoofie", backup.getName());
assertEquals(new Integer(sliceId), backup.getSliceId());
backupId = backup.getId();
}
@Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateBackup")
public void testRebuildSlice() throws Exception {
client.rebuildSliceFromBackup(sliceId, backupId);
blockUntilSliceActive(sliceId);
// issue Web Hosting #119580 imageId comes back incorrect after rebuild
// assertEquals(new Integer(imageId),
// client.getSlice(sliceId).getImageId());
}
@Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebuildSlice")
public void testRebootHard() throws Exception {
client.hardRebootSlice(sliceId);
blockUntilSliceActive(sliceId);
@ -318,14 +297,6 @@ public class SlicehostClientLiveTest {
}
@Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
void testDeleteBackup() {
if (backupId > 0) {
client.destroyBackup(backupId);
assert client.getBackup(backupId) == null;
}
}
@Test(enabled = true, timeOut = 10 * 60 * 1000, dependsOnMethods = "testDeleteBackup")
void destroySlice1() {
if (sliceId > 0) {
client.destroySlice(sliceId);

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.rest.RestContext;
@ -51,9 +50,9 @@ public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "slicehost");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "DFW");
assertEquals(defaultTemplate.getSize().getCores(), 0.25d);
}

View File

@ -92,8 +92,7 @@ public class ComputeTask extends Task {
try {
for (String action : Splitter.on(',').split(actions)) {
Action act = Action.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE,
action));
Action act = Action.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, action));
try {
invokeActionOnService(act, context.getComputeService());
} catch (RunNodesException e) {
@ -105,8 +104,7 @@ public class ComputeTask extends Task {
}
}
private void invokeActionOnService(Action action, ComputeService computeService)
throws RunNodesException {
private void invokeActionOnService(Action action, ComputeService computeService) throws RunNodesException {
switch (action) {
case CREATE:
case GET:
@ -162,49 +160,45 @@ public class ComputeTask extends Task {
private void listImages(ComputeService computeService) {
log("list images");
for (Image image : computeService.listImages()) {// TODO
log(String
.format(
" image location=%s, id=%s, name=%s, version=%s, arch=%s, osfam=%s, osdesc=%s, desc=%s",
image.getLocation(), image.getProviderId(), image.getName(), image
.getVersion(), image.getArchitecture(), image.getOsFamily(),
image.getOsDescription(), image.getDescription()));
log(String.format(" image location=%s, id=%s, name=%s, version=%s, osArch=%s, osfam=%s, osdesc=%s, desc=%s",
image.getLocation(), image.getProviderId(), image.getName(), image.getVersion(), image
.getOperatingSystem().getArch(), image.getOperatingSystem().getFamily(), image
.getOperatingSystem().getDescription(), image.getDescription()));
}
}
private void listSizes(ComputeService computeService) {
log("list sizes");
for (Size size : computeService.listSizes()) {// TODO
log(String.format(" size id=%s, cores=%s, ram=%s, disk=%s", size.getProviderId(), size
.getCores(), size.getRam(), size.getDisk()));
log(String.format(" size id=%s, cores=%s, ram=%s, disk=%s", size.getProviderId(), size.getCores(), size
.getRam(), size.getDisk()));
}
}
private void listLocations(ComputeService computeService) {
log("list locations");
for (Location location : computeService.listAssignableLocations()) {// TODO
log(String.format(" location id=%s, scope=%s, description=%s, parent=%s", location
.getId(), location.getScope(), location.getDescription(), location.getParent()));
log(String.format(" location id=%s, scope=%s, description=%s, parent=%s", location.getId(), location
.getScope(), location.getDescription(), location.getParent()));
}
}
private void list(ComputeService computeService) {
log("list");
for (ComputeMetadata node : computeService.listNodes()) {
log(String.format(" location=%s, id=%s, tag=%s", node.getLocation(), node
.getProviderId(), node.getName()));
log(String.format(" location=%s, id=%s, tag=%s", node.getLocation(), node.getProviderId(), node.getName()));
}
}
private void create(ComputeService computeService) throws RunNodesException {
String tag = nodeElement.getTag();
log(String.format("create tag: %s, count: %d, size: %s, os: %s", tag, nodeElement.getCount(),
nodeElement.getSize(), nodeElement.getOs()));
log(String.format("create tag: %s, count: %d, size: %s, os: %s", tag, nodeElement.getCount(), nodeElement
.getSize(), nodeElement.getOs()));
Template template = createTemplateFromElement(nodeElement, computeService);
for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(),
template)) {
for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(), template)) {
logDetails(computeService, createdNode);
addNodeDetailsAsProjectProperties(createdNode);
}
@ -214,14 +208,11 @@ public class ComputeTask extends Task {
if (nodeElement.getIdproperty() != null)
getProject().setProperty(nodeElement.getIdproperty(), createdNode.getProviderId());
if (nodeElement.getHostproperty() != null)
getProject().setProperty(nodeElement.getHostproperty(),
ipOrEmptyString(createdNode.getPublicAddresses()));
getProject().setProperty(nodeElement.getHostproperty(), ipOrEmptyString(createdNode.getPublicAddresses()));
if (nodeElement.getPasswordproperty() != null && !isKeyAuth(createdNode))
getProject().setProperty(nodeElement.getPasswordproperty(),
createdNode.getCredentials().credential);
getProject().setProperty(nodeElement.getPasswordproperty(), createdNode.getCredentials().credential);
if (nodeElement.getUsernameproperty() != null)
getProject().setProperty(nodeElement.getUsernameproperty(),
createdNode.getCredentials().identity);
getProject().setProperty(nodeElement.getUsernameproperty(), createdNode.getCredentials().identity);
}
private void reboot(ComputeService computeService) {
@ -250,23 +241,19 @@ public class ComputeTask extends Task {
logDetails(computeService, computeService.getNodeMetadata(nodeElement.getId()));
} else {
log(String.format("get tag: %s", nodeElement.getTag()));
for (ComputeMetadata node : Iterables.filter(computeService
.listNodesDetailsMatching(NodePredicates.all()), NodePredicates
.withTag(nodeElement.getTag()))) {
for (ComputeMetadata node : Iterables.filter(computeService.listNodesDetailsMatching(NodePredicates.all()),
NodePredicates.withTag(nodeElement.getTag()))) {
logDetails(computeService, node);
}
}
}
private void logDetails(ComputeService computeService, ComputeMetadata node) {
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node)
: computeService.getNodeMetadata(node.getId());
log(String
.format(
" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, extra=%s",
metadata.getProviderId(), metadata.getName(), metadata.getTag(), metadata
.getLocation(), metadata.getState(), ComputeTaskUtils
.ipOrEmptyString(metadata.getPublicAddresses()),
NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node) : computeService
.getNodeMetadata(node.getId());
log(String.format(" node id=%s, name=%s, tag=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, extra=%s",
metadata.getProviderId(), metadata.getName(), metadata.getTag(), metadata.getLocation(), metadata
.getState(), ComputeTaskUtils.ipOrEmptyString(metadata.getPublicAddresses()),
ipOrEmptyString(metadata.getPrivateAddresses()), metadata.getExtra()));
}

View File

@ -21,7 +21,6 @@ package org.jclouds.vcloud.bluelock.compute;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
@ -46,8 +45,8 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "https://express3.bluelock.com/api/v0.8/vdc/133");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
}

View File

@ -24,8 +24,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.internal.ImageImpl;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
@ -42,10 +41,10 @@ public class VCloudImage extends ImageImpl {
private final VAppTemplate template;
public VCloudImage(VAppTemplate template, String providerId, String name, String id, Location location, URI uri,
Map<String, String> userMetadata, String description, String version, @Nullable OsFamily osFamily,
String osDescription, Architecture architecture, Credentials defaultCredentials) {
super(providerId, name, id, location, uri, userMetadata, description, version, osFamily, osDescription,
architecture, defaultCredentials);
Map<String, String> userMetadata, OperatingSystem operatingSystem, String description,
@Nullable String version, @Nullable Credentials defaultCredentials) {
super(providerId, name, id, location, uri, userMetadata, operatingSystem, description, version,
defaultCredentials);
this.template = template;
}

View File

@ -20,13 +20,12 @@
package org.jclouds.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseArchitectureOrNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrNull;
import javax.inject.Inject;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.domain.Location;
@ -59,14 +58,19 @@ public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
@Override
public Image apply(VAppTemplate from) {
OsFamily myOs = parseOsFamilyOrNull(checkNotNull(from, "vapp template").getName());
Architecture arch = parseArchitectureOrNull(from.getName());
OsFamily osFamily = parseOsFamilyOrNull(checkNotNull(from, "vapp template").getName());
String osName = null;
String osArch = null;
String osVersion = null;
String osDescription = from.getName();
boolean is64Bit = from.getName().indexOf("64") != -1;
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
Location location = findLocationForResource.apply(checkNotNull(parent, "parent"));
String name = getName(from.getName());
String desc = from.getDescription() != null ? from.getDescription() : from.getName();
return new VCloudImage(from, from.getId().toASCIIString(), name, from.getId().toASCIIString(), location, from
.getId(), ImmutableMap.<String, String> of(), desc, "", myOs, name, arch, credentialsProvider
.execute(from));
.getId(), ImmutableMap.<String, String> of(), os, desc, "", credentialsProvider.execute(from));
}
protected String getName(String name) {

View File

@ -35,6 +35,7 @@ import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
@ -86,8 +87,9 @@ public class VCloudGetNodeMetadata {
String tag = parseTagFromName(from.getName());
Location location = findLocationForResourceInVDC.apply(from.getVDC());
return new NodeMetadataImpl(in, from.getName(), in, location, from.getId(), ImmutableMap.<String, String> of(),
tag, null, vAppStatusToNodeState.get(from.getStatus()), computeClient.getPublicAddresses(id),
computeClient.getPrivateAddresses(id), getExtra.apply(from), null);
tag, null, new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(from.getOsType()), null, null,
from.getOperatingSystemDescription()), vAppStatusToNodeState.get(from.getStatus()),
computeClient.getPublicAddresses(id), computeClient.getPrivateAddresses(id), getExtra.apply(from), null);
}
}

View File

@ -29,8 +29,10 @@ import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudClient;
@ -72,10 +74,16 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map<String, String> metaMap, VApp vApp) {
return new NodeMetadataImpl(vApp.getId().toASCIIString(), vApp.getName(), vApp.getId().toASCIIString(), template
.getLocation(), vApp.getId(), ImmutableMap.<String, String> of(), tag, template.getImage(),
.getLocation(), vApp.getId(), ImmutableMap.<String, String> of(), tag, template.getImage().getId(),
getOperatingSystemForVAppOrDefaultTo(vApp, template.getImage().getOperatingSystem()),
vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getId()),
computeClient.getPrivateAddresses(vApp.getId()), ImmutableMap.<String, String> of(), new Credentials(
metaMap.get("username"), metaMap.get("password")));
}
private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) {
return vApp.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()),
null, null, vApp.getOperatingSystemDescription()) : operatingSystem;
}
}

View File

@ -21,16 +21,17 @@ package org.jclouds.vcloud.domain;
import java.util.Set;
import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.internal.VAppImpl;
import com.google.common.collect.ListMultimap;
import com.google.inject.ImplementedBy;
/**
* A virtual application (vApp) is a software solution, packaged in OVF
* containing one or more virtual machines. A vApp can be authored by Developers
* at ISVs and VARs or by IT Administrators in Enterprises and Service
* Providers.
* A virtual application (vApp) is a software solution, packaged in OVF containing one or more
* virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators
* in Enterprises and Service Providers.
*
* @author Adrian Cole
*/
@ -44,6 +45,19 @@ public interface VApp extends NamedResource {
ListMultimap<String, String> getNetworkToAddresses();
/**
*
* @return CIM OSType of the image or null, if this information isn't available yet
* @see <a href="http://dmtf.org/standards/cim/cim_schema_v2260">DMTF CIM model</a>
*/
@Nullable
Integer getOsType();
/**
*
* @return description or null, if this information isn't available yet
*/
@Nullable
String getOperatingSystemDescription();
VirtualSystem getSystem();

View File

@ -48,19 +48,21 @@ public class VAppImpl implements VApp {
private final String operatingSystemDescription;
private final VirtualSystem system;
private final Set<ResourceAllocation> resourceAllocations;
private final Integer osType;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public VAppImpl(String name, URI id, VAppStatus status, Long size, NamedResource vDC,
ListMultimap<String, String> networkToAddresses, String operatingSystemDescription, VirtualSystem system,
Set<ResourceAllocation> resourceAllocations) {
ListMultimap<String, String> networkToAddresses, Integer osType, String operatingSystemDescription,
VirtualSystem system, Set<ResourceAllocation> resourceAllocations) {
this.name = checkNotNull(name, "name");
this.id = checkNotNull(id, "id");
this.status = checkNotNull(status, "status");
this.size = size;// hostingdotcom
this.vDC = vDC;
this.networkToAddresses = checkNotNull(networkToAddresses, "networkToAddresses");
this.osType = osType;
this.operatingSystemDescription = operatingSystemDescription;
this.system = system;
this.resourceAllocations = checkNotNull(resourceAllocations, "resourceAllocations");
@ -76,6 +78,11 @@ public class VAppImpl implements VApp {
return networkToAddresses;
}
@Override
public Integer getOsType() {
return osType;
}
@Override
public String getOperatingSystemDescription() {
return operatingSystemDescription;
@ -106,6 +113,7 @@ public class VAppImpl implements VApp {
result = prime * result + ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode());
result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
result = prime * result + ((size == null) ? 0 : size.hashCode());
result = prime * result + ((osType == null) ? 0 : osType.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode());
result = prime * result + ((vDC == null) ? 0 : vDC.hashCode());
@ -131,6 +139,11 @@ public class VAppImpl implements VApp {
return false;
} else if (!name.equals(other.name))
return false;
if (osType == null) {
if (other.osType != null)
return false;
} else if (!osType.equals(other.osType))
return false;
if (networkToAddresses == null) {
if (other.networkToAddresses != null)
return false;
@ -186,7 +199,7 @@ public class VAppImpl implements VApp {
@Override
public String toString() {
return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses
return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses + ", osType=" + osType
+ ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType="
+ resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC
+ "]";
@ -201,4 +214,5 @@ public class VAppImpl implements VApp {
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
}

View File

@ -67,13 +67,14 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
protected boolean inOs;
protected String networkName;
protected String name;
protected Integer osType;
protected URI location;
protected Long size;
protected NamedResource vDC;
public VApp getResult() {
return new VAppImpl(name, location, status, size, vDC, networkToAddresses, operatingSystemDescription, system,
allocations);
return new VAppImpl(name, location, status, size, vDC, networkToAddresses, osType, operatingSystemDescription,
system, allocations);
}
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
@ -91,6 +92,9 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
}
} else if (qName.equals("OperatingSystemSection")) {
inOs = true;
for (int i = 0; i < attributes.getLength(); i++)
if (attributes.getQName(i).indexOf("id") != -1)
osType = Integer.parseInt(attributes.getValue(i));
} else if (qName.endsWith("NetworkConnection")) {
networkName = attributes.getValue(attributes.getIndex("Network"));
} else {

View File

@ -1,110 +0,0 @@
/**
*
* 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.vcloud.compute.strategy;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.SortedSet;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VirtualSystem;
import org.jclouds.vcloud.domain.internal.VAppImpl;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.ListMultimap;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.VCloudListNodesStrategyTest")
public class VCloudListNodesStrategyTest {
@SuppressWarnings("unused")
private VApp newVApp() throws UnknownHostException {
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Network 1",
"127.0.0.1");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 512, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3, null,
20971520, "byte * 2^20")).build();
return new VAppImpl("10", URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/10"), VAppStatus.OFF,
new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
}
// TODO rewrite this test
//
// consistency delay specifically in terremark beta where a vapp is present
// for listing, but not
// yet available for get vapp command.
// @Test
// public void
// testRetryOnVAppNotFoundForGetVAppEvenWhenPresentInAvailableResources()
// throws ExecutionException, InterruptedException, TimeoutException,
// IOException {
// VCloudClient client = createMock(VCloudClient.class);
// GetExtra getExtra = new GetExtra();
//
// VCloudComputeClient computeClient = createMock(VCloudComputeClient.class);
// Map<VAppStatus, NodeState> vAppStatusToNodeState = Maps.newHashMap();
// VApp vApp = newVApp();
// expect(client.getVApp("10")).andThrow(new NullPointerException());
// expect(client.getVApp("10")).andThrow(new NullPointerException());
// expect(client.getVApp("10")).andReturn(vApp);
//
// replay(client);
// replay(computeClient);
//
// Location vdcL = new LocationImpl(LocationScope.ZONE, "1", "1", null);
// Supplier<Set<? extends Location>> locations = Providers
// .<Set<? extends Location>> of(ImmutableSet.of(vdcL));
// Supplier<Set<? extends Image>> images = Providers
// .<Set<? extends Image>> of(ImmutableSet.<Image> of());
// FindLocationForResourceInVDC findLocationForResourceInVDC = new
// FindLocationForResourceInVDC(
// locations, null);
// VCloudListNodesStrategy strategy = new VCloudListNodesStrategy(client,
// computeClient, vAppStatusToNodeState, getExtra,
// findLocationForResourceInVDC, images);
//
// Set<NodeMetadata> nodes = Sets.newHashSet();
// NamedResource vdc = new NamedResourceImpl("1", null, null, null);
// NamedResource resource = new NamedResourceImpl("10", null, null, null);
//
// strategy.addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
//
// verify(client);
// verify(computeClient);
// }
}

View File

@ -60,19 +60,19 @@ public class VAppHandlerTest extends BaseHandlerTest {
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null,
null, null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 512, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER,
"lsilogic", null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3, null,
20971520, "byte * 2^20")).build();
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3,
null, 20971520, "byte * 2^20")).build();
VApp expects = new VAppImpl("188849-96", URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"),
VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null, null, system, resourceAllocations);
assertEquals(result, expects);
}
@ -84,8 +84,8 @@ public class VAppHandlerTest extends BaseHandlerTest {
VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.RESOLVED,
123456789l, new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap.<String, String> of(), null,
null, ImmutableSet.<ResourceAllocation> of());
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap.<String, String> of(),
null, null, null, ImmutableSet.<ResourceAllocation> of());
assertEquals(result, expects);
}
@ -99,21 +99,21 @@ public class VAppHandlerTest extends BaseHandlerTest {
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "centos53", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null,
null, null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "16MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 16, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER,
"lsilogic", null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1", "PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null, true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "104857", null, 0, 3, null,
104857, "byte * 2^20")).build();
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "104857", null, 0, 3,
null, 104857, "byte * 2^20")).build();
VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.ON,
new Long(104857), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses, "Other Linux (32-bit)", system,
resourceAllocations);
.create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses, null,
"Other Linux (32-bit)", system, resourceAllocations);
assertEquals(result.getId(), expects.getId());
assertEquals(result.getName(), expects.getName());
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
@ -136,20 +136,20 @@ public class VAppHandlerTest extends BaseHandlerTest {
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "m1", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null,
null, null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 512, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER,
"lsilogic", null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1", "PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null, true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "10485760", null, 0, 3, null,
10485760, "byte * 2^20")).build();
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "10485760", null, 0, 3,
null, 10485760, "byte * 2^20")).build();
VApp expects = new VAppImpl("m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"), VAppStatus.ON, new Long(
10485760), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses,
.create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses, null,
"Microsoft Windows XP Professional (32-bit)", system, resourceAllocations);
assertEquals(result.getId(), expects.getId());
assertEquals(result.getName(), expects.getName());

View File

@ -46,9 +46,9 @@ public class HostingDotComVAppImpl extends VAppImpl implements HostingDotComVApp
private static final long serialVersionUID = 8464716396538298809L;
public HostingDotComVAppImpl(String name, URI location, VAppStatus status, Long size, NamedResource vDC,
ListMultimap<String, String> networkToAddresses, String operatingSystemDescription, VirtualSystem system,
Set<ResourceAllocation> resourceAllocations, String username, String password) {
super(name, location, status, size, vDC, networkToAddresses, operatingSystemDescription, system,
ListMultimap<String, String> networkToAddresses, Integer osType, String operatingSystemDescription,
VirtualSystem system, Set<ResourceAllocation> resourceAllocations, String username, String password) {
super(name, location, status, size, vDC, networkToAddresses, osType, operatingSystemDescription, system,
resourceAllocations);
this.username = username;
this.password = password;

View File

@ -43,7 +43,7 @@ public class HostingDotComVAppHandler extends VAppHandler {
}
public HostingDotComVApp getResult() {
return new HostingDotComVAppImpl(name, location, status, size, vDC, networkToAddresses,
return new HostingDotComVAppImpl(name, location, status, size, vDC, networkToAddresses, osType,
operatingSystemDescription, system, allocations, username, password);
}

View File

@ -21,7 +21,6 @@ package org.jclouds.vcloud.hostingdotcom.compute;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
@ -44,8 +43,8 @@ public class HostingDotComVCloudComputeServiceLiveTest extends VCloudComputeServ
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getLocation().getId(), "188849");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
}

View File

@ -54,7 +54,7 @@ public class HostingDotComVAppHandlerTest extends BaseHandlerTest {
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-33"), VAppStatus.RESOLVED, null,
new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")), ImmutableListMultimap
.<String, String> of(), null, null, ImmutableSortedSet.<ResourceAllocation> of(), "root",
.<String, String> of(), null, null, null, ImmutableSortedSet.<ResourceAllocation> of(), "root",
"meatisyummy");
assertEquals(result, expects);

View File

@ -51,7 +51,6 @@ import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient;
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeService;
import org.jclouds.vcloud.terremark.compute.config.providers.VAppTemplatesInOrgs;
import org.jclouds.vcloud.terremark.compute.domain.KeyPairCredentials;
import org.jclouds.vcloud.terremark.compute.domain.OrgAndName;
import org.jclouds.vcloud.terremark.compute.functions.NodeMetadataToOrgAndName;
@ -60,6 +59,7 @@ import org.jclouds.vcloud.terremark.compute.strategy.ParseVAppTemplateDescriptio
import org.jclouds.vcloud.terremark.compute.strategy.TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy;
import org.jclouds.vcloud.terremark.compute.strategy.TerremarkVCloudAddNodeWithTagStrategy;
import org.jclouds.vcloud.terremark.compute.strategy.TerremarkVCloudGetNodeMetadataStrategy;
import org.jclouds.vcloud.terremark.compute.suppliers.VAppTemplatesInOrgs;
import com.google.common.base.Function;
import com.google.common.base.Supplier;

View File

@ -1,63 +0,0 @@
/**
*
* 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.vcloud.terremark.compute.functions;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Image;
import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.functions.AllCatalogItemsInOrganization;
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
/**
* @author Adrian Cole
*/
@Singleton
public class ImagesInOrganization implements Function<Organization, Iterable<? extends Image>> {
private final AllCatalogItemsInOrganization allCatalogItemsInOrganization;
private final VAppTemplatesForCatalogItems vAppTemplatesForCatalogItems;
private final Provider<ImageForVAppTemplate> imageForVAppTemplateProvider;
@Inject
ImagesInOrganization(AllCatalogItemsInOrganization allCatalogItemsInOrganization,
Provider<ImageForVAppTemplate> imageForVAppTemplateProvider,
VAppTemplatesForCatalogItems vAppTemplatesForCatalogItems) {
this.imageForVAppTemplateProvider = imageForVAppTemplateProvider;
this.allCatalogItemsInOrganization = allCatalogItemsInOrganization;
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
}
@Override
public Iterable<? extends Image> apply(Organization from) {
Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrganization.apply(from);
Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return Iterables.transform(vAppTemplates, imageForVAppTemplateProvider.get().withParent(from));
}
}

View File

@ -66,8 +66,6 @@ public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadat
if (node.getTag() != null) {
node = installCredentialsFromCache(node);
}
if (node.getCredentials() == null)
node = installDefaultCredentialsFromImage(node);
return node;
}
@ -86,9 +84,4 @@ public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadat
return orgAndName;
}
NodeMetadata installDefaultCredentialsFromImage(NodeMetadata node) {
if (node.getImage() != null && node.getImage().getDefaultCredentials() != null)
node = installNewCredentials(node, node.getImage().getDefaultCredentials());
return node;
}
}

View File

@ -17,7 +17,7 @@
* ====================================================================
*/
package org.jclouds.vcloud.terremark.compute.config.providers;
package org.jclouds.vcloud.terremark.compute.suppliers;
import static com.google.common.collect.Sets.newLinkedHashSet;

View File

@ -66,12 +66,12 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testChangeName() throws IOException {
VAppImpl vApp = new VAppImpl("MyAppServer6", URI
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, null,
ImmutableListMultimap.<String, String> of(), null, null, ImmutableSet.of(new ResourceAllocation(1, "n/a",
null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null), new ResourceAllocation(2,
"n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024, null),
new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null,
209152, null)));
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l,
null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null,
null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
null, null, null, null, null, 1024, null), new ResourceAllocation(9, "n/a", null,
ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null, 209152, null)));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")).replace(
"eduardo", "roberto");
@ -93,13 +93,14 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testRemoveDisk() throws IOException {
VAppImpl vApp = new VAppImpl("MyAppServer6", URI
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, null,
ImmutableListMultimap.<String, String> of(), null, null, ImmutableSet.of(new ResourceAllocation(1, "n/a",
null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null), new ResourceAllocation(2,
"n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024, null),
new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null,
209152, null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576",
null, 1, null, null, 209152, null)));
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l,
null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null,
null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
null, null, null, null, null, 1024, null), new ResourceAllocation(9, "n/a", null,
ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null, 209152, null),
new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, 1, null,
null, 209152, null)));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")).replace(
"eduardo", "MyAppServer6");
@ -121,12 +122,12 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testChangeCPUCountTo4() throws IOException {
VAppImpl vApp = new VAppImpl("eduardo", URI
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, null,
ImmutableListMultimap.<String, String> of(), null, null, ImmutableSet.of(new ResourceAllocation(1, "n/a",
null, ResourceType.PROCESSOR, null, null, null, null, null, null, 4, null), new ResourceAllocation(2,
"n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024, null),
new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null,
209152, null)));
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l,
null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null,
null, 4, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
null, null, null, null, null, 1024, null), new ResourceAllocation(9, "n/a", null,
ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null, 209152, null)));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp4.xml"));
VAppConfiguration config = new VAppConfiguration().changeProcessorCountTo(4);
@ -146,12 +147,12 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testChangeMemoryTo1536() throws IOException {
VAppImpl vApp = new VAppImpl("MyAppServer6", URI
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, null,
ImmutableListMultimap.<String, String> of(), null, null, ImmutableSet.of(new ResourceAllocation(1, "n/a",
null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null), new ResourceAllocation(2,
"n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1536, null),
new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null,
209152, null)));
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l,
null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null,
null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
null, null, null, null, null, 1536, null), new ResourceAllocation(9, "n/a", null,
ResourceType.DISK_DRIVE, null, "1048576", null, 0, null, null, 209152, null)));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")).replace(
"eduardo", "MyAppServer6").replace("1024", "1536");

View File

@ -22,9 +22,9 @@ package org.jclouds.vcloud.terremark.compute;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
@ -56,8 +56,8 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL
@Test
public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getDescription(), "Miami Environment 1");
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
}
@ -77,6 +77,13 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL
return template;
}
// currently, the wrong CIM OSType data is coming back.
@Override
protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null)
assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNKNOWN);
}
@Override
public void testListImages() throws Exception {
for (Image image : client.listImages()) {
@ -84,7 +91,7 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL
// image.getLocationId() can be null, if it is a location-free image
assertEquals(image.getType(), ComputeType.IMAGE);
assert image.getDefaultCredentials().identity != null : image;
if (image.getOsFamily() != OsFamily.WINDOWS)
if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS)
assert image.getDefaultCredentials().credential != null : image;
}
}

View File

@ -17,7 +17,7 @@
* ====================================================================
*/
package org.jclouds.vcloud.terremark.providers;
package org.jclouds.vcloud.terremark.compute.suppliers;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
@ -33,7 +33,6 @@ import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.functions.AllCatalogItemsInOrganization;
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
import org.jclouds.vcloud.terremark.compute.config.providers.VAppTemplatesInOrgs;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;