コード例 #1
0
  protected boolean shutdownRouterVM(DomainRouterVO router) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("Try to shutdown router VM " + router.getInstanceName() + " directly.");
    }

    Pair<Boolean, String> result;
    try {
      result =
          SshHelper.sshExecute(
              router.getPrivateIpAddress(),
              DEFAULT_DOMR_SSHPORT,
              "root",
              getSystemVMKeyFile(),
              null,
              "poweroff -f");

      if (!result.first()) {
        s_logger.debug("Unable to shutdown " + router.getInstanceName() + " directly");
        return false;
      }
    } catch (Throwable e) {
      s_logger.warn("Unable to shutdown router " + router.getInstanceName() + " directly.");
      return false;
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("Shutdown router " + router.getInstanceName() + " successful.");
    }
    return true;
  }
コード例 #2
0
ファイル: TestVmwareUtil.java プロジェクト: xiufan/CloudStack
  public void testSsh() {
    try {
      File file = new File("c:\\temp\\id_rsa.kelven");
      if (!file.exists()) {
        System.out.println("key file does not exist!");
      }

      Pair<Boolean, String> result =
          SshHelper.sshExecute("192.168.1.107", 22, "kelven", file, null, "ls -al");
      System.out.println("Result: " + result.second());
    } catch (Exception e) {
      s_logger.error("Unexpected exception : ", e);
    }
  }
コード例 #3
0
ファイル: TestVmwareUtil.java プロジェクト: xiufan/CloudStack
  public void testScp() {
    try {
      File file = new File("c:\\temp\\id_rsa.kelven");
      if (!file.exists()) {
        System.out.println("key file does not exist!");
      }

      SshHelper.scpTo(
          "192.168.1.107",
          22,
          "kelven",
          file,
          null,
          "~",
          "Hello, world".getBytes(),
          "hello.txt",
          null);
    } catch (Exception e) {
      s_logger.error("Unexpected exception : ", e);
    }
  }