if (cmd.getVmIpAddress() != null) { args += " -4 " + cmd.getVmIpAddress();
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("/usr/bin/dnsmasq_edithosts.sh %1$s %2$s %3$s", cmd.getVmMac(), cmd.getVmIpAddress(), cmd.getVmName()); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, addDhcp)) { return new Answer(cmd, false, "add Dhcp entry failed"); } else { return new Answer(cmd); } } finally { SSHCmdHelper.releaseSshConnection(sshConnection); } }
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); } }
@Override public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) { final DhcpEntryCommand command = (DhcpEntryCommand) cmd; final VmDhcpConfig vmDhcpConfig = new VmDhcpConfig(command.getVmName(), command.getVmMac(), command.getVmIpAddress(), command.getVmIp6Address(), command.getDuid(), command.getDefaultDns(), command.getDefaultRouter(), command.getStaticRoutes(), command.isDefault()); return generateConfigItems(vmDhcpConfig); }