diff options
author | Micael Karlberg <[email protected]> | 2013-10-09 11:28:03 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2013-10-09 11:28:03 +0200 |
commit | f9f49c3ae40eef669ed165efdc4b03ecb551a8a0 (patch) | |
tree | 3085b3e94bb51c8d822c277a6c9786960b4d9f55 /lib/snmp/src/manager/snmpm_config.erl | |
parent | e0ecc86e35475b434efa6cccba44074ca1040b7a (diff) | |
parent | bf552c9138427070b1e17c6fc92f8972d8aef112 (diff) | |
download | otp-f9f49c3ae40eef669ed165efdc4b03ecb551a8a0.tar.gz otp-f9f49c3ae40eef669ed165efdc4b03ecb551a8a0.tar.bz2 otp-f9f49c3ae40eef669ed165efdc4b03ecb551a8a0.zip |
Merge branch 'bmk/snmp/create_db_dir/OTP-11352' into bmk/snmp/snmp425_integration
Diffstat (limited to 'lib/snmp/src/manager/snmpm_config.erl')
-rw-r--r-- | lib/snmp/src/manager/snmpm_config.erl | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/snmp/src/manager/snmpm_config.erl b/lib/snmp/src/manager/snmpm_config.erl index 736debe544..2101ad46e1 100644 --- a/lib/snmp/src/manager/snmpm_config.erl +++ b/lib/snmp/src/manager/snmpm_config.erl @@ -1215,6 +1215,12 @@ dets_open(Dir, DbInitError, Repair, AutoSave) -> end end; _ -> + case DbInitError of + create_db_and_dir -> + ok = filelib:ensure_dir(Filename); + _ -> + ok + end, case do_dets_open(Name, Filename, Repair, AutoSave) of {ok, _Dets} -> ok; @@ -1316,7 +1322,14 @@ verify_option({server, ServerOpts}) -> verify_server_opts(ServerOpts); verify_option({note_store, NoteStoreOpts}) -> verify_note_store_opts(NoteStoreOpts); -verify_option({config, ConfOpts}) -> +verify_option({config, ConfOpts0}) -> + %% Make sure any db_dir option is first in the options list to make it + %% easier to check if the db_init_error option specifies that a missing + %% db_dir should be created. + ConfOpts = case lists:keytake(db_dir, 1, ConfOpts0) of + false -> ConfOpts0; + {value, Result, OtherOpts} -> [Result|OtherOpts] + end, verify_config_opts(ConfOpts); verify_option({versions, Vsns}) -> verify_versions(Vsns); @@ -1365,7 +1378,12 @@ verify_config_opts([{dir, Dir}|Opts]) -> verify_conf_dir(Dir), verify_config_opts(Opts); verify_config_opts([{db_dir, Dir}|Opts]) -> - verify_conf_db_dir(Dir), + case lists:keyfind(db_init_error, 1, Opts) of + {db_init_error, create_db_and_dir} -> + verify_conf_db_dir(Dir, false); + _ -> + verify_conf_db_dir(Dir, true) + end, verify_config_opts(Opts); verify_config_opts([{db_init_error, DbInitErr}|Opts]) -> verify_conf_db_init_error(DbInitErr), @@ -1443,7 +1461,7 @@ verify_conf_dir(Dir) -> error({invalid_conf_dir, Dir}) end. -verify_conf_db_dir(Dir) -> +verify_conf_db_dir(Dir, true) -> case (catch verify_dir(Dir)) of ok -> ok; @@ -1451,13 +1469,16 @@ verify_conf_db_dir(Dir) -> error({invalid_conf_db_dir, Dir, Reason}); _ -> error({invalid_conf_db_dir, Dir}) - end. - + end; +verify_conf_db_dir(_Dir, false) -> + ok. verify_conf_db_init_error(terminate) -> ok; verify_conf_db_init_error(create) -> ok; +verify_conf_db_init_error(create_db_and_dir) -> + ok; verify_conf_db_init_error(InvalidDbInitError) -> error({invalid_conf_db_init_error, InvalidDbInitError}). |