jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From najtmar <notificati...@github.com>
Subject Re: [jclouds-examples] Adding an example to run a simple program on a GCE VM. (#56)
Date Fri, 01 Aug 2014 09:11:01 GMT
> +   private void executeSimpleCommand(
> +         final NodeMetadata instance, final String googleUserName, final String sshPrivateKey)
{
> +      Statement script = Statements.exec("ls -l /");
> +
> +      // Set up credentials.
> +      RunScriptOptions options = overrideLoginCredentials((new LoginCredentials.Builder())
> +            .user(googleUserName)
> +            .privateKey(sshPrivateKey)
> +            .build())
> +          .blockOnComplete(true)
> +          .runAsRoot(false);
> +
> +      ExecResponse response = computeService.runScriptOnNode(instance.getId(), script,
options);
> +
> +      if (response.getExitStatus() == 0) {
> +         System.out.format("Exit Status:%n============%n%s%n%n", response.getExitStatus());

Done.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/56/files#r15687506
Mime
View raw message