summaryrefslogtreecommitdiffstats
path: root/src/Client/SystemCommands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client/SystemCommands.cpp')
-rw-r--r--src/Client/SystemCommands.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/Client/SystemCommands.cpp b/src/Client/SystemCommands.cpp
index 490f278..5b2d4e5 100644
--- a/src/Client/SystemCommands.cpp
+++ b/src/Client/SystemCommands.cpp
@@ -18,9 +18,9 @@
*/
#include "SystemCommands.h"
+#include "Application.h"
#include "CommandParser.h"
-#include <Core/Logger.h>
#include <Common/RequestManager.h>
#include "Requests/DaemonFSInfoRequest.h"
@@ -138,26 +138,26 @@ void SystemCommands::printHostStatus(boost::shared_ptr<const Common::XmlPacket>
}
-void SystemCommands::fsinfoCommand(const std::vector<std::string> &args, Common::Connection *connection) {
+void SystemCommands::fsinfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) {
boost::shared_ptr<Common::Request> request;
if(args.size() == 1)
- request = boost::shared_ptr<Common::Requests::FSInfoRequest>(new Common::Requests::FSInfoRequest);
+ request = boost::shared_ptr<Common::Requests::FSInfoRequest>(new Common::Requests::FSInfoRequest(commandParser->application));
else if(args.size() == 2)
- request = boost::shared_ptr<Requests::DaemonFSInfoRequest>(new Requests::DaemonFSInfoRequest(args[1]));
+ request = boost::shared_ptr<Requests::DaemonFSInfoRequest>(new Requests::DaemonFSInfoRequest(commandParser->application, args[1]));
else {
- Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
- CommandParser::printUsage("fsinfo");
+ std::cerr << args[0] << ": Too many arguments." << std::endl;
+ commandParser->printUsage("fsinfo");
return;
}
- Common::RequestManager::get()->sendRequest(connection, request);
+ commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
request->wait();
std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
}
else {
if(args.size() == 1)
@@ -169,20 +169,20 @@ void SystemCommands::fsinfoCommand(const std::vector<std::string> &args, Common:
}
}
-void SystemCommands::rebootCommand(const std::vector<std::string> &args, Common::Connection *connection) {
+void SystemCommands::rebootCommand(CommandParser *commandParser, const std::vector<std::string> &args) {
if(args.size() < 2) {
- Core::Logger::logf(Core::Logger::ERROR, "%s: No host given.", args[0].c_str());
- CommandParser::printUsage("reboot");
+ std::cerr << args[0] << ": No host given." << std::endl;
+ commandParser->printUsage("reboot");
return;
}
- std::map<std::string, Common::HostInfo> hosts = CommandParser::parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true);
+ std::map<std::string, Common::HostInfo> hosts = commandParser->parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true);
std::vector<boost::shared_ptr<Requests::DaemonCommandRequest> > requests;
for(std::map<std::string, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) {
- boost::shared_ptr<Requests::DaemonCommandRequest> request(new Requests::DaemonCommandRequest(host->first, true));
- Common::RequestManager::get()->sendRequest(connection, request);
+ boost::shared_ptr<Requests::DaemonCommandRequest> request(new Requests::DaemonCommandRequest(commandParser->application, host->first, true));
+ commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
requests.push_back(request);
}
@@ -194,24 +194,24 @@ void SystemCommands::rebootCommand(const std::vector<std::string> &args, Common:
std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = (*request)->getResult();
if(result.second)
- Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
}
}
-void SystemCommands::shutdownCommand(const std::vector<std::string> &args, Common::Connection *connection) {
+void SystemCommands::shutdownCommand(CommandParser *commandParser, const std::vector<std::string> &args) {
if(args.size() < 2) {
- Core::Logger::logf(Core::Logger::ERROR, "%s: No host given.", args[0].c_str());
- CommandParser::printUsage("shutdown");
+ std::cerr << args[0] << ": No host given." << std::endl;
+ commandParser->printUsage("shutdown");
return;
}
- std::map<std::string, Common::HostInfo> hosts = CommandParser::parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true);
+ std::map<std::string, Common::HostInfo> hosts = commandParser->parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true);
std::vector<boost::shared_ptr<Requests::DaemonCommandRequest> > requests;
for(std::map<std::string, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) {
- boost::shared_ptr<Requests::DaemonCommandRequest> request(new Requests::DaemonCommandRequest(host->first, false));
- Common::RequestManager::get()->sendRequest(connection, request);
+ boost::shared_ptr<Requests::DaemonCommandRequest> request(new Requests::DaemonCommandRequest(commandParser->application, host->first, false));
+ commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
requests.push_back(request);
}
@@ -223,30 +223,30 @@ void SystemCommands::shutdownCommand(const std::vector<std::string> &args, Commo
std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = (*request)->getResult();
if(result.second)
- Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
}
}
-void SystemCommands::statusCommand(const std::vector<std::string> &args, Common::Connection *connection) {
+void SystemCommands::statusCommand(CommandParser *commandParser, const std::vector<std::string> &args) {
boost::shared_ptr<Common::Request> request;
if(args.size() == 1)
- request = boost::shared_ptr<Common::Requests::StatusRequest>(new Common::Requests::StatusRequest);
+ request = boost::shared_ptr<Common::Requests::StatusRequest>(new Common::Requests::StatusRequest(commandParser->application));
else if(args.size() == 2)
- request = boost::shared_ptr<Requests::DaemonStatusRequest>(new Requests::DaemonStatusRequest(args[1]));
+ request = boost::shared_ptr<Requests::DaemonStatusRequest>(new Requests::DaemonStatusRequest(commandParser->application, args[1]));
else {
- Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
- CommandParser::printUsage("status");
+ std::cerr << args[0] << ": Too many arguments." << std::endl;
+ commandParser->printUsage("status");
return;
}
- Common::RequestManager::get()->sendRequest(connection, request);
+ commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
request->wait();
std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
}
else {
if(args.size() == 1)