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)
|
||||
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||
|
||||
/**
|
||||
* @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.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);
|
||||
String templateId = imageCatalogIdMap.get(image);
|
||||
String vDCId = tmClient.getDefaultVDC().getId();
|
||||
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) minCores(%d) minMegs(%d) properties(%s)",vDCId, templateId,
|
||||
name, minCores, minMegs, properties);
|
||||
logger
|
||||
.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,
|
||||
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(minCores)
|
||||
.memory(minMegs).productProperties(properties));
|
||||
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(minCores).memory(
|
||||
minMegs).productProperties(properties));
|
||||
logger.debug("<< instantiated VApp(%s)", vApp.getId());
|
||||
|
||||
logger.debug(">> deploying vApp(%s)", vApp.getId());
|
||||
|
@ -125,32 +128,37 @@ public class TerremarkVCloudComputeClient {
|
|||
switch (port) {
|
||||
case 22:
|
||||
protocol = Protocol.TCP;
|
||||
break;
|
||||
case 80:
|
||||
case 8080:
|
||||
protocol = Protocol.HTTP;
|
||||
break;
|
||||
case 443:
|
||||
protocol = Protocol.HTTPS;
|
||||
break;
|
||||
default:
|
||||
protocol = Protocol.HTTP;
|
||||
|
||||
break;
|
||||
}
|
||||
if (ip == null) {
|
||||
logger.debug(">> creating InternetService in vDC %s; port %d", vApp.getVDC().getId(),
|
||||
port);
|
||||
logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getId(),
|
||||
protocol, port);
|
||||
is = tmClient.addInternetServiceToVDC(vApp.getVDC().getId(), vApp.getName() + "-"
|
||||
+ port, protocol, port,
|
||||
withDescription(String.format("port %d access to serverId: %s name: %s", port,
|
||||
vApp.getId(), vApp.getName())));
|
||||
ip = is.getPublicIpAddress();
|
||||
} 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,
|
||||
protocol, port, withDescription(String.format(
|
||||
"port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||
.getName())));
|
||||
}
|
||||
logger.debug("<< created InternetService(%s) %s:%d", is.getId(), is.getPublicIpAddress()
|
||||
.getAddress().getHostAddress(), is.getPort());
|
||||
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getId(), is
|
||||
.getPublicIpAddress().getAddress().getHostAddress(), is.getProtocol(), is
|
||||
.getPort());
|
||||
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress()
|
||||
.getHostAddress(), is.getPort(), privateAddress.getHostAddress(), port);
|
||||
Node node = tmClient
|
||||
|
|
|
@ -85,7 +85,7 @@ public class TerremarkVCloudComputeService implements ComputeService {
|
|||
public CreateServerResponse createServer(String name, Profile profile, Image image) {
|
||||
String id = computeClient.start(name, image, 1, 512, ImmutableMap.<String, String> of());
|
||||
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
|
||||
.get(vApp.getStatus()), ImmutableSet.<InetAddress> of(publicIp), vApp
|
||||
.getNetworkToAddresses().values(), 22, LoginType.SSH, new Credentials("vcloud",
|
||||
|
|
|
@ -120,8 +120,10 @@ public class TerremarkVCloudComputeClientLiveTest {
|
|||
|
||||
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
||||
public void testSshLoadBalanceIp() {
|
||||
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22, 80,
|
||||
8080);
|
||||
// InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22,
|
||||
// 80,
|
||||
// 443, 8080); /// error 500
|
||||
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22);
|
||||
assert addressTester.apply(publicIp);
|
||||
// client.exec(publicIp, "uname -a");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue