Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #include <boost/program_options.hpp> 6 : #include "config_client_options.h" 7 : #include "io/event_manager.h" 8 : #include "sandesh/sandesh.h" 9 : 10 : class ConfigClientManager; 11 : 12 : // Process command line/configuration file options for control-node. 13 : class Options { 14 : public: 15 : Options(); 16 : bool Parse(EventManager &evm, int argc, char **argv); 17 : 18 6 : std::string bgp_config_file() const { return bgp_config_file_; } 19 6 : uint16_t bgp_port() const { return bgp_port_; } 20 36 : std::vector<std::string> collector_server_list() const { 21 36 : return collector_server_list_; 22 : } 23 : std::vector<std::string> randomized_collector_server_list() const { 24 : return randomized_collector_server_list_; 25 : } 26 6 : std::string config_file() const { return config_file_; }; 27 6 : std::string hostname() const { return hostname_; } 28 6 : std::string host_ip() const { return host_ip_; } 29 6 : uint16_t http_server_port() const { return http_server_port_; } 30 6 : std::string log_category() const { return log_category_; } 31 6 : bool log_disable() const { return log_disable_; } 32 6 : std::string log_file() const { return log_file_; } 33 : std::string log_property_file() const { return log_property_file_; } 34 6 : int log_files_count() const { return log_files_count_; } 35 6 : long log_file_size() const { return log_file_size_; } 36 6 : std::string log_level() const { return log_level_; } 37 6 : bool log_local() const { return log_local_; } 38 : bool use_syslog() const { return use_syslog_; } 39 : std::string syslog_facility() const { return syslog_facility_; } 40 6 : bool mvpn_ipv4_enable() const { return mvpn_ipv4_enable_; } 41 1 : bool task_track_run_time() const { return task_track_run_time_; } 42 6 : std::string config_db_user() const { 43 6 : return configdb_options_.config_db_username; 44 : } 45 6 : std::string config_db_password() const { 46 6 : return configdb_options_.config_db_password; 47 : } 48 3 : bool config_db_use_ssl() const { 49 3 : return configdb_options_.config_db_use_ssl; 50 : } 51 24 : std::vector<std::string> config_db_server_list() const { 52 24 : return configdb_options_.config_db_server_list; 53 : } 54 24 : std::vector<std::string> rabbitmq_server_list() const { 55 24 : return configdb_options_.rabbitmq_server_list; 56 : } 57 7 : std::string rabbitmq_user() const { 58 7 : return configdb_options_.rabbitmq_user; 59 : } 60 7 : std::string rabbitmq_password() const { 61 7 : return configdb_options_.rabbitmq_password; 62 : } 63 5 : bool rabbitmq_ssl_enabled() const { 64 5 : return configdb_options_.rabbitmq_use_ssl; 65 : } 66 2 : bool using_etcd_client() const { 67 2 : return configdb_options_.config_db_use_etcd; 68 : } 69 3 : const ConfigClientOptions &configdb_options() const { 70 3 : return configdb_options_; 71 : } 72 6 : uint16_t xmpp_port() const { return xmpp_port_; } 73 1 : bool xmpp_auth_enabled() const { return xmpp_auth_enable_; } 74 1 : std::string xmpp_server_cert() const { return xmpp_server_cert_; } 75 1 : std::string xmpp_server_key() const { return xmpp_server_key_; } 76 1 : std::string xmpp_ca_cert() const { return xmpp_ca_cert_; } 77 6 : bool test_mode() const { return test_mode_; } 78 : bool collectors_configured() const { return collectors_configured_; } 79 : int tcp_hold_time() const { return tcp_hold_time_; } 80 1 : bool optimize_snat() const { return optimize_snat_; } 81 6 : bool gr_helper_bgp_disable() const { return gr_helper_bgp_disable_; } 82 6 : bool gr_helper_xmpp_disable() const { return gr_helper_xmpp_disable_; } 83 : const std::string cassandra_user() const { return cassandra_user_; } 84 : const std::string cassandra_password() const { return cassandra_password_; } 85 : const std::vector<std::string> cassandra_server_list() const { 86 : return cassandra_server_list_; 87 : } 88 13 : const SandeshConfig &sandesh_config() const { return sandesh_config_; } 89 : 90 : void ParseReConfig(bool force_reinit); 91 : 92 : void set_config_client_manager(ConfigClientManager *mgr) { 93 : config_client_manager_ = mgr; 94 : } 95 : 96 : private: 97 : 98 : bool Process(int argc, char *argv[], 99 : boost::program_options::options_description &cmdline_options); 100 : void Initialize(EventManager &evm, 101 : boost::program_options::options_description &options); 102 : void ParseConfigOptions(const boost::program_options::variables_map 103 : &var_map); 104 : uint32_t GenerateHash(const std::vector<std::string> &list); 105 : uint32_t GenerateHash(const ConfigClientOptions &config); 106 : 107 : std::string bgp_config_file_; 108 : uint16_t bgp_port_; 109 : std::vector<std::string> collector_server_list_; 110 : std::vector<std::string> randomized_collector_server_list_; 111 : uint32_t collector_chksum_; 112 : uint32_t configdb_chksum_; 113 : std::string config_file_; 114 : std::string hostname_; 115 : std::string host_ip_; 116 : uint16_t http_server_port_; 117 : std::string log_category_; 118 : bool log_disable_; 119 : std::string log_file_; 120 : std::string log_property_file_; 121 : int log_files_count_; 122 : long log_file_size_; 123 : std::string log_level_; 124 : bool log_local_; 125 : bool use_syslog_; 126 : std::string syslog_facility_; 127 : bool mvpn_ipv4_enable_; 128 : bool task_track_run_time_; 129 : ConfigClientOptions configdb_options_; 130 : uint16_t xmpp_port_; 131 : bool xmpp_auth_enable_; 132 : std::string xmpp_server_cert_; 133 : std::string xmpp_server_key_; 134 : std::string xmpp_ca_cert_; 135 : bool test_mode_; 136 : bool collectors_configured_; 137 : int tcp_hold_time_; 138 : bool optimize_snat_; 139 : uint32_t sandesh_ratelimit_; 140 : bool gr_helper_bgp_disable_; 141 : bool gr_helper_xmpp_disable_; 142 : std::string cassandra_user_; 143 : std::string cassandra_password_; 144 : std::vector<std::string> cassandra_server_list_; 145 : std::vector<std::string> default_collector_server_list_; 146 : SandeshConfig sandesh_config_; 147 : boost::program_options::options_description config_file_options_; 148 : ConfigClientManager *config_client_manager_; 149 : };