fixed pattern to id windows 2008

This commit is contained in:
Adrian Cole 2011-01-29 21:06:22 -08:00
parent b351223f5e
commit c8d4008c98
17 changed files with 87 additions and 75 deletions

View File

@ -63,7 +63,7 @@ public class VCloudComputeUtils {
} }
public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystemSection os) { 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) { public static Credentials getCredentialsFrom(VApp vApp) {

View File

@ -26,6 +26,7 @@ import org.jclouds.compute.config.BindComputeStrategiesByClass;
import org.jclouds.compute.config.BindComputeSuppliersByClass; import org.jclouds.compute.config.BindComputeSuppliersByClass;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl; 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.CommonVCloudComputeClient;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
import org.jclouds.vcloud.compute.functions.ImagesInVCloudExpressOrg; 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.functions.VCloudExpressVAppToNodeMetadata;
import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl;
import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.Org;
@ -64,6 +66,8 @@ public class VCloudExpressComputeServiceContextModule extends CommonVCloudComput
bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() { bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() {
}).to(new TypeLiteral<ImagesInVCloudExpressOrg>() { }).to(new TypeLiteral<ImagesInVCloudExpressOrg>() {
}); });
bind(new TypeLiteral<Function<String, OperatingSystem>>() {
}).to(ParseOsFromVAppTemplateName.class);
} }
protected void bindVAppConverter() { protected void bindVAppConverter() {

View File

@ -51,19 +51,33 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions;
*/ */
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
public interface TerremarkVCloudClient extends VCloudExpressClient { public interface TerremarkVCloudClient extends VCloudExpressClient {
/**
* {@inheritDoc}
*/
@Override @Override
TerremarkCatalogItem getCatalogItem(URI catalogItem); TerremarkCatalogItem getCatalogItem(URI catalogItem);
/**
* {@inheritDoc}
*/
@Override @Override
TerremarkVDC getVDC(URI catalogItem); TerremarkVDC getVDC(URI catalogItem);
/**
* {@inheritDoc}
*/
@Override @Override
TerremarkCatalogItem findCatalogItemInOrgCatalogNamed(String orgName, String catalogName, String itemName); TerremarkCatalogItem findCatalogItemInOrgCatalogNamed(String orgName, String catalogName, String itemName);
/**
* {@inheritDoc}
*/
@Override @Override
TerremarkOrg getOrg(URI orgId); TerremarkOrg getOrg(URI orgId);
/**
* {@inheritDoc}
*/
@Override @Override
TerremarkOrg findOrgNamed(String orgName); TerremarkOrg findOrgNamed(String orgName);

View File

@ -34,6 +34,7 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.InsufficientResourcesException;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.util.Strings2; 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("because it is already powered off") != -1)
|| (response.getMessage().indexOf("exists") != -1))) || (response.getMessage().indexOf("exists") != -1)))
exception = new IllegalStateException(response.getMessage(), exception); 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 else
switch (response.getStatusCode()) { switch (response.getStatusCode()) {
case 400: case 400:

View File

@ -220,16 +220,13 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
abstract TerremarkInstantiateVAppTemplateOptions createInstantiateOptions(); abstract TerremarkInstantiateVAppTemplateOptions createInstantiateOptions();
protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(URI vdc); protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp);
@Test @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
public void testAddInternetService() throws InterruptedException, ExecutionException, TimeoutException, IOException { public void testAddInternetService() throws InterruptedException, ExecutionException, TimeoutException, IOException {
Entry<InternetService, PublicIpAddress> entry = getNewInternetServiceAndIpForSSH(vApp);
Entry<InternetService, PublicIpAddress> entry = getNewInternetServiceAndIpForSSH(tmClient.findVDCInOrgNamed(null,
null).getHref());
is = entry.getKey(); is = entry.getKey();
publicIp = entry.getValue().getAddress(); publicIp = entry.getValue().getAddress();
} }
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn") @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")

View File

