Line data Source code
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 84 : void AddOptions(opt::options_description *sandesh_options,
16 : SandeshConfig *sandesh_config) {
17 : // Command line and config file options.
18 84 : sandesh_options->add_options()
19 168 : ("SANDESH.sandesh_keyfile", opt::value<std::string>()->default_value(
20 : "/etc/contrail/ssl/private/server-privkey.pem"),
21 : "Sandesh SSL private key")
22 168 : ("SANDESH.sandesh_certfile", opt::value<std::string>()->default_value(
23 : "/etc/contrail/ssl/certs/server.pem"),
24 : "Sandesh SSL certificate")
25 168 : ("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 168 : ("SANDESH.sandesh_server_certfile", opt::value<std::string>()->default_value(
29 : "/etc/contrail/ssl/certs/server.pem"),
30 : "Sandesh SSL Server certificate")
31 168 : ("SANDESH.sandesh_ca_cert", opt::value<std::string>()->default_value(
32 : "/etc/contrail/ssl/certs/ca-cert.pem"),
33 : "Sandesh CA SSL certificate")
34 168 : ("SANDESH.sandesh_ssl_enable",
35 84 : opt::bool_switch(&sandesh_config->sandesh_ssl_enable),
36 : "Enable SSL for sandesh connection")
37 168 : ("SANDESH.introspect_ssl_enable",
38 84 : opt::bool_switch(&sandesh_config->introspect_ssl_enable),
39 : "Enable SSL for introspect connection")
40 168 : ("SANDESH.introspect_ssl_insecure",
41 84 : opt::bool_switch(&sandesh_config->introspect_ssl_insecure),
42 : "Enable SSL insecure for introspect connection")
43 168 : ("SANDESH.disable_object_logs",
44 84 : opt::bool_switch(&sandesh_config->disable_object_logs),
45 : "Disable sending of object logs to collector")
46 168 : ("STATS.stats_collector", opt::value<std::string>()->default_value(
47 : ""),
48 : "External Stats Collector")
49 168 : ("DEFAULT.sandesh_send_rate_limit",
50 84 : 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 168 : ("DEFAULT.http_server_ip",
54 168 : opt::value<std::string>()->default_value(
55 : "0.0.0.0"),
56 : "Listen IP for the Introspect")
57 168 : ("SANDESH.tcp_keepalive_enable",
58 168 : opt::bool_switch(&sandesh_config->tcp_keepalive_enable)->default_value(true),
59 : "Enable Keepalive for tcp socket")
60 168 : ("SANDESH.tcp_keepalive_idle_time",
61 84 : opt::value<int>(&sandesh_config->tcp_keepalive_idle_time),
62 : "Keepalive idle time for tcp socket")
63 168 : ("SANDESH.tcp_keepalive_probes",
64 84 : opt::value<int>(&sandesh_config->tcp_keepalive_probes),
65 : "Keepalive probes for tcp socket")
66 84 : ("SANDESH.tcp_keepalive_interval",
67 84 : opt::value<int>(&sandesh_config->tcp_keepalive_interval),
68 : "Keepalive interval for tcp socket")
69 : ;
70 84 : }
71 :
72 80 : void ProcessOptions(const opt::variables_map &var_map,
73 : SandeshConfig *sandesh_config) {
74 80 : GetOptValue<std::string>(var_map, sandesh_config->keyfile,
75 : "SANDESH.sandesh_keyfile");
76 80 : GetOptValue<std::string>(var_map, sandesh_config->certfile,
77 : "SANDESH.sandesh_certfile");
78 80 : GetOptValue<std::string>(var_map, sandesh_config->server_keyfile,
79 : "SANDESH.sandesh_server_keyfile");
80 80 : GetOptValue<std::string>(var_map, sandesh_config->server_certfile,
81 : "SANDESH.sandesh_server_certfile");
82 80 : GetOptValue<std::string>(var_map, sandesh_config->ca_cert,
83 : "SANDESH.sandesh_ca_cert");
84 80 : GetOptValue<bool>(var_map, sandesh_config->sandesh_ssl_enable,
85 : "SANDESH.sandesh_ssl_enable");
86 80 : GetOptValue<bool>(var_map, sandesh_config->introspect_ssl_enable,
87 : "SANDESH.introspect_ssl_enable");
88 80 : GetOptValue<bool>(var_map, sandesh_config->introspect_ssl_insecure,
89 : "SANDESH.introspect_ssl_insecure");
90 80 : GetOptValue<bool>(var_map, sandesh_config->disable_object_logs,
91 : "SANDESH.disable_object_logs");
92 80 : GetOptValue<std::string>(var_map, sandesh_config->stats_collector,
93 : "STATS.stats_collector");
94 80 : GetOptValue<uint32_t>(var_map, sandesh_config->system_logs_rate_limit,
95 : "DEFAULT.sandesh_send_rate_limit");
96 80 : GetOptValue<std::string>(var_map, sandesh_config->http_server_ip,
97 : "DEFAULT.http_server_ip");
98 80 : GetOptValue<bool>(var_map, sandesh_config->tcp_keepalive_enable,
99 : "SANDESH.tcp_keepalive_enable");
100 80 : GetOptValue<int>(var_map, sandesh_config->tcp_keepalive_idle_time,
101 : "SANDESH.tcp_keepalive_idle_time");
102 80 : GetOptValue<int>(var_map, sandesh_config->tcp_keepalive_probes,
103 : "SANDESH.tcp_keepalive_probes");
104 80 : GetOptValue<int>(var_map, sandesh_config->tcp_keepalive_interval,
105 : "SANDESH.tcp_keepalive_interval");
106 80 : }
107 :
108 : } // namespace options
109 : } // namespace sandesh
|