From daaca58b6a94ce2ca6225c28c91d50575d74f712 Mon Sep 17 00:00:00 2001 From: ramonn Date: Fri, 14 Mar 2008 13:41:31 +0000 Subject: [PATCH] 2008-03-14 Ramon Novoa * win32/pandora_windows_service.cc: Added support for Tentacle file transfers. * win32/pandora_windows_service.h: Added support for Tentacle file transfers. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@750 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/ChangeLog | 5 ++ .../win32/pandora_windows_service.cc | 70 +++++++++++++++++++ .../win32/pandora_windows_service.h | 2 + 3 files changed, 77 insertions(+) diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index de0b0bf7c0..2805f3e757 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,8 @@ +2008-03-14 Ramon Novoa + + * win32/pandora_windows_service.cc: Added support for Tentacle file transfers. + * win32/pandora_windows_service.h: Added support for Tentacle file transfers. + 2008-03-11 Ramon Novoa * linux/pandora_agent: Added support for Tentacle file transfers. diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index df1b8c025e..4302b065d6 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -160,6 +160,74 @@ Pandora_Windows_Service::getXmlHeader () { return agent; } +void +Pandora_Windows_Service::copyTentacleDataFile (string host, + string filename) +{ + int rc; + string var, filepath; + string pubkey_file, privkey_file; + string tentacle_cmd; + + var = conf->getValue ("temporal"); + if (var[var.length () - 1] != '\\') { + var += "\\"; + } + + filepath = var + filename; + + /* Build the command to launch the Tentacle client */ + tentacle_cmd = "tentacle_client.exe -a " + host; + + var = conf->getValue ("server_port"); + if (var != "") { + tentacle_cmd += " -p " + var; + } + + var = conf->getValue ("server_ssl"); + if (var == "1") { + tentacle_cmd += " -c"; + } + + var = conf->getValue ("server_pwd"); + if (var != "") { + tentacle_cmd += " -x " + var; + } + + var = conf->getValue ("server_opts"); + if (var != "") { + tentacle_cmd += " " + var; + } + + tentacle_cmd += " " + filepath; + + /* Copy the file */ + pandoraDebug ("Remote copying XML %s on server %s", + filepath.c_str (), host.c_str ()); + pandoraDebug ("Command %s", tentacle_cmd.c_str()); + + rc = system (tentacle_cmd.c_str()); + switch (rc) { + + /* system() error */ + case -1: + pandoraLog ("Unable to copy %s", filename.c_str ()); + throw Pandora_Exception (); + + /* tentacle_client.exe returned OK */ + case 0: + break; + + /* tentacle_client.exe error */ + default: + pandoraLog ("Tentacle client was unable to copy %s", + filename.c_str ()); + throw Pandora_Exception (); + } + + return; +} + void Pandora_Windows_Service::copyScpDataFile (string host, string remote_path, @@ -274,6 +342,8 @@ Pandora_Windows_Service::copyDataFile (string filename) try { if (mode == "ftp") { copyFtpDataFile (host, remote_path, filename); + } else if (mode == "tentacle") { + copyTentacleDataFile (host, filename); } else if (mode == "ssh" || mode == "") { copyScpDataFile (host, remote_path, filename); } else { diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index 0bbd4974d6..75c068b7f3 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -43,6 +43,8 @@ namespace Pandora { TiXmlElement *getXmlHeader (); void copyDataFile (string filename); + void copyTentacleDataFile (string host, + string filename); void copyScpDataFile (string host, string remote_path, string filename);