diff --git a/archetypes/compute-service-archetype/src/main/resources/archetype-resources/src/test/java/compute/__providerName__ComputeServiceLiveTest.java b/archetypes/compute-service-archetype/src/main/resources/archetype-resources/src/test/java/compute/__providerName__ComputeServiceLiveTest.java index 25f181bab4..6e48291b9e 100644 --- a/archetypes/compute-service-archetype/src/main/resources/archetype-resources/src/test/java/compute/__providerName__ComputeServiceLiveTest.java +++ b/archetypes/compute-service-archetype/src/main/resources/archetype-resources/src/test/java/compute/__providerName__ComputeServiceLiveTest.java @@ -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); } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java index e6aaa033ea..b54486f673 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -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 diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/ImageParser.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/ImageParser.java index b7a10b298c..5fb2d1103e 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/ImageParser.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/ImageParser.java @@ -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 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); + . of("owner", from.getImageOwnerId()), os, description, version, defaultCredentials); } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java index 64c3f714c3..f6151307be 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -117,7 +117,8 @@ public class RunningInstanceToNodeMetadata implements Function of("jclouds#" + tag + "#" - + instance.getRegion(), tag)); + + instance.getRegion(), tag)); // make sure our dummy group has no rules SecurityGroup group = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null, - "jclouds#" + tag + "#" + instance.getRegion())); + "jclouds#" + tag + "#" + instance.getRegion())); 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)); @@ -169,11 +168,11 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { assertEquals(instance.getMonitoringState(), MonitoringState.ENABLED); RestContext monitoringContext = new RestContextFactory().createContext( - "cloudwatch", identity, credential, ImmutableSet. of(new Log4JLoggingModule())); + "cloudwatch", identity, credential, ImmutableSet. of(new Log4JLoggingModule())); try { Set datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(), - "CPUUtilization", before, new Date(), 60, "Average"); + "CPUUtilization", before, new Date(), 60, "Average"); assert datapoints != null; } finally { monitoringContext.close(); @@ -183,13 +182,13 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testExtendedOptionsNoKeyPair() throws Exception { SecurityGroupClient securityGroupClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) - .getSecurityGroupServices(); + .getSecurityGroupServices(); KeyPairClient keyPairClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) - .getKeyPairServices(); + .getKeyPairServices(); InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) - .getInstanceServices(); + .getInstanceServices(); String tag = this.tag + "optionsnokey"; @@ -217,11 +216,11 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { // make sure we made our dummy group and also let in the user's group assertEquals(instance.getGroupIds(), ImmutableSet. of(tag, String.format("jclouds#%s#%s", tag, - instance.getRegion()))); + instance.getRegion()))); // make sure our dummy group has no rules SecurityGroup group = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null, String - .format("jclouds#%s#%s", tag, instance.getRegion()))); + .format("jclouds#%s#%s", tag, instance.getRegion()))); assert group.getIpPermissions().size() == 0 : group; } finally { @@ -243,13 +242,13 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { return; } SecurityGroupClient securityGroupClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) - .getSecurityGroupServices(); + .getSecurityGroupServices(); KeyPairClient keyPairClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) - .getKeyPairServices(); + .getKeyPairServices(); InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) - .getInstanceServices(); + .getInstanceServices(); String tag = this.tag + "optionswithsubnetid"; @@ -297,12 +296,12 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { private RunningInstance getInstance(InstanceClient instanceClient, String id) { RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(instanceClient - .describeInstancesInRegion(null, id))); + .describeInstancesInRegion(null, id))); return instance; } private void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient, String tag) - throws InterruptedException { + throws InterruptedException { try { securityGroupClient.deleteSecurityGroupInRegion(null, tag); } catch (Exception e) { diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceTest.java index 0b4781421a..31354bc30c 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceTest.java @@ -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 - . newHashMap(), "description", "1.0", null, "ubuntu", Architecture.X86_64, - new Credentials("root", null)); + . newHashMap(), new OperatingSystem(OsFamily.UBUNTU, null, "1.0", null, "ubuntu", true), + "description", "1.0", new Credentials("root", null)); replay(optionsProvider); replay(templateBuilderProvider); Supplier> locations = Suppliers.> ofInstance(ImmutableSet diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2TemplateBuilderLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2TemplateBuilderLiveTest.java index 50ef96bc86..ae33f0fb1e 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2TemplateBuilderLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2TemplateBuilderLiveTest.java @@ -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,23 +93,22 @@ 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 - - //ensure we cache the new image for next time + + // ensure we cache the new image for next time assertEquals(newContext.getComputeService().listImages().size(), 1); } finally { diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java index 4085e7bdd0..206802db36 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java @@ -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); } diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/ImageParserTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/ImageParserTest.java index 32624ff782..ee5f3904eb 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/ImageParserTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/ImageParserTest.java @@ -57,44 +57,57 @@ public class ImageParserTest extends BaseEC2HandlerTest { assertEquals(result.size(), 7); ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers - .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers - .ofInstance(defaultLocation)); + .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers + .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(), - "ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml"); - assertEquals(ubuntuHardy.getOsFamily(), OsFamily.UBUNTU); + 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.getOperatingSystem().is64Bit(), false); assertEquals(ubuntuHardy.getUserMetadata(), ImmutableMap. 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. 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"); + "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(), - "ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml"); - assertEquals(ubuntuKarmic.getOsFamily(), OsFamily.UBUNTU); + 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.getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(ubuntuKarmic.getUserMetadata(), ImmutableMap. 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. 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"); + "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(), - "ubuntu-images-us-west-1/ubuntu-lucid-10.04-i386-server-20100427.1.manifest.xml"); - assertEquals(ubuntuLucid.getOsFamily(), OsFamily.UBUNTU); + 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.getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(ubuntuLucid.getUserMetadata(), ImmutableMap. of("owner", "099720109477")); assertEquals(ubuntuLucid.getVersion(), "20100427.1"); @@ -139,53 +161,94 @@ public class ImageParserTest extends BaseEC2HandlerTest { Set result = parseImages(is); ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers - .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers - .ofInstance(defaultLocation)); + .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers + .ofInstance(defaultLocation)); 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. of("owner", "133804938231")); assertEquals(image.getVersion(), "5622"); } + public void testParseCCImage() { + InputStream is = getClass().getResourceAsStream("/ec2/describe_images_cc.xml"); + + Set result = parseImages(is); + + ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers + .> ofInstance(ImmutableSet. 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. of("owner", "206029621532")); + assertEquals(image.getVersion(), null); + + } + public void testParseRightScaleImage() { InputStream is = getClass().getResourceAsStream("/ec2/rightscale_images.xml"); Set result = parseImages(is); ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers - .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers - .ofInstance(defaultLocation)); + .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers + .ofInstance(defaultLocation)); 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. 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. of("owner", "411009282317")); assertEquals(image.getVersion(), "4.5.3_EBS_Alpha"); @@ -197,20 +260,24 @@ public class ImageParserTest extends BaseEC2HandlerTest { Set result = parseImages(is); assertEquals(result.size(), 4); ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), Suppliers - .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers - .ofInstance(defaultLocation)); + .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers + .ofInstance(defaultLocation)); 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. of("owner", "admin")); - assertEquals(image.getVersion(), ""); + assertEquals(image.getVersion(), null); // should skip test images image = parser.apply(Iterables.get(result, 3)); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java index 323d61394c..e4c5082df0 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java @@ -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 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")); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImplTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImplTest.java index a86f8407ba..9123cfa29c 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImplTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImplTest.java @@ -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; @@ -69,22 +68,22 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { @Override protected EC2TemplateBuilderImpl createTemplateBuilder(final Image knownImage, - Supplier> locations, Supplier> images, - Supplier> sizes, Location defaultLocation, Provider optionsProvider, - Provider templateBuilderProvider) { + Supplier> locations, Supplier> images, + Supplier> sizes, Location defaultLocation, Provider optionsProvider, + Provider templateBuilderProvider) { final RegionAndName knownRegionAndName = new RegionAndName("region", "ami"); ConcurrentMap imageMap = new MapMaker() - .makeComputingMap(new Function() { - @Override - public Image apply(RegionAndName from) { - return from.equals(knownRegionAndName) ? knownImage : null; - } + .makeComputingMap(new Function() { + @Override + public Image apply(RegionAndName from) { + return from.equals(knownRegionAndName) ? knownImage : null; + } - }); + }); return new EC2TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(defaultLocation), - optionsProvider, templateBuilderProvider, imageMap); + optionsProvider, templateBuilderProvider, imageMap); } @SuppressWarnings("unchecked") @@ -93,11 +92,11 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { Location location = new LocationImpl(LocationScope.REGION, "region", "region", null); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(location)); + . of(location)); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet - . of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap. of(), 1, 1, 1, - ImagePredicates.any()))); + . of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap. of(), 1, 1, + 1, ImagePredicates.any()))); Provider optionsProvider = createMock(Provider.class); Provider 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(); @@ -130,7 +128,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, location, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); assertEquals(template.imageId("region/ami").build().getImage(), knownImage); @@ -147,11 +145,11 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { Location location = new LocationImpl(LocationScope.REGION, "region", "region", null); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(location)); + . of(location)); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet - . of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap. of(), 1, 1, 1, - ImagePredicates.any()))); + . of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap. of(), 1, 1, + 1, ImagePredicates.any()))); Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); @@ -166,7 +164,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, location, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); try { template.imageId("ami").build(); assert false; @@ -185,11 +183,11 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { Location location = new LocationImpl(LocationScope.REGION, "region", "region", null); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(location)); + . of(location)); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet - . of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap. of(), 1, 1, 1, - ImagePredicates.any()))); + . of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap. of(), 1, 1, + 1, ImagePredicates.any()))); Location defaultLocation = createMock(Location.class); Provider 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); @@ -208,7 +205,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); assertEquals(template.imageId("region/bad").build().getImage(), knownImage); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index 46d5a95ea3..3b95660d06 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -84,11 +84,11 @@ public class PlacementGroupClientLiveTest { String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential"); keyPair = BaseComputeServiceLiveTest.setupKeyPair(); context = new ComputeServiceContextFactory().createContext("ec2", identity, credential, ImmutableSet. of( - new Log4JLoggingModule(), new JschSshClientModule())); + new Log4JLoggingModule(), new JschSshClientModule())); client = EC2Client.class.cast(context.getProviderSpecificContext().getApi()); availableTester = new RetryablePredicate(new PlacementGroupAvailable(client), 60, 1, - TimeUnit.SECONDS); + TimeUnit.SECONDS); deletedTester = new RetryablePredicate(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS); } @@ -97,12 +97,12 @@ public class PlacementGroupClientLiveTest { void testDescribe() { for (String region : Lists.newArrayList(Region.US_EAST_1)) { SortedSet allResults = Sets.newTreeSet(client.getPlacementGroupServices() - .describePlacementGroupsInRegion(region)); + .describePlacementGroupsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { PlacementGroup group = allResults.last(); SortedSet result = Sets.newTreeSet(client.getPlacementGroupServices() - .describePlacementGroupsInRegion(region, group.getName())); + .describePlacementGroupsInRegion(region, group.getName())); assertNotNull(result); PlacementGroup compare = result.last(); assertEquals(compare, group); @@ -131,7 +131,7 @@ public class PlacementGroupClientLiveTest { private void verifyPlacementGroup(String groupName) { assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group; Set oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null, - groupName); + groupName); assertNotNull(oneResult); assertEquals(oneResult.size(), 1); group = oneResult.iterator().next(); @@ -166,8 +166,8 @@ public class PlacementGroupClientLiveTest { assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17"); template.getOptions().installPrivateKey(newStringPayload(keyPair.get("private"))).authorizePublicKey( - newStringPayload(keyPair.get("public"))).runScript( - newStringPayload(BaseComputeServiceLiveTest.buildScript(template.getImage().getOsFamily()))); + newStringPayload(keyPair.get("public"))).runScript( + newStringPayload(BaseComputeServiceLiveTest.buildScript(template.getImage().getOperatingSystem()))); String tag = PREFIX + "cccluster"; context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); @@ -177,7 +177,7 @@ public class PlacementGroupClientLiveTest { NodeMetadata node = Iterables.getOnlyElement(nodes); RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceServices() - .describeInstancesInRegion(null, node.getProviderId()))); + .describeInstancesInRegion(null, node.getProviderId()))); assertEquals(instance.getVirtualizationType(), node.getExtra().get("virtualizationType")); assertEquals(instance.getPlacementGroup(), node.getExtra().get("placementGroup")); diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index 7d227f9cf4..0583635680 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -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)] diff --git a/compute/src/main/java/org/jclouds/compute/domain/Architecture.java b/compute/src/main/java/org/jclouds/compute/domain/Architecture.java deleted file mode 100644 index 81d44b32bb..0000000000 --- a/compute/src/main/java/org/jclouds/compute/domain/Architecture.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.compute.domain; - -/** - * Architecture of a node - * - *

