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