From b55d2165d0fc39cc204c0788fd2b0ae097d0393c Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Sun, 13 Dec 2009 23:52:56 +0000 Subject: [PATCH] Issue 131: regression git-svn-id: http://jclouds.googlecode.com/svn/trunk@2413 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../org/jclouds/vcloud/xml/VDCHandler.java | 2 +- .../core/src/test/resources/vdc-hosting.xml | 12 +- .../TerremarkVCloudComputeService.java | 4 +- .../options/ReturnVoidOnDeleteDefaultIp.java | 2 +- .../terremark/InternetServiceLiveTest.java | 33 +++-- .../TerremarkVCloudComputeClientLiveTest.java | 8 +- .../xml/TerremarkVDCHandlerTest.java | 120 +++++++++--------- .../src/test/resources/terremark/vdc.xml | 5 +- 8 files changed, 98 insertions(+), 88 deletions(-) diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java index d94c48565c..9bf37605ef 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java @@ -82,7 +82,7 @@ public class VDCHandler extends ParseSax.HandlerWithResult { vDC = newNamedResource(attributes); } else if (qName.equals("Network")) { putNamedResource(availableNetworks, attributes); - } else if (qName.equals("ResourcePayload")) { + } else if (qName.equals("ResourceEntity")) { putNamedResource(resourceEntities, attributes); } } diff --git a/vcloud/core/src/test/resources/vdc-hosting.xml b/vcloud/core/src/test/resources/vdc-hosting.xml index 20219856cc..6254112cf8 100644 --- a/vcloud/core/src/test/resources/vdc-hosting.xml +++ b/vcloud/core/src/test/resources/vdc-hosting.xml @@ -38,22 +38,22 @@ - - - - - - diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java index 0b88a0e4c6..f913617c24 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeService.java @@ -72,7 +72,9 @@ public class TerremarkVCloudComputeService implements ComputeService { public CreateServerResponse createServer(String name, Profile profile, Image image) { String id = computeClient.start(name, 1, 512, image); VApp vApp = tmClient.getVApp(id); - InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22, 80, 8080); + // bug creating more than one internet service returns 503 or 500 + // InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22, 80, 8080); + InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22); return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), ImmutableSet . of(publicIp), vApp.getNetworkToAddresses().values(), 22, LoginType.SSH, new Credentials("vcloud", "p4ssw0rd")); diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/ReturnVoidOnDeleteDefaultIp.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/ReturnVoidOnDeleteDefaultIp.java index 6d525e9dab..2e7d368011 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/ReturnVoidOnDeleteDefaultIp.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/ReturnVoidOnDeleteDefaultIp.java @@ -56,11 +56,11 @@ public class ReturnVoidOnDeleteDefaultIp implements Function { if (from instanceof HttpResponseException) { HttpResponseException hre = (HttpResponseException) from; if (hre.getResponse().getStatusCode() == 503 + || hre.getResponse().getStatusCode() == 401 || hre.getMessage().matches( ".*Cannot release this Public IP as it is default oubound IP.*")) return v; } return null; } - } \ No newline at end of file diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java index 87f3d97de0..42725208e7 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java @@ -62,29 +62,18 @@ public class InternetServiceLiveTest { } @Test - public void testAddInternetService() { - + public void testAddInternetService() throws InterruptedException { InternetService is = tmClient.addInternetService("test-" + 22, Protocol.TCP, 22); services.add(is); PublicIpAddress ip = is.getPublicIpAddress(); - for (int port : new int[] { 80, 8080 }) { - services.add(tmClient.addInternetServiceToExistingIp(ip.getId(), "test-" + port, - Protocol.HTTP, port)); - } + // current bug in terremark + // for (int port : new int[] { 80, 8080 }) { + // services.add(tmClient.addInternetServiceToExistingIp(ip.getId(), "test-" + port, + // Protocol.HTTP, port)); + // } print(tmClient.getInternetServicesOnPublicIp(ip.getId())); } - private void print(SortedSet set) { - for (InternetService service : set) { - System.out.printf("%d (%s:%d%n)", service.getId(), service.getPublicIpAddress() - .getAddress().getHostAddress(), service.getPort()); - for (Node node : tmClient.getNodes(service.getId())) { - System.out.printf(" %d (%s:%d%n)", node.getId(), - node.getIpAddress().getHostAddress(), node.getPort()); - } - } - } - private void delete(SortedSet set) { for (InternetService service : set) { for (Node node : tmClient.getNodes(service.getId())) { @@ -120,4 +109,14 @@ public class InternetServiceLiveTest { } + private void print(SortedSet set) { + for (InternetService service : set) { + System.out.printf("%d (%s:%d%n)", service.getId(), service.getPublicIpAddress() + .getAddress().getHostAddress(), service.getPort()); + for (Node node : tmClient.getNodes(service.getId())) { + System.out.printf(" %d (%s:%d%n)", node.getId(), + node.getIpAddress().getHostAddress(), node.getPort()); + } + } + } } diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java index 6cbc5b1e15..5ef1a18d93 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java @@ -118,9 +118,11 @@ public class TerremarkVCloudComputeClientLiveTest { @Test(dependsOnMethods = "testGetAnyPrivateAddress") public void testSshLoadBalanceIp() { - - InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22, 80, - 8080); + // bug creating more than one internet service returns 503 or 500 + // InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22, + // 80, + // 8080); + InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22); assert addressTester.apply(publicIp); // client.exec(publicIp, "uname -a"); } diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandlerTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandlerTest.java index 8fb3b56947..fbcb1dcbe9 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandlerTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandlerTest.java @@ -35,6 +35,7 @@ import org.jclouds.http.functions.config.ParserModule; import org.jclouds.rest.domain.NamedResource; import org.jclouds.rest.domain.internal.NamedLinkImpl; import org.jclouds.rest.internal.NamedResourceImpl; +import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.endpoints.VCloudApi; import org.jclouds.vcloud.terremark.domain.TerremarkVDC; import org.testng.annotations.Test; @@ -53,66 +54,69 @@ import com.google.inject.Provides; @Test(groups = "unit", testName = "vcloud.TerremarkVDCHandlerTest") public class TerremarkVDCHandlerTest { - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml"); - Injector injector = Guice.createInjector(new ParserModule(), - new AbstractModule() { + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml"); + Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() { - @Override - protected void configure() { - } + @Override + protected void configure() { + } - @SuppressWarnings("unused") - @Provides - @VCloudApi - URI provide() { - return URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8"); - } + @SuppressWarnings("unused") + @Provides + @VCloudApi + URI provide() { + return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8"); + } - }); - Factory factory = injector.getInstance(ParseSax.Factory.class); + }); + Factory factory = injector.getInstance(ParseSax.Factory.class); - TerremarkVDC result = (TerremarkVDC) factory.create( - injector.getInstance(TerremarkVDCHandler.class)).parse(is); - assertEquals(result.getName(), "Miami Environment 1"); - assertEquals( - result.getLocation(), - URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")); - assertEquals(result.getResourceEntities(), ImmutableMap - . of()); - assertEquals( - result.getAvailableNetworks(), - ImmutableMap - .of( - "10.114.34.128/26", - new NamedResourceImpl( - "1708", - "10.114.34.128/26", - "application/vnd.vmware.vcloud.network+xml", - URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708")))); - assertEquals( - result.getCatalog(), - new NamedLinkImpl( - "Miami Environment 1", - CATALOG_XML, - URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))); - assertEquals( - result.getPublicIps(), - new NamedLinkImpl( - "Public IPs", - "application/xml", - URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps"))); - assertEquals( - result.getInternetServices(), - new NamedLinkImpl( - "Internet Services", - "application/xml", - URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices"))); - } + TerremarkVDC result = (TerremarkVDC) factory.create( + injector.getInstance(TerremarkVDCHandler.class)).parse(is); + assertEquals(result.getName(), "Miami Environment 1"); + assertEquals(result.getLocation(), URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")); + assertEquals( + result.getResourceEntities(), + ImmutableMap + . of( + "adriantest", + new NamedResourceImpl( + "15124", + "adriantest", + VCloudMediaType.VAPP_XML, + URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")), + "centos-53", + new NamedResourceImpl( + "15120", + "centos-53", + VCloudMediaType.VAPP_XML, + URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120")))); + + assertEquals( + result.getAvailableNetworks(), + ImmutableMap + .of( + "10.114.34.128/26", + new NamedResourceImpl( + "1708", + "10.114.34.128/26", + "application/vnd.vmware.vcloud.network+xml", + URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708")))); + assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1", CATALOG_XML, URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))); + assertEquals(result.getPublicIps(), new NamedLinkImpl("Public IPs", "application/xml", URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps"))); + assertEquals( + result.getInternetServices(), + new NamedLinkImpl( + "Internet Services", + "application/xml", + URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices"))); + } } diff --git a/vcloud/terremark/src/test/resources/terremark/vdc.xml b/vcloud/terremark/src/test/resources/terremark/vdc.xml index 981d296170..9e4cdcd286 100644 --- a/vcloud/terremark/src/test/resources/terremark/vdc.xml +++ b/vcloud/terremark/src/test/resources/terremark/vdc.xml @@ -3,7 +3,10 @@ - + + + +