mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
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:
parent
c074316cf7
commit
f8792f1fb7
@ -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>
|
2008-12-11 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* win32/windows/pandora_wmi.cc,
|
* win32/windows/pandora_wmi.cc,
|
||||||
|
@ -201,7 +201,11 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Windows_Service::copyTentacleDataFile (string host,
|
Pandora_Windows_Service::copyTentacleDataFile (string host,
|
||||||
string filename)
|
string filename,
|
||||||
|
string port,
|
||||||
|
string ssl,
|
||||||
|
string pass,
|
||||||
|
string opts)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
string var, filepath;
|
string var, filepath;
|
||||||
@ -217,24 +221,20 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
|
|||||||
/* Build the command to launch the Tentacle client */
|
/* Build the command to launch the Tentacle client */
|
||||||
tentacle_cmd = "tentacle_client.exe -a " + host;
|
tentacle_cmd = "tentacle_client.exe -a " + host;
|
||||||
|
|
||||||
var = conf->getValue ("server_port");
|
if (port != "") {
|
||||||
if (var != "") {
|
tentacle_cmd += " -p " + port;
|
||||||
tentacle_cmd += " -p " + var;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var = conf->getValue ("server_ssl");
|
if (ssl == "1") {
|
||||||
if (var == "1") {
|
|
||||||
tentacle_cmd += " -c";
|
tentacle_cmd += " -c";
|
||||||
}
|
}
|
||||||
|
|
||||||
var = conf->getValue ("server_pwd");
|
if (pass != "") {
|
||||||
if (var != "") {
|
tentacle_cmd += " -x " + pass;
|
||||||
tentacle_cmd += " -x " + var;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var = conf->getValue ("server_opts");
|
if (opts != "") {
|
||||||
if (var != "") {
|
tentacle_cmd += " " + opts;
|
||||||
tentacle_cmd += " " + var;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tentacle_cmd += " " + filepath;
|
tentacle_cmd += " " + filepath;
|
||||||
@ -322,11 +322,11 @@ Pandora_Windows_Service::copyScpDataFile (string host,
|
|||||||
void
|
void
|
||||||
Pandora_Windows_Service::copyFtpDataFile (string host,
|
Pandora_Windows_Service::copyFtpDataFile (string host,
|
||||||
string remote_path,
|
string remote_path,
|
||||||
string filename)
|
string filename,
|
||||||
|
string password)
|
||||||
{
|
{
|
||||||
FTP::Pandora_Ftp_Client ftp_client;
|
FTP::Pandora_Ftp_Client ftp_client;
|
||||||
string filepath;
|
string filepath;
|
||||||
string password;
|
|
||||||
|
|
||||||
filepath = conf->getValue ("temporal");
|
filepath = conf->getValue ("temporal");
|
||||||
if (filepath[filepath.length () - 1] != '\\') {
|
if (filepath[filepath.length () - 1] != '\\') {
|
||||||
@ -334,8 +334,6 @@ Pandora_Windows_Service::copyFtpDataFile (string host,
|
|||||||
}
|
}
|
||||||
filepath += filename;
|
filepath += filename;
|
||||||
|
|
||||||
password = conf->getValue ("server_pwd");
|
|
||||||
|
|
||||||
ftp_client.connect (host,
|
ftp_client.connect (host,
|
||||||
22,
|
22,
|
||||||
"pandora",
|
"pandora",
|
||||||
@ -368,6 +366,7 @@ Pandora_Windows_Service::copyFtpDataFile (string host,
|
|||||||
void
|
void
|
||||||
Pandora_Windows_Service::copyDataFile (string filename)
|
Pandora_Windows_Service::copyDataFile (string filename)
|
||||||
{
|
{
|
||||||
|
unsigned char copy_to_secondary = 0;
|
||||||
string mode, host, remote_path;
|
string mode, host, remote_path;
|
||||||
|
|
||||||
mode = conf->getValue ("transfer_mode");
|
mode = conf->getValue ("transfer_mode");
|
||||||
@ -379,9 +378,11 @@ Pandora_Windows_Service::copyDataFile (string filename)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (mode == "ftp") {
|
if (mode == "ftp") {
|
||||||
copyFtpDataFile (host, remote_path, filename);
|
copyFtpDataFile (host, remote_path, filename, conf->getValue ("server_pwd"));
|
||||||
} else if (mode == "tentacle") {
|
} 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 == "") {
|
} else if (mode == "ssh" || mode == "") {
|
||||||
copyScpDataFile (host, remote_path, filename);
|
copyScpDataFile (host, remote_path, filename);
|
||||||
} else {
|
} else {
|
||||||
@ -391,6 +392,37 @@ Pandora_Windows_Service::copyDataFile (string filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pandoraDebug ("Successfuly copied XML file to server.");
|
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) {
|
} catch (Pandora_Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,18 @@ namespace Pandora {
|
|||||||
TiXmlElement *getXmlHeader ();
|
TiXmlElement *getXmlHeader ();
|
||||||
void copyDataFile (string filename);
|
void copyDataFile (string filename);
|
||||||
void copyTentacleDataFile (string host,
|
void copyTentacleDataFile (string host,
|
||||||
string filename);
|
string filename,
|
||||||
|
string port,
|
||||||
|
string ssl,
|
||||||
|
string pass,
|
||||||
|
string opts);
|
||||||
void copyScpDataFile (string host,
|
void copyScpDataFile (string host,
|
||||||
string remote_path,
|
string remote_path,
|
||||||
string filename);
|
string filename);
|
||||||
void copyFtpDataFile (string host,
|
void copyFtpDataFile (string host,
|
||||||
string remote_path,
|
string remote_path,
|
||||||
string filename);
|
string filename,
|
||||||
|
string password);
|
||||||
void recvDataFile (string filename);
|
void recvDataFile (string filename);
|
||||||
void recvTentacleDataFile (string host,
|
void recvTentacleDataFile (string host,
|
||||||
string filename);
|
string filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user