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