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; }
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); } }
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); } }