5 using GTS::SettingsParser;
7 SettingsParser::SettingsParser()
8 : _desc("Allowed options")
10 // Declare the supported options.
12 ("help", "produce help message")
13 ("config,c", po::value<std::string>()->default_value("/etc/gssmd/gssmd.conf"), "config file location")
14 ("daemon,d", "daemonize after start")
15 ("debug", "gssmd debugging")
16 ("log-file", po::value<std::string>(), "log file location")
17 ("pid-file", po::value<std::string>(), "PID file location")
18 ("switch-sync-interval,s", po::value<time_t>(), "switch synchronization interval")
19 ("info-sync-interval,i", po::value<time_t>(), "info synchronization interval")
20 ("up-profile-id", po::value<unsigned>(), "switch's upload profile id")
21 ("down-profile-id", po::value<unsigned>(), "switch's download profile id")
22 ("max-acl-per-pdu", po::value<size_t>(), "maximum ACL's per PDU")
23 ("data-url", po::value<std::string>(), "data access URL")
24 ("version,v", "show gssmd version and exit")
28 void SettingsParser::init(int argc, char * argv[])
31 po::store(po::parse_command_line(argc, argv, _desc), vm);
34 _settings._isHelp = vm.count("help");
35 _settings._isVersion = vm.count("version");
37 if (vm.count("config")) {
38 _settings._configFile = vm["config"].as<std::string>();
41 if (!_settings._isHelp &&
42 !_settings._isVersion) {
44 parseFile(_settings._configFile);
46 catch (std::exception & ex) {
47 logger << "Error parsing config file '" << _settings._configFile << "': " << ex.what() << std::endl;
51 if (vm.count("debug")) {
52 _settings._isDebug = true;
54 if (vm.count("daemon")) {
55 _settings._isDaemon = true;
58 if (vm.count("log-file")) {
59 _settings._logFile = vm["log-file"].as<std::string>();
62 if (vm.count("pid-file")) {
63 _settings._PIDFile = vm["pid-file"].as<std::string>();
66 if (vm.count("switch-sync-interval")) {
67 _settings._switchSyncInterval = vm["switch-sync-interval"].as<time_t>();
70 if (vm.count("info-sync-interval")) {
71 _settings._infoSyncInterval = vm["info-sync-interval"].as<time_t>();
74 if (vm.count("up-profile-id")) {
75 _settings._upProfileId = vm["up-profile-id"].as<unsigned>();
78 if (vm.count("down-profile-id")) {
79 _settings._downProfileId = vm["down-profile-id"].as<unsigned>();
82 if (vm.count("max-acl-per-pdu")) {
83 _settings._downProfileId = vm["max-acl-per-pdu"].as<unsigned>();
86 if (vm.count("data-url")) {
87 _settings._dataURL = vm["data-url"].as<std::string>();
91 void SettingsParser::reloadConfig()
93 parseFile(_settings._configFile);