- * Please transition to {@link OperatingSystem} - * - * @author Adrian Cole - */ -@Deprecated -public enum Architecture { - - /** - * 32-bit platform - */ - X86_32, - /** - * 64-bit platform - */ - X86_64; -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/domain/Image.java b/compute/src/main/java/org/jclouds/compute/domain/Image.java index ef72c895e3..f5dd31bc04 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/Image.java +++ b/compute/src/main/java/org/jclouds/compute/domain/Image.java @@ -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 */ diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java index 0f1aed233f..133acd5f4d 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java @@ -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 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(); diff --git a/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java index 5ecdd4c510..d9bd97322a 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java @@ -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. *

@@ -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); diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java index 1e1dac03ab..3f29f85e16 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java @@ -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 userMetadata, OperatingSystem operatingSystem, String description, String version, - @Nullable Architecture architecture, Credentials defaultCredentials) { + Map 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 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} */ @@ -132,14 +91,13 @@ public class ImageImpl extends ComputeMetadataImpl implements Image { @Override public String toString() { return "[id=" + getId() + ", name=" + getName() + ", operatingSystem=" + operatingSystem + ", description=" - + description + ", version=" + version + ", location=" + getLocation() + "]"; + + description + ", version=" + version + ", location=" + getLocation() + "]"; } @Override 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; diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java index 2f399ddac9..06697aa74c 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java @@ -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 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 userMetadata, - @Nullable String tag, @Nullable Image image, NodeState state, - Iterable publicAddresses, Iterable privateAddresses, - Map extra, @Nullable Credentials credentials) { + public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri, + Map userMetadata, @Nullable String tag, @Nullable String imageId, + @Nullable OperatingSystem os, NodeState state, Iterable publicAddresses, + Iterable privateAddresses, Map 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; + } + } diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index ef9fee7689..e7439066ce 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -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 optionsProvider; protected final Provider defaultTemplateProvider; - @VisibleForTesting - protected Architecture arch; @VisibleForTesting protected Location location; @VisibleForTesting @@ -116,8 +112,9 @@ public class TemplateBuilderImpl implements TemplateBuilder { @Inject protected TemplateBuilderImpl(Supplier> locations, Supplier> images, - Supplier> sizes, Supplier defaultLocation2, - Provider optionsProvider, @Named("DEFAULT") Provider defaultTemplateProvider) { + Supplier> sizes, Supplier defaultLocation2, + Provider optionsProvider, + @Named("DEFAULT") Provider 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 locationPredicate = new Predicate() { @Override @@ -141,7 +136,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { boolean returnVal = true; if (location != null && input.getLocation() != null) returnVal = location.equals(input.getLocation()) || location.getParent() != null - && location.getParent().equals(input.getLocation()); + && location.getParent().equals(input.getLocation()); return returnVal; } }; @@ -172,17 +167,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { } }; - private final Predicate imageArchPredicate = new Predicate() { - @Override - public boolean apply(Image input) { - boolean returnVal = true; - if (arch != null) - returnVal = arch.equals(input.getArchitecture()); - return returnVal; - } - - }; private final Predicate osNamePredicate = new Predicate() { @Override public boolean apply(OperatingSystem input) { @@ -206,7 +191,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { returnVal = false; else returnVal = input.getDescription().contains(osDescription) - || input.getDescription().matches(osDescription); + || input.getDescription().matches(osDescription); } return returnVal; } @@ -290,8 +275,8 @@ public class TemplateBuilderImpl implements TemplateBuilder { returnVal = false; else returnVal = input.getDescription().equals(imageDescription) - || input.getDescription().contains(imageDescription) - || input.getDescription().matches(imageDescription); + || input.getDescription().contains(imageDescription) + || input.getDescription().matches(imageDescription); } return returnVal; } @@ -325,12 +310,12 @@ public class TemplateBuilderImpl implements TemplateBuilder { } }; private final Predicate sizePredicate = and(sizeIdPredicate, locationPredicate, sizeCoresPredicate, - sizeRamPredicate); + sizeRamPredicate); static final Ordering DEFAULT_SIZE_ORDERING = new Ordering() { public int compare(Size left, Size right) { return ComparisonChain.start().compare(left.getCores(), right.getCores()).compare(left.getRam(), - right.getRam()).compare(left.getDisk(), right.getDisk()).result(); + right.getRam()).compare(left.getDisk(), right.getDisk()).result(); } }; static final Ordering BY_CORES_ORDERING = new Ordering() { @@ -341,15 +326,15 @@ public class TemplateBuilderImpl implements TemplateBuilder { static final Ordering DEFAULT_IMAGE_ORDERING = new Ordering() { public int compare(Image left, Image right) { return ComparisonChain.start().compare(left.getName(), right.getName(), - Ordering. natural().nullsLast()).compare(left.getVersion(), right.getVersion(), - Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getName(), - right.getOperatingSystem().getName(),// - Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getVersion(), - right.getOperatingSystem().getVersion(),// - Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getDescription(), - right.getOperatingSystem().getDescription(),// - Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getArch(), - right.getOperatingSystem().getArch()).result(); + Ordering. natural().nullsLast()).compare(left.getVersion(), right.getVersion(), + Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getName(), + right.getOperatingSystem().getName(),// + Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getVersion(), + right.getOperatingSystem().getVersion(),// + Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getDescription(), + right.getOperatingSystem().getDescription(),// + Ordering. natural().nullsLast()).compare(left.getOperatingSystem().getArch(), + right.getOperatingSystem().getArch()).result(); } }; @@ -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); } @@ -513,7 +485,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { size = sizeOrdering.max(filter(sizesThatAreCompatibleWithOurImages, sizePredicate)); } catch (NoSuchElementException exception) { throw new NoSuchElementException("sizes don't support any images: " + toString() + "\n" + sizesl + "\n" - + images); + + images); } logger.debug("<< matched size(%s)", size); return size; @@ -566,28 +538,43 @@ public class TemplateBuilderImpl implements TemplateBuilder { if (imageId != null) { predicates.add(idPredicate); } else { + if (location != null) + predicates.add(new Predicate() { + + @Override + public boolean apply(Image input) { + return locationPredicate.apply(input); + } + + }); + + final List> 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() { @Override public boolean apply(Image input) { - return locationPredicate.apply(input); + return Predicates.and(osPredicates).apply(input.getOperatingSystem()); } }); - predicates.add(new Predicate() { - - @Override - public boolean apply(Image input) { - return Predicates.and( - ImmutableSet.of(osFamilyPredicate, osNamePredicate, osDescriptionPredicate, osVersionPredicate, - os64BitPredicate, osArchPredicate)).apply(input.getOperatingSystem()); - } - - }); - predicates.add(imageArchPredicate); - predicates.add(imageVersionPredicate); - predicates.add(imageNamePredicate); - predicates.add(imageDescriptionPredicate); + if (imageVersion != null) + predicates.add(imageVersionPredicate); + if (imageName != null) + predicates.add(imageNamePredicate); + if (imageDescription != null) + predicates.add(imageDescriptionPredicate); } Predicate imagePredicate = and(predicates); @@ -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,10 +718,10 @@ 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 - && os64Bit == null && imageName == null && imageDescription == null && minCores == 0 && minRam == 0 - && !biggest && !fastest; + 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; } diff --git a/compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java b/compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java index 91da0de6de..2ac10eb05e 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java +++ b/compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java @@ -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 */ diff --git a/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java b/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java index 10e99c5655..f7fd99fcbb 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java @@ -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). @@ -43,13 +44,16 @@ public class OperatingSystemPredicates { public boolean apply(OperatingSystem os) { if (os.getFamily() != null) { switch (os.getFamily()) { - case DEBIAN: - case UBUNTU: - return true; + case DEBIAN: + case UBUNTU: + 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 @@ -69,16 +73,19 @@ public class OperatingSystemPredicates { public boolean apply(OperatingSystem os) { if (os.getFamily() != null) { switch (os.getFamily()) { - case CENTOS: - case FEDORA: - case RHEL: - return true; + case CENTOS: + case FEDORA: + case RHEL: + 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 supportsZypper() { + return new Predicate() { + @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. */ diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java index 7f614801fd..5abe8415e6 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java @@ -137,7 +137,7 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo @Inject public StubSocketOpen(ConcurrentMap nodes, - @Named("PUBLIC_IP_PREFIX") String publicIpPrefix) { + @Named("PUBLIC_IP_PREFIX") String publicIpPrefix) { this.nodes = nodes; this.publicIpPrefix = publicIpPrefix; } @@ -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 userMetadata, String tag, Image image, NodeState state, - Iterable publicAddresses, Iterable privateAddresses, Map extra, - Credentials credentials, ExecutorService service) { - super(providerId, name, id, location, uri, userMetadata, tag, image, state, publicAddresses, privateAddresses, - extra, credentials); + Map userMetadata, String tag, String imageId, Image image, OperatingSystem os, + NodeState state, Iterable publicAddresses, Iterable privateAddresses, + Map 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; } @@ -225,9 +225,9 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo @Inject public StubAddNodeWithTagStrategy(ConcurrentMap nodes, Supplier location, - @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, - @Named("NODE_ID") Provider idProvider, @Named("PUBLIC_IP_PREFIX") String publicIpPrefix, - @Named("PRIVATE_IP_PREFIX") String privateIpPrefix, @Named("PASSWORD_PREFIX") String passwordPrefix) { + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, + @Named("NODE_ID") Provider idProvider, @Named("PUBLIC_IP_PREFIX") String publicIpPrefix, + @Named("PRIVATE_IP_PREFIX") String privateIpPrefix, @Named("PASSWORD_PREFIX") String passwordPrefix) { this.nodes = nodes; this.location = location; this.service = Executors.newCachedThreadPool(); @@ -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 - . of(), tag, template.getImage(), NodeState.PENDING, ImmutableSet - . of(publicIpPrefix + id), ImmutableSet. of(privateIpPrefix + id), ImmutableMap - . of(), new Credentials("root", passwordPrefix + id), service); + . of(), tag, template.getImage().getId(), template.getImage(), template.getImage() + .getOperatingSystem(), NodeState.PENDING, ImmutableSet. of(publicIpPrefix + id), ImmutableSet + . of(privateIpPrefix + id), ImmutableMap. of(), new Credentials("root", + passwordPrefix + id), service); nodes.put(id, node); node.setState(NodeState.RUNNING, 100); return node; @@ -314,7 +315,7 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo @Inject protected StubDestroyNodeStrategy(ConcurrentMap nodes, - @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service) { + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service) { this.nodes = nodes; this.service = service; } @@ -352,18 +353,18 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo Location zone = defaultLocation.get().getParent(); String parentId = zone.getId(); return Suppliers.> ofInstance(ImmutableSet. of(// - new ImageImpl("1", OsFamily.UBUNTU.name(), parentId + "/1", zone, null, - ImmutableMap. of(), // - new OperatingSystem(OsFamily.UBUNTU, "ubuntu 32", null, "X86_32", "ubuntu 32", false), - "stub ubuntu 32", "", null, new Credentials("root", null)), // - new ImageImpl("2", OsFamily.UBUNTU.name(), parentId + "/2", zone, null, - ImmutableMap. of(),// - new OperatingSystem(OsFamily.UBUNTU, "ubuntu 64", null, "X86_64", "ubuntu 64", true), - "stub ubuntu 64", "", null, new Credentials("root", null)),// - new ImageImpl("3", OsFamily.CENTOS.name(), parentId + "/3", zone, null, - ImmutableMap. of(), // - new OperatingSystem(OsFamily.CENTOS, "centos 64", null, "X86_64", "centos 64", true), - "stub centos 64", "", null, new Credentials("root", null)))); + new ImageImpl("1", OsFamily.UBUNTU.name(), parentId + "/1", zone, null, + ImmutableMap. of(), // + new OperatingSystem(OsFamily.UBUNTU, "ubuntu 32", null, "X86_32", "ubuntu 32", false), + "stub ubuntu 32", "", new Credentials("root", null)), // + new ImageImpl("2", OsFamily.UBUNTU.name(), parentId + "/2", zone, null, + ImmutableMap. of(),// + new OperatingSystem(OsFamily.UBUNTU, "ubuntu 64", null, "X86_64", "ubuntu 64", true), + "stub ubuntu 64", "", new Credentials("root", null)),// + new ImageImpl("3", OsFamily.CENTOS.name(), parentId + "/3", zone, null, + ImmutableMap. of(), // + new OperatingSystem(OsFamily.CENTOS, "centos 64", null, "X86_64", "centos 64", true), + "stub centos 64", "", new Credentials("root", null)))); } @Provides @@ -371,15 +372,15 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo protected Set provideLocations(@org.jclouds.rest.annotations.Provider String providerName) { Location provider = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); Location region = new LocationImpl(LocationScope.REGION, providerName + "region", providerName + "region", - provider); + provider); return ImmutableSet - .of(new LocationImpl(LocationScope.ZONE, providerName + "zone", providerName + "zone", region)); + .of(new LocationImpl(LocationScope.ZONE, providerName + "zone", providerName + "zone", region)); } @Override protected Supplier> getSourceSizeSupplier(Injector injector) { return Suppliers.> ofInstance(ImmutableSet. of(new StubSize("small", 1, 1740, 160), - new StubSize("medium", 4, 7680, 850), new StubSize("large", 8, 15360, 1690))); + new StubSize("medium", 4, 7680, 850), new StubSize("large", 8, 15360, 1690))); } private static class StubSize extends org.jclouds.compute.domain.internal.SizeImpl { diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index 9d0de65a67..0c13bbd06c 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -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 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 getSupportedProviders() { diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 5040348970..6b72297bf1 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -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 responses = runScriptWithCreds(tag, image.getOsFamily(), - new Credentials(good.identity, "romeo")); + Map 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 runScriptWithCreds(final String tag, OsFamily osFamily, + protected Map 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()); diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 1982220848..44251b4036 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -111,17 +111,17 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes expect(open.apply(new IPSocket("144.175.1.4", 22))).andReturn(true); expect( - factory.create(eq(new IPSocket("144.175.1.1", 22)), eq("root"), aryEq(keyPair.get("private") - .getBytes()))).andReturn(client1).atLeastOnce(); + factory.create(eq(new IPSocket("144.175.1.1", 22)), eq("root"), aryEq(keyPair.get("private") + .getBytes()))).andReturn(client1).atLeastOnce(); expect( - factory.create(eq(new IPSocket("144.175.1.2", 22)), eq("root"), aryEq(keyPair.get("private") - .getBytes()))).andReturn(client2).atLeastOnce(); + factory.create(eq(new IPSocket("144.175.1.2", 22)), eq("root"), aryEq(keyPair.get("private") + .getBytes()))).andReturn(client2).atLeastOnce(); expect( - factory.create(eq(new IPSocket("144.175.1.3", 22)), eq("root"), aryEq(keyPair.get("private") - .getBytes()))).andReturn(client3).atLeastOnce(); + factory.create(eq(new IPSocket("144.175.1.3", 22)), eq("root"), aryEq(keyPair.get("private") + .getBytes()))).andReturn(client3).atLeastOnce(); expect( - factory.create(eq(new IPSocket("144.175.1.4", 22)), eq("root"), aryEq(keyPair.get("private") - .getBytes()))).andReturn(client4).atLeastOnce(); + factory.create(eq(new IPSocket("144.175.1.4", 22)), eq("root"), aryEq(keyPair.get("private") + .getBytes()))).andReturn(client4).atLeastOnce(); helloAndJava(client1); helloAndJava(client2); @@ -165,20 +165,20 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes SshClient client4 = createMock(SshClient.class); expect(factory.create(new IPSocket("144.175.1.1", 22), "root", "romeo")).andThrow( - new SshException("Auth fail")); + new SshException("Auth fail")); expect(factory.create(new IPSocket("144.175.1.1", 22), "root", "password1")).andReturn(client1) - .atLeastOnce(); + .atLeastOnce(); client1.connect(); runScript(client1, "computeserv", 1); client1.disconnect(); expect(factory.create(new IPSocket("144.175.1.2", 22), "root", "password2")).andReturn(client2) - .atLeastOnce(); + .atLeastOnce(); expect(factory.create(new IPSocket("144.175.1.3", 22), "root", "password3")).andReturn(client3) - .atLeastOnce(); + .atLeastOnce(); expect(factory.create(new IPSocket("144.175.1.4", 22), "root", "password4")).andReturn(client4) - .atLeastOnce(); + .atLeastOnce(); runScriptAndInstallSsh(client2, "runscript", 2); runScriptAndInstallSsh(client3, "runscript", 3); @@ -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(); @@ -242,9 +242,9 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes public static String initScript(String scriptName, String script) { return new InitBuilder(scriptName, "/tmp/" + scriptName, "/tmp/" + scriptName, - ImmutableMap. of(), Iterables.toArray(Splitter.on("\n").split( - new String(checkNotNull(script, "script"))), String.class)) - .build(org.jclouds.scriptbuilder.domain.OsFamily.UNIX); + ImmutableMap. of(), Iterables.toArray(Splitter.on("\n").split( + new String(checkNotNull(script, "script"))), String.class)) + .build(org.jclouds.scriptbuilder.domain.OsFamily.UNIX); } public static Payload payloadEq(String value) { @@ -255,7 +255,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext, ConcurrentMap> stubContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); } private static class PayloadEquals implements IArgumentMatcher, Serializable { @@ -305,7 +305,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes return false; PayloadEquals other = (PayloadEquals) o; return this.expected == null && other.expected == null || this.expected != null - && this.expected.equals(other.expected); + && this.expected.equals(other.expected); } @Override diff --git a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java index c03655a733..81dc09ae66 100644 --- a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java +++ b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java @@ -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; @@ -63,12 +62,12 @@ public class TemplateBuilderImplTest { OperatingSystem os2 = createMock(OperatingSystem.class); Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap. of(), - 1.0, 0, 0, ImagePredicates.any()); + 1.0, 0, 0, ImagePredicates.any()); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(defaultLocation)); + . of(defaultLocation)); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of( - image, image2)); + image, image2)); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of(size)); Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); @@ -99,7 +98,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); assertEquals(template.resolveImage(size, images.get()), image2); @@ -123,12 +122,12 @@ public class TemplateBuilderImplTest { OperatingSystem os2 = createMock(OperatingSystem.class); Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap. of(), - 1.0, 0, 0, ImagePredicates.any()); + 1.0, 0, 0, ImagePredicates.any()); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(defaultLocation)); + . of(defaultLocation)); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of( - image, image2)); + image, image2)); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of(size)); Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); @@ -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); @@ -154,9 +153,9 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + 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); @@ -176,12 +175,12 @@ public class TemplateBuilderImplTest { OperatingSystem os = createMock(OperatingSystem.class); Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap. of(), 0, - 0, 0, ImagePredicates.idEquals("imageId")); + 0, 0, ImagePredicates.idEquals("imageId")); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(defaultLocation)); + . of(defaultLocation)); Supplier> images = Suppliers.> ofInstance(ImmutableSet - . of(image)); + . of(image)); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of(size)); Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); @@ -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(); @@ -211,7 +209,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); template.imageId("imageId").build(); @@ -231,12 +229,12 @@ public class TemplateBuilderImplTest { OperatingSystem os = createMock(OperatingSystem.class); Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap. of(), 0, - 0, 0, ImagePredicates.idEquals("imageId")); + 0, 0, ImagePredicates.idEquals("imageId")); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of(defaultLocation)); + . of(defaultLocation)); Supplier> images = Suppliers.> ofInstance(ImmutableSet - . of(image)); + . of(image)); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of(size)); Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); @@ -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(); @@ -266,7 +263,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(image, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); try { template.imageId("notImageId").build(); assert false; @@ -287,7 +284,7 @@ public class TemplateBuilderImplTest { TemplateOptions from = provideTemplateOptions(); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); Location defaultLocation = createMock(Location.class); @@ -306,7 +303,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); template.options(options).build(); @@ -321,7 +318,7 @@ public class TemplateBuilderImplTest { public void testNothingUsesDefaultTemplateBuilder() { Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); @@ -339,7 +336,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); template.build(); @@ -350,10 +347,10 @@ public class TemplateBuilderImplTest { } protected TemplateBuilderImpl createTemplateBuilder(Image knownImage, Supplier> locations, - Supplier> images, Supplier> sizes, Location defaultLocation, - Provider optionsProvider, Provider templateBuilderProvider) { + Supplier> images, Supplier> sizes, Location defaultLocation, + Provider optionsProvider, Provider templateBuilderProvider) { TemplateBuilderImpl template = new TemplateBuilderImpl(locations, images, sizes, Suppliers - .ofInstance(defaultLocation), optionsProvider, templateBuilderProvider); + .ofInstance(defaultLocation), optionsProvider, templateBuilderProvider); return template; } @@ -361,7 +358,7 @@ public class TemplateBuilderImplTest { @Test public void testSuppliedLocationWithNoOptions() { Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); Location defaultLocation = createMock(Location.class); @@ -375,7 +372,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); try { template.imageId("foo").locationId("location").build(); @@ -396,7 +393,7 @@ public class TemplateBuilderImplTest { TemplateOptions from = provideTemplateOptions(); Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); Location defaultLocation = createMock(Location.class); @@ -410,7 +407,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); try { template.imageId("foo").options(provideTemplateOptions()).locationId("location").build(); @@ -428,7 +425,7 @@ public class TemplateBuilderImplTest { @Test public void testDefaultLocationWithNoOptionsNoSuchElement() { Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); Location defaultLocation = createMock(Location.class); @@ -444,7 +441,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); try { template.imageId("region/ami").build(); @@ -467,7 +464,7 @@ public class TemplateBuilderImplTest { @Test public void testDefaultLocationWithOptions() { Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); Location defaultLocation = createMock(Location.class); @@ -484,7 +481,7 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider); try { template.imageId("region/ami").options(provideTemplateOptions()).build(); @@ -502,7 +499,7 @@ public class TemplateBuilderImplTest { @Test public void testImageIdNullsEverythingElse() { Supplier> locations = Suppliers.> ofInstance(ImmutableSet - . of()); + . of()); Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet. of()); Location defaultLocation = createMock(Location.class); @@ -514,16 +511,16 @@ public class TemplateBuilderImplTest { replay(templateBuilderProvider); TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + 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); diff --git a/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java index ca94d11c2e..49c170ca89 100755 --- a/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java +++ b/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java @@ -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)); } } \ No newline at end of file diff --git a/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java b/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java index f16e5fa6fb..050351ea90 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java @@ -100,7 +100,9 @@ public class ServerToNodeMetadata implements Function { 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. of(), tag, image, state, ipSet, - ImmutableList. of(), ImmutableMap. of(), creds); + from.getDatacenter().getId() + ""), null, ImmutableMap. of(), tag, from.getImage() + .getId() + + "", image != null ? image.getOperatingSystem() : null, state, ipSet, ImmutableList. of(), + ImmutableMap. of(), creds); } } \ No newline at end of file diff --git a/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java b/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java index 6066970ac4..98d3b47498 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/compute/suppliers/GoGridImageSupplier.java @@ -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> { logger.debug(">> providing images"); Set 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. of(), from.getDescription(), version, os, osDescription, arch, - defaultCredentials)); + ImmutableMap. of(), os, description, version, defaultCredentials)); } logger.debug("<< images(%d)", images.size()); return images; diff --git a/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index a2a1f9270c..890ccce7f4 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -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); } diff --git a/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java b/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java index 0a3ece2794..194578217e 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java @@ -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")); diff --git a/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceContextModule.java b/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceContextModule.java index 7710510256..9e72066cfa 100644 --- a/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceContextModule.java +++ b/ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceContextModule.java @@ -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 diff --git a/ibmdev/src/main/java/org/jclouds/ibmdev/compute/domain/IBMImage.java b/ibmdev/src/main/java/org/jclouds/ibmdev/compute/domain/IBMImage.java index 4b0b9b7367..9ab634d693 100644 --- a/ibmdev/src/main/java/org/jclouds/ibmdev/compute/domain/IBMImage.java +++ b/ibmdev/src/main/java/org/jclouds/ibmdev/compute/domain/IBMImage.java @@ -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. 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. 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; } diff --git a/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java b/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java index 1c761fe979..46e5d5cf03 100644 --- a/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java +++ b/ibmdev/src/main/java/org/jclouds/ibmdev/compute/functions/InstanceToNodeMetadata.java @@ -76,8 +76,8 @@ public class InstanceToNodeMetadata implements Function 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. of(), tag, image, state, ipSet, ImmutableList - . of(), ImmutableMap. of(), new Credentials( - image.getDefaultCredentials().identity, key)); + image.getLocation()), null, ImmutableMap. of(), tag, from.getImageId(), + image != null ? image.getOperatingSystem() : null, state, ipSet, ImmutableList. of(), + ImmutableMap. of(), new Credentials(image.getDefaultCredentials().identity, key)); } } \ No newline at end of file diff --git a/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTestDisabled.java b/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTestDisabled.java index 37f7de9490..e1c519f1d2 100644 --- a/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTestDisabled.java +++ b/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTestDisabled.java @@ -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); } @@ -73,7 +72,7 @@ public class IBMDeveloperCloudComputeServiceLiveTestDisabled extends BaseCompute public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); } } \ No newline at end of file diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java index 4dbe1b8ca5..b1b83aae36 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java @@ -94,8 +94,9 @@ public class ServerToNodeMetadata implements Function { 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. of(), null); + tag, from.getImageId() + "", image != null ? image.getOperatingSystem() : null, serverToNodeState + .get(from.getStatus()), from.getAddresses().getPublicAddresses(), from.getAddresses() + .getPrivateAddresses(), ImmutableMap. of(), null); } } \ No newline at end of file diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java index cb28269b6f..0dd6738f95 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/strategy/CloudServersAddNodeWithTagStrategy.java @@ -53,11 +53,11 @@ 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 - . of(), new Credentials("root", server.getAdminPass())); + 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 + . of(), new Credentials("root", server.getAdminPass())); } } \ No newline at end of file diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/suppliers/CloudServersImageSupplier.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/suppliers/CloudServersImageSupplier.java index f45c8e3a2c..71d3653972 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/suppliers/CloudServersImageSupplier.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/suppliers/CloudServersImageSupplier.java @@ -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> 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. of(), from.getName(), version, os, osDescription, arch, - new Credentials("root", null))); + ImmutableMap. of(), os, from.getName(), version, new Credentials("root", null))); } logger.debug("<< images(%d)", images.size()); return images; diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java index 9944c1f761..a689605c0c 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -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); } diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadataTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadataTest.java index 7955ca72b1..0c678ee1d9 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadataTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadataTest.java @@ -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); diff --git a/rackspace/src/test/resources/log4j.xml b/rackspace/src/test/resources/log4j.xml index 825de7fcc8..5b548a0f48 100755 --- a/rackspace/src/test/resources/log4j.xml +++ b/rackspace/src/test/resources/log4j.xml @@ -161,13 +161,12 @@ - + diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java index 67a0d2f75b..b04d4961b9 100755 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java @@ -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 diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java index 0f2f87c5bc..674554bdd6 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java @@ -107,8 +107,9 @@ public class ServerToNodeMetadata implements Function { } NodeState state = runningStateToNodeState.get(from.getState()); return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", location, null, ImmutableMap - . of(), tag, image, state, getPublicAddresses.apply(from), ImmutableList. of(), - ImmutableMap. of(), creds); + . of(), tag, from.getImageId(), image != null ? image.getOperatingSystem() : null, + state, getPublicAddresses.apply(from), ImmutableList. of(), ImmutableMap. of(), + creds); } } \ No newline at end of file diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java index e9bf50449e..8218b6854b 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingAddNodeWithTagStrategy.java @@ -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. of(), tag, template.getImage(), - runningStateToNodeState.get(server.getState()), getPublicAddresses.apply(server), ImmutableList - . of(), ImmutableMap. of(), new Credentials("root", serverResponse - .getNewInstanceRequest().getCreateOptions().getPassword())); + .getLocation(), null, ImmutableMap. of(), tag, template.getImage().getId(), template + .getImage().getOperatingSystem(), runningStateToNodeState.get(server.getState()), getPublicAddresses + .apply(server), ImmutableList. of(), ImmutableMap. of(), new Credentials("root", + serverResponse.getNewInstanceRequest().getCreateOptions().getPassword())); return node; } diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java index cf9fc0412e..bdeb149e9c 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java @@ -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> final Set 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 - . of(), from.getDescription(), version, os, osDescription, arch, new Credentials( - "root", null))); + . of(), os, from.getDescription(), version, new Credentials("root", null))); } logger.debug("<< images(%d)", images.size()); return images; diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index 0958aa4f64..12197428dc 100755 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -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); diff --git a/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java b/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java index 8a2eaf3cec..2d8513e3e5 100644 --- a/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java +++ b/slicehost/src/main/java/org/jclouds/slicehost/SlicehostAsyncClient.java @@ -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. *

- * 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 @@ -107,7 +106,7 @@ public interface SlicehostAsyncClient { * @see SlicehostClient#hardRebootSlice */ @PUT - @Path("/slices/{id}/hardReboot.xml") + @Path("/slices/{id}/hard_reboot.xml") ListenableFuture hardRebootSlice(@PathParam("id") int id); /** @@ -118,7 +117,7 @@ public interface SlicehostAsyncClient { @MapBinder(BindCreateSliceToXmlPayload.class) @XMLResponseParser(SliceHandler.class) ListenableFuture createSlice(@MapPayloadParam("name") String name, @MapPayloadParam("image_id") int imageId, - @MapPayloadParam("flavor_id") int flavorId); + @MapPayloadParam("flavor_id") int flavorId); /** * @see SlicehostClient#rebuildSliceFromImage @@ -170,13 +169,6 @@ public interface SlicehostAsyncClient { @XMLResponseParser(ImageHandler.class) ListenableFuture getImage(@PathParam("id") int id); - /** - * @see SlicehostClient#destroyBackup - */ - @DELETE - @Path("/backups/{id}/destroy.xml") - ListenableFuture destroyBackup(@PathParam("id") int id); - /** * @see SlicehostClient#listBackups */ @@ -195,13 +187,4 @@ public interface SlicehostAsyncClient { @XMLResponseParser(BackupHandler.class) ListenableFuture getBackup(@PathParam("id") int id); - /** - * @see BackuphostClient#createBackup - */ - @POST - @Path("/slices.xml") - @MapBinder(BindCreateBackupToXmlPayload.class) - @XMLResponseParser(BackupHandler.class) - ListenableFuture createBackup(@MapPayloadParam("name") String name, @MapPayloadParam("slice_id") int sliceId); - } diff --git a/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java b/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java index 71ba4adbf1..c639657c16 100644 --- a/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java +++ b/slicehost/src/main/java/org/jclouds/slicehost/SlicehostClient.java @@ -34,9 +34,9 @@ import com.google.common.util.concurrent.ListenableFuture; /** * Provides access to Slicehost via their REST API. *

- * 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 @@ -68,12 +68,8 @@ public interface SlicehostClient { Image getImage(int id); - Void destroyBackup(int id); - Set listBackups(); Backup getBackup(int id); - Backup createBackup(String name, int sliceId); - } diff --git a/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java b/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java index dd736ba962..15c7553261 100644 --- a/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java +++ b/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java @@ -86,15 +86,16 @@ public class SliceToNodeMetadata implements Function { } return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", location.get(), null, - ImmutableMap. of(), tag, image, sliceToNodeState.get(from.getStatus()), Iterables - .filter(from.getAddresses(), new Predicate() { + ImmutableMap. of(), tag, from.getImageId() + "", image != null ? image + .getOperatingSystem() : null, sliceToNodeState.get(from.getStatus()), Iterables.filter(from + .getAddresses(), new Predicate() { - @Override - public boolean apply(String input) { - return !input.startsWith("10."); - } + @Override + public boolean apply(String input) { + return !input.startsWith("10."); + } - }), Iterables.filter(from.getAddresses(), new Predicate() { + }), Iterables.filter(from.getAddresses(), new Predicate() { @Override public boolean apply(String input) { diff --git a/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java b/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java index 4dd6bf4a30..75f36d679e 100644 --- a/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java +++ b/slicehost/src/main/java/org/jclouds/slicehost/compute/strategy/SlicehostAddNodeWithTagStrategy.java @@ -55,15 +55,16 @@ 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. of(), tag, template.getImage(), NodeState.PENDING, Iterables.filter(slice - .getAddresses(), new Predicate() { + ImmutableMap. of(), tag, template.getImage().getId(), template.getImage() + .getOperatingSystem(), NodeState.PENDING, Iterables.filter(slice.getAddresses(), + new Predicate() { - @Override - public boolean apply(String input) { - return !input.startsWith("10."); - } + @Override + public boolean apply(String input) { + return !input.startsWith("10."); + } - }), Iterables.filter(slice.getAddresses(), new Predicate() { + }), Iterables.filter(slice.getAddresses(), new Predicate() { @Override public boolean apply(String input) { diff --git a/slicehost/src/main/java/org/jclouds/slicehost/compute/suppliers/SlicehostImageSupplier.java b/slicehost/src/main/java/org/jclouds/slicehost/compute/suppliers/SlicehostImageSupplier.java index 74ca945f8b..21c168439d 100644 --- a/slicehost/src/main/java/org/jclouds/slicehost/compute/suppliers/SlicehostImageSupplier.java +++ b/slicehost/src/main/java/org/jclouds/slicehost/compute/suppliers/SlicehostImageSupplier.java @@ -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> { final Set 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. of(), from.getName(), version, os, osDescription, arch, - new Credentials("root", null))); + ImmutableMap. of(), os, from.getName(), version, new Credentials("root", null))); } logger.debug("<< images(%d)", images.size()); return images; diff --git a/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java b/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java index 8c1d8cec2e..c86d980d2e 100644 --- a/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java +++ b/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java @@ -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 RestClientTest2ralphie", - "application/xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, BackupHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - - } - @Override protected TypeLiteral> createTypeLiteral() { return new TypeLiteral>() { diff --git a/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index b3c0c69e33..4ac12c3152 100644 --- a/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -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; @@ -73,8 +72,8 @@ public class SlicehostClientLiveTest { String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity"); Injector injector = new RestContextFactory().createContextBuilder("slicehost", identity, null, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), new Properties()) - .buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), new Properties()) + .buildInjector(); client = injector.getInstance(SlicehostClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); @@ -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 { @@ -230,7 +228,7 @@ public class SlicehostClientLiveTest { private void blockUntilSliceActive(int sliceId) throws InterruptedException { Slice currentDetails = null; for (currentDetails = client.getSlice(sliceId); currentDetails.getStatus() != Slice.Status.ACTIVE; currentDetails = client - .getSlice(sliceId)) { + .getSlice(sliceId)) { System.out.printf("blocking on status active%n%s%n", currentDetails); Thread.sleep(5 * 1000); } @@ -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 - 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); diff --git a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java index 8241cc18f6..e0b8f6c129 100644 --- a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java +++ b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java @@ -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); } @@ -65,6 +64,6 @@ public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext tmContext = new ComputeServiceContextFactory().createContext( - provider, identity, credential).getProviderSpecificContext(); + provider, identity, credential).getProviderSpecificContext(); } } diff --git a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java index 097a7b5848..a8c2ae3acd 100644 --- a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java +++ b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java @@ -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,24 +241,20 @@ 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()), - ipOrEmptyString(metadata.getPrivateAddresses()), metadata.getExtra())); + 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())); } /** diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java index d3a6a317ce..e46a2cf410 100644 --- a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java @@ -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); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/domain/VCloudImage.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/domain/VCloudImage.java index 4aba44a4b0..d96d81602b 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/domain/VCloudImage.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/domain/VCloudImage.java @@ -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 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 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; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java index dda5b62799..13d827cc36 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java @@ -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 { @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. of(), desc, "", myOs, name, arch, credentialsProvider - .execute(from)); + .getId(), ImmutableMap. of(), os, desc, "", credentialsProvider.execute(from)); } protected String getName(String name) { diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/VCloudGetNodeMetadata.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/VCloudGetNodeMetadata.java index bd87dba231..65a6df7e3f 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/VCloudGetNodeMetadata.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/VCloudGetNodeMetadata.java @@ -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. 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); } } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java index 597759a4e8..d33ad7dfb5 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java @@ -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 metaMap, VApp vApp) { return new NodeMetadataImpl(vApp.getId().toASCIIString(), vApp.getName(), vApp.getId().toASCIIString(), template - .getLocation(), vApp.getId(), ImmutableMap. of(), tag, template.getImage(), + .getLocation(), vApp.getId(), ImmutableMap. of(), tag, template.getImage().getId(), + getOperatingSystemForVAppOrDefaultTo(vApp, template.getImage().getOperatingSystem()), vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getId()), computeClient.getPrivateAddresses(vApp.getId()), ImmutableMap. 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; + } + } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java index e4e6976362..90c599eff9 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java @@ -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 getNetworkToAddresses(); + /** + * + * @return CIM OSType of the image or null, if this information isn't available yet + * @see DMTF CIM model + */ + @Nullable + Integer getOsType(); + + /** + * + * @return description or null, if this information isn't available yet + */ + @Nullable String getOperatingSystemDescription(); VirtualSystem getSystem(); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java index ff01a885d9..eecebcc461 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java @@ -48,19 +48,21 @@ public class VAppImpl implements VApp { private final String operatingSystemDescription; private final VirtualSystem system; private final Set 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 networkToAddresses, String operatingSystemDescription, VirtualSystem system, - Set resourceAllocations) { + ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, + VirtualSystem system, Set 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,10 +199,10 @@ public class VAppImpl implements VApp { @Override public String toString() { - return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses - + ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType=" - + resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC - + "]"; + return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses + ", osType=" + osType + + ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType=" + + resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC + + "]"; } @Override @@ -201,4 +214,5 @@ public class VAppImpl implements VApp { public int compareTo(NamedResource o) { return (this == o) ? 0 : getId().compareTo(o.getId()); } + } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java index bd12fa9ca5..efa50e6162 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java @@ -67,13 +67,14 @@ public class VAppHandler extends ParseSax.HandlerWithResult { 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 { @@ -86,11 +87,14 @@ public class VAppHandler extends ParseSax.HandlerWithResult { size = new Long(attributes.getValue(attributes.getIndex("size"))); } else if (qName.equals("Link")) { // type should never be missing if (attributes.getIndex("type") != -1 - && attributes.getValue(attributes.getIndex("type")).equals(VCloudMediaType.VDC_XML)) { + && attributes.getValue(attributes.getIndex("type")).equals(VCloudMediaType.VDC_XML)) { vDC = Utils.newNamedResource(attributes); } } 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 { diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudListNodesStrategyTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudListNodesStrategyTest.java deleted file mode 100644 index ac9e5aff69..0000000000 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudListNodesStrategyTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.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 networkToAddresses = ImmutableListMultimap. of("Network 1", - "127.0.0.1"); - - VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07"); - - SortedSet resourceAllocations = ImmutableSortedSet. 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 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> locations = Providers - // .> of(ImmutableSet.of(vdcL)); - // Supplier> images = Providers - // .> of(ImmutableSet. of()); - // FindLocationForResourceInVDC findLocationForResourceInVDC = new - // FindLocationForResourceInVDC( - // locations, null); - // VCloudListNodesStrategy strategy = new VCloudListNodesStrategy(client, - // computeClient, vAppStatusToNodeState, getExtra, - // findLocationForResourceInVDC, images); - // - // Set 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); - // } -} \ No newline at end of file diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java index 0e0da37de2..db1181542d 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java @@ -55,24 +55,24 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); ListMultimap networkToAddresses = ImmutableListMultimap. of("Network 1", - "204.12.11.167"); + "204.12.11.167"); VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07"); SortedSet resourceAllocations = ImmutableSortedSet. 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(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); } @@ -83,9 +83,9 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); 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. of(), null, - null, ImmutableSet. of()); + 123456789l, new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI + .create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap. of(), + null, null, null, ImmutableSet. of()); assertEquals(result, expects); } @@ -95,25 +95,25 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", - "10.150.4.93"); + "10.150.4.93"); VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "centos53", "vmx-07"); SortedSet resourceAllocations = ImmutableSortedSet. 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, "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(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(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(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(); 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); + 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, null, + "Other Linux (32-bit)", system, resourceAllocations); assertEquals(result.getId(), expects.getId()); assertEquals(result.getName(), expects.getName()); assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); @@ -132,25 +132,25 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", - "10.23.119.221"); + "10.23.119.221"); VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "m1", "vmx-07"); SortedSet resourceAllocations = ImmutableSortedSet. 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(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(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(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(); 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, - "Microsoft Windows XP Professional (32-bit)", system, resourceAllocations); + 10485760), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI + .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()); assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java index c54e0de861..6e362d0daa 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java @@ -46,10 +46,10 @@ 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 networkToAddresses, String operatingSystemDescription, VirtualSystem system, - Set resourceAllocations, String username, String password) { - super(name, location, status, size, vDC, networkToAddresses, operatingSystemDescription, system, - resourceAllocations); + ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, + VirtualSystem system, Set resourceAllocations, String username, String password) { + super(name, location, status, size, vDC, networkToAddresses, osType, operatingSystemDescription, system, + resourceAllocations); this.username = username; this.password = password; diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java index e6d14b8d7f..6a3af72d82 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java @@ -43,8 +43,8 @@ public class HostingDotComVAppHandler extends VAppHandler { } public HostingDotComVApp getResult() { - return new HostingDotComVAppImpl(name, location, status, size, vDC, networkToAddresses, - operatingSystemDescription, system, allocations, username, password); + return new HostingDotComVAppImpl(name, location, status, size, vDC, networkToAddresses, osType, + operatingSystemDescription, system, allocations, username, password); } @Override diff --git a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java index e05c0d7dd1..a25f26f6f7 100644 --- a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java +++ b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java @@ -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); } diff --git a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandlerTest.java b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandlerTest.java index 7b0c8231a9..5ab80b14ea 100644 --- a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandlerTest.java +++ b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandlerTest.java @@ -48,14 +48,14 @@ public class HostingDotComVAppHandlerTest extends BaseHandlerTest { InputStream is = getClass().getResourceAsStream("/hostingdotcom/instantiatevapp.xml"); HostingDotComVApp result = (HostingDotComVApp) factory.create( - injector.getInstance(HostingDotComVAppHandler.class)).parse(is); + injector.getInstance(HostingDotComVAppHandler.class)).parse(is); HostingDotComVApp expects = new HostingDotComVAppImpl("188849-33", URI - .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 - . of(), null, null, ImmutableSortedSet. of(), "root", - "meatisyummy"); + .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 + . of(), null, null, null, ImmutableSortedSet. of(), "root", + "meatisyummy"); assertEquals(result, expects); } diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java index 335d9a7c6e..8c9348d874 100755 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -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; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/functions/ImagesInOrganization.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/functions/ImagesInOrganization.java deleted file mode 100644 index f1752c7ebd..0000000000 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/functions/ImagesInOrganization.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.terremark.compute.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> { - - private final AllCatalogItemsInOrganization allCatalogItemsInOrganization; - private final VAppTemplatesForCatalogItems vAppTemplatesForCatalogItems; - private final Provider imageForVAppTemplateProvider; - - @Inject - ImagesInOrganization(AllCatalogItemsInOrganization allCatalogItemsInOrganization, - Provider imageForVAppTemplateProvider, - VAppTemplatesForCatalogItems vAppTemplatesForCatalogItems) { - this.imageForVAppTemplateProvider = imageForVAppTemplateProvider; - this.allCatalogItemsInOrganization = allCatalogItemsInOrganization; - this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems; - } - - @Override - public Iterable apply(Organization from) { - Iterable catalogs = allCatalogItemsInOrganization.apply(from); - Iterable vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs); - return Iterables.transform(vAppTemplates, imageForVAppTemplateProvider.get().withParent(from)); - } - -} \ No newline at end of file diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java index 1ef5bbf76f..b916e6bdeb 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java @@ -53,7 +53,7 @@ public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadat @Inject protected TerremarkVCloudGetNodeMetadataStrategy(VCloudGetNodeMetadata getNodeMetadata, - ConcurrentMap credentialsMap) { + ConcurrentMap credentialsMap) { super(getNodeMetadata); this.credentialsMap = credentialsMap; } @@ -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; - } } \ No newline at end of file diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/providers/VAppTemplatesInOrgs.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/suppliers/VAppTemplatesInOrgs.java similarity index 97% rename from vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/providers/VAppTemplatesInOrgs.java rename to vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/suppliers/VAppTemplatesInOrgs.java index c924a57c06..8bc6c7a3aa 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/providers/VAppTemplatesInOrgs.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/suppliers/VAppTemplatesInOrgs.java @@ -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; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java index a0221ba345..6023365813 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java @@ -66,15 +66,15 @@ 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. 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. 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"); + "eduardo", "roberto"); VAppConfiguration config = new VAppConfiguration().changeNameTo("roberto"); @@ -93,16 +93,17 @@ 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. 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. 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"); + "eduardo", "MyAppServer6"); VAppConfiguration config = new VAppConfiguration().deleteDiskWithAddressOnParent(1); @@ -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. 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. 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,15 +147,15 @@ 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. 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. 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"); + "eduardo", "MyAppServer6").replace("1024", "1536"); VAppConfiguration config = new VAppConfiguration().changeMemoryTo(1536); diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java index ccbf0bb068..d1c580faf4 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java @@ -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); } @@ -65,7 +65,7 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); } @Override @@ -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; } } diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/providers/VAppTemplatesInOrgsLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/suppliers/VAppTemplatesInOrgsLiveTest.java similarity index 92% rename from vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/providers/VAppTemplatesInOrgsLiveTest.java rename to vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/suppliers/VAppTemplatesInOrgsLiveTest.java index fa6f8f02cf..2e986f9ccd 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/providers/VAppTemplatesInOrgsLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/suppliers/VAppTemplatesInOrgsLiveTest.java @@ -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; @@ -66,7 +65,7 @@ public class VAppTemplatesInOrgsLiveTest { if (endpoint != null && !"".equals(endpoint)) props.setProperty("terremark.endpoint", endpoint); Injector injector = new RestContextFactory().createContextBuilder("trmk-vcloudexpress", identity, credential, - ImmutableSet. of(new Log4JLoggingModule()), props).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule()), props).buildInjector(); tmClient = injector.getInstance(TerremarkVCloudClient.class); allCatalogItemsInOrganization = injector.getInstance(AllCatalogItemsInOrganization.class); @@ -80,7 +79,7 @@ public class VAppTemplatesInOrgsLiveTest { Set images = parser.get(); Iterable templates = allCatalogItemsInOrganization.apply(tmClient - .findOrganizationNamed(null)); + .findOrganizationNamed(null)); assertEquals(images.size(), Iterables.size(templates)); assert images.size() > 0;