Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.ExecResponse


   public void testCanRunCommandAsCurrentUser() throws Exception {
      Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup("goo", 1);
      NodeMetadata node = Iterables.get(nodes, 0);

      try {
         ExecResponse response = view.getComputeService().runScriptOnNode(node.getId(), exec("id"),
                  wrapInInitScript(false).runAsRoot(false));
         assert response.getOutput().trim().contains(System.getProperty("user.name")) : node + ": " + response;
      } finally {
         view.getComputeService().destroyNode(node.getId());
      }
   }
View Full Code Here


   }

   public boolean enableNetworkInterface(NodeMetadata nodeMetadata, NetworkInterfaceCard networkInterfaceCard) {
      ListenableFuture<ExecResponse> execEnableNetworkInterface = machineUtils.runScriptOnNode(nodeMetadata,
              new EnableNetworkInterface(networkInterfaceCard), RunScriptOptions.NONE);
      ExecResponse execEnableNetworkInterfaceResponse = Futures.getUnchecked(execEnableNetworkInterface);
      return execEnableNetworkInterfaceResponse.getExitStatus() == 0;
   }
View Full Code Here

      String dhcpNetmask = "255.255.255.0";
      String dhcpLowerIp = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".2";
      String dhcpUpperIp = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".253";
      NodeMetadata hostNodeMetadata = getHostNodeMetadata();

      ExecResponse response = scriptRunnerFactory
            .create(
                  hostNodeMetadata,
                  Statements.exec(String
                        .format(
                              "VBoxManage dhcpserver add --ifname %s --ip %s --netmask %s --lowerip %s --upperip %s --enable",
                              hostOnlyIfName, dhcpIpAddress, dhcpNetmask, dhcpLowerIp, dhcpUpperIp)),
                  runAsRoot(false).wrapInInitScript(false)).init().call();
      checkState(response.getExitStatus() == 0);
   }
View Full Code Here

      checkState(response.getExitStatus() == 0);
   }

   private String createHostOnlyIf() {
      NodeMetadata hostNodeMetadata = getHostNodeMetadata();
      ExecResponse createHostOnlyResponse = scriptRunnerFactory
            .create(hostNodeMetadata, Statements.exec("VBoxManage hostonlyif create"),
                  runAsRoot(false).wrapInInitScript(false)).init().call();
      String output = createHostOnlyResponse.getOutput();
      checkState(createHostOnlyResponse.getExitStatus() == 0, "cannot create hostonly interface ");
      checkState(output.contains("'"), "cannot create hostonly interface");
      return output.substring(output.indexOf("'") + 1, output.lastIndexOf("'"));
   }
View Full Code Here

      String network = activeBridgedIf.getIpAddress();

      // scan ip
      RunScriptOnNode ipScanRunScript = scriptRunnerFactory.create(hostSupplier.get(),
            new ScanNetworkWithPing(network), RunScriptOptions.NONE);
      ExecResponse execResponse = ipScanRunScript.init().call();
      checkState(execResponse.getExitStatus() == 0);

      // retrieve ip from mac
      RunScriptOnNode getIpFromMACAddressRunScript = scriptRunnerFactory.create(hostSupplier.get(),
            new GetIPAddressFromMAC(networkAdapter.getMACAddress()), RunScriptOptions.NONE);
      ExecResponse ipExecResponse = getIpFromMACAddressRunScript.init().call();
      checkState(ipExecResponse.getExitStatus() == 0);
      return checkNotNull(ipExecResponse.getOutput(), "ipAddress");
   }
View Full Code Here

      if (expectedMd5 != null) {
         String filePath = isosDir + File.separator + fileName;
         ListenableFuture<ExecResponse> md5future = runScriptOnNodeFactory.submit(hostNode, new Md5(filePath),
               runAsRoot(false));

         ExecResponse responseMd5 = Futures.getUnchecked(md5future);
         assert responseMd5.getExitStatus() == 0 : hostNode.getId() + ": " + responseMd5;
         checkNotNull(responseMd5.getOutput(), "iso_md5 missing");
         String actualMd5 = responseMd5.getOutput().trim();
         checkState(actualMd5.equals(expectedMd5), "md5 of %s is %s but expected %s", filePath, actualMd5, expectedMd5);
      }
      return file.getAbsolutePath();
   }
