mirror of https://github.com/apache/jclouds.git
Issue 112: only create port 22 as there are persistent errors creating multiple internet services
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2509 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
953d480ce0
commit
d22717bbcc
|
@ -96,6 +96,7 @@ import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
*/
|
*/
|
||||||
@RequestFilters(SetVCloudTokenCookie.class)
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TerremarkVCloudClient#getDefaultVDC
|
* @see TerremarkVCloudClient#getDefaultVDC
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -74,15 +74,18 @@ public class TerremarkVCloudComputeClient {
|
||||||
Image.CENTOS_53, "6").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
Image.CENTOS_53, "6").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
||||||
Image.UMBUNTU_JEOS, "11").build();
|
Image.UMBUNTU_JEOS, "11").build();
|
||||||
|
|
||||||
public String start(String name, Image image, int minCores, int minMegs, Map<String, String> properties) {
|
public String start(String name, Image image, int minCores, int minMegs,
|
||||||
|
Map<String, String> properties) {
|
||||||
checkArgument(imageCatalogIdMap.containsKey(image), "image not configured: " + image);
|
checkArgument(imageCatalogIdMap.containsKey(image), "image not configured: " + image);
|
||||||
String templateId = imageCatalogIdMap.get(image);
|
String templateId = imageCatalogIdMap.get(image);
|
||||||
String vDCId = tmClient.getDefaultVDC().getId();
|
String vDCId = tmClient.getDefaultVDC().getId();
|
||||||
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) minCores(%d) minMegs(%d) properties(%s)",vDCId, templateId,
|
logger
|
||||||
name, minCores, minMegs, properties);
|
.debug(
|
||||||
|
">> instantiating vApp vDC(%s) template(%s) name(%s) minCores(%d) minMegs(%d) properties(%s)",
|
||||||
|
vDCId, templateId, name, minCores, minMegs, properties);
|
||||||
TerremarkVApp vApp = tmClient.instantiateVAppTemplateInVDC(vDCId, name, templateId,
|
TerremarkVApp vApp = tmClient.instantiateVAppTemplateInVDC(vDCId, name, templateId,
|
||||||
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(minCores)
|
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(minCores).memory(
|
||||||
.memory(minMegs).productProperties(properties));
|
minMegs).productProperties(properties));
|
||||||
logger.debug("<< instantiated VApp(%s)", vApp.getId());
|
logger.debug("<< instantiated VApp(%s)", vApp.getId());
|
||||||
|
|
||||||
logger.debug(">> deploying vApp(%s)", vApp.getId());
|
logger.debug(">> deploying vApp(%s)", vApp.getId());
|
||||||
|
@ -125,32 +128,37 @@ public class TerremarkVCloudComputeClient {
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case 22:
|
case 22:
|
||||||
protocol = Protocol.TCP;
|
protocol = Protocol.TCP;
|
||||||
|
break;
|
||||||
case 80:
|
case 80:
|
||||||
case 8080:
|
case 8080:
|
||||||
protocol = Protocol.HTTP;
|
protocol = Protocol.HTTP;
|
||||||
|
break;
|
||||||
case 443:
|
case 443:
|
||||||
protocol = Protocol.HTTPS;
|
protocol = Protocol.HTTPS;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
protocol = Protocol.HTTP;
|
protocol = Protocol.HTTP;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
logger.debug(">> creating InternetService in vDC %s; port %d", vApp.getVDC().getId(),
|
logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getId(),
|
||||||
port);
|
protocol, port);
|
||||||
is = tmClient.addInternetServiceToVDC(vApp.getVDC().getId(), vApp.getName() + "-"
|
is = tmClient.addInternetServiceToVDC(vApp.getVDC().getId(), vApp.getName() + "-"
|
||||||
+ port, protocol, port,
|
+ port, protocol, port,
|
||||||
withDescription(String.format("port %d access to serverId: %s name: %s", port,
|
withDescription(String.format("port %d access to serverId: %s name: %s", port,
|
||||||
vApp.getId(), vApp.getName())));
|
vApp.getId(), vApp.getName())));
|
||||||
ip = is.getPublicIpAddress();
|
ip = is.getPublicIpAddress();
|
||||||
} else {
|
} else {
|
||||||
logger.debug(">> adding InternetService %s:%d", ip.getAddress().getHostAddress(), port);
|
logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress().getHostAddress(),
|
||||||
|
protocol, port);
|
||||||
is = tmClient.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port,
|
is = tmClient.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port,
|
||||||
protocol, port, withDescription(String.format(
|
protocol, port, withDescription(String.format(
|
||||||
"port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
"port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||||
.getName())));
|
.getName())));
|
||||||
}
|
}
|
||||||
logger.debug("<< created InternetService(%s) %s:%d", is.getId(), is.getPublicIpAddress()
|
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getId(), is
|
||||||
.getAddress().getHostAddress(), is.getPort());
|
.getPublicIpAddress().getAddress().getHostAddress(), is.getProtocol(), is
|
||||||
|
.getPort());
|
||||||
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress()
|
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress()
|
||||||
.getHostAddress(), is.getPort(), privateAddress.getHostAddress(), port);
|
.getHostAddress(), is.getPort(), privateAddress.getHostAddress(), port);
|
||||||
Node node = tmClient
|
Node node = tmClient
|
||||||
|
|
|
@ -85,7 +85,7 @@ 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, image, 1, 512, ImmutableMap.<String, String> of());
|
String id = computeClient.start(name, image, 1, 512, ImmutableMap.<String, String> of());
|
||||||
TerremarkVApp vApp = tmClient.getVApp(id);
|
TerremarkVApp vApp = tmClient.getVApp(id);
|
||||||
InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22, 80, 443, 8080);
|
InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22);
|
||||||
return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), vAppStatusToServerState
|
return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), vAppStatusToServerState
|
||||||
.get(vApp.getStatus()), ImmutableSet.<InetAddress> of(publicIp), vApp
|
.get(vApp.getStatus()), ImmutableSet.<InetAddress> of(publicIp), vApp
|
||||||
.getNetworkToAddresses().values(), 22, LoginType.SSH, new Credentials("vcloud",
|
.getNetworkToAddresses().values(), 22, LoginType.SSH, new Credentials("vcloud",
|
||||||
|
|
|
@ -120,8 +120,10 @@ public class TerremarkVCloudComputeClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
||||||
public void testSshLoadBalanceIp() {
|
public void testSshLoadBalanceIp() {
|
||||||
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22, 80,
|
// InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22,
|
||||||
8080);
|
// 80,
|
||||||
|
// 443, 8080); /// error 500
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue