use of org.jclouds.compute.domain.ExecResponse in project whirr by apache.
the class ChefServiceTest method testChefRunRecipeFromURL.
@Test(timeout = TestConstants.ITEST_TIMEOUT)
public void testChefRunRecipeFromURL() throws Exception {
// As chef will be mostly used indirectly in other services
// this test tests chef's ability to run a recipe, specifically to
// install nginx.
Recipe nginx = new Recipe("nginx", null, "http://s3.amazonaws.com/opscode-community/cookbook_versions/tarballs/529/original/nginx.tgz");
Map<? extends NodeMetadata, ExecResponse> responses = runRecipe(nginx);
printResponses(nginx, responses);
HttpClient client = new HttpClient();
final GetMethod getIndex = new GetMethod(String.format("http://%s", responses.keySet().iterator().next().getPublicAddresses().iterator().next()));
assertTrue("Could not connect with nginx server", retry(new Predicate<HttpClient>() {
@Override
public boolean apply(HttpClient input) {
try {
int statusCode = input.executeMethod(getIndex);
assertEquals("Status code should be 200", HttpStatus.SC_OK, statusCode);
return true;
} catch (Exception e) {
return false;
}
}
}, 10, 1, TimeUnit.SECONDS).apply(client));
String indexPageHTML = getIndex.getResponseBodyAsString();
assertTrue("The string 'nginx' should appear on the index page", indexPageHTML.contains("nginx"));
}
use of org.jclouds.compute.domain.ExecResponse in project whirr by apache.
the class PigServiceTest method testPigBin.
@Test(timeout = TestConstants.ITEST_TIMEOUT)
public void testPigBin() throws Exception {
Statement binPig = Statements.exec(". /etc/profile && pig -e fs -ls /");
Cluster.Instance pigInstance = findPigInstance();
Predicate<NodeMetadata> pigClientRole = and(alwaysTrue(), withIds(pigInstance.getId()));
Map<? extends NodeMetadata, ExecResponse> responses = controller.runScriptOnNodesMatching(clusterSpec, pigClientRole, binPig);
LOG.info("Responses for Statement: " + binPig);
for (Map.Entry<? extends NodeMetadata, ExecResponse> entry : responses.entrySet()) {
LOG.info("Node[" + entry.getKey().getId() + "]: " + entry.getValue());
}
assertResponsesContain(responses, binPig, "/hadoop");
}
use of org.jclouds.compute.domain.ExecResponse in project legacy-jclouds-examples by jclouds.
the class CreateVolumeAndAttach method mountVolume.
private void mountVolume(NodeMetadata node) {
System.out.println("Mount Volume and Create Filesystem");
String script = new ScriptBuilder().addStatement(exec("mkfs -t ext4 /dev/xvdd")).addStatement(exec("mount /dev/xvdd /mnt")).render(OsFamily.UNIX);
RunScriptOptions options = RunScriptOptions.Builder.blockOnComplete(true).overrideLoginPassword(Constants.PASSWORD);
ExecResponse response = compute.runScriptOnNode(node.getId(), script, options);
if (response.getExitStatus() == 0) {
System.out.println(" Exit Status: " + response.getExitStatus());
} else {
System.out.println(" Error: " + response.getOutput());
}
}
use of org.jclouds.compute.domain.ExecResponse in project legacy-jclouds-examples by jclouds.
the class DetachVolume method unmountVolume.
/**
* Make sure you've unmounted the volume first. Failure to do so could result in failure or data loss.
*/
private void unmountVolume(VolumeAttachment volumeAttachment) {
System.out.println("Unmount Volume");
String script = new ScriptBuilder().addStatement(exec("umount /mnt")).render(OsFamily.UNIX);
RunScriptOptions options = RunScriptOptions.Builder.overrideLoginUser(Constants.ROOT).overrideLoginPassword(Constants.PASSWORD).blockOnComplete(true);
ZoneAndId zoneAndId = ZoneAndId.fromZoneAndId(Constants.ZONE, volumeAttachment.getServerId());
ExecResponse response = compute.runScriptOnNode(zoneAndId.slashEncode(), script, options);
if (response.getExitStatus() == 0) {
System.out.println(" Exit Status: " + response.getExitStatus());
} else {
System.out.println(" Error: " + response.getOutput());
}
}
Aggregations