8 #define DRIPLINE_API_EXPORTS
12 #include "application.hh"
13 #include "param_codec.hh"
14 #include "param_helpers_impl.hh"
19 using scarab::param_node;
22 LOGGER(
dlog,
"dripline_config" );
30 add(
"broker_port", 5672 );
31 add(
"broker",
"localhost" );
32 add(
"requests_exchange",
"requests" );
33 add(
"alerts_exchange",
"alerts" );
35 add(
"heartbeat_routing_key",
"heartbeat" );
36 add(
"max_connection_attempts", 10 );
39 if( a_read_mesh_file )
41 scarab::path t_file_path = scarab::path(getenv(
"HOME")) / scarab::path(
".dripline_mesh.yaml");
42 if( boost::filesystem::exists( t_file_path ) )
44 LDEBUG(
dlog,
"Loading mesh file " << t_file_path );
45 scarab::param_translator t_translator;
46 scarab::param_ptr_t t_config_from_file = t_translator.read_file(t_file_path.native());
47 merge( t_config_from_file->as_node() );
51 LDEBUG(
dlog,
"Mesh file is not present: " << t_file_path );
58 LDEBUG(
dlog,
"Adding dripline config options" );
61 an_app.auth_file_key() =
"auth_file";
62 an_app.auth_groups_key() =
"auth_groups";
68 an_app.add_config_option< std::string >(
"-u,--username",
"auth_groups.dripline.username.value",
"Specify the username for the rabbitmq broker" );
69 an_app.add_config_option< std::string >(
"--password",
"auth_groups.dripline.password.value",
"Specify a password for the rabbitmq broker -- NOTE: this will be plain text on the command line and may end up in your command history!" );
70 an_app.add_config_option< std::string >(
"--password-file",
"auth_groups.dripline.password.file",
"Specify a file (e.g. a secrets file) to be read in as the rabbitmq broker password" );
71 an_app.add_config_option< std::string >(
"--auth-file",
"auth_file",
"Set the authentication file path" );
74 an_app.add_config_option< std::string >(
"-b,--broker",
"dripline_mesh.broker",
"Set the dripline broker address" );
75 an_app.add_config_option<
unsigned >(
"-p,--port",
"dripline_mesh.broker_port",
"Set the port for communication with the dripline broker" );
76 an_app.add_config_option< std::string >(
"--requests-exchange",
"dripline_mesh.requests_exchange",
"Set the name of the requests exchange" );
77 an_app.add_config_option< std::string >(
"--alerts-exchange",
"dripline_mesh.alerts_exchange",
"Set the name of the alerts exchange" );
78 an_app.add_config_option<
unsigned >(
"--max-payload",
"dripline_mesh.max_payload_size",
"Set the maximum payload size (in bytes)" );
79 an_app.add_config_option< std::string >(
"--heartbeat-routing-key",
"dripline_mesh.heartbeat_routing_key",
"Set the first token of heartbeat routing keys: [token].[origin]" );
80 an_app.add_config_option<
unsigned >(
"--max-connection-attempts",
"dripline_mesh.max_connection_attempts",
"Maximum number of times to attempt to connect to the broker" );
87 return scarab::param_node(
88 "username"_a=scarab::param_node(
90 "env"_a=
"DRIPLINE_USER"
92 "password"_a=scarab::param_node(
94 "env"_a=
"DRIPLINE_PASSWORD"
101 scarab::param_node t_spec;
104 scarab::authentication t_auth;
105 t_auth.add_groups( t_spec );
109 t_auth.process_spec();
117 LDEBUG(
dlog,
"Adding dripline auth spec" );
123 if( a_use_auth_file )
125 an_app.set_default_auth_file(
"authentications.json" );
dripline_config(bool a_read_mesh_file=true)
Creates the mesh config object with default values merged (optionally) with anything in $HOME/....
static ::scarab::logger_type< ::scarab::spd_initializer_async_stdout_color_mt > dlog("dripline_config", __FILE_NAME__, __LINE__)
using_param_args_and_kwargs
#define DL_MAX_PAYLOAD_SIZE
void add_dripline_auth_spec(scarab::main_app &an_app, bool a_use_auth_file)
scarab::authentication create_auth_with_dripline(bool a_process_spec)
Create an authentication object with the default dripline authentication specification.
static ::scarab::logger_type< ::scarab::spd_initializer_async_stdout_color_mt > dlog("agent", __FILE_NAME__, __LINE__)
void add_dripline_options(scarab::main_app &an_app)
Add dripline mesh CL options to an app object.
scarab::param_node create_dripline_auth_spec()
Create a param_node with the default dripline authentication specification.