diff options
author | Steve Vinoski <[email protected]> | 2013-09-20 14:23:35 -0400 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2013-10-09 11:21:04 +0200 |
commit | c83c236f6a0a1a5299376e40db57e7b7527cbac7 (patch) | |
tree | 61253108c10682e359d7260ea6547a1a7ac4e10d /lib/snmp/src/agent | |
parent | 50e91bde3403c788bb1cabe644534f351d6dc1c1 (diff) | |
download | otp-c83c236f6a0a1a5299376e40db57e7b7527cbac7.tar.gz otp-c83c236f6a0a1a5299376e40db57e7b7527cbac7.tar.bz2 otp-c83c236f6a0a1a5299376e40db57e7b7527cbac7.zip |
[snmp/agent] enable SNMP to create missing database directories
Add {db_init_error, create_db_and_dir} option to SNMP manager and
agent. This allows them to create any missing parent directories for
db_dir, rather than treating any missing directories as a fatal error.
The default for db_init_error, which is terminate, is unchanged.
Add create_db_and_dir to the documentation.
Add new tests to verify that using create_db_and_dir results in missing
parent directories being created.
Diffstat (limited to 'lib/snmp/src/agent')
-rw-r--r-- | lib/snmp/src/agent/snmpa_local_db.erl | 6 | ||||
-rw-r--r-- | lib/snmp/src/agent/snmpa_supervisor.erl | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/snmp/src/agent/snmpa_local_db.erl b/lib/snmp/src/agent/snmpa_local_db.erl index 5198c6ec4e..a1e41257ce 100644 --- a/lib/snmp/src/agent/snmpa_local_db.erl +++ b/lib/snmp/src/agent/snmpa_local_db.erl @@ -191,6 +191,12 @@ dets_open(DbDir, DbInitError, Opts) -> end end; _ -> + case DbInitError of + create_db_and_dir -> + ok = filelib:ensure_dir(Filename); + _ -> + ok + end, case do_dets_open(Name, Filename, Opts) of {ok, Dets} -> ?vdebug("dets open done",[]), diff --git a/lib/snmp/src/agent/snmpa_supervisor.erl b/lib/snmp/src/agent/snmpa_supervisor.erl index aebcdbaa84..77ed54bee4 100644 --- a/lib/snmp/src/agent/snmpa_supervisor.erl +++ b/lib/snmp/src/agent/snmpa_supervisor.erl @@ -356,7 +356,7 @@ init([AgentType, Opts]) -> SymStoreSpec = worker_spec(snmpa_symbolic_store, SymStoreArgs, Restart, 2000), - LdbArgs = [Prio, DbDir, LdbOpts], + LdbArgs = [Prio, DbDir, DbInitError, LdbOpts], LocalDbSpec = worker_spec(snmpa_local_db, LdbArgs, Restart, 5000), |