mirror of https://github.com/apache/jclouds.git
Issue 296 make terremark ecloud and vcloudexpress work from mvn -Plive install
This commit is contained in:
parent
f895756c65
commit
5413e12fcc
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
|
||||||
|
<requestId>31e35e56-dd3e-43d3-9c3b-656cb202d6e7</requestId>
|
||||||
|
<imagesSet>
|
||||||
|
<item>
|
||||||
|
<imageId>ami-7ea24a17</imageId>
|
||||||
|
<imageLocation>amazon/EC2 CentOS 5.4 HVM AMI</imageLocation>
|
||||||
|
<imageState>available</imageState>
|
||||||
|
<imageOwnerId>206029621532</imageOwnerId>
|
||||||
|
<isPublic>true</isPublic>
|
||||||
|
<architecture>x86_64</architecture>
|
||||||
|
<imageType>machine</imageType>
|
||||||
|
<imageOwnerAlias>amazon</imageOwnerAlias>
|
||||||
|
<name>EC2 CentOS 5.4 HVM AMI</name>
|
||||||
|
<description>EC2 CentOS 5.4 HVM AMI</description>
|
||||||
|
<rootDeviceType>ebs</rootDeviceType>
|
||||||
|
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||||
|
<blockDeviceMapping>
|
||||||
|
<item>
|
||||||
|
<deviceName>/dev/sda1</deviceName>
|
||||||
|
<ebs>
|
||||||
|
<snapshotId>snap-1099e578</snapshotId>
|
||||||
|
<volumeSize>20</volumeSize>
|
||||||
|
<deleteOnTermination>true</deleteOnTermination>
|
||||||
|
</ebs>
|
||||||
|
</item>
|
||||||
|
</blockDeviceMapping>
|
||||||
|
<virtualizationType>hvm</virtualizationType>
|
||||||
|
</item>
|
||||||
|
</imagesSet>
|
||||||
|
</DescribeImagesResponse>
|
|
@ -75,7 +75,6 @@ import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -121,7 +120,6 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
.append("sudo zypper install java-1.6.0-openjdk-devl\n")//
|
.append("sudo zypper install java-1.6.0-openjdk-devl\n")//
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
abstract public void setServiceDefaults();
|
abstract public void setServiceDefaults();
|
||||||
|
|
||||||
protected String provider;
|
protected String provider;
|
||||||
|
@ -139,6 +137,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
|
setServiceDefaults();
|
||||||
if (tag == null)
|
if (tag == null)
|
||||||
tag = checkNotNull(provider, "provider");
|
tag = checkNotNull(provider, "provider");
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
|
@ -272,11 +271,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
template = buildTemplate(client.templateBuilder());
|
refreshTemplate();
|
||||||
|
|
||||||
template.getOptions().installPrivateKey(newStringPayload(keyPair.get("private"))).authorizePublicKey(
|
|
||||||
newStringPayload(keyPair.get("public"))).runScript(
|
|
||||||
newStringPayload(buildScript(template.getImage().getOperatingSystem())));
|
|
||||||
try {
|
try {
|
||||||
nodes = newTreeSet(client.runNodesWithTag(tag, 2, template));
|
nodes = newTreeSet(client.runNodesWithTag(tag, 2, template));
|
||||||
} catch (RunNodesException e) {
|
} catch (RunNodesException e) {
|
||||||
|
@ -298,6 +293,14 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
checkOsMatchesTemplate(node2);
|
checkOsMatchesTemplate(node2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refreshTemplate() {
|
||||||
|
template = buildTemplate(client.templateBuilder());
|
||||||
|
|
||||||
|
template.getOptions().installPrivateKey(newStringPayload(keyPair.get("private"))).authorizePublicKey(
|
||||||
|
newStringPayload(keyPair.get("public"))).runScript(
|
||||||
|
newStringPayload(buildScript(template.getImage().getOperatingSystem())));
|
||||||
|
}
|
||||||
|
|
||||||
protected void checkImageIdMatchesTemplate(NodeMetadata node) {
|
protected void checkImageIdMatchesTemplate(NodeMetadata node) {
|
||||||
if (node.getImageId() != null)
|
if (node.getImageId() != null)
|
||||||
assertEquals(node.getImageId(), template.getImage().getId());
|
assertEquals(node.getImageId(), template.getImage().getId());
|
||||||
|
@ -319,13 +322,14 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript")
|
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript")
|
||||||
public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception {
|
public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception {
|
||||||
initializeContextAndClient();
|
initializeContextAndClient();
|
||||||
|
refreshTemplate();
|
||||||
TreeSet<NodeMetadata> nodes = newTreeSet(client.runNodesWithTag(tag, 1, template));
|
TreeSet<NodeMetadata> nodes = newTreeSet(client.runNodesWithTag(tag, 1, template));
|
||||||
checkNodes(nodes, tag);
|
checkNodes(nodes, tag);
|
||||||
NodeMetadata node = nodes.first();
|
NodeMetadata node = nodes.first();
|
||||||
this.nodes.add(node);
|
this.nodes.add(node);
|
||||||
assertEquals(nodes.size(), 1);
|
assertEquals(nodes.size(), 1);
|
||||||
assertLocationSameOrChild(node.getLocation(), template.getLocation());
|
assertLocationSameOrChild(node.getLocation(), template.getLocation());
|
||||||
assertEquals(node.getOperatingSystem().getFamily(), template.getImage().getOperatingSystem().getFamily());
|
checkOsMatchesTemplate(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os,
|
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os,
|
||||||
|
@ -334,11 +338,6 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)),
|
return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)),
|
||||||
overrideCredentialsWith(creds));
|
overrideCredentialsWith(creds));
|
||||||
} catch (SshException e) {
|
} catch (SshException e) {
|
||||||
if (getRootCause(e).getMessage().contains("Auth fail")) {
|
|
||||||
// System.err.printf("bad credentials: %s:%s for %s%n",
|
|
||||||
// creds.identity, creds.key, client
|
|
||||||
// .listNodesDetailsMatching(tag));
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.jclouds.rackspace.cloudservers.CloudServersAsyncClient;
|
||||||
import org.jclouds.rackspace.cloudservers.CloudServersClient;
|
import org.jclouds.rackspace.cloudservers.CloudServersClient;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +44,6 @@ import org.testng.annotations.Test;
|
||||||
@Test(groups = "live", enabled = true, sequential = true, testName = "cloudservers.CloudServersComputeServiceLiveTest")
|
@Test(groups = "live", enabled = true, sequential = true, testName = "cloudservers.CloudServersComputeServiceLiveTest")
|
||||||
public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
@Override
|
@Override
|
||||||
public void setServiceDefaults() {
|
public void setServiceDefaults() {
|
||||||
provider = "cloudservers";
|
provider = "cloudservers";
|
||||||
|
|
|
@ -87,9 +87,10 @@ public class VCloudGetNodeMetadata {
|
||||||
String tag = parseTagFromName(from.getName());
|
String tag = parseTagFromName(from.getName());
|
||||||
Location location = findLocationForResourceInVDC.apply(from.getVDC());
|
Location location = findLocationForResourceInVDC.apply(from.getVDC());
|
||||||
return new NodeMetadataImpl(in, from.getName(), in, location, from.getId(), ImmutableMap.<String, String> of(),
|
return new NodeMetadataImpl(in, from.getName(), in, location, from.getId(), ImmutableMap.<String, String> of(),
|
||||||
tag, null, new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(from.getOsType()), null, null,
|
tag, null, from.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(from
|
||||||
from.getOperatingSystemDescription()), vAppStatusToNodeState.get(from.getStatus()),
|
.getOsType()), null, null, from.getOperatingSystemDescription()) : null, vAppStatusToNodeState
|
||||||
computeClient.getPublicAddresses(id), computeClient.getPrivateAddresses(id), getExtra.apply(from), null);
|
.get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient
|
||||||
|
.getPrivateAddresses(id), getExtra.apply(from), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,7 +31,6 @@ import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +41,6 @@ import org.testng.annotations.Test;
|
||||||
@Test(groups = "live", enabled = true, sequential = true, testName = "vcloud.VCloudComputeServiceLiveTest")
|
@Test(groups = "live", enabled = true, sequential = true, testName = "vcloud.VCloudComputeServiceLiveTest")
|
||||||
public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
@Override
|
@Override
|
||||||
public void setServiceDefaults() {
|
public void setServiceDefaults() {
|
||||||
System.setProperty("vcloud.endpoint", checkNotNull(System.getProperty("jclouds.test.endpoint"),
|
System.setProperty("vcloud.endpoint", checkNotNull(System.getProperty("jclouds.test.endpoint"),
|
||||||
|
|
|
@ -31,10 +31,16 @@
|
||||||
<name>jclouds terremark Components Core</name>
|
<name>jclouds terremark Components Core</name>
|
||||||
<description>jclouds Core components to access terremark</description>
|
<description>jclouds Core components to access terremark</description>
|
||||||
<properties>
|
<properties>
|
||||||
<jclouds.terremark.endpoint></jclouds.terremark.endpoint>
|
<!-- when instances are hung, open a ticket and add here -->
|
||||||
<jclouds.test.identity>${jclouds.terremark.user}</jclouds.test.identity>
|
<jclouds.compute.blacklist.nodes>trmkrun-ccc,trmk-924</jclouds.compute.blacklist.nodes>
|
||||||
<jclouds.test.credential>${jclouds.terremark.password}</jclouds.test.credential>
|
<trmk-vcloudexpress.endpoint>https://services.vcloudexpress.terremark.com/api</trmk-vcloudexpress.endpoint>
|
||||||
<jclouds.test.endpoint>${jclouds.terremark.password}</jclouds.test.endpoint>
|
<trmk-vcloudexpress.apiversion>0.8a-ext1.6</trmk-vcloudexpress.apiversion>
|
||||||
|
<trmk-vcloudexpress.identity>FIXME</trmk-vcloudexpress.identity>
|
||||||
|
<trmk-vcloudexpress.credential>FIXME</trmk-vcloudexpress.credential>
|
||||||
|
<trmk-ecloud.endpoint>https://services.enterprisecloud.terremark.com/api</trmk-ecloud.endpoint>
|
||||||
|
<trmk-ecloud.apiversion>0.8b-ext2.3</trmk-ecloud.apiversion>
|
||||||
|
<trmk-ecloud.identity>FIXME</trmk-ecloud.identity>
|
||||||
|
<trmk-ecloud.credential>FIXME</trmk-ecloud.credential>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -58,4 +64,68 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>trmk-vcloudexpress.endpoint</name>
|
||||||
|
<value>${trmk-vcloudexpress.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-vcloudexpress.apiversion</name>
|
||||||
|
<value>${trmk-vcloudexpress.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-vcloudexpress.identity</name>
|
||||||
|
<value>${trmk-vcloudexpress.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-vcloudexpress.credential</name>
|
||||||
|
<value>${trmk-vcloudexpress.credential}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-ecloud.endpoint</name>
|
||||||
|
<value>${trmk-ecloud.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-ecloud.apiversion</name>
|
||||||
|
<value>${trmk-ecloud.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-ecloud.identity</name>
|
||||||
|
<value>${trmk-ecloud.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>trmk-ecloud.credential</name>
|
||||||
|
<value>${trmk-ecloud.credential}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>jclouds.compute.blacklist.nodes</name>
|
||||||
|
<value>${jclouds.compute.blacklist.nodes}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
||||||
return new Supplier<String>() {
|
return new Supplier<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String get() {
|
public String get() {
|
||||||
return random.nextInt(100) + "";
|
return random.nextInt(4096) + "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,10 @@ public class CreateUniqueKeyPair implements Function<OrgAndName, KeyPair> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KeyPair apply(OrgAndName from) {
|
public KeyPair apply(OrgAndName from) {
|
||||||
return createNewKeyPairInRegion(from.getOrg(), from.getName());
|
return createNewKeyPairInOrg(from.getOrg(), from.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyPair createNewKeyPairInRegion(URI org, String keyPairName) {
|
private KeyPair createNewKeyPairInOrg(URI org, String keyPairName) {
|
||||||
checkNotNull(org, "org");
|
checkNotNull(org, "org");
|
||||||
checkNotNull(keyPairName, "keyPairName");
|
checkNotNull(keyPairName, "keyPairName");
|
||||||
logger.debug(">> creating keyPair org(%s) name(%s)", org, keyPairName);
|
logger.debug(">> creating keyPair org(%s) name(%s)", org, keyPairName);
|
||||||
|
@ -82,6 +82,6 @@ public class CreateUniqueKeyPair implements Function<OrgAndName, KeyPair> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNextName(String keyPairName) {
|
private String getNextName(String keyPairName) {
|
||||||
return "jclouds#" + keyPairName + "-" + randomSuffix.get();
|
return "jclouds#" + keyPairName + "#" + randomSuffix.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,15 @@ public class DeleteKeyPair {
|
||||||
final ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap;
|
final ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DeleteKeyPair(TerremarkVCloudExpressClient terremarkClient, ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap) {
|
DeleteKeyPair(TerremarkVCloudExpressClient terremarkClient,
|
||||||
|
ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap) {
|
||||||
this.terremarkClient = terremarkClient;
|
this.terremarkClient = terremarkClient;
|
||||||
this.credentialsMap = credentialsMap;
|
this.credentialsMap = credentialsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(OrgAndName orgTag) {
|
public void execute(OrgAndName orgTag) {
|
||||||
for (KeyPair keyPair : terremarkClient.listKeyPairsInOrg(orgTag.getOrg())) {
|
for (KeyPair keyPair : terremarkClient.listKeyPairsInOrg(orgTag.getOrg())) {
|
||||||
if (keyPair.getName().matches("jclouds#" + orgTag.getName() + "-[0-9a-f]+")) {
|
if (keyPair.getName().matches("jclouds#" + orgTag.getName() + "#[0-9a-f]+")) {
|
||||||
logger.debug(">> deleting keyPair(%s)", keyPair.getName());
|
logger.debug(">> deleting keyPair(%s)", keyPair.getName());
|
||||||
terremarkClient.deleteKeyPair(keyPair.getId());
|
terremarkClient.deleteKeyPair(keyPair.getId());
|
||||||
// TODO: test this clear happens
|
// TODO: test this clear happens
|
||||||
|
|
|
@ -55,16 +55,15 @@ public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandl
|
||||||
try {
|
try {
|
||||||
String content = parseErrorFromContentOrNull(command, response);
|
String content = parseErrorFromContentOrNull(command, response);
|
||||||
switch (response.getStatusCode()) {
|
switch (response.getStatusCode()) {
|
||||||
case 400:
|
case 400:
|
||||||
exception = new IllegalArgumentException(response.getMessage(), exception);
|
exception = new IllegalArgumentException(response.getMessage(), exception);
|
||||||
break;
|
break;
|
||||||
case 401:
|
case 401:
|
||||||
exception = new AuthorizationException(command.getRequest(), content);
|
exception = new AuthorizationException(command.getRequest(), content);
|
||||||
break;
|
break;
|
||||||
case 403: // TODO temporary as terremark mistakenly uses this for vApp
|
case 403: // TODO temporary as terremark mistakenly uses this for vApp
|
||||||
// not found.
|
// not found.
|
||||||
case 404:
|
case 404:
|
||||||
if (!command.getRequest().getMethod().equals("DELETE")) {
|
|
||||||
String path = command.getRequest().getEndpoint().getPath();
|
String path = command.getRequest().getEndpoint().getPath();
|
||||||
Matcher matcher = RESOURCE_PATTERN.matcher(path);
|
Matcher matcher = RESOURCE_PATTERN.matcher(path);
|
||||||
String message;
|
String message;
|
||||||
|
@ -74,17 +73,16 @@ public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandl
|
||||||
message = path;
|
message = path;
|
||||||
}
|
}
|
||||||
exception = new ResourceNotFoundException(message, exception);
|
exception = new ResourceNotFoundException(message, exception);
|
||||||
}
|
break;
|
||||||
break;
|
case 500:
|
||||||
case 500:
|
if ((response.getMessage().indexOf("because there is a pending task running") != -1)
|
||||||
if ((response.getMessage().indexOf("because there is a pending task running") != -1)
|
|| (response.getMessage().indexOf("because it is already powered off") != -1)
|
||||||
|| (response.getMessage().indexOf("because it is already powered off") != -1)
|
|| (response.getMessage().indexOf("already exists") != -1)
|
||||||
|| (response.getMessage().indexOf("already exists") != -1)
|
|| (response.getMessage().indexOf("same name exists") != -1))
|
||||||
|| (response.getMessage().indexOf("same name exists") != -1))
|
exception = new IllegalStateException(response.getMessage(), exception);
|
||||||
exception = new IllegalStateException(response.getMessage(), exception);
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
exception = new HttpResponseException(command, response, content);
|
||||||
exception = new HttpResponseException(command, response, content);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
releasePayload(response);
|
releasePayload(response);
|
||||||
|
|
|
@ -22,14 +22,13 @@ package org.jclouds.vcloud.terremark;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
@ -78,8 +77,7 @@ public class InternetServiceLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllPublicIps() throws Exception {
|
public void testGetAllPublicIps() throws Exception {
|
||||||
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(tmClient.findVDCInOrgNamed(null, null)
|
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(tmClient.findVDCInOrgNamed(null, null).getId())) {
|
||||||
.getId())) {
|
|
||||||
tmClient.getInternetServicesOnPublicIp(ip.getId());
|
tmClient.getInternetServicesOnPublicIp(ip.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,15 +89,11 @@ public class InternetServiceLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
String identity = checkNotNull(System.getProperty("trmk-vcloudexpress.identity"), "trmk-vcloudexpress.identity");
|
||||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
String credential = checkNotNull(System.getProperty("trmk-vcloudexpress.credential"), "trmk-vcloudexpress.credential");
|
||||||
|
|
||||||
String endpoint = System.getProperty("jclouds.test.endpoint");
|
context = new ComputeServiceContextFactory().createContext("trmk-vcloudexpress", identity, credential, ImmutableSet
|
||||||
Properties props = new Properties();
|
.<Module> of(new Log4JLoggingModule(), new JschSshClientModule())).getProviderSpecificContext();
|
||||||
if (endpoint != null && !"".equals(endpoint))
|
|
||||||
props.setProperty("terremark.endpoint", endpoint);
|
|
||||||
context = new RestContextFactory().createContext("trmk-vcloudexpress", identity, credential, ImmutableSet
|
|
||||||
.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), props);
|
|
||||||
|
|
||||||
tmClient = context.getApi();
|
tmClient = context.getApi();
|
||||||
|
|
||||||
|
@ -108,7 +102,7 @@ public class InternetServiceLiveTest {
|
||||||
void print(Set<InternetService> set) {
|
void print(Set<InternetService> set) {
|
||||||
for (InternetService service : set) {
|
for (InternetService service : set) {
|
||||||
System.out.printf("%d (%s:%d%n)", service.getName(), service.getPublicIpAddress().getAddress(), service
|
System.out.printf("%d (%s:%d%n)", service.getName(), service.getPublicIpAddress().getAddress(), service
|
||||||
.getPort());
|
.getPort());
|
||||||
for (Node node : tmClient.getNodes(service.getId())) {
|
for (Node node : tmClient.getNodes(service.getId())) {
|
||||||
System.out.printf(" %d (%s:%d%n)", node.getName(), node.getIpAddress(), node.getPort());
|
System.out.printf(" %d (%s:%d%n)", node.getName(), node.getIpAddress(), node.getPort());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static com.google.common.collect.Iterables.find;
|
import static com.google.common.collect.Iterables.find;
|
||||||
import static com.google.common.collect.Iterables.size;
|
import static com.google.common.collect.Iterables.size;
|
||||||
|
@ -34,7 +33,6 @@ import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
@ -103,12 +101,13 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
private RetryablePredicate<URI> successTester;
|
private RetryablePredicate<URI> successTester;
|
||||||
private VApp clone;
|
private VApp clone;
|
||||||
private VDC vdc;
|
private VDC vdc;
|
||||||
|
protected String credential;
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllInternetServices() throws Exception {
|
public void testGetAllInternetServices() throws Exception {
|
||||||
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null)
|
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null)
|
||||||
.getId())) {
|
.getId())) {
|
||||||
assertNotNull(tmClient.getNodes(service.getId()));
|
assertNotNull(tmClient.getNodes(service.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +143,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
IOException {
|
IOException {
|
||||||
prepare();
|
prepare();
|
||||||
StringBuffer name = new StringBuffer();
|
StringBuffer name = new StringBuffer();
|
||||||
for (int i = 0; i < 15; i++)
|
for (int i = 0; i < 15; i++)
|
||||||
|
@ -168,7 +167,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
// if this template supports setting the root password, let's add it to
|
// if this template supports setting the root password, let's add it to
|
||||||
// our options
|
// our options
|
||||||
CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions()
|
CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions()
|
||||||
.getId());
|
.getId());
|
||||||
if (customizationOptions.canCustomizePassword())
|
if (customizationOptions.canCustomizePassword())
|
||||||
instantiateOptions.withPassword("robotsarefun");
|
instantiateOptions.withPassword("robotsarefun");
|
||||||
|
|
||||||
|
@ -229,11 +228,11 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
PublicIpAddress ip;
|
PublicIpAddress ip;
|
||||||
if (tmClient instanceof TerremarkVCloudExpressClient) {
|
if (tmClient instanceof TerremarkVCloudExpressClient) {
|
||||||
is = TerremarkVCloudExpressClient.class.cast(tmClient).addInternetServiceToVDC(
|
is = TerremarkVCloudExpressClient.class.cast(tmClient).addInternetServiceToVDC(
|
||||||
tmClient.findVDCInOrgNamed(null, null).getId(), "SSH", Protocol.TCP, 22);
|
tmClient.findVDCInOrgNamed(null, null).getId(), "SSH", Protocol.TCP, 22);
|
||||||
ip = is.getPublicIpAddress();
|
ip = is.getPublicIpAddress();
|
||||||
} else {
|
} else {
|
||||||
ip = TerremarkECloudClient.class.cast(tmClient).activatePublicIpInVDC(
|
ip = TerremarkECloudClient.class.cast(tmClient).activatePublicIpInVDC(
|
||||||
tmClient.findVDCInOrgNamed(null, null).getId());
|
tmClient.findVDCInOrgNamed(null, null).getId());
|
||||||
is = tmClient.addInternetServiceToExistingIp(ip.getId(), "SSH", Protocol.TCP, 22);
|
is = tmClient.addInternetServiceToExistingIp(ip.getId(), "SSH", Protocol.TCP, 22);
|
||||||
}
|
}
|
||||||
publicIp = ip.getAddress();
|
publicIp = ip.getAddress();
|
||||||
|
@ -274,7 +273,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
||||||
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
|
node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
|
||||||
+ "-SSH", 22);
|
+ "-SSH", 22);
|
||||||
loopAndCheckPass();
|
loopAndCheckPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +336,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
|
||||||
Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
|
Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
|
||||||
.addDisk(25 * 1048576).addDisk(25 * 1048576));
|
.addDisk(25 * 1048576).addDisk(25 * 1048576));
|
||||||
|
|
||||||
assert successTester.apply(task.getLocation());
|
assert successTester.apply(task.getLocation());
|
||||||
|
|
||||||
|
@ -355,7 +354,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
|
|
||||||
// extract the disks on the vApp sorted by addressOnParent
|
// extract the disks on the vApp sorted by addressOnParent
|
||||||
List<ResourceAllocation> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
List<ResourceAllocation> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
||||||
resourceType(ResourceType.DISK_DRIVE)));
|
resourceType(ResourceType.DISK_DRIVE)));
|
||||||
|
|
||||||
// delete the second disk
|
// delete the second disk
|
||||||
task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1).getAddressOnParent()));
|
task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1).getAddressOnParent()));
|
||||||
|
@ -367,18 +366,18 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
|
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
|
||||||
long memory, long hardDisk) {
|
long memory, long hardDisk) {
|
||||||
assertEquals(vApp.getName(), serverName);
|
assertEquals(vApp.getName(), serverName);
|
||||||
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(),
|
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(),
|
||||||
processorCount);
|
processorCount);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1);
|
find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1);
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory);
|
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory);
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
||||||
hardDisk);
|
hardDisk);
|
||||||
assertEquals(vApp.getSize().longValue(), find(vApp.getResourceAllocations(),
|
assertEquals(vApp.getSize().longValue(), find(vApp.getResourceAllocations(),
|
||||||
resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCheckPass(String address) throws IOException {
|
private void doCheckPass(String address) throws IOException {
|
||||||
|
@ -431,15 +430,10 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
setupCredentials();
|
||||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
|
||||||
|
|
||||||
String endpoint = System.getProperty("jclouds.test.endpoint");
|
|
||||||
Properties props = new Properties();
|
|
||||||
if (endpoint != null && !"".equals(endpoint))
|
|
||||||
props.setProperty("terremark.endpoint", endpoint);
|
|
||||||
Injector injector = new RestContextFactory().createContextBuilder(provider, identity, credential,
|
Injector injector = new RestContextFactory().createContextBuilder(provider, identity, credential,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), props).buildInjector();
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule())).buildInjector();
|
||||||
|
|
||||||
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
|
|
||||||
|
@ -453,4 +447,6 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
successTester = new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS);
|
successTester = new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract void setupCredentials();
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
|
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
|
@ -45,6 +46,12 @@ public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest {
|
||||||
return processorCount(1).memory(512);
|
return processorCount(1).memory(512);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupCredentials() {
|
||||||
|
identity = checkNotNull(System.getProperty("trmk-ecloud.identity"), "trmk-ecloud.identity");
|
||||||
|
credential = checkNotNull(System.getProperty("trmk-ecloud.credential"), "trmk-ecloud.credential");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SshClient getConnectionFor(IPSocket socket) {
|
protected SshClient getConnectionFor(IPSocket socket) {
|
||||||
return sshFactory.create(socket, "ecloud", "$Ep455l0ud!2");
|
return sshFactory.create(socket, "ecloud", "$Ep455l0ud!2");
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -41,7 +42,12 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkVCloudClientLiveTest")
|
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkVCloudClientLiveTest")
|
||||||
public class TerremarkVCloudClientLiveTest extends TerremarkClientLiveTest {
|
public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest {
|
||||||
|
@Override
|
||||||
|
protected void setupCredentials() {
|
||||||
|
identity = checkNotNull(System.getProperty("trmk-vcloudexpress.identity"), "trmk-vcloudexpress.identity");
|
||||||
|
credential = checkNotNull(System.getProperty("trmk-vcloudexpress.credential"), "trmk-vcloudexpress.credential");
|
||||||
|
}
|
||||||
|
|
||||||
KeyPair key;
|
KeyPair key;
|
||||||
|
|
||||||
|
@ -74,7 +80,7 @@ public class TerremarkVCloudClientLiveTest extends TerremarkClientLiveTest {
|
||||||
assertNotNull(key.getFingerPrint());
|
assertNotNull(key.getFingerPrint());
|
||||||
assertEquals(key.isDefault(), false);
|
assertEquals(key.isDefault(), false);
|
||||||
assertEquals(key.getFingerPrint(), vCloudExpressClient.findKeyPairInOrg(org.getId(), key.getName())
|
assertEquals(key.getFingerPrint(), vCloudExpressClient.findKeyPairInOrg(org.getId(), key.getName())
|
||||||
.getFingerPrint());
|
.getFingerPrint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
|
@ -0,0 +1,100 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.vcloud.terremark.compute;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkECloudAsyncClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkECloudClient;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", enabled = true, sequential = true, testName = "terremark.TerremarkVCloudComputeServiceLiveTest")
|
||||||
|
public class TerremarkECloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setServiceDefaults() {
|
||||||
|
provider = "trmk-ecloud";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupCredentials() {
|
||||||
|
identity = checkNotNull(System.getProperty("trmk-ecloud.identity"), "trmk-ecloud.identity");
|
||||||
|
credential = checkNotNull(System.getProperty("trmk-ecloud.credential"), "trmk-ecloud.credential");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTemplateBuilder() {
|
||||||
|
Template defaultTemplate = client.templateBuilder().build();
|
||||||
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||||
|
assertEquals(defaultTemplate.getLocation().getDescription(), "Miami Environment 1");
|
||||||
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAssignability() throws Exception {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
RestContext<TerremarkECloudClient, TerremarkECloudAsyncClient> tmContext = new ComputeServiceContextFactory()
|
||||||
|
.createContext(provider, identity, credential).getProviderSpecificContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
||||||
|
Template template = super.buildTemplate(templateBuilder);
|
||||||
|
Image image = template.getImage();
|
||||||
|
assert image.getDefaultCredentials().identity != null : image;
|
||||||
|
assert image.getDefaultCredentials().credential != null : image;
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
// currently, the wrong CIM OSType data is coming back.
|
||||||
|
@Override
|
||||||
|
protected void checkOsMatchesTemplate(NodeMetadata node) {
|
||||||
|
if (node.getOperatingSystem() != null)
|
||||||
|
assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testListImages() throws Exception {
|
||||||
|
for (Image image : client.listImages()) {
|
||||||
|
assert image.getProviderId() != null : image;
|
||||||
|
// image.getLocationId() can be null, if it is a location-free image
|
||||||
|
assertEquals(image.getType(), ComputeType.IMAGE);
|
||||||
|
assert image.getDefaultCredentials().identity != null : image;
|
||||||
|
if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS)
|
||||||
|
assert image.getDefaultCredentials().credential != null : image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.compute;
|
package org.jclouds.vcloud.terremark.compute;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
@ -32,7 +33,6 @@ import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressAsyncClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressAsyncClient;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressClient;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,16 +41,18 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = true, sequential = true, testName = "terremark.TerremarkVCloudComputeServiceLiveTest")
|
@Test(groups = "live", enabled = true, sequential = true, testName = "terremark.TerremarkVCloudComputeServiceLiveTest")
|
||||||
public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
|
public class TerremarkVCloudExpressComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
@Override
|
@Override
|
||||||
public void setServiceDefaults() {
|
public void setServiceDefaults() {
|
||||||
String endpoint = System.getProperty("jclouds.test.endpoint");
|
|
||||||
if (endpoint != null && !"".equals(endpoint))
|
|
||||||
System.setProperty("terremark.endpoint", endpoint);
|
|
||||||
provider = "trmk-vcloudexpress";
|
provider = "trmk-vcloudexpress";
|
||||||
tag = "trmk";
|
tag = "trmk-vcx";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupCredentials() {
|
||||||
|
identity = checkNotNull(System.getProperty("trmk-vcloudexpress.identity"), "trmk-vcloudexpress.identity");
|
||||||
|
credential = checkNotNull(System.getProperty("trmk-vcloudexpress.credential"), "trmk-vcloudexpress.credential");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -75,7 +75,7 @@ public class DeleteKeyPairTest {
|
||||||
|
|
||||||
// setup expectations
|
// setup expectations
|
||||||
expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of(keyPair));
|
expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of(keyPair));
|
||||||
expect(keyPair.getName()).andReturn("jclouds#" + orgTag.getName() + "-123").atLeastOnce();
|
expect(keyPair.getName()).andReturn("jclouds#" + orgTag.getName() + "#123").atLeastOnce();
|
||||||
expect(keyPair.getId()).andReturn(URI.create("1245"));
|
expect(keyPair.getId()).andReturn(URI.create("1245"));
|
||||||
strategy.terremarkClient.deleteKeyPair(URI.create("1245"));
|
strategy.terremarkClient.deleteKeyPair(URI.create("1245"));
|
||||||
expect(strategy.credentialsMap.remove(orgTag)).andReturn(null);
|
expect(strategy.credentialsMap.remove(orgTag)).andReturn(null);
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -57,15 +56,12 @@ public class VAppTemplatesInOrgsLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
String identity = checkNotNull(System.getProperty("trmk-vcloudexpress.identity"), "trmk-vcloudexpress.identity");
|
||||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
String credential = checkNotNull(System.getProperty("trmk-vcloudexpress.credential"),
|
||||||
|
"trmk-vcloudexpress.credential");
|
||||||
|
|
||||||
String endpoint = System.getProperty("jclouds.test.endpoint");
|
|
||||||
Properties props = new Properties();
|
|
||||||
if (endpoint != null && !"".equals(endpoint))
|
|
||||||
props.setProperty("terremark.endpoint", endpoint);
|
|
||||||
Injector injector = new RestContextFactory().createContextBuilder("trmk-vcloudexpress", identity, credential,
|
Injector injector = new RestContextFactory().createContextBuilder("trmk-vcloudexpress", identity, credential,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), props).buildInjector();
|
ImmutableSet.<Module> of(new Log4JLoggingModule())).buildInjector();
|
||||||
|
|
||||||
tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
allCatalogItemsInOrganization = injector.getInstance(AllCatalogItemsInOrganization.class);
|
allCatalogItemsInOrganization = injector.getInstance(AllCatalogItemsInOrganization.class);
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.http.BaseHttpErrorHandlerTest;
|
import org.jclouds.http.BaseHttpErrorHandlerTest;
|
||||||
import org.jclouds.http.HttpErrorHandler;
|
import org.jclouds.http.HttpErrorHandler;
|
||||||
import org.jclouds.http.HttpResponseException;
|
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -36,13 +35,10 @@ import org.testng.annotations.Test;
|
||||||
public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest {
|
public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGet400SetsIllegalArgumentException() {
|
public void testGet400SetsIllegalArgumentException() {
|
||||||
assertCodeMakes(
|
assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 400,
|
||||||
"GET",
|
"HTTP/1.1 400 Service name is required.", "", IllegalArgumentException.class);
|
||||||
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
|
|
||||||
400,
|
|
||||||
"HTTP/1.1 400 Service name is required.",
|
|
||||||
"", IllegalArgumentException.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGet403SetsResourceNotFoundException() {
|
public void testGet403SetsResourceNotFoundException() {
|
||||||
assertCodeMakes(
|
assertCodeMakes(
|
||||||
|
@ -54,33 +50,35 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGet404SetsResourceNotFoundException() {
|
public void testDelete403SetsResourceNotFoundException() {
|
||||||
assertCodeMakes("GET", URI
|
assertCodeMakes(
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
|
"DELETE",
|
||||||
404, "", "", ResourceNotFoundException.class);
|
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vapp/361849"),
|
||||||
|
403,
|
||||||
|
"HTTP/1.1 403 Server does not exist in the system. Server was probably deleted by another user. Please refresh and retry the operation",
|
||||||
|
"", ResourceNotFoundException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete404SetsHttpResponseException() {
|
public void testGet404SetsResourceNotFoundException() {
|
||||||
assertCodeMakes("DELETE", URI
|
assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 404,
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
|
"", "", ResourceNotFoundException.class);
|
||||||
404, "", "", HttpResponseException.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test401SetsAuthorizationException() {
|
public void test401SetsAuthorizationException() {
|
||||||
assertCodeMakes("GET", URI
|
assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 401,
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
|
"", "", AuthorizationException.class);
|
||||||
401, "", "", AuthorizationException.class);
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Test
|
//
|
||||||
// public void testbecause_there_is_a_pending_task_runningSetsIllegalStateException() {
|
// @Test
|
||||||
// assertCodeMakes("GET", URI
|
// public void testbecause_there_is_a_pending_task_runningSetsIllegalStateException() {
|
||||||
// .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
|
// assertCodeMakes("GET", URI
|
||||||
// 500, "because there is a pending task running",
|
// .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
|
||||||
// "because there is a pending task running", IllegalStateException.class);
|
// 500, "because there is a pending task running",
|
||||||
// }
|
// "because there is a pending task running", IllegalStateException.class);
|
||||||
|
// }
|
||||||
|
|
||||||
// case 401:
|
// case 401:
|
||||||
// exception = new AuthorizationException(command.getRequest(), content);
|
// exception = new AuthorizationException(command.getRequest(), content);
|
||||||
|
|
Loading…
Reference in New Issue