2008-12-11 Ramon Novoa <rnovoa@artica.es>

* win32/pandora_windows_service.h,
          win32/pandora_windows_service.cc: Added support for a secondary server
          .




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1288 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2008-12-11 11:57:03 +00:00
parent c074316cf7
commit f8792f1fb7
3 changed files with 64 additions and 20 deletions

View File

@ -1,3 +1,10 @@
2008-12-11 Ramon Novoa <rnovoa@artica.es>
* win32/pandora_windows_service.h,
win32/pandora_windows_service.cc: Added support for a secondary server
.
2008-12-11 Ramon Novoa <rnovoa@artica.es>
* win32/windows/pandora_wmi.cc,

View File

@ -201,7 +201,11 @@ Pandora_Windows_Service::getXmlHeader () {
void
Pandora_Windows_Service::copyTentacleDataFile (string host,
string filename)
string filename,
string port,
string ssl,
string pass,
string opts)
{
int rc;
string var, filepath;
@ -217,24 +221,20 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
/* 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;
if (port != "") {
tentacle_cmd += " -p " + port;
}
var = conf->getValue ("server_ssl");
if (var == "1") {
if (ssl == "1") {
tentacle_cmd += " -c";
}
var = conf->getValue ("server_pwd");
if (var != "") {
tentacle_cmd += " -x " + var;
if (pass != "") {
tentacle_cmd += " -x " + pass;
}
var = conf->getValue ("server_opts");
if (var != "") {
tentacle_cmd += " " + var;
if (opts != "") {
tentacle_cmd += " " + opts;
}
tentacle_cmd += " " + filepath;
@ -322,11 +322,11 @@ Pandora_Windows_Service::copyScpDataFile (string host,
void
Pandora_Windows_Service::copyFtpDataFile (string host,
string remote_path,
string filename)
string filename,
string password)
{
FTP::Pandora_Ftp_Client ftp_client;
string filepath;
string password;
filepath = conf->getValue ("temporal");
if (filepath[filepath.length () - 1] != '\\') {
@ -334,8 +334,6 @@ Pandora_Windows_Service::copyFtpDataFile (string host,
}
filepath += filename;
password = conf->getValue ("server_pwd");
ftp_client.connect (host,
22,
"pandora",
@ -368,6 +366,7 @@ Pandora_Windows_Service::copyFtpDataFile (string host,
void
Pandora_Windows_Service::copyDataFile (string filename)
{
unsigned char copy_to_secondary = 0;
string mode, host, remote_path;
mode = conf->getValue ("transfer_mode");
@ -379,9 +378,11 @@ Pandora_Windows_Service::copyDataFile (string filename)
try {
if (mode == "ftp") {
copyFtpDataFile (host, remote_path, filename);
copyFtpDataFile (host, remote_path, filename, conf->getValue ("server_pwd"));
} else if (mode == "tentacle") {
copyTentacleDataFile (host, filename);
copyTentacleDataFile (host, filename, conf->getValue ("server_port"),
conf->getValue ("server_ssl"), conf->getValue ("server_pwd"),
conf->getValue ("server_opts"));
} else if (mode == "ssh" || mode == "") {
copyScpDataFile (host, remote_path, filename);
} else {
@ -391,6 +392,37 @@ Pandora_Windows_Service::copyDataFile (string filename)
}
pandoraDebug ("Successfuly copied XML file to server.");
} catch (Pandora_Exception e) {
if (conf->getValue ("secondary_mode") == "on_error") {
copy_to_secondary = 1;
}
}
if (conf->getValue ("secondary_mode") == "always") {
copy_to_secondary = 1;
}
// Copy the file to the secondary server if needed
if (copy_to_secondary == 0) {
return;
}
try {
if (mode == "ftp") {
copyFtpDataFile (host, remote_path, filename, conf->getValue ("secondary_server_pwd"));
} else if (mode == "tentacle") {
copyTentacleDataFile (host, filename, conf->getValue ("secondary_server_port"),
conf->getValue ("secondary_server_ssl"), conf->getValue ("secondary_server_pwd"),
conf->getValue ("secondary_server_opts"));
} else if (mode == "ssh" || mode == "") {
copyScpDataFile (host, remote_path, filename);
} else {
pandoraLog ("Invalid transfer mode: %s."
"Please recheck transfer_mode option "
"in configuration file.");
}
pandoraDebug ("Successfuly copied XML file to secondary server.");
} catch (Pandora_Exception e) {
}
}

View File

@ -49,13 +49,18 @@ namespace Pandora {
TiXmlElement *getXmlHeader ();
void copyDataFile (string filename);
void copyTentacleDataFile (string host,
string filename);
string filename,
string port,
string ssl,
string pass,
string opts);
void copyScpDataFile (string host,
string remote_path,
string filename);
void copyFtpDataFile (string host,
string remote_path,
string filename);
string filename,
string password);
void recvDataFile (string filename);
void recvTentacleDataFile (string host,
string filename);