diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java index d2c195257e..f17fdb4e8e 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java @@ -63,7 +63,7 @@ public class VCloudComputeUtils { } public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystemSection os) { - return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), null, null, os.getDescription()); + return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), "", null, os.getDescription()); } public static Credentials getCredentialsFrom(VApp vApp) { diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java index 9eb35ffdf7..a156a564e7 100755 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java @@ -26,6 +26,7 @@ import org.jclouds.compute.config.BindComputeStrategiesByClass; import org.jclouds.compute.config.BindComputeSuppliersByClass; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; @@ -33,6 +34,7 @@ import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.compute.CommonVCloudComputeClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.functions.ImagesInVCloudExpressOrg; +import org.jclouds.vcloud.compute.functions.ParseOsFromVAppTemplateName; import org.jclouds.vcloud.compute.functions.VCloudExpressVAppToNodeMetadata; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.domain.Org; @@ -64,6 +66,8 @@ public class VCloudExpressComputeServiceContextModule extends CommonVCloudComput bind(new TypeLiteral>>() { }).to(new TypeLiteral() { }); + bind(new TypeLiteral>() { + }).to(ParseOsFromVAppTemplateName.class); } protected void bindVAppConverter() { diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java index bb6d3d5955..3239407105 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java @@ -51,19 +51,33 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions; */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface TerremarkVCloudClient extends VCloudExpressClient { - + /** + * {@inheritDoc} + */ @Override TerremarkCatalogItem getCatalogItem(URI catalogItem); + /** + * {@inheritDoc} + */ @Override TerremarkVDC getVDC(URI catalogItem); + /** + * {@inheritDoc} + */ @Override TerremarkCatalogItem findCatalogItemInOrgCatalogNamed(String orgName, String catalogName, String itemName); + /** + * {@inheritDoc} + */ @Override TerremarkOrg getOrg(URI orgId); + /** + * {@inheritDoc} + */ @Override TerremarkOrg findOrgNamed(String orgName); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java index 2426af62cf..482d0500c0 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java @@ -34,6 +34,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; import org.jclouds.logging.Logger; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.InsufficientResourcesException; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.util.Strings2; @@ -61,6 +62,9 @@ public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandl || (response.getMessage().indexOf("because it is already powered off") != -1) || (response.getMessage().indexOf("exists") != -1))) exception = new IllegalStateException(response.getMessage(), exception); + else if (response.getMessage() != null + && ((response.getMessage().indexOf("There are no additional Public IPs available") != -1))) + exception = new InsufficientResourcesException(response.getMessage(), exception); else switch (response.getStatusCode()) { case 400: diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index 8baf7694bf..5c58625632 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -220,16 +220,13 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes abstract TerremarkInstantiateVAppTemplateOptions createInstantiateOptions(); - protected abstract Entry getNewInternetServiceAndIpForSSH(URI vdc); + protected abstract Entry getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp); - @Test + @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn") public void testAddInternetService() throws InterruptedException, ExecutionException, TimeoutException, IOException { - - Entry entry = getNewInternetServiceAndIpForSSH(tmClient.findVDCInOrgNamed(null, - null).getHref()); + Entry entry = getNewInternetServiceAndIpForSSH(vApp); is = entry.getKey(); publicIp = entry.getValue().getAddress(); - } @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn") diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java index 1c1365a1cc..b43b5c1650 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java @@ -24,6 +24,7 @@ import java.net.URI; import org.jclouds.http.BaseHttpErrorHandlerTest; import org.jclouds.http.HttpErrorHandler; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.InsufficientResourcesException; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; @@ -71,6 +72,12 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError "", "", AuthorizationException.class); } + @Test + public void test403SetsInsufficientResourcesException() { + assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 403, + "There are no additional Public IPs available", "", InsufficientResourcesException.class); + } + @Test public void test501SetsNotImplementedMakesUnsupportedOperationException() { assertCodeMakes("POST", URI @@ -87,11 +94,12 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError @Test public void testKeyAlreadyExistsSetsIllegalStateException() { - assertCodeMakes("POST", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/org/48/keys"), 400, + assertCodeMakes("POST", URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/org/48/keys"), 400, "Security key with name livetest exists.", "Security key with name livetest exists.", IllegalStateException.class); } - + @Override protected Class getHandlerClass() { return ParseTerremarkVCloudErrorFromHttpResponse.class; diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java index aa478c5b73..74541aeb9d 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java @@ -25,7 +25,6 @@ import static org.jclouds.vcloud.util.Utils.putReferenceType; import java.util.List; import java.util.Map; -import java.util.SortedMap; import javax.inject.Inject; @@ -56,7 +55,7 @@ public class CatalogHandler extends ParseSax.HandlerWithResult { private StringBuilder currentText = new StringBuilder(); private ReferenceType catalog; - private SortedMap contents = Maps.newTreeMap(); + private Map contents = Maps.newLinkedHashMap(); protected List tasks = Lists.newArrayList(); private String description; private ReferenceType org; diff --git a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java index 18c983fbee..65f5c4dfe3 100644 --- a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java +++ b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java @@ -58,7 +58,7 @@ public interface ComputeServiceConstants { public static class ReferenceData { @Inject(optional = true) @Named(PROPERTY_OS_VERSION_MAP_JSON) - public String osVersionMapJson = "{\"centos\":{\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"ubuntu\":{\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"Server 2008\":\"2008\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; + public String osVersionMapJson = "{\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; } @Singleton diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index 8c14032bb6..e0bcc661a2 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -201,7 +201,7 @@ public class ComputeServiceUtils { "node does not have IP addresses configured: " + node); } - public static String parseVersionOrReturnEmptyString(org.jclouds.compute.domain.OsFamily family, final String in, + public static String parseVersionOrReturnEmptyString(org.jclouds.compute.domain.OsFamily family, String in, Map> osVersionMap) { if (osVersionMap.containsKey(family)) { if (osVersionMap.get(family).containsKey(in)) diff --git a/providers/trmk-ecloud/pom.xml b/providers/trmk-ecloud/pom.xml index eef065ac0d..f3e4b855f5 100644 --- a/providers/trmk-ecloud/pom.xml +++ b/providers/trmk-ecloud/pom.xml @@ -36,7 +36,7 @@ https://services.enterprisecloud.terremark.com/api - 0.8b-ext2.6 + 0.8b-ext2.7 FIXME FIXME diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java index a317c1921a..f8e1bf97f1 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java @@ -44,6 +44,8 @@ public interface TerremarkECloudClient extends TerremarkVCloudClient { * * @param vDCId * @return + * @throws org.jclouds.rest.InsufficientResourcesException + * if there's no additional ips available */ PublicIpAddress activatePublicIpInVDC(URI vDCId); diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java index a6fc4a6514..fcac949205 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java @@ -36,10 +36,10 @@ public class TerremarkECloudPropertiesBuilder extends TerremarkVCloudPropertiesB @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "0.8b-ext2.6"); + properties.setProperty(PROPERTY_API_VERSION, "0.8b-ext2.7"); properties.setProperty(PROPERTY_ENDPOINT, "https://services.enterprisecloud.terremark.com/api"); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.6"); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.7"); // for some reason the centos template is very slow to deploy properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 720l * 1000l + ""); return properties; diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java index b3386085aa..25c5138557 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java @@ -22,6 +22,8 @@ package org.jclouds.vcloud.terremark.compute.config; import static org.jclouds.compute.domain.OsFamily.CENTOS; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.vcloud.compute.functions.ParseOsFromVAppTemplateName; +import org.jclouds.vcloud.terremark.compute.functions.TerremarkECloudParseOsFromVAppTemplateName; import org.jclouds.vcloud.terremark.suppliers.InternetServiceAndPublicIpAddressSupplier; import org.jclouds.vcloud.terremark.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier; @@ -32,6 +34,14 @@ import com.google.inject.Injector; */ public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudComputeServiceContextModule { + @Override + protected void configure() { + bind(InternetServiceAndPublicIpAddressSupplier.class).to( + TerremarkECloudInternetServiceAndPublicIpAddressSupplier.class); + bind(ParseOsFromVAppTemplateName.class).to(TerremarkECloudParseOsFromVAppTemplateName.class); + super.configure(); + } + // as of 6-nov-2010 only centos has ssh key injection in the images. // ssh key injection in ubuntu is targeted for dec-2010 or sooner @Override @@ -39,10 +49,4 @@ public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudC return template.osFamily(CENTOS).os64Bit(true); } - @Override - protected void configure() { - bind(InternetServiceAndPublicIpAddressSupplier.class).to( - TerremarkECloudInternetServiceAndPublicIpAddressSupplier.class); - super.configure(); - } } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java index 7154b57445..d19d6c6cd5 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java @@ -31,14 +31,13 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.http.HttpResponseException; import org.jclouds.logging.Logger; +import org.jclouds.rest.InsufficientResourcesException; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.terremark.TerremarkECloudClient; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; -import org.jclouds.vcloud.terremark.suppliers.InternetServiceAndPublicIpAddressSupplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -64,28 +63,22 @@ public class TerremarkECloudInternetServiceAndPublicIpAddressSupplier implements public Entry getNewInternetServiceAndIp(VCloudExpressVApp vApp, int port, Protocol protocol) { logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getName(), protocol, port); - // http://support.theenterprisecloud.com/kb/default.asp?id=706&Lang=1&SID= - // response with a 500 error code means we should look for an existing public ip to - // use InternetService is = null; PublicIpAddress ip = null; try { ip = client.activatePublicIpInVDC(vApp.getVDC().getHref()); - } catch (HttpResponseException e) { - if (e.getResponse().getStatusCode() == 500) { - logger.warn(">> no more ip addresses available, looking for one to re-use"); - for (PublicIpAddress existingIp : client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref())) { - Set services = client.getInternetServicesOnPublicIp(existingIp.getId()); - if (services.size() == 0) { - ip = existingIp; - break; - } + } catch (InsufficientResourcesException e) { + logger.warn(">> no more ip addresses available, looking for one to re-use"); + for (PublicIpAddress existingIp : client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref())) { + Set services = client.getInternetServicesOnPublicIp(existingIp.getId()); + if (services.size() == 0) { + ip = existingIp; + break; } - if (ip == null) - throw e; - } else { - throw e; } + if (ip == null) + throw e; + } is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port, withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), vApp diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java index 09784f608b..72ced2e021 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java @@ -285,7 +285,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTestnametrueeggs", + "nametrueeggs", "application/vnd.tmrk.vCloud.nodeService+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, NodeHandler.class); @@ -399,7 +399,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTestnametrue", + "nametrue", "application/vnd.tmrk.vCloud.nodeService+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, NodeHandler.class); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTestDisabled.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTestDisabled.java index 97c4051ec6..948926ad93 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTestDisabled.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTestDisabled.java @@ -21,34 +21,32 @@ package org.jclouds.vcloud.terremark; import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount; -import java.net.URI; -import java.util.Map; import java.util.Map.Entry; import org.jclouds.domain.Credentials; import org.jclouds.net.IPSocket; import org.jclouds.ssh.SshClient; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; +import org.jclouds.vcloud.terremark.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; - /** * Tests behavior of {@code TerremarkVCloudClient} * * @author Adrian Cole */ -@Test(groups = "live", enabled = false, sequential = true) +@Test(groups = "live", enabled = true, sequential = true) public class TerremarkECloudClientLiveTestDisabled extends TerremarkClientLiveTest { @BeforeClass void setProvider() { this.provider = "trmk-ecloud"; this.itemName = "Ubuntu 8.04 LTS (x86)"; + expectedOs = "Ubuntu Linux (32-bit)"; } @Override @@ -62,13 +60,9 @@ public class TerremarkECloudClientLiveTestDisabled extends TerremarkClientLiveTe } @Override - protected Entry getNewInternetServiceAndIpForSSH(URI vdc) { - PublicIpAddress ip = TerremarkECloudClient.class.cast(tmClient).activatePublicIpInVDC( - tmClient.findVDCInOrgNamed(null, null).getHref()); - InternetService is = tmClient.addInternetServiceToExistingIp(ip.getId(), "SSH", Protocol.TCP, 22); - Map result = ImmutableMap. of(is, ip); - Entry entry = Iterables.getOnlyElement(result.entrySet()); - return entry; + protected Entry getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp) { + return new TerremarkECloudInternetServiceAndPublicIpAddressSupplier(TerremarkECloudClient.class.cast(tmClient)) + .getNewInternetServiceAndIp(vApp, 22, Protocol.TCP); } } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java index a01b730154..9901ecb592 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java @@ -23,8 +23,6 @@ import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTempl import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.net.URI; -import java.util.Map; import java.util.Set; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; @@ -33,18 +31,17 @@ import java.util.concurrent.TimeoutException; import org.jclouds.domain.Credentials; import org.jclouds.net.IPSocket; import org.jclouds.ssh.SshClient; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.KeyPair; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; +import org.jclouds.vcloud.terremark.suppliers.TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier; import org.testng.annotations.AfterTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; - /** * Tests behavior of {@code TerremarkVCloudClient} * @@ -53,16 +50,6 @@ import com.google.common.collect.Iterables; @Test(groups = "live", sequential = true) public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest { - @Override - protected Entry getNewInternetServiceAndIpForSSH(URI vdc) { - InternetService is = TerremarkVCloudExpressClient.class.cast(tmClient).addInternetServiceToVDC( - tmClient.findVDCInOrgNamed(null, null).getHref(), "SSH", Protocol.TCP, 22); - PublicIpAddress ip = is.getPublicIpAddress(); - Map result = ImmutableMap. of(is, ip); - Entry entry = Iterables.getOnlyElement(result.entrySet()); - return entry; - } - KeyPair key; @Test @@ -114,4 +101,10 @@ public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTes protected TerremarkInstantiateVAppTemplateOptions createInstantiateOptions() { return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint()); } + + @Override + protected Entry getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp) { + return new TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier(TerremarkVCloudExpressClient.class + .cast(tmClient)).getNewInternetServiceAndIp(vApp, 22, Protocol.TCP); + } }