View Full Code Here

      for (NodeMetadata node : nodes) {
         assertTrue(node.getGroup().equals("test-launch-cluster"));
         logger.debug("Created Node: %s", node);
         SshClient client = context.utils().sshForNode().apply(node);
         client.connect();
         ExecResponse hello = client.exec("echo hello");
         assertEquals(hello.getOutput().trim(), "hello");
      }
      context.getComputeService().destroyNodesMatching(new Predicate<NodeMetadata>() {
         @Override
         public boolean apply(NodeMetadata input) {
            return input.getId().contains(clusterName);
View Full Code Here

      NodeMetadata nodeMetadata = imachineToNodeMetadata.apply(masterMachine);

      logger.debug(">> awaiting post-installation actions on vm: %s", masterName);
      ListenableFuture<ExecResponse> execCleanup = machineUtils.runScriptOnNode(nodeMetadata,
               call("cleanupUdevIfNeeded"), RunScriptOptions.NONE);
      ExecResponse cleanupResponse = Futures.getUnchecked(execCleanup);
      checkState(cleanupResponse.getExitStatus() == 0, "post-installation actions on vm(%s) failed", masterName);

      logger.debug(">> awaiting installation of guest additions on vm: %s", masterName);
      ListenableFuture<ExecResponse> execInstallGA = machineUtils.runScriptOnNode(nodeMetadata,
               new InstallGuestAdditions(vmSpec, version), RunScriptOptions.NONE);

      logger.debug(">> check installation of guest additions on vm: %s", masterName);
      ListenableFuture<ExecResponse> checkGAinstallation = machineUtils.runScriptOnNode(nodeMetadata,
              call("checkVBoxService"), RunScriptOptions.NONE);
      ExecResponse checkGAinstallationResponse = Futures.getUnchecked(checkGAinstallation);
      checkState(checkGAinstallationResponse.getExitStatus() == 0, "check installation of guest additions on vm(%s) " +
              "failed", masterName);

      machineController.ensureMachineIsShutdown(masterName);

      // detach DVD and ISOs, if needed
View Full Code Here

                     simplifiedMacAddressOfClonedVM.indexOf("0"), simplifiedMacAddressOfClonedVM.indexOf("0") + 1)
                     .toString();
      }

      // TODO: This is both shell-dependent and hard-coded. Needs to be fixed.
      ExecResponse execResponse = runScriptOnNode(hostId, "for i in {1..254} ; do ping -c 1 -t 1 192.168.2.$i & done",
            runAsRoot(false).wrapInInitScript(false));
      System.out.println(execResponse);

      String arpLine = runScriptOnNode(hostId, "arp -an | grep " + simplifiedMacAddressOfClonedVM,
            runAsRoot(false).wrapInInitScript(false)).getOutput();
View Full Code Here

             responseMap = service.runScriptOnNodesMatching(getNodeFilter(),
                      getStatement(), overrideLoginCredentials(credentials).runAsRoot(runAsRoot()));
          }

          for (Map.Entry<? extends NodeMetadata, ExecResponse> entry : responseMap.entrySet()) {
            ExecResponse response = entry.getValue();
            NodeMetadata node = entry.getKey();
            System.out.println("");
            if (response.getOutput() != null && !response.getOutput().isEmpty()) {
               System.out.println("Node:" + node.getId() + " Output:" + response.getOutput());
            }

            if (response.getError() != null && !response.getError().isEmpty()) {
               System.out.println("Node:" + node.getId() + " Error:" + response.getError());
            }
         }
      }

      return null;
View Full Code Here

TOP

Related Classes of org.jclouds.compute.domain.ExecResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.