OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sandesh_options.cc
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3 //
4 
5 #include <cassert>
6 #include <base/options_util.h>
7 #include <sandesh/sandesh_options.h>
8 
9 namespace opt = boost::program_options;
10 using namespace options::util;
11 
12 namespace sandesh {
13 namespace options {
14 
15 void AddOptions(opt::options_description *sandesh_options,
16  SandeshConfig *sandesh_config) {
17  // Command line and config file options.
18  sandesh_options->add_options()
19  ("SANDESH.sandesh_keyfile", opt::value<std::string>()->default_value(
20  "/etc/contrail/ssl/private/server-privkey.pem"),
21  "Sandesh SSL private key")
22  ("SANDESH.sandesh_certfile", opt::value<std::string>()->default_value(
23  "/etc/contrail/ssl/certs/server.pem"),
24  "Sandesh SSL certificate")
25  ("SANDESH.sandesh_server_keyfile", opt::value<std::string>()->default_value(
26  "/etc/contrail/ssl/private/server-privkey.pem"),
27  "Sandesh SSL Server private key")
28  ("SANDESH.sandesh_server_certfile", opt::value<std::string>()->default_value(
29  "/etc/contrail/ssl/certs/server.pem"),
30  "Sandesh SSL Server certificate")
31  ("SANDESH.sandesh_ca_cert", opt::value<std::string>()->default_value(
32  "/etc/contrail/ssl/certs/ca-cert.pem"),
33  "Sandesh CA SSL certificate")
34  ("SANDESH.sandesh_ssl_enable",
35  opt::bool_switch(&sandesh_config->sandesh_ssl_enable),
36  "Enable SSL for sandesh connection")
37  ("SANDESH.introspect_ssl_enable",
38  opt::bool_switch(&sandesh_config->introspect_ssl_enable),
39  "Enable SSL for introspect connection")
40  ("SANDESH.introspect_ssl_insecure",
41  opt::bool_switch(&sandesh_config->introspect_ssl_insecure),
42  "Enable SSL insecure for introspect connection")
43  ("SANDESH.disable_object_logs",
44  opt::bool_switch(&sandesh_config->disable_object_logs),
45  "Disable sending of object logs to collector")
46  ("STATS.stats_collector", opt::value<std::string>()->default_value(
47  ""),
48  "External Stats Collector")
49  ("DEFAULT.sandesh_send_rate_limit",
50  opt::value<uint32_t>()->default_value(
51  g_sandesh_constants.DEFAULT_SANDESH_SEND_RATELIMIT),
52  "System logs send rate limit in messages per second per message type")
53  ("DEFAULT.http_server_ip",
54  opt::value<std::string>()->default_value(
55  "0.0.0.0"),
56  "Listen IP for the Introspect")
57  ("SANDESH.tcp_keepalive_enable",
58  opt::bool_switch(&sandesh_config->tcp_keepalive_enable)->default_value(true),
59  "Enable Keepalive for tcp socket")
60  ("SANDESH.tcp_keepalive_idle_time",
61  opt::value<int>(&sandesh_config->tcp_keepalive_idle_time),
62  "Keepalive idle time for tcp socket")
63  ("SANDESH.tcp_keepalive_probes",
64  opt::value<int>(&sandesh_config->tcp_keepalive_probes),
65  "Keepalive probes for tcp socket")
66  ("SANDESH.tcp_keepalive_interval",
67  opt::value<int>(&sandesh_config->tcp_keepalive_interval),
68  "Keepalive interval for tcp socket")
69  ;
70 }
71 
72 void ProcessOptions(const opt::variables_map &var_map,
73  SandeshConfig *sandesh_config) {
74  GetOptValue<std::string>(var_map, sandesh_config->keyfile,
75  "SANDESH.sandesh_keyfile");
76  GetOptValue<std::string>(var_map, sandesh_config->certfile,
77  "SANDESH.sandesh_certfile");
78  GetOptValue<std::string>(var_map, sandesh_config->server_keyfile,
79  "SANDESH.sandesh_server_keyfile");
80  GetOptValue<std::string>(var_map, sandesh_config->server_certfile,
81  "SANDESH.sandesh_server_certfile");
82  GetOptValue<std::string>(var_map, sandesh_config->ca_cert,
83  "SANDESH.sandesh_ca_cert");
84  GetOptValue<bool>(var_map, sandesh_config->sandesh_ssl_enable,
85  "SANDESH.sandesh_ssl_enable");
86  GetOptValue<bool>(var_map, sandesh_config->introspect_ssl_enable,
87  "SANDESH.introspect_ssl_enable");
88  GetOptValue<bool>(var_map, sandesh_config->introspect_ssl_insecure,
89  "SANDESH.introspect_ssl_insecure");
90  GetOptValue<bool>(var_map, sandesh_config->disable_object_logs,
91  "SANDESH.disable_object_logs");
92  GetOptValue<std::string>(var_map, sandesh_config->stats_collector,
93  "STATS.stats_collector");
94  GetOptValue<uint32_t>(var_map, sandesh_config->system_logs_rate_limit,
95  "DEFAULT.sandesh_send_rate_limit");
96  GetOptValue<std::string>(var_map, sandesh_config->http_server_ip,
97  "DEFAULT.http_server_ip");
98  GetOptValue<bool>(var_map, sandesh_config->tcp_keepalive_enable,
99  "SANDESH.tcp_keepalive_enable");
100  GetOptValue<int>(var_map, sandesh_config->tcp_keepalive_idle_time,
101  "SANDESH.tcp_keepalive_idle_time");
102  GetOptValue<int>(var_map, sandesh_config->tcp_keepalive_probes,
103  "SANDESH.tcp_keepalive_probes");
104  GetOptValue<int>(var_map, sandesh_config->tcp_keepalive_interval,
105  "SANDESH.tcp_keepalive_interval");
106 }
107 
108 } // namespace options
109 } // namespace sandesh
bool introspect_ssl_enable
uint32_t system_logs_rate_limit
std::string server_certfile
bool tcp_keepalive_enable
int tcp_keepalive_idle_time
bool introspect_ssl_insecure
static Options options
std::string http_server_ip
std::string server_keyfile
std::string certfile
void ProcessOptions(const opt::variables_map &var_map, SandeshConfig *sandesh_config)
std::string stats_collector
void AddOptions(opt::options_description *sandesh_options, SandeshConfig *sandesh_config)
int tcp_keepalive_interval
bool disable_object_logs
std::string keyfile
std::string ca_cert