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);
} else if (qName.equals("Network")) {
putNamedResource(availableNetworks, attributes);
} else if (qName.equals("ResourcePayload")) {
} else if (qName.equals("ResourceEntity")) {
putNamedResource(resourceEntities, attributes);
}
}

View File

@ -38,22 +38,22 @@
</DeployedVmsQuota>
</ComputeCapacity>
<ResourceEntities>
<ResourcePayload
<ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1"
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"
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"
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"
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"
type="application/vnd.vmware.vcloud.vApp+xml" name="188849-1" />
<ResourcePayload
<ResourceEntity
href="https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"
type="application/vnd.vmware.vcloud.vApp+xml" name="188849-2" />
</ResourceEntities>

View File

@ -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
.<InetAddress> of(publicIp), vApp.getNetworkToAddresses().values(), 22,
LoginType.SSH, new Credentials("vcloud", "p4ssw0rd"));

View File

@ -56,11 +56,11 @@ public class ReturnVoidOnDeleteDefaultIp implements Function<Exception, Void> {
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;
}
}

View File

@ -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<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) {
for (InternetService service : set) {
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")
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");
}

View File

@ -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;
@ -55,8 +56,7 @@ public class TerremarkVDCHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml");
Injector injector = Guice.createInjector(new ParserModule(),
new AbstractModule() {
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
@Override
protected void configure() {
@ -66,8 +66,7 @@ public class TerremarkVDCHandlerTest {
@Provides
@VCloudApi
URI provide() {
return URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8");
return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
}
});
@ -76,12 +75,27 @@ public class TerremarkVDCHandlerTest {
TerremarkVDC result = (TerremarkVDC) factory.create(
injector.getInstance(TerremarkVDCHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1");
assertEquals(
result.getLocation(),
URI
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
assertEquals(result.getResourceEntities(), ImmutableMap
.<String, NamedResource> of());
assertEquals(
result.getResourceEntities(),
ImmutableMap
.<String, NamedResource> 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
@ -93,19 +107,9 @@ public class TerremarkVDCHandlerTest {
"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
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
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(),

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/internetServices" type="application/xml" name="Internet Services"/>
<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>
<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>