2 * @brief The updater class implementation. This class implements the updater logic.
6 * @copyright Intra2net AG
12 #include <boost/foreach.hpp>
17 * Default constructor which initializes the member Conf.
22 LoggerPtr _log(new Logger);
26 ConfigPtr _config(new Config(Log));
29 Log->print_constructor_call("Updater");
38 Log->print_destructor_call("Updater");
43 * Parse the command line arguments and initialize corresponding options.
44 * @param argc Number command line arguments.
45 * @param argv[] Array with arguments.
46 * @return 0 if cmd options successfully parsed, 1 if usage or version.
48 int Updater::init_config_from_cmd(int argc, char *argv[])
50 // Load the command line parameters
51 if( Conf->parse_cmd_line( argc, argv ) != 0)
55 Log->print_cmd_parsed();
61 * Load the main config and the service definition files in config path.
62 * @return 0 if all is fine,
64 int Updater::init_config_from_files()
66 // Load the main and service config files in config path
67 if( Conf->load_config_from_files() != 0)
76 * Getter for member Config.
77 * @return Member Config.
79 ConfigPtr Updater::get_config()
86 * Getter for member Logger.
87 * @return Member Logger.
89 LoggerPtr Updater::get_logger()
96 * Reloading the config. Delete all Service objects and then init new Service objects from config files.
98 void Updater::reload_config()
100 // delete all service objects
101 Conf->delete_services();
103 // delete the actual Variables_map, perhaps with old cmd options which would overwrite new config file options.
104 Conf->delete_variables_map();
106 // load only config files
107 init_config_from_files();
109 // re_init log facility, perhaps new config file options for logger are set.
114 void Updater::init_log_facility()
116 Log->set_log_facility(Conf->get_loglevel(),Conf->get_syslog());
117 Log->print_init_log_facility();
122 * Update all configured services.
124 void Updater::update_services()
126 list<ServicePtr> services = this->Conf->get_services();
128 string ip = "192.168.1.1";
130 BOOST_FOREACH( ServicePtr service, services )