You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/07/16 11:20:47 UTC

[5/9] [JCLOUDS-474] refactor SoftLayer support

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java
index eb39aa8..5b0dc44 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java
@@ -19,9 +19,8 @@ package org.jclouds.softlayer;
 import org.jclouds.providers.internal.BaseProviderMetadataTest;
 import org.testng.annotations.Test;
 
-@Test(groups = "unit", testName = "SoftLayerProviderTest")
+@Test(groups = "unit", testName = "SoftLayerApiMetadataTest")
 public class SoftLayerProviderTest extends BaseProviderMetadataTest {
-
    public SoftLayerProviderTest() {
       super(new SoftLayerProviderMetadata(), new SoftLayerApiMetadata());
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/ProductOrderToJsonTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/ProductOrderToJsonTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/ProductOrderToJsonTest.java
deleted file mode 100644
index d3fae78..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/ProductOrderToJsonTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.softlayer.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.json.internal.GsonWrapper;
-import org.jclouds.rest.Binder;
-import org.jclouds.softlayer.domain.ProductItemPrice;
-import org.jclouds.softlayer.domain.ProductOrder;
-import org.jclouds.softlayer.domain.VirtualGuest;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.gson.Gson;
-
-/**
- * Tests behavior of {@code ProductOrderToJsonTest}
- */
-@Test(groups = "unit")
-public class ProductOrderToJsonTest {
-
-   private static final String FORMAT =
-         "{'parameters':[{'complexType':'SoftLayer_Container_Product_Order_Virtual_Guest'," +
-                         "'packageId':%d," +
-                         "'location':'%s'," +
-                         "'prices':[{'id':%d},{'id':%d}]," +
-                         "'virtualGuests':[{'hostname':'%s','domain':'%s'}]," +
-                         "'quantity':%d," +
-                         "'useHourlyPricing':%b}" +
-                       "]}";
-
-   private HttpRequest request;
-   private Binder binder;
-
-   @BeforeGroups(groups = { "unit" })
-   public void setup() {
-      request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
-      Json json = new GsonWrapper(new Gson());
-      binder = new ProductOrderToJson(json);
-   }
-
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testNullOrder() {
-      binder.bindToRequest(request, null);
-   }
-
-   @Test
-   public void testCorrect() {
-
-      ProductItemPrice price1 = ProductItemPrice.builder().id(100).build();
-      ProductItemPrice price2 = ProductItemPrice.builder().id(101).build();
-
-      VirtualGuest guest = VirtualGuest.builder().hostname("myhost")
-                                                 .domain("mydomain")
-                                                 .build();
-
-      ProductOrder order = ProductOrder.builder()
-                                       .packageId(123)
-                                       .location("loc456")
-                                       .quantity(99)
-                                       .useHourlyPricing(true)
-                                       .prices(ImmutableSet.of(price1, price2))
-                                       .virtualGuests(guest)
-                                       .build();
-      
-      String expected = String.format(FORMAT.replaceAll("'", "\""),
-                                      123, "loc456", 100, 101, "myhost", "mydomain", 99, true);
-
-      HttpRequest req = binder.bindToRequest(request, order);
-
-      assertEquals(req.getPayload().getRawContent(), expected);
-
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/TagToJsonTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/TagToJsonTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/TagToJsonTest.java
new file mode 100644
index 0000000..58c9624
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/TagToJsonTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.binders;
+
+import static org.testng.Assert.assertEquals;
+import java.util.Set;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.json.Json;
+import org.jclouds.json.internal.GsonWrapper;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.gson.Gson;
+
+@Test(groups = "unit", testName = "TagToJsonTest")
+public class TagToJsonTest {
+
+   private Json json;
+
+   @BeforeClass
+   public void init() {
+      json = new GsonWrapper(new Gson());
+   }
+
+   @Test
+   public void testVirtualGuestWithOperatingSystem() {
+      HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest").build();
+      TagToJson binder = new TagToJson(json);
+      Set<String> tags = ImmutableSet.of("jclouds");
+
+      request = binder.bindToRequest(request, tags);
+
+      assertEquals(request.getPayload().getRawContent(), "{\"parameters\":[\"jclouds\"]}");
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java
new file mode 100644
index 0000000..3adf0dc
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.json.Json;
+import org.jclouds.json.internal.GsonWrapper;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.jclouds.softlayer.domain.OperatingSystem;
+import org.jclouds.softlayer.domain.VirtualGuest;
+import org.jclouds.softlayer.domain.VirtualGuestBlockDeviceTemplateGroup;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.gson.Gson;
+
+@Test(groups = "unit", testName = "VirtualGuestToJsonTest")
+public class VirtualGuestToJsonTest {
+
+   private Json json;
+
+   @BeforeClass
+   public void init() {
+      json = new GsonWrapper(new Gson());
+   }
+
+   @Test
+   public void testVirtualGuestWithOperatingSystem() {
+      HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest").build();
+      VirtualGuestToJson binder = new VirtualGuestToJson(json);
+      VirtualGuest virtualGuestWithOS = VirtualGuest.builder()
+              .hostname("hostname")
+              .domain("domain")
+              .startCpus(1)
+              .maxMemory(1024)
+              .datacenter(Datacenter.builder()
+                      .name("datacenterName")
+                      .build())
+              .operatingSystem(OperatingSystem.builder().id("123456789")
+                      .operatingSystemReferenceCode("UBUNTU_12_64")
+                      .build())
+              .localDiskFlag(true)
+              .build();
+
+      request = binder.bindToRequest(request, virtualGuestWithOS);
+
+      assertEquals(request.getPayload().getRawContent(),
+                     "{" +
+                      "\"parameters\":[" +
+                      "{" +
+                      "\"hostname\":\"hostname\"," +
+                      "\"domain\":\"domain\"," +
+                      "\"startCpus\":1," +
+                      "\"maxMemory\":1024," +
+                      "\"hourlyBillingFlag\":true," +
+                      "\"operatingSystemReferenceCode\":\"UBUNTU_12_64\"," +
+                      "\"localDiskFlag\":true," +
+                      "\"datacenter\":{" +
+                      "\"name\":\"datacenterName\"" +
+                      "}" +
+                      "}" +
+                      "]" +
+                      "}");
+   }
+
+   @Test
+   public void testVirtualGuestWithVirtualGuestBlockDeviceTemplateGroup() {
+      HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest").build();
+      VirtualGuestToJson binder = new VirtualGuestToJson(json);
+      VirtualGuest virtualGuestWithOS = VirtualGuest.builder()
+              .hostname("hostname")
+              .domain("domain")
+              .startCpus(1)
+              .maxMemory(1024)
+              .datacenter(Datacenter.builder()
+                      .name("datacenterName")
+                      .build())
+              .blockDeviceTemplateGroup(VirtualGuestBlockDeviceTemplateGroup.builder()
+                      .globalIdentifier("ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0")
+                      .build())
+              .localDiskFlag(true)
+              .build();
+
+      request = binder.bindToRequest(request, virtualGuestWithOS);
+
+      assertEquals(request.getPayload().getRawContent(),
+              "{" +
+              "\"parameters\":[{" +
+              "\"hostname\":\"hostname\"," +
+              "\"domain\":\"domain\"," +
+              "\"startCpus\":1," +
+              "\"maxMemory\":1024," +
+              "\"hourlyBillingFlag\":true," +
+              "\"blockDeviceTemplateGroup\":{" +
+              "\"globalIdentifier\":\"ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0\"" +
+              "}," +
+               "\"localDiskFlag\":true," +
+               "\"datacenter\":{" +
+               "\"name\":\"datacenterName\"" +
+               "}" +
+               "}" +
+               "]" +
+               "}");
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
index 61a8b82..327150c 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
@@ -16,14 +16,15 @@
  */
 package org.jclouds.softlayer.compute;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
-import java.util.Properties;
-import java.util.Random;
-
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
+import com.google.common.net.InetAddresses;
+import com.google.inject.Injector;
+import com.google.inject.Module;
 import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
 import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.Hardware;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
 import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
@@ -32,7 +33,6 @@ import org.jclouds.domain.LoginCredentials;
 import org.jclouds.softlayer.SoftLayerApi;
 import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
 import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter;
-import org.jclouds.softlayer.domain.ProductItem;
 import org.jclouds.softlayer.domain.VirtualGuest;
 import org.jclouds.softlayer.features.BaseSoftLayerApiLiveTest;
 import org.jclouds.ssh.SshClient;
@@ -41,12 +41,12 @@ import org.jclouds.sshj.config.SshjSshClientModule;
 import org.testng.annotations.AfterGroups;
 import org.testng.annotations.Test;
 
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.net.HostAndPort;
-import com.google.common.net.InetAddresses;
-import com.google.inject.Injector;
-import com.google.inject.Module;
+import java.util.Properties;
+import java.util.Random;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
 
 @Test(groups = "live", singleThreaded = true, testName = "SoftLayerComputeServiceAdapterLiveTest")
 public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerApiLiveTest {
@@ -67,7 +67,12 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerApiLive
 
    @Test
    public void testListLocations() {
-      assertFalse(Iterables.isEmpty(adapter.listLocations()));
+      assertFalse(Iterables.isEmpty(adapter.listLocations()), "locations must not be empty");
+   }
+
+   @Test
+   public void testListImages() {
+      assertFalse(Iterables.isEmpty(adapter.listImages()), "images must not be empty");
    }
 
    private static final PrioritizeCredentialsFromTemplate prioritizeCredentialsFromTemplate = new PrioritizeCredentialsFromTemplate(
@@ -108,19 +113,19 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerApiLive
 
    @Test
    public void testListHardwareProfiles() {
-      Iterable<Iterable<ProductItem>> profiles = adapter.listHardwareProfiles();
+      Iterable<Hardware> profiles = adapter.listHardwareProfiles();
       assertFalse(Iterables.isEmpty(profiles));
 
-      for (Iterable<ProductItem> profile : profiles) {
-         // CPU, RAM and Volume
-         assertEquals(Iterables.size(profile), 3);
+      for (Hardware profile : profiles) {
+         assertNotNull(profile);
       }
    }
 
    @AfterGroups(groups = "live")
    protected void tearDown() {
-      if (guest != null)
+      if (guest != null) {
          adapter.destroyNode(guest.getNodeId() + "");
+      }
       super.tearDown();
    }
 
@@ -128,4 +133,11 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerApiLive
    protected Iterable<Module> setupModules() {
       return ImmutableSet.<Module> of(getLoggingModule(), new SshjSshClientModule());
    }
+
+   @Override
+   protected Properties setupProperties() {
+      Properties properties = super.setupProperties();
+      properties.setProperty("jclouds.ssh.max-retries", "10");
+      return properties;
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java
new file mode 100644
index 0000000..6c6fb51
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.compute;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.ContextBuilder;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
+import org.jclouds.softlayer.SoftLayerApi;
+import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
+import org.jclouds.softlayer.domain.VirtualGuest;
+import org.jclouds.softlayer.domain.VirtualGuestBlockDevice;
+import org.jclouds.ssh.SshClient;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+import java.util.Set;
+
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "live", testName = "SoftLayerComputeServiceContextLiveTest")
+public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceContextLiveTest {
+
+   @Resource
+   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+   protected Logger logger = Logger.NULL;
+
+   public SoftLayerComputeServiceContextLiveTest() {
+      provider = "softlayer";
+   }
+
+   @Test
+   public void testLaunchClusterWithMinDisk() throws RunNodesException {
+      int numNodes = 1;
+      final String name = "node";
+
+      ComputeServiceContext context = ContextBuilder.newBuilder("softlayer").credentials(identity, credential)
+              .modules(ImmutableSet.of(new SLF4JLoggingModule(),
+                      new SshjSshClientModule()))
+              .build(ComputeServiceContext.class);
+
+      TemplateBuilder templateBuilder = context.getComputeService().templateBuilder();
+      //templateBuilder.minDisk(15d);
+      //templateBuilder.hardwareId("cpu=1,memory=4096,disk=100,type=SAN");
+      //templateBuilder.hardwareId("cpu=1,memory=4096,disk=100,type=LOCAL");
+      templateBuilder.imageId("CENTOS_6_64");
+      //templateBuilder.osFamily(OsFamily.CENTOS);
+      //templateBuilder.imageId("7bcd78dc-eb11-4e1b-8d93-111c62ed5fd1");
+      //templateBuilder.locationId("dal01");
+      //templateBuilder.minRam(8192);
+
+      Template template = templateBuilder.build();
+      // test passing custom options
+      SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class);
+      options.domainName("live.org");
+      //options.diskType("SAN");
+      //options.portSpeed(10);
+      // multi-disk option
+      options.blockDevices(ImmutableSet.of(100));
+      //tags
+      options.tags(ImmutableList.of("jclouds"));
+
+      Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(name, numNodes, template);
+      assertEquals(numNodes, nodes.size(), "wrong number of nodes");
+      for (NodeMetadata node : nodes) {
+         logger.debug("Created Node: %s", node);
+         SshClient client = context.utils().sshForNode().apply(node);
+         client.connect();
+         ExecResponse hello = client.exec("mount");
+         logger.debug(hello.getOutput().trim());
+
+         VirtualGuest virtualGuest = context.unwrapApi(SoftLayerApi.class).getVirtualGuestApi()
+                 .getVirtualGuest(Long.parseLong(node.getId()));
+         for (VirtualGuestBlockDevice blockDevice : virtualGuest.getVirtualGuestBlockDevices()) {
+            logger.debug(blockDevice.toString());
+         }
+
+         context.getComputeService().destroyNode(node.getId());
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java
index 48a858a..d513240 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java
@@ -16,6 +16,8 @@
  */
 package org.jclouds.softlayer.compute;
 
+import java.util.Properties;
+
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
 import org.jclouds.sshj.config.SshjSshClientModule;
@@ -25,10 +27,10 @@ import com.google.common.collect.ImmutableMap;
 import com.google.inject.Module;
 
 /**
- * 
+ *
  * Generally disabled, as it incurs higher fees.
  */
-@Test(groups = "live", enabled = true, sequential = true)
+@Test(groups = "live", enabled = true, singleThreaded = true)
 public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest {
 
    public SoftLayerComputeServiceLiveTest() {
@@ -40,7 +42,7 @@ public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest
    protected Module getSshModule() {
       return new SshjSshClientModule();
    }
-   
+
    // softlayer does not support metadata
    @Override
    protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
@@ -52,4 +54,11 @@ public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest
    public void testOptionToNotBlock() {
       // start call is blocking anyway.
    }
+
+   @Override
+   protected Properties setupProperties() {
+      Properties properties = super.setupProperties();
+      properties.setProperty("jclouds.ssh.max-retries", "20");
+      return properties;
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java
index 8872c1c..5ef638c 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java
@@ -16,17 +16,9 @@
  */
 package org.jclouds.softlayer.compute;
 
-import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
-import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
-import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX;
-import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE;
-import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Set;
-
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableSet;
 import org.jclouds.compute.ComputeServiceContext;
 import org.jclouds.compute.domain.OsFamily;
 import org.jclouds.compute.domain.OsFamilyVersion64Bit;
@@ -34,15 +26,22 @@ import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.Volume;
 import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
 import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableSet;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Set;
 
-@Test(groups = "live")
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
+import static org.testng.Assert.assertEquals;
+
+@Test(groups = "live", alwaysRun = false)
 public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
 
+   public static final int MAX_RAM = 64 * 1024;
+
    public SoftLayerTemplateBuilderLiveTest() {
       provider = "softlayer";
    }
@@ -57,15 +56,18 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
             // For each os-type both 32- and 64-bit are supported.
             switch (input.family) {
             case UBUNTU:
-               return input.version.equals("") || input.version.equals("10.04") || input.version.equals("12.04") || input.version.equals("8");
+               return input.version.equals("") || input.version.equals("10.04") || input.version.equals("12.04") ||
+                       input.version.equals("8.04");
             case DEBIAN:
                return input.version.equals("") || input.version.matches("[56].0");
             case FEDORA:
                return input.version.equals("") || input.version.equals("13") || input.version.equals("15");
             case RHEL:
-               return input.version.equals("") || input.version.equals("5") || input.version.equals("6");
+               return input.version.equals("") || input.version.equals("5") || input.version.equals("6") ||
+                       input.version.equals("6.1") || input.version.equals("5.4") || input.version.equals("5.7");
             case CENTOS:
-               return input.version.equals("") || input.version.equals("5") || input.version.equals("6.0");
+               return input.version.equals("") || input.version.equals("5") || input.version.equals("6.0") ||
+                       input.version.equals("6.1") || input.version.equals("6.2") || input.version.equals("6");
             case WINDOWS:
                return input.version.equals("") || input.version.equals("2003") || input.version.equals("2008");
             default:
@@ -83,7 +85,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
       assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
       assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
       assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
-      assertEquals(defaultTemplate.getHardware().getRam(), 1 * 1024);
+      assertEquals(defaultTemplate.getHardware().getRam(), 1*1024);
       assertEquals(getSpace(defaultTemplate.getHardware()), 25.0d);
       assertEquals(defaultTemplate.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
       // test that we bound the correct templateoptions in guice
@@ -95,7 +97,6 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
       ComputeServiceContext context = null;
       try {
          Properties overrides = setupProperties();
-         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000");
 
          context = createView(overrides, setupModules());
 
@@ -113,8 +114,6 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
       ComputeServiceContext context = null;
       try {
          Properties overrides = setupProperties();
-         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100");
-
          context = createView(overrides, setupModules());
 
          // TODO add something to the template about port speed?
@@ -127,37 +126,15 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
    }
 
    @Test
-   public void testBiggestTemplateBuilderWhenBootIsSAN() throws IOException {
-      ComputeServiceContext context = null;
-      try {
-         Properties overrides = setupProperties();
-         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "SAN");
-
-         context = createView(overrides, setupModules());
-
-         Template template = context.getComputeService().templateBuilder().biggest().build();
-         assertEquals(getCores(template.getHardware()), 16.0d);
-         assertEquals(template.getHardware().getRam(), 16 * 1024);
-         assertEquals(getSpace(template.getHardware()), 100.0d);
-         assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.SAN);
-      } finally {
-         if (context != null)
-            context.close();
-      }
-   }
-
-   @Test
    public void testDefaultTemplateBuilderWhenPrivateNetwork() throws IOException {
       ComputeServiceContext context = null;
       try {
          Properties overrides = setupProperties();
-         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?");
-
          context = createView(overrides, setupModules());
 
          Template template = context.getComputeService().templateBuilder().build();
          assertEquals(getCores(template.getHardware()), 1.0d);
-         assertEquals(template.getHardware().getRam(), 1 * 1024);
+         assertEquals(template.getHardware().getRam(), 1*1024);
          assertEquals(getSpace(template.getHardware()), 25.0d);
          assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
       } finally {
@@ -167,30 +144,10 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
    }
 
    @Test
-   public void testBiggestTemplateBuilderWhenPrivateNetwork() throws IOException {
-      ComputeServiceContext context = null;
-      try {
-         Properties overrides = setupProperties();
-         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?");
-
-         context = createView(overrides, setupModules());
-         
-         Template template = context.getComputeService().templateBuilder().biggest().build();
-         assertEquals(getCores(template.getHardware()), 8.0d);
-         assertEquals(template.getHardware().getRam(), 16 * 1024);
-         assertEquals(getSpace(template.getHardware()), 100.0d);
-         assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
-      } finally {
-         if (context != null)
-            context.close();
-      }
-   }
-
-   @Test
    public void testFastestTemplateBuilder() throws IOException {
       Template template = view.getComputeService().templateBuilder().fastest().build();
       assertEquals(getCores(template.getHardware()), 16.0d);
-      assertEquals(template.getHardware().getRam(), 1 * 1024);
+      assertEquals(template.getHardware().getRam(), 1*1024);
       assertEquals(getSpace(template.getHardware()), 25.0d);
       assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
    }
@@ -199,14 +156,19 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
    public void testBiggestTemplateBuilder() throws IOException {
       Template template = view.getComputeService().templateBuilder().biggest().build();
       assertEquals(getCores(template.getHardware()), 16.0d);
-      assertEquals(template.getHardware().getRam(), 16 * 1024);
+      assertEquals(template.getHardware().getRam(), MAX_RAM);
       assertEquals(getSpace(template.getHardware()), 100.0d);
       assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL);
    }
 
    @Override
    protected Set<String> getIso3166Codes() {
-      return ImmutableSet.<String> of("SG", "US-CA", "US-TX", "US-VA", "US-WA", "NL");
+      return ImmutableSet.<String> of("SG", "US-CA", "US-TX", "US-VA", "US-WA", "NL", "HK", "NSFTW-IL");
    }
 
+   @BeforeClass(groups = "live")
+   @Override
+   public void setupContext() {
+      super.setupContext();
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/DatacenterToLocationTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/DatacenterToLocationTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/DatacenterToLocationTest.java
index 0a54f4c..cd5970f 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/DatacenterToLocationTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/DatacenterToLocationTest.java
@@ -44,11 +44,12 @@ public class DatacenterToLocationTest {
    public void testDatacenterToLocation() {
       Address address = Address.builder().country("US").state("TX").description("This is Texas!").build();
 
-      Datacenter datacenter = Datacenter.builder().id(1).longName("Texas Datacenter").locationAddress(address).build();
+      Datacenter datacenter = Datacenter.builder().id(1).name("Texas").longName("Texas Datacenter")
+              .locationAddress(address).build();
 
       Location location = function.apply(datacenter);
 
-      assertEquals(location.getId(), Long.toString(datacenter.getId()));
+      assertEquals(location.getId(), datacenter.getName());
       Set<String> iso3166Codes = location.getIso3166Codes();
       assertEquals(iso3166Codes.size(), 1);
       assertTrue(iso3166Codes.contains("US-TX"));
@@ -56,11 +57,11 @@ public class DatacenterToLocationTest {
 
    @Test
    public void testGetIso3166CodeNoCountryAndState() {
-      Datacenter datacenter = Datacenter.builder().id(1).longName("Nowhere").build();
+      Datacenter datacenter = Datacenter.builder().id(1).name("Nowhere").longName("No where").build();
 
       Location location = function.apply(datacenter);
 
-      assertEquals(location.getId(), Long.toString(datacenter.getId()));
+      assertEquals(location.getId(), datacenter.getName());
       Set<String> iso3166Codes = location.getIso3166Codes();
       assertEquals(iso3166Codes.size(), 0);
    }
@@ -69,11 +70,12 @@ public class DatacenterToLocationTest {
    public void testGetIso3166CodeCountryOnly() {
       Address address = Address.builder().country("US").description("This is North America!").build();
 
-      Datacenter datacenter = Datacenter.builder().id(1).longName("Nowhere").locationAddress(address).build();
+      Datacenter datacenter = Datacenter.builder().id(1).name("Nowhere").longName("No where").locationAddress(address)
+              .build();
 
       Location location = function.apply(datacenter);
 
-      assertEquals(location.getId(), Long.toString(datacenter.getId()));
+      assertEquals(location.getId(), datacenter.getName());
       Set<String> iso3166Codes = location.getIso3166Codes();
       assertEquals(iso3166Codes.size(), 1);
       assertTrue(iso3166Codes.contains("US"));
@@ -84,11 +86,12 @@ public class DatacenterToLocationTest {
       Address address = Address.builder().country(" US ").state("  TX  ").description("This is spaced out Texas")
             .build();
 
-      Datacenter datacenter = Datacenter.builder().id(1).longName("Nowhere").locationAddress(address).build();
+      Datacenter datacenter = Datacenter.builder().id(1).name("NoWhere").longName("Nowhere").locationAddress(address)
+             .build();
 
       Location location = function.apply(datacenter);
 
-      assertEquals(location.getId(), Long.toString(datacenter.getId()));
+      assertEquals(location.getId(), datacenter.getName());
       Set<String> iso3166Codes = location.getIso3166Codes();
       assertEquals(iso3166Codes.size(), 1);
       assertTrue(iso3166Codes.contains("US-TX"));

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/OperatingSystemToImageTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/OperatingSystemToImageTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/OperatingSystemToImageTest.java
new file mode 100644
index 0000000..dadc911
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/OperatingSystemToImageTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.softlayer.domain.OperatingSystem;
+import org.jclouds.softlayer.domain.SoftwareDescription;
+import org.jclouds.softlayer.domain.SoftwareLicense;
+import org.testng.annotations.Test;
+
+/**
+ * Tests the function that transforms SoftLayer OperatingSystem to generic image.
+ */
+@Test(groups="unit", testName = "OperatingSystemToImageTest")
+public class OperatingSystemToImageTest {
+
+   @Test
+   public void testOperatingSystemToImage() {
+      OperatingSystem operatingSystem = OperatingSystem.builder()
+              .id("123456789")
+              .softwareLicense(SoftwareLicense.builder()
+                      .softwareDescription(SoftwareDescription.builder()
+                              .version("12.04-64 Minimal for CCI")
+                              .referenceCode("UBUNTU_12_64")
+                              .longDescription("Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit)")
+                              .build())
+                      .build())
+              .build();
+      Image image = new OperatingSystemToImage().apply(operatingSystem);
+
+      assertEquals(image.getId(), operatingSystem.getId());
+      String referenceCode = operatingSystem.getSoftwareLicense().getSoftwareDescription().getReferenceCode();
+      assertEquals(image.getDescription(), referenceCode);
+      assertTrue(image.getOperatingSystem().getFamily().toString().equalsIgnoreCase("UBUNTU"));
+      assertEquals(image.getOperatingSystem().getVersion(), "12.04");
+      assertEquals(image.getOperatingSystem().is64Bit(), true);
+      assertEquals(image.getStatus(), Image.Status.AVAILABLE);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemToImageTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemToImageTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemToImageTest.java
deleted file mode 100644
index 8723064..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemToImageTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.softlayer.compute.functions;
-
-import static org.jclouds.softlayer.compute.functions.ProductItemToImage.imageId;
-import static org.jclouds.softlayer.compute.functions.ProductItemToImage.osBits;
-import static org.jclouds.softlayer.compute.functions.ProductItemToImage.osFamily;
-import static org.jclouds.softlayer.compute.functions.ProductItemToImage.osVersion;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.softlayer.domain.ProductItem;
-import org.jclouds.softlayer.domain.ProductItemPrice;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Tests {@code ProductItemToImage}
- */
-@Test(groups = "unit", testName = "ProductItemToImageTest")
-public class ProductItemToImageTest {
-   // Operating Systems available MAR 2012
-   private static final List<String> operatingSystems = Arrays.asList(
-         "CentOS 5 - LAMP Install (32 bit)",
-         "CentOS 5 - LAMP Install (64 bit)",
-         "CentOS 5 - Minimal Install (32 bit)",
-         "CentOS 5 - Minimal Install (64 bit)",
-         "CentOS 6.0 - LAMP Install (32 bit)",
-         "CentOS 6.0 - LAMP Install (64 bit)",
-         "CentOS 6.0 - Minimal Install (32 bit)",
-         "CentOS 6.0 - Minimal Install (64 bit)",
-         "Debian GNU/Linux 5.0 Lenny/Stable - LAMP Install (32 bit)",
-         "Debian GNU/Linux 5.0 Lenny/Stable - LAMP Install (64 bit)",
-         "Debian GNU/Linux 5.0 Lenny/Stable - Minimal Install (32 bit)",
-         "Debian GNU/Linux 5.0 Lenny/Stable - Minimal Install (64 bit)",
-         "Fedora Release 13 (32bit) - LAMP Install",
-         "Fedora Release 13 (32bit) - Minimal Install",
-         "Fedora Release 13 (64bit) - LAMP Install",
-         "Fedora Release 13 (64bit) - Minimal Install",
-         "Fedora Release 15 (32bit) - LAMP Install",
-         "Fedora Release 15 (32bit) - Minimal Install",
-         "Fedora Release 15 (64bit) - LAMP Install",
-         "Fedora Release 15 (64bit) - Minimal Install",
-         "Red Hat Enterprise Linux 5 - LAMP Install (32 bit)",
-         "Red Hat Enterprise Linux 5 - LAMP Install (64 bit)",
-         "Red Hat Enterprise Linux 5 - Minimal Install (64 bit)",
-         "Red Hat Enterprise Linux 6 - LAMP Install (32 bit)",
-         "Red Hat Enterprise Linux 6 - LAMP Install (64 bit)",
-         "Red Hat Enterprise Linux 6 - Minimal Install (32 bit)",
-         "Red Hat Enterprise Linux 6 - Minimal Install (64 bit)",
-         "Ubuntu Linux 10.04 LTS Lucid Lynx - LAMP Install (32 bit)",
-         "Ubuntu Linux 10.04 LTS Lucid Lynx - LAMP Install (64 bit)",
-         "Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install (32 bit)",
-         "Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install (64 bit)",
-         "Ubuntu Linux 8 LTS Hardy Heron - LAMP Install (32 bit)",
-         "Ubuntu Linux 8 LTS Hardy Heron - LAMP Install (64 bit)",
-         "Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (32 bit)",
-         "Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)",
-         "CloudLinux 6 (32 bit)", 
-         "CloudLinux 6 (64 bit)",          
-         "Windows Server 2003 Datacenter SP2 with R2 (32 bit)",
-         "Windows Server 2003 Datacenter SP2 with R2 (64 bit)",
-         "Windows Server 2003 Enterprise SP2 with R2 (64 bit)",
-         "Windows Server 2003 Standard SP2 with R2 (64 bit)",
-         "Windows Server 2008 Datacenter Edition SP2 (32bit)",
-         "Windows Server 2008 Datacenter Edition SP2 (64bit)",
-         "Windows Server 2008 Enterprise Edition SP2 (32bit)",
-         "Windows Server 2008 Enterprise Edition SP2 (64bit)",
-         "Windows Server 2008 R2 Datacenter Edition (64bit)",
-         "Windows Server 2008 R2 Enterprise Edition (64bit)",
-         "Windows Server 2008 R2 Standard Edition (64bit)",
-         "Windows Server 2008 Standard Edition SP2 (32bit)",
-         "Windows Server 2008 Standard Edition SP2 (64bit)");
-
-   @Test
-   public void testConversion() {
-      for ( String description : operatingSystems )
-      {
-         ProductItem item = ProductItem.builder()
-                                       .description(description)
-                                       .prices(ProductItemPrice.builder().id(1234).build())
-                                       .build();
-         Image i = new ProductItemToImage().apply(item);
-         OperatingSystem os = i.getOperatingSystem();
-         assertNotNull(os);
-         assertNotNull(os.getFamily());
-         assertFalse(os.getFamily().equals(OsFamily.UNRECOGNIZED));
-         assertNotNull(os.getVersion());
-      }
-   }
-
-   @Test
-   public void testUbuntu() {
-         ProductItem item = ProductItem.builder()
-                                       .description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install (64 bit)")
-                                       .prices(ProductItemPrice.builder().id(1234).build())
-                                       .build();
-         Image i = new ProductItemToImage().apply(item);
-         OperatingSystem os = i.getOperatingSystem();
-         assertNotNull(os);
-         assertEquals(OsFamily.UBUNTU, os.getFamily());
-         assertEquals("10.04", os.getVersion());
-         assertTrue(os.is64Bit());
-   }
-
-   @Test
-   public void testUbuntuNoBitCount() {
-      ProductItem item = ProductItem.builder()
-            .description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install")
-            .prices(ProductItemPrice.builder().id(1234).build())
-            .build();
-      Image i = new ProductItemToImage().apply(item);
-      OperatingSystem os = i.getOperatingSystem();
-      assertNotNull(os);
-      assertEquals(OsFamily.UBUNTU, os.getFamily());
-      assertEquals("10.04", os.getVersion());
-      assertFalse(os.is64Bit());
-   }
-
-
-   @Test
-   public void testCompletelyUnknown() {
-      ProductItem item = ProductItem.builder()
-            .description("This fails to match anything!!!")
-            .prices(ProductItemPrice.builder().id(1234).build())
-            .build();
-      Image i = new ProductItemToImage().apply(item);
-      OperatingSystem os = i.getOperatingSystem();
-      assertNotNull(os);
-      assertEquals(OsFamily.UNRECOGNIZED, os.getFamily());
-      assertNull(os.getVersion());
-      assertFalse(os.is64Bit());
-   }
-   
-   @Test
-   public void test64BitUnknown() {
-      ProductItem item = ProductItem.builder()
-            .description("This only has the bit-count (64 bit)")
-            .prices(ProductItemPrice.builder().id(1234).build())
-            .build();
-      Image i = new ProductItemToImage().apply(item);
-      OperatingSystem os = i.getOperatingSystem();
-      assertNotNull(os);
-      assertEquals(OsFamily.UNRECOGNIZED, os.getFamily());
-      assertNull(os.getVersion());
-      assertTrue(os.is64Bit());
-   }
-
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testNull() {
-      new ProductItemToImage().apply(null);
-   }
-   
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testNoDescription() {
-      ProductItem item = ProductItem.builder()
-            .prices(ProductItemPrice.builder().id(1234).build())
-            .build();
-      new ProductItemToImage().apply(item);
-   }
-   
-   @Test
-   public void testId() {
-      ProductItemPrice price = ProductItemPrice.builder().id(1234).build();
-      ProductItem item = ProductItem.builder().prices(price).build();
-      assertEquals("1234", imageId().apply(item));
-   }
-
-   @Test
-   public void testIdManyPrices() {
-      ProductItemPrice price1 = ProductItemPrice.builder().id(1234).build();
-      ProductItemPrice price2 = ProductItemPrice.builder().id(5678).build();
-      ProductItem item = ProductItem.builder().prices(ImmutableSet.of(price1, price2)).build();
-      assertEquals("1234", imageId().apply(item));
-   }
-
-   @Test(expectedExceptions = NoSuchElementException.class)
-   public void testIdMissingPrices() {
-      ProductItem item = ProductItem.builder().build();
-      imageId().apply(item);
-   }
-   
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testIdNull() {
-      imageId().apply(null);
-   }
-
-   @Test
-   public void testOsFamily() {
-      assertEquals(OsFamily.UBUNTU, osFamily().apply("Ubuntu Linux os"));
-   }
-
-   @Test
-   public void testOsFamilyUnrecognized() {
-      assertEquals(OsFamily.UNRECOGNIZED, osFamily().apply("not a known operating system"));
-   }
-   
-   @Test
-   public void testOsFamilyNull() {
-      assertEquals(OsFamily.UNRECOGNIZED, osFamily().apply(null));
-   }
-
-   @Test
-   public void testOsBitsWithSpace() {
-      assertEquals(osBits().apply("a (32 bit) os"), Integer.valueOf(32));
-   }
-
-   @Test
-   public void testOsBitsNoSpace() {
-      assertEquals(osBits().apply("a (64bit) os"), Integer.valueOf(64));
-   }
-
-   @Test
-   public void testOsBitsMissing() {
-      assertNull(osBits().apply("an os"));
-   }
-
-   @Test
-   public void testOsBitsNull() {
-      assertNull(osBits().apply(null));
-   }
-
-   @Test
-   public void testOsVersion() {
-      assertEquals("2099", osVersion().apply("Windows Server 2099 (256 bit)"));
-   }
-
-   @Test
-   public void testOsVersionMissing() {
-      assertNull(osVersion().apply("asd Server"));
-   }
-
-   @Test
-   public void testOsVersionNull() {
-      assertNull(osVersion().apply(null));
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java
deleted file mode 100644
index bfc602e..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.softlayer.compute.functions;
-
-import static org.jclouds.softlayer.compute.functions.ProductItems.capacity;
-import static org.jclouds.softlayer.compute.functions.ProductItems.description;
-import static org.jclouds.softlayer.compute.functions.ProductItems.item;
-import static org.jclouds.softlayer.compute.functions.ProductItems.price;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-
-import java.util.NoSuchElementException;
-
-import org.jclouds.softlayer.domain.ProductItem;
-import org.jclouds.softlayer.domain.ProductItemCategory;
-import org.jclouds.softlayer.domain.ProductItemPrice;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Tests {@code ProductItems}
- */
-@Test(groups = "unit")
-public class ProductItemsTest {
-
-   private ProductItemCategory category;
-   private ProductItemPrice price;
-   private ProductItem item;
-
-   @BeforeMethod
-   public void setup() {
-
-       category = ProductItemCategory.builder().id(1).categoryCode("category").build();
-
-       price = ProductItemPrice.builder().id(1).build();
-
-       item = ProductItem.builder().id(1)
-                                   .capacity(2.0f)
-                                   .description("an item")
-                                   .prices(price)
-                                   .build();
-   }
-
-   @Test
-   public void testCapacity() {
-       assertEquals(capacity().apply(item), 2.0f);
-   }
-
-   @Test
-   public void testCapacityMissing() {
-       ProductItem item = ProductItem.builder().id(1).build();
-       assertNull(capacity().apply(item));
-   }
-
-   @Test
-   public void testDescription() {
-       assertEquals(description().apply(item), "an item");
-   }
-
-   @Test
-   public void testDescriptionMissing() {
-       ProductItem item = ProductItem.builder().id(1).build();
-       assertNull(description().apply(item));
-   }
-
-   @Test
-   public void testPrice() {
-      assertEquals(price().apply(item), price);
-   }
-
-   @Test
-   public void testPriceMultiplePrices() {
-       ImmutableSet<ProductItemPrice> prices = ImmutableSet.of(price, ProductItemPrice.builder().id(2).build());
-       ProductItem item2 = ProductItem.builder().prices(prices).build();
-       assertEquals(price().apply(item2), price);
-   }
-
-   @Test(expectedExceptions = NoSuchElementException.class)
-   public void testPriceMissing() {
-      ProductItem noPriceItem = ProductItem.builder().id(1).build();
-      price().apply(noPriceItem);
-   }
-   
-   @Test
-   public void testItemCallGetsCategory() {
-      ProductItemPrice price = ProductItemPrice.builder().id(1)
-                                                         .categories(category)
-                                                         .item(item)
-                                                         .build();
-      ProductItem newItem = item().apply(price);
-      assertEquals(newItem.getCategories(), ImmutableSet.of(category));
-   }
-
-   @Test
-   public void testItemCallNoCategoryOnPrice() {
-
-      ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category)).build();
-
-      ProductItemPrice price = ProductItemPrice.builder().id(1)
-                                                         .item(item1)
-                                                         .build();
-      ProductItem newItem = item().apply(price);
-      assertEquals(newItem.getCategories(), ImmutableSet.of(category));
-   }
-
-   @Test
-   public void testItemCallCategoryExists() {
-
-      ProductItemCategory category2 = ProductItemCategory.builder()
-            .id(12)
-            .categoryCode("new category")
-            .build();
-
-      ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category2)).build();
-
-      ProductItemPrice price = ProductItemPrice.builder().id(1)
-                                                         .categories(category)
-                                                         .item(item1)
-                                                         .build();
-      ProductItem newItem = item().apply(price);
-      assertEquals(newItem.getCategories(), ImmutableSet.of(category2));
-   }
-
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java
deleted file mode 100644
index 94db760..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.softlayer.compute.functions;
-
-import static com.google.inject.name.Names.bindProperties;
-import static org.jclouds.softlayer.compute.functions.ProductItemsToHardware.hardwareId;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.util.List;
-
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume;
-import org.jclouds.softlayer.SoftLayerProviderMetadata;
-import org.jclouds.softlayer.domain.ProductItem;
-import org.jclouds.softlayer.domain.ProductItemCategory;
-import org.jclouds.softlayer.domain.ProductItemPrice;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-
-/**
- * Tests {@code ProductItemsToHardware}
- */
-@Test(groups = "unit")
-public class ProductItemsToHardwareTest {
-
-   private ProductItemsToHardware toHardware;
-   private ProductItem cpuItem;
-   private ProductItem ramItem;
-   private ProductItem volumeItem;
-
-   @BeforeMethod
-   public void setup() {
-
-      toHardware = Guice.createInjector(new AbstractModule() {
-         @Override
-         protected void configure() {
-            bindProperties(binder(), new SoftLayerProviderMetadata().getDefaultProperties());
-         }
-      }).getInstance(ProductItemsToHardware.class);
-
-
-      cpuItem = ProductItem.builder()
-            .id(1)
-            .description("2 x 2.0 GHz Cores")
-            .capacity(2F)
-            .categories(ProductItemCategory.builder().categoryCode("guest_core").build())
-            .prices(ProductItemPrice.builder().id(123).build())
-            .build();
-
-      ramItem = ProductItem.builder().id(2).description("2GB ram").capacity(2F).categories(
-            ProductItemCategory.builder().categoryCode("ram").build()).prices(
-            ProductItemPrice.builder().id(456).build()).build();
-
-      volumeItem = ProductItem.builder().id(3).description("100 GB (SAN)").capacity(100F).prices(
-            ProductItemPrice.builder().id(789).build()).categories(
-            ProductItemCategory.builder().categoryCode("guest_disk0").build()).build();
-
-
-   }
-
-   @Test
-   public void testHardwareId() {
-      ProductItem item1 = ProductItem.builder().prices(ProductItemPrice.builder().id(123).build()).build();
-      ProductItem item2 = ProductItem.builder().prices(ProductItemPrice.builder().id(456).build()).build();
-      ProductItem item3 = ProductItem.builder().prices(ProductItemPrice.builder().id(789).build()).build();
-
-      String id = hardwareId().apply(ImmutableList.of(item1, item2, item3));
-      assertEquals("123,456,789", id);
-   }
-
-   @Test
-   public void testHardware() {
-
-      Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem));
-
-      assertEquals("123,456,789", hardware.getId());
-
-      List<? extends Processor> processors = hardware.getProcessors();
-      assertEquals(1, processors.size());
-      assertEquals(2.0, processors.get(0).getCores());
-
-      assertEquals(2048, hardware.getRam());
-
-      List<? extends Volume> volumes = hardware.getVolumes();
-      assertEquals(1, volumes.size());
-      Volume volume = volumes.get(0);
-      assertEquals(100F, volume.getSize());
-      assertEquals(Volume.Type.SAN, volume.getType());
-      assertEquals(true, volume.isBootDevice());
-
-   }
-
-   @Test
-   public void testHardwareWithPrivateCore() {
-
-     cpuItem = cpuItem.toBuilder()
-           .description("Private 2 x 2.0 GHz Cores")
-           .build();
-
-     Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem));
-
-     assertEquals("123,456,789", hardware.getId());
-
-     List<? extends Processor> processors = hardware.getProcessors();
-     assertEquals(1, processors.size());
-     assertEquals(2.0, processors.get(0).getCores());
-
-     assertEquals(2048, hardware.getRam());
-
-     List<? extends Volume> volumes = hardware.getVolumes();
-     assertEquals(1, volumes.size());
-     assertEquals(100F, volumes.get(0).getSize());
-   }
-
-   @Test
-   public void testHardwareWithTwoDisks() {
-      ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).prices(
-            ProductItemPrice.builder().id(987).build()).categories(
-            ProductItemCategory.builder().categoryCode("guest_disk1").build()).build();
-
-      Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem, localVolumeItem));
-
-      List<? extends Volume> volumes = hardware.getVolumes();
-      assertEquals(2, volumes.size());
-      Volume volume = volumes.get(0);
-      assertEquals(100F, volume.getSize());
-      assertEquals(Volume.Type.SAN, volume.getType());
-      assertEquals(true, volume.isBootDevice());
-
-      Volume volume1 = volumes.get(1);
-      assertEquals(25F, volume1.getSize());
-      assertEquals(Volume.Type.LOCAL, volume1.getType());
-      assertEquals(false, volume1.isBootDevice());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToHardwareTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToHardwareTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToHardwareTest.java
new file mode 100644
index 0000000..108c437
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToHardwareTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.jclouds.softlayer.domain.OperatingSystem;
+import org.jclouds.softlayer.domain.VirtualGuest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests the function that transforms SoftLayer VirtualGuest to generic hardware.
+ */
+@Test(groups="unit", testName = "VirtualGuestToHardwareTest")
+public class VirtualGuestToHardwareTest {
+
+   @Test
+   public void testVirtualGuestToHardware() {
+      VirtualGuest virtualGuest = createVirtualGuest();
+      Hardware hardware = new VirtualGuestToHardware().apply(virtualGuest);
+      assertNotNull(hardware);
+      assertEquals(hardware.getRam(), virtualGuest.getMaxMemory());
+      assertTrue(hardware.getProcessors().size() == 1);
+      assertEquals(Iterables.get(hardware.getProcessors(), 0).getCores(), (double) virtualGuest.getStartCpus());
+   }
+
+   private VirtualGuest createVirtualGuest() {
+      return VirtualGuest.builder()
+              .domain("example.com")
+              .hostname("host1")
+              .id(1301396)
+              .maxMemory(1024)
+              .startCpus(1)
+              .localDiskFlag(true)
+              .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST")
+                      .operatingSystemReferenceCode("UBUNTU_LATEST")
+                      .build())
+              .datacenter(Datacenter.builder().name("test").build())
+              .build();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToImageTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToImageTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToImageTest.java
new file mode 100644
index 0000000..b903a37
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToImageTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.softlayer.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.jclouds.softlayer.domain.OperatingSystem;
+import org.jclouds.softlayer.domain.SoftwareDescription;
+import org.jclouds.softlayer.domain.SoftwareLicense;
+import org.jclouds.softlayer.domain.VirtualGuest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+
+/**
+ * Tests the function that transforms SoftLayer VirtualGuest to generic image.
+ */
+@Test(groups="unit", testName = "VirtualGuestToImageTest")
+public class VirtualGuestToImageTest {
+
+   OperatingSystemToImage operatingSystemToImage = Guice.createInjector().getInstance(OperatingSystemToImage.class);
+
+   @Test
+   public void testVirtualGuestToImageWhenOperatingSystemIsNull() {
+      VirtualGuest virtualGuest = createVirtualGuestWithoutOperatingSystem();
+      Image image = new VirtualGuestToImage(operatingSystemToImage).apply(virtualGuest);
+      assertNotNull(image);
+      assertEquals(image.getStatus(), Image.Status.UNRECOGNIZED);
+      assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED);
+      assertEquals(image.getOperatingSystem().getVersion(), "UNRECOGNIZED");
+   }
+
+   @Test
+   public void testVirtualGuestToImageWhenVirtualGuestIsSoftwareLicense() {
+      VirtualGuest virtualGuest = createVirtualGuestWithoutSoftwareLicenseDetails();
+      Image image = new VirtualGuestToImage(operatingSystemToImage).apply(virtualGuest);
+      assertNotNull(image);
+      assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED);
+      assertEquals(image.getOperatingSystem().getVersion(), "UNRECOGNIZED");
+   }
+
+   @Test
+   public void testVirtualGuestToImageWithSoftwareLicense() {
+      VirtualGuest virtualGuest = createVirtualGuestWithSoftwareLicenseDetails();
+      Image image = new VirtualGuestToImage(operatingSystemToImage).apply(virtualGuest);
+      assertNotNull(image);
+      assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+      assertEquals(image.getOperatingSystem().getVersion(), "12.04");
+      assertEquals(image.getOperatingSystem().is64Bit(), true);
+   }
+
+   private VirtualGuest createVirtualGuestWithoutOperatingSystem() {
+      return VirtualGuest.builder()
+              .domain("example.com")
+              .hostname("host1")
+              .id(1301396)
+              .maxMemory(1024)
+              .startCpus(1)
+              .localDiskFlag(true)
+              .datacenter(Datacenter.builder().name("test").build())
+              .softwareLicense(SoftwareLicense.builder().build())
+              .build();
+   }
+
+   private VirtualGuest createVirtualGuestWithoutSoftwareLicenseDetails() {
+      return VirtualGuest.builder()
+              .domain("example.com")
+              .hostname("host1")
+              .id(1301396)
+              .maxMemory(1024)
+              .startCpus(1)
+              .localDiskFlag(true)
+              .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST")
+                      .operatingSystemReferenceCode("UBUNTU_LATEST")
+                      .build())
+              .datacenter(Datacenter.builder().name("test").build())
+              .build();
+   }
+
+   private VirtualGuest createVirtualGuestWithSoftwareLicenseDetails() {
+      return VirtualGuest.builder()
+              .domain("example.com")
+              .hostname("host1")
+              .id(1301396)
+              .maxMemory(1024)
+              .startCpus(1)
+              .localDiskFlag(true)
+              .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST")
+                      .operatingSystemReferenceCode("UBUNTU_LATEST")
+                      .softwareLicense(SoftwareLicense.builder()
+                              .softwareDescription(SoftwareDescription.builder()
+                                      .version("12.04-64 Minimal for CCI")
+                                      .referenceCode("UBUNTU_12_64")
+                                      .longDescription("Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit)")
+                                      .build())
+                              .build())
+                      .build())
+              .datacenter(Datacenter.builder().name("test").build())
+              .build();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/717a545b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
index 8fa91c9..637333b 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
@@ -16,198 +16,85 @@
  */
 package org.jclouds.softlayer.compute.functions;
 
-import static org.easymock.EasyMock.createNiceMock;
 import static org.testng.Assert.assertEquals;
-
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
 import java.util.Set;
 
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
 import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
 import org.jclouds.compute.functions.GroupNamingConvention;
 import org.jclouds.domain.Location;
-import org.jclouds.softlayer.SoftLayerApi;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.jclouds.softlayer.domain.OperatingSystem;
+import org.jclouds.softlayer.domain.PowerState;
+import org.jclouds.softlayer.domain.SoftwareDescription;
+import org.jclouds.softlayer.domain.SoftwareLicense;
 import org.jclouds.softlayer.domain.VirtualGuest;
-import org.jclouds.softlayer.parse.ParseBadVirtualGuest;
-import org.jclouds.softlayer.parse.ParseVirtualGuestHaltedTest;
-import org.jclouds.softlayer.parse.ParseVirtualGuestPausedTest;
-import org.jclouds.softlayer.parse.ParseVirtualGuestRunningTest;
-import org.jclouds.softlayer.parse.ParseVirtualGuestWithNoPasswordTest;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Function;
 import com.google.common.base.Supplier;
 import com.google.common.base.Suppliers;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import com.google.inject.Guice;
 
-@Test(groups = "unit", testName = "VirtualGuestToNodeMetadataTest")
+/**
+ * Tests the function that transforms SoftLayer VirtualGuest to NodeMetadata.
+ */
+@Test(groups="unit", testName = "VirtualGuestToNodeMetadataTest")
 public class VirtualGuestToNodeMetadataTest {
-   GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
-
-   @Test
-   public void testApplyWhereVirtualGuestWithNoPassword() {
-
-      // notice if we've already parsed this properly here, we can rely on it.
-      VirtualGuest guest = new ParseVirtualGuestWithNoPasswordTest().expected();
-
-      // setup so that we have an expected Location to be parsed from the guest.
-      Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter());
-      Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
-            .<Location> of(expectedLocation));
-
-      VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(
-            locationSupplier, new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention);
-
-      NodeMetadata node = parser.apply(guest);
-
-      assertEquals(
-            node,
-            new NodeMetadataBuilder().ids("416788").name("node1000360500").hostname("node1000360500")
-                  .location(expectedLocation).status(Status.PENDING)
-                  .publicAddresses(ImmutableSet.of("173.192.29.186"))
-                  .privateAddresses(ImmutableSet.of("10.37.102.194"))
-                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
-                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
-                  .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
-
-   }
-
-   @Test
-   public void testApplyWhereVirtualIsBad() {
-
-      // notice if we've already parsed this properly here, we can rely on it.
-      VirtualGuest guest = new ParseBadVirtualGuest().expected();
-
-      // no location here
-      Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
-            .<Location> of());
-
-      VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier,
-            new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention);
-
-      NodeMetadata node = parser.apply(guest);
-
-      assertEquals(
-            node,
-            new NodeMetadataBuilder().ids("413348").name("foo-ef4").hostname("foo-ef4").group("foo")
-                  .status(Status.PENDING).hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
-                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
-                  .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
-
-   }
-
-   @Test
-   public void testApplyWhereVirtualGuestIsHalted() {
-
-      // notice if we've already parsed this properly here, we can rely on it.
-      VirtualGuest guest = new ParseVirtualGuestHaltedTest().expected();
 
-      // setup so that we have an expected Location to be parsed from the guest.
-      Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter());
-      Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
-            .<Location> of(expectedLocation));
-
-      VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier,
-            new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention);
-
-      NodeMetadata node = parser.apply(guest);
-
-      assertEquals(
-            node,
-            new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
-                  .location(expectedLocation).status(Status.PENDING)
-                  .publicAddresses(ImmutableSet.of("173.192.29.187"))
-                  .privateAddresses(ImmutableSet.of("10.37.102.195"))
-                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
-                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
-                  .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
-
-   }
-
-   @Test
-   public void testApplyWhereVirtualGuestIsPaused() {
-
-      // notice if we've already parsed this properly here, we can rely on it.
-      VirtualGuest guest = new ParseVirtualGuestPausedTest().expected();
-
-      // setup so that we have an expected Location to be parsed from the guest.
-      Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter());
-      Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
-            .<Location> of(expectedLocation));
-
-      VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier,
-            new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention);
-
-      NodeMetadata node = parser.apply(guest);
-
-      assertEquals(
-            node,
-            new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
-                  .location(expectedLocation).status(Status.SUSPENDED)
-                  .publicAddresses(ImmutableSet.of("173.192.29.187"))
-                  .privateAddresses(ImmutableSet.of("10.37.102.195"))
-                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
-                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
-                  .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
+   VirtualGuestToImage virtualGuestToImage = Guice.createInjector().getInstance(VirtualGuestToImage.class);
+   VirtualGuestToHardware virtualGuestToHardware = Guice.createInjector().getInstance(VirtualGuestToHardware.class);
+   GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
 
-   }
+   Location location = new LocationBuilder().id("123456789")
+                                            .description("example")
+                                            .scope(LocationScope.ZONE)
+                                            .build();
+   Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.of(location));
 
    @Test
-   public void testApplyWhereVirtualGuestIsRunning() {
-
-      // notice if we've already parsed this properly here, we can rely on it.
-      VirtualGuest guest = new ParseVirtualGuestRunningTest().expected();
-
-      // setup so that we have an expected Location to be parsed from the guest.
-      Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter());
-      Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
-            .<Location> of(expectedLocation));
-
-      VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier,
-            new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention);
-
-      NodeMetadata node = parser.apply(guest);
-
-      assertEquals(
-            node,
-            new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
-                  .location(expectedLocation).status(Status.RUNNING)
-                  .publicAddresses(ImmutableSet.of("173.192.29.187"))
-                  .privateAddresses(ImmutableSet.of("10.37.102.195"))
-                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
-                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
-                  .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
-
+   public void testVirtualGuestToNodeMetadata() {
+
+      VirtualGuest virtualGuest = createVirtualGuest();
+      NodeMetadata nodeMetadata = new VirtualGuestToNodeMetadata(locationSupplier, namingConvention,
+              virtualGuestToImage, virtualGuestToHardware).apply(virtualGuest);
+      assertNotNull(nodeMetadata);
+      assertEquals(nodeMetadata.getName(), virtualGuest.getHostname());
+      assertEquals(nodeMetadata.getHostname(), virtualGuest.getHostname() + virtualGuest.getDomain());
+      assertEquals(nodeMetadata.getHardware().getRam(), virtualGuest.getMaxMemory());
+      assertTrue(nodeMetadata.getHardware().getProcessors().size() == 1);
+      assertEquals(Iterables.get(nodeMetadata.getHardware().getProcessors(), 0).getCores(), (double) virtualGuest.getStartCpus());
+      assertEquals(nodeMetadata.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+      assertEquals(nodeMetadata.getOperatingSystem().getVersion(), "12.04");
+      assertEquals(nodeMetadata.getOperatingSystem().is64Bit(), true);
    }
 
-   private static class GetHardwareForVirtualGuestMock extends VirtualGuestToNodeMetadata.GetHardwareForVirtualGuest {
-      @SuppressWarnings("unchecked")
-      public GetHardwareForVirtualGuestMock() {
-         super(createNiceMock(SoftLayerApi.class), createNiceMock(Function.class));
-      }
-
-      @Override
-      public Hardware getHardware(VirtualGuest guest) {
-         return new HardwareBuilder().ids("mocked hardware").build();
-      }
+   private VirtualGuest createVirtualGuest() {
+      return VirtualGuest.builder()
+              .domain("example.com")
+              .hostname("host1")
+              .id(1301396)
+              .maxMemory(1024)
+              .startCpus(1)
+              .localDiskFlag(true)
+              .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST")
+                      .operatingSystemReferenceCode("UBUNTU_LATEST")
+                      .softwareLicense(SoftwareLicense.builder()
+                              .softwareDescription(SoftwareDescription.builder()
+                                      .version("12.04-64 Minimal for CCI")
+                                      .referenceCode("UBUNTU_12_64")
+                                      .longDescription("Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit)")
+                                      .build())
+                              .build())
+                      .build())
+              .datacenter(Datacenter.builder().name("test").build())
+              .powerState(PowerState.builder().keyName(VirtualGuest.State.RUNNING).build())
+              .build();
    }
 
-   private static class GetImageForVirtualGuestMock extends VirtualGuestToNodeMetadata.GetImageForVirtualGuest {
-      public GetImageForVirtualGuestMock() {
-         super(null);
-      }
-
-      @Override
-      public Image getImage(VirtualGuest guest) {
-         return new ImageBuilder().ids("123").description("mocked image")
-               .operatingSystem(OperatingSystem.builder().description("foo os").build())
-               .status(Image.Status.AVAILABLE).build();
-      }
-   }
 }