@ -24,6 +24,7 @@ import java.net.URI;
import org.jclouds.http.BaseHttpErrorHandlerTest; import org.jclouds.http.BaseHttpErrorHandlerTest;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.InsufficientResourcesException;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -71,6 +72,12 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError
"", "", AuthorizationException.class); "", "", 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 @Test
public void test501SetsNotImplementedMakesUnsupportedOperationException() { public void test501SetsNotImplementedMakesUnsupportedOperationException() {
assertCodeMakes("POST", URI assertCodeMakes("POST", URI
@ -87,7 +94,8 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError
@Test @Test
public void testKeyAlreadyExistsSetsIllegalStateException() { 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.", "Security key with name livetest exists.", "Security key with name livetest exists.",
IllegalStateException.class); IllegalStateException.class);
} }

View File

@ -25,7 +25,6 @@ import static org.jclouds.vcloud.util.Utils.putReferenceType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedMap;
import javax.inject.Inject; import javax.inject.Inject;
@ -56,7 +55,7 @@ public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private ReferenceType catalog; private ReferenceType catalog;
private SortedMap<String, ReferenceType> contents = Maps.newTreeMap(); private Map<String, ReferenceType> contents = Maps.newLinkedHashMap();
protected List<Task> tasks = Lists.newArrayList(); protected List<Task> tasks = Lists.newArrayList();
private String description; private String description;
private ReferenceType org; private ReferenceType org;

View File

@ -58,7 +58,7 @@ public interface ComputeServiceConstants {
public static class ReferenceData { public static class ReferenceData {
@Inject(optional = true) @Inject(optional = true)
@Named(PROPERTY_OS_VERSION_MAP_JSON) @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 @Singleton

View File

@ -201,7 +201,7 @@ public class ComputeServiceUtils {
"node does not have IP addresses configured: " + node); "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<OsFamily, Map<String, String>> osVersionMap) { Map<OsFamily, Map<String, String>> osVersionMap) {
if (osVersionMap.containsKey(family)) { if (osVersionMap.containsKey(family)) {
if (osVersionMap.get(family).containsKey(in)) if (osVersionMap.get(family).containsKey(in))

View File

@ -36,7 +36,7 @@
<properties> <properties>
<test.trmk-ecloud.endpoint>https://services.enterprisecloud.terremark.com/api</test.trmk-ecloud.endpoint> <test.trmk-ecloud.endpoint>https://services.enterprisecloud.terremark.com/api</test.trmk-ecloud.endpoint>
<test.trmk-ecloud.apiversion>0.8b-ext2.6</test.trmk-ecloud.apiversion> <test.trmk-ecloud.apiversion>0.8b-ext2.7</test.trmk-ecloud.apiversion>
<test.trmk-ecloud.identity>FIXME</test.trmk-ecloud.identity> <test.trmk-ecloud.identity>FIXME</test.trmk-ecloud.identity>
<test.trmk-ecloud.credential>FIXME</test.trmk-ecloud.credential> <test.trmk-ecloud.credential>FIXME</test.trmk-ecloud.credential>
</properties> </properties>

View File

@ -44,6 +44,8 @@ public interface TerremarkECloudClient extends TerremarkVCloudClient {
* *
* @param vDCId * @param vDCId
* @return * @return
* @throws org.jclouds.rest.InsufficientResourcesException
* if there's no additional ips available
*/ */
PublicIpAddress activatePublicIpInVDC(URI vDCId); PublicIpAddress activatePublicIpInVDC(URI vDCId);

View File

@ -36,10 +36,10 @@ public class TerremarkECloudPropertiesBuilder extends TerremarkVCloudPropertiesB
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.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_ENDPOINT, "https://services.enterprisecloud.terremark.com/api");
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); 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 // for some reason the centos template is very slow to deploy
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 720l * 1000l + ""); properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 720l * 1000l + "");
return properties; return properties;

View File

@ -22,6 +22,8 @@ package org.jclouds.vcloud.terremark.compute.config;
import static org.jclouds.compute.domain.OsFamily.CENTOS; import static org.jclouds.compute.domain.OsFamily.CENTOS;
import org.jclouds.compute.domain.TemplateBuilder; 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.InternetServiceAndPublicIpAddressSupplier;
import org.jclouds.vcloud.terremark.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier; import org.jclouds.vcloud.terremark.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier;
@ -32,6 +34,14 @@ import com.google.inject.Injector;
*/ */
public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudComputeServiceContextModule { 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. // 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 // ssh key injection in ubuntu is targeted for dec-2010 or sooner
@Override @Override
@ -39,10 +49,4 @@ public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudC
return template.osFamily(CENTOS).os64Bit(true); return template.osFamily(CENTOS).os64Bit(true);
} }
@Override
protected void configure() {
bind(InternetServiceAndPublicIpAddressSupplier.class).to(
TerremarkECloudInternetServiceAndPublicIpAddressSupplier.class);
super.configure();
}
} }

View File

@ -31,14 +31,13 @@ import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.http.HttpResponseException;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rest.InsufficientResourcesException;
import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.terremark.TerremarkECloudClient; import org.jclouds.vcloud.terremark.TerremarkECloudClient;
import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.Protocol;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress; 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.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -64,28 +63,22 @@ public class TerremarkECloudInternetServiceAndPublicIpAddressSupplier implements
public Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIp(VCloudExpressVApp vApp, int port, public Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIp(VCloudExpressVApp vApp, int port,
Protocol protocol) { Protocol protocol) {
logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getName(), protocol, port); 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; InternetService is = null;
PublicIpAddress ip = null; PublicIpAddress ip = null;
try { try {
ip = client.activatePublicIpInVDC(vApp.getVDC().getHref()); ip = client.activatePublicIpInVDC(vApp.getVDC().getHref());
} catch (HttpResponseException e) { } catch (InsufficientResourcesException e) {
if (e.getResponse().getStatusCode() == 500) { logger.warn(">> no more ip addresses available, looking for one to re-use");
logger.warn(">> no more ip addresses available, looking for one to re-use"); for (PublicIpAddress existingIp : client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref())) {
for (PublicIpAddress existingIp : client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref())) { Set<InternetService> services = client.getInternetServicesOnPublicIp(existingIp.getId());
Set<InternetService> services = client.getInternetServicesOnPublicIp(existingIp.getId()); if (services.size() == 0) {
if (services.size() == 0) { ip = existingIp;
ip = existingIp; break;
break;
}
} }
if (ip == null)
throw e;
} else {
throw e;
} }
if (ip == null)
throw e;
} }
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port, 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 withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), vApp

View File

@ -285,7 +285,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request, Strings2.toStringAndClose(
getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")).replace( getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")).replace(
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.6"), "vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
"application/vnd.tmrk.ecloud.internetService+xml", false); "application/vnd.tmrk.ecloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
@ -305,7 +305,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request, Strings2.toStringAndClose(
getClass().getResourceAsStream("/terremark/CreateInternetService-options-test.xml")).replace( getClass().getResourceAsStream("/terremark/CreateInternetService-options-test.xml")).replace(
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.6"), "vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
"application/vnd.tmrk.ecloud.internetService+xml", false); "application/vnd.tmrk.ecloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class); assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
@ -324,7 +324,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request, Strings2.toStringAndClose(
getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml")).replace( getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml")).replace(
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.6"), "application/vnd.tmrk.vCloud.nodeService+xml", "vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), "application/vnd.tmrk.vCloud.nodeService+xml",
false); false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
@ -345,7 +345,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request, Strings2.toStringAndClose(
getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml")).replace( getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml")).replace(
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.6"), "application/vnd.tmrk.vCloud.nodeService+xml", "vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), "application/vnd.tmrk.vCloud.nodeService+xml",
false); false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);
@ -380,7 +380,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals( assertPayloadEquals(
request, request,
"<NodeService xmlns=\"urn:tmrk:eCloudExtensions-2.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>name</Name><Enabled>true</Enabled><Description>eggs</Description></NodeService>", "<NodeService xmlns=\"urn:tmrk:eCloudExtensions-2.7\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>name</Name><Enabled>true</Enabled><Description>eggs</Description></NodeService>",
"application/vnd.tmrk.vCloud.nodeService+xml", false); "application/vnd.tmrk.vCloud.nodeService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);
@ -399,7 +399,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals( assertPayloadEquals(
request, request,
"<NodeService xmlns=\"urn:tmrk:eCloudExtensions-2.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>name</Name><Enabled>true</Enabled></NodeService>", "<NodeService xmlns=\"urn:tmrk:eCloudExtensions-2.7\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>name</Name><Enabled>true</Enabled></NodeService>",
"application/vnd.tmrk.vCloud.nodeService+xml", false); "application/vnd.tmrk.vCloud.nodeService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);

View File

@ -21,34 +21,32 @@ package org.jclouds.vcloud.terremark;
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount; import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
import java.net.URI;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.Protocol;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.suppliers.TerremarkECloudInternetServiceAndPublicIpAddressSupplier;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
/** /**
* Tests behavior of {@code TerremarkVCloudClient} * Tests behavior of {@code TerremarkVCloudClient}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", enabled = false, sequential = true) @Test(groups = "live", enabled = true, sequential = true)
public class TerremarkECloudClientLiveTestDisabled extends TerremarkClientLiveTest { public class TerremarkECloudClientLiveTestDisabled extends TerremarkClientLiveTest {
@BeforeClass @BeforeClass
void setProvider() { void setProvider() {
this.provider = "trmk-ecloud"; this.provider = "trmk-ecloud";
this.itemName = "Ubuntu 8.04 LTS (x86)"; this.itemName = "Ubuntu 8.04 LTS (x86)";
expectedOs = "Ubuntu Linux (32-bit)";
} }
@Override @Override
@ -62,13 +60,9 @@ public class TerremarkECloudClientLiveTestDisabled extends TerremarkClientLiveTe
} }
@Override @Override
protected Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(URI vdc) { protected Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp) {
PublicIpAddress ip = TerremarkECloudClient.class.cast(tmClient).activatePublicIpInVDC( return new TerremarkECloudInternetServiceAndPublicIpAddressSupplier(TerremarkECloudClient.class.cast(tmClient))
tmClient.findVDCInOrgNamed(null, null).getHref()); .getNewInternetServiceAndIp(vApp, 22, Protocol.TCP);
InternetService is = tmClient.addInternetServiceToExistingIp(ip.getId(), "SSH", Protocol.TCP, 22);
Map<InternetService, PublicIpAddress> result = ImmutableMap.<InternetService, PublicIpAddress> of(is, ip);
Entry<InternetService, PublicIpAddress> entry = Iterables.getOnlyElement(result.entrySet());
return entry;
} }
} }

View File

@ -23,8 +23,6 @@ import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTempl
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -33,18 +31,17 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.KeyPair; import org.jclouds.vcloud.terremark.domain.KeyPair;
import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.Protocol;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.suppliers.TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
/** /**
* Tests behavior of {@code TerremarkVCloudClient} * Tests behavior of {@code TerremarkVCloudClient}
* *
@ -53,16 +50,6 @@ import com.google.common.collect.Iterables;
@Test(groups = "live", sequential = true) @Test(groups = "live", sequential = true)
public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest { public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest {
@Override
protected Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(URI vdc) {
InternetService is = TerremarkVCloudExpressClient.class.cast(tmClient).addInternetServiceToVDC(
tmClient.findVDCInOrgNamed(null, null).getHref(), "SSH", Protocol.TCP, 22);
PublicIpAddress ip = is.getPublicIpAddress();
Map<InternetService, PublicIpAddress> result = ImmutableMap.<InternetService, PublicIpAddress> of(is, ip);
Entry<InternetService, PublicIpAddress> entry = Iterables.getOnlyElement(result.entrySet());
return entry;
}
KeyPair key; KeyPair key;
@Test @Test
@ -114,4 +101,10 @@ public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTes
protected TerremarkInstantiateVAppTemplateOptions createInstantiateOptions() { protected TerremarkInstantiateVAppTemplateOptions createInstantiateOptions() {
return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint()); return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint());
} }
@Override
protected Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp) {
return new TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier(TerremarkVCloudExpressClient.class
.cast(tmClient)).getNewInternetServiceAndIp(vApp, 22, Protocol.TCP);
}
} }