Answer execute(DhcpEntryCommand cmd) { com.trilead.ssh2.Connection sshConnection = null; try { sshConnection = SSHCmdHelper.acquireAuthorizedConnection(_ip, _username, _password); if (sshConnection == null) { return new Answer(cmd, false, "ssh authenticate failed"); } String addDhcp = String.format("python /usr/bin/dhcpd_edithosts.py %1$s %2$s %3$s %4$s %5$s %6$s", cmd.getVmMac(), cmd.getVmIpAddress(), cmd.getVmName(), cmd.getDns(), cmd.getGateway(), cmd.getNextServer()); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, addDhcp)) { return new Answer(cmd, false, "add Dhcp entry failed"); } else { return new Answer(cmd); } } finally { SSHCmdHelper.releaseSshConnection(sshConnection); } }