From 2760345bd3af7d7aefe89f94a8642961c28c5588 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 20 Dec 2010 14:36:04 +0100 Subject: [PATCH] promoted os version bundle object to be accessible outside tests --- .../compute/EC2TemplateBuilderLiveTest.java | 2 +- .../domain/os}/OsFamilyVersion64Bit.java | 18 +++-- .../compute/BaseTemplateBuilderLiveTest.java | 1 + .../functions/WellKnownImageToImage.java | 70 +++++++++++++++++++ .../ElasticStackTemplateBuilderLiveTest.java | 2 +- .../GoGridTemplateBuilderLiveTest.java | 2 +- .../CloudServersTemplateBuilderLiveTest.java | 2 +- .../RimuHostingTemplateBuilderLiveTest.java | 2 +- .../SlicehostTemplateBuilderLiveTest.java | 2 +- ...erremarkECloudTemplateBuilderLiveTest.java | 2 +- ...kVCloudExpressTemplateBuilderLiveTest.java | 2 +- 11 files changed, 93 insertions(+), 12 deletions(-) rename compute/src/{test/java/org/jclouds/compute => main/java/org/jclouds/compute/domain/os}/OsFamilyVersion64Bit.java (90%) create mode 100644 elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java 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 3c592eed75..0bae72c07d 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,9 +30,9 @@ import org.jclouds.aws.ec2.reference.EC2Constants; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.testng.annotations.Test; diff --git a/compute/src/test/java/org/jclouds/compute/OsFamilyVersion64Bit.java b/compute/src/main/java/org/jclouds/compute/domain/os/OsFamilyVersion64Bit.java similarity index 90% rename from compute/src/test/java/org/jclouds/compute/OsFamilyVersion64Bit.java rename to compute/src/main/java/org/jclouds/compute/domain/os/OsFamilyVersion64Bit.java index a2f13d634c..e015b580e6 100644 --- a/compute/src/test/java/org/jclouds/compute/OsFamilyVersion64Bit.java +++ b/compute/src/main/java/org/jclouds/compute/domain/os/OsFamilyVersion64Bit.java @@ -17,14 +17,24 @@ * ==================================================================== */ -package org.jclouds.compute; +package org.jclouds.compute.domain.os; import org.jclouds.compute.domain.OsFamily; +/** + * + * @author Adrian Cole + * + */ public class OsFamilyVersion64Bit { - public final OsFamily family; - public final String version; - public final boolean is64Bit; + public OsFamily family; + public String version; + public boolean is64Bit; + + // for serialization + OsFamilyVersion64Bit() { + + } public OsFamilyVersion64Bit(OsFamily family, String version, boolean is64Bit) { this.family = family; diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index ddf8fcc2e6..a40c075c42 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -36,6 +36,7 @@ import org.jclouds.Constants; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.json.Json; import org.jclouds.json.config.GsonModule; diff --git a/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java b/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java new file mode 100644 index 0000000000..ea12b435d2 --- /dev/null +++ b/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java @@ -0,0 +1,70 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.elasticstack.compute.functions; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.ImageBuilder; +import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.domain.Credentials; +import org.jclouds.domain.Location; +import org.jclouds.elasticstack.domain.DriveInfo; +import org.jclouds.elasticstack.domain.WellKnownImage; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; + +/** + * @author Adrian Cole + */ +@Singleton +public class WellKnownImageToImage implements Function { + private final Supplier locationSupplier; + private final Map preinstalledImages; + + @Inject + public WellKnownImageToImage(Supplier locationSupplier, Map preinstalledImages) { + this.locationSupplier = locationSupplier; + this.preinstalledImages = preinstalledImages; + } + + @Override + public Image apply(DriveInfo drive) { + WellKnownImage input = preinstalledImages.get(drive.getUuid()); + return new ImageBuilder() + .ids(drive.getUuid()) + .userMetadata( + ImmutableMap. builder().putAll(drive.getUserMetadata()) + .put("size", input.getSize() + "").build()) + .defaultCredentials(new Credentials("toor", null)) + .location(locationSupplier.get()) + .name(input.getDescription()) + .description(drive.getName()) + .operatingSystem( + new OperatingSystemBuilder().family(input.getOsFamily()).version(input.getOsVersion()) + .name(input.getDescription()).description(drive.getName()).is64Bit(true).build()).version("") + .build(); + } +} \ No newline at end of file diff --git a/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackTemplateBuilderLiveTest.java b/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackTemplateBuilderLiveTest.java index d1d09b1e8d..1808c71a83 100644 --- a/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackTemplateBuilderLiveTest.java +++ b/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackTemplateBuilderLiveTest.java @@ -20,8 +20,8 @@ package org.jclouds.elasticstack.compute; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index ab09cf3337..57f881899b 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -25,9 +25,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java index 0eb104d29a..8152a48dc7 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersTemplateBuilderLiveTest.java @@ -20,8 +20,8 @@ package org.jclouds.rackspace.cloudservers.compute; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index 4206b962db..72256eea09 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -20,8 +20,8 @@ package org.jclouds.rimuhosting.miro.compute; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index cf88d5ac72..c001b33f05 100644 --- a/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -25,9 +25,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java index 95845f31a0..3770e566b8 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -25,9 +25,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index 514b15fac3..c30a81d0c4 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -25,9 +25,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate;