Issue 131: regression

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2413 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-12-13 23:52:56 +00:00
parent 8023ccefff
commit b55d2165d0
8 changed files with 98 additions and 88 deletions

View File

@ -82,7 +82,7 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
vDC = newNamedResource(attributes); vDC = newNamedResource(attributes);
} else if (qName.equals("Network")) { } else if (qName.equals("Network")) {
putNamedResource(availableNetworks, attributes); putNamedResource(availableNetworks, attributes);
} else if (qName.equals("ResourcePayload")) { } else if (qName.equals("ResourceEntity")) {
putNamedResource(resourceEntities, attributes); putNamedResource(resourceEntities, attributes);
} }
} }

View File

@ -38,22 +38,22 @@
</DeployedVmsQuota> </DeployedVmsQuota>
</ComputeCapacity> </ComputeCapacity>
<ResourceEntities> <ResourceEntities>
<ResourcePayload <ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1" href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1"
type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Plesk (Linux) 64-bit Template" /> type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Plesk (Linux) 64-bit Template" />
<ResourcePayload <ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2" href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"
type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Windows 2008 Datacenter 64 Bit Template" /> type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Windows 2008 Datacenter 64 Bit Template" />
<ResourcePayload <ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3" href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"
type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Cent OS 64 Bit Template" /> type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Cent OS 64 Bit Template" />
<ResourcePayload <ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4" href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4"
type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="cPanel (Linux) 64 Bit Template" /> type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="cPanel (Linux) 64 Bit Template" />
<ResourcePayload <ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1" href="https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1"
type="application/vnd.vmware.vcloud.vApp+xml" name="188849-1" /> type="application/vnd.vmware.vcloud.vApp+xml" name="188849-1" />
<ResourcePayload <ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2" href="https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"
type="application/vnd.vmware.vcloud.vApp+xml" name="188849-2" /> type="application/vnd.vmware.vcloud.vApp+xml" name="188849-2" />
</ResourceEntities> </ResourceEntities>

View File

@ -72,7 +72,9 @@ public class TerremarkVCloudComputeService implements ComputeService {
public CreateServerResponse createServer(String name, Profile profile, Image image) { public CreateServerResponse createServer(String name, Profile profile, Image image) {
String id = computeClient.start(name, 1, 512, image); String id = computeClient.start(name, 1, 512, image);
VApp vApp = tmClient.getVApp(id); 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 return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), ImmutableSet
.<InetAddress> of(publicIp), vApp.getNetworkToAddresses().values(), 22, .<InetAddress> of(publicIp), vApp.getNetworkToAddresses().values(), 22,
LoginType.SSH, new Credentials("vcloud", "p4ssw0rd")); LoginType.SSH, new Credentials("vcloud", "p4ssw0rd"));

View File

@ -56,11 +56,11 @@ public class ReturnVoidOnDeleteDefaultIp implements Function<Exception, Void> {
if (from instanceof HttpResponseException) { if (from instanceof HttpResponseException) {
HttpResponseException hre = (HttpResponseException) from; HttpResponseException hre = (HttpResponseException) from;
if (hre.getResponse().getStatusCode() == 503 if (hre.getResponse().getStatusCode() == 503
|| hre.getResponse().getStatusCode() == 401
|| hre.getMessage().matches( || hre.getMessage().matches(
".*Cannot release this Public IP as it is default oubound IP.*")) ".*Cannot release this Public IP as it is default oubound IP.*"))
return v; return v;
} }
return null; return null;
} }
} }

View File

@ -62,29 +62,18 @@ public class InternetServiceLiveTest {
} }
@Test @Test
public void testAddInternetService() { public void testAddInternetService() throws InterruptedException {
InternetService is = tmClient.addInternetService("test-" + 22, Protocol.TCP, 22); InternetService is = tmClient.addInternetService("test-" + 22, Protocol.TCP, 22);
services.add(is); services.add(is);
PublicIpAddress ip = is.getPublicIpAddress(); PublicIpAddress ip = is.getPublicIpAddress();
for (int port : new int[] { 80, 8080 }) { // current bug in terremark
services.add(tmClient.addInternetServiceToExistingIp(ip.getId(), "test-" + port, // for (int port : new int[] { 80, 8080 }) {
Protocol.HTTP, port)); // services.add(tmClient.addInternetServiceToExistingIp(ip.getId(), "test-" + port,
} // Protocol.HTTP, port));
// }
print(tmClient.getInternetServicesOnPublicIp(ip.getId())); print(tmClient.getInternetServicesOnPublicIp(ip.getId()));
} }
private void print(SortedSet<InternetService> 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<InternetService> set) { private void delete(SortedSet<InternetService> set) {
for (InternetService service : set) { for (InternetService service : set) {
for (Node node : tmClient.getNodes(service.getId())) { for (Node node : tmClient.getNodes(service.getId())) {
@ -120,4 +109,14 @@ public class InternetServiceLiveTest {
} }
private void print(SortedSet<InternetService> 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());
}
}
}
} }

View File

@ -118,9 +118,11 @@ public class TerremarkVCloudComputeClientLiveTest {
@Test(dependsOnMethods = "testGetAnyPrivateAddress") @Test(dependsOnMethods = "testGetAnyPrivateAddress")
public void testSshLoadBalanceIp() { public void testSshLoadBalanceIp() {
// bug creating more than one internet service returns 503 or 500
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22, 80, // InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22,
8080); // 80,
// 8080);
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22);
assert addressTester.apply(publicIp); assert addressTester.apply(publicIp);
// client.exec(publicIp, "uname -a"); // client.exec(publicIp, "uname -a");
} }

View File

@ -35,6 +35,7 @@ import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.domain.NamedResource; import org.jclouds.rest.domain.NamedResource;
import org.jclouds.rest.domain.internal.NamedLinkImpl; import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.rest.internal.NamedResourceImpl; import org.jclouds.rest.internal.NamedResourceImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.endpoints.VCloudApi; import org.jclouds.vcloud.endpoints.VCloudApi;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC; import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -53,66 +54,69 @@ import com.google.inject.Provides;
@Test(groups = "unit", testName = "vcloud.TerremarkVDCHandlerTest") @Test(groups = "unit", testName = "vcloud.TerremarkVDCHandlerTest")
public class TerremarkVDCHandlerTest { public class TerremarkVDCHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml"); InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml");
Injector injector = Guice.createInjector(new ParserModule(), Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Provides @Provides
@VCloudApi @VCloudApi
URI provide() { URI provide() {
return URI return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
.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( TerremarkVDC result = (TerremarkVDC) factory.create(
injector.getInstance(TerremarkVDCHandler.class)).parse(is); injector.getInstance(TerremarkVDCHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1"); assertEquals(result.getName(), "Miami Environment 1");
assertEquals( assertEquals(result.getLocation(), URI
result.getLocation(), .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
URI assertEquals(
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")); result.getResourceEntities(),
assertEquals(result.getResourceEntities(), ImmutableMap ImmutableMap
.<String, NamedResource> of()); .<String, NamedResource> of(
assertEquals( "adriantest",
result.getAvailableNetworks(), new NamedResourceImpl(
ImmutableMap "15124",
.of( "adriantest",
"10.114.34.128/26", VCloudMediaType.VAPP_XML,
new NamedResourceImpl( URI
"1708", .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")),
"10.114.34.128/26", "centos-53",
"application/vnd.vmware.vcloud.network+xml", new NamedResourceImpl(
URI "15120",
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708")))); "centos-53",
assertEquals( VCloudMediaType.VAPP_XML,
result.getCatalog(), URI
new NamedLinkImpl( .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120"))));
"Miami Environment 1",
CATALOG_XML, assertEquals(
URI result.getAvailableNetworks(),
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))); ImmutableMap
assertEquals( .of(
result.getPublicIps(), "10.114.34.128/26",
new NamedLinkImpl( new NamedResourceImpl(
"Public IPs", "1708",
"application/xml", "10.114.34.128/26",
URI "application/vnd.vmware.vcloud.network+xml",
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps"))); URI
assertEquals( .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
result.getInternetServices(), assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1", CATALOG_XML, URI
new NamedLinkImpl( .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
"Internet Services", assertEquals(result.getPublicIps(), new NamedLinkImpl("Public IPs", "application/xml", URI
"application/xml", .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
URI assertEquals(
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices"))); result.getInternetServices(),
} new NamedLinkImpl(
"Internet Services",
"application/xml",
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices")));
}
} }

View File

@ -3,7 +3,10 @@
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps" type="application/xml" name="Public IPs"/> <Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps" type="application/xml" name="Public IPs"/>
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices" type="application/xml" name="Internet Services"/> <Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices" type="application/xml" name="Internet Services"/>
<Description/> <Description/>
<ResourceEntities/> <ResourceEntities>
<ResourceEntity href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124" type="application/vnd.vmware.vcloud.vApp+xml" name="adriantest"/>
<ResourceEntity href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120" type="application/vnd.vmware.vcloud.vApp+xml" name="centos-53"/>
</ResourceEntities>
<AvailableNetworks> <AvailableNetworks>
<Network href="https://services.vcloudexpress.terremark.com/api/v0.8/network/1708" type="application/vnd.vmware.vcloud.network+xml" name="10.114.34.128/26"/> <Network href="https://services.vcloudexpress.terremark.com/api/v0.8/network/1708" type="application/vnd.vmware.vcloud.network+xml" name="10.114.34.128/26"/>
</AvailableNetworks> </AvailableNetworks>