aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2012-02-27 16:09:38 +0100
committerMicael Karlberg <[email protected]>2012-02-27 16:09:38 +0100
commita05886528ce9a02a79eda82c8868f489dd478aaa (patch)
treea8060cb88342da0816c54a40cd3d7c1b6f516661
parentf6b7aade87b64c4c60eba65dfac6310a8c7bf139 (diff)
parentd11e013575ed400b7167342be4b08ba3d1166ee9 (diff)
downloadotp-a05886528ce9a02a79eda82c8868f489dd478aaa.tar.gz
otp-a05886528ce9a02a79eda82c8868f489dd478aaa.tar.bz2
otp-a05886528ce9a02a79eda82c8868f489dd478aaa.zip
Merge branch 'bmk/snmp/improve_error_handling_reading_config/OTP-9943' into bmk/snmp/snmp422_integration/r15
Conflicts: lib/snmp/doc/src/notes.xml lib/snmp/src/app/snmp.appup.src
-rw-r--r--lib/snmp/doc/src/notes.xml6
-rw-r--r--lib/snmp/src/agent/snmp_community_mib.erl19
-rw-r--r--lib/snmp/src/agent/snmp_framework_mib.erl27
-rw-r--r--lib/snmp/src/agent/snmp_notification_mib.erl19
-rw-r--r--lib/snmp/src/agent/snmp_standard_mib.erl17
-rw-r--r--lib/snmp/src/agent/snmp_target_mib.erl8
-rw-r--r--lib/snmp/src/agent/snmp_user_based_sm_mib.erl6
-rw-r--r--lib/snmp/src/agent/snmp_view_based_acm_mib.erl2
-rw-r--r--lib/snmp/src/app/snmp.appup.src188
-rw-r--r--lib/snmp/src/misc/snmp_conf.erl17
10 files changed, 255 insertions, 54 deletions
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml
index 9cc6ae0b16..844409dd21 100644
--- a/lib/snmp/doc/src/notes.xml
+++ b/lib/snmp/doc/src/notes.xml
@@ -69,6 +69,12 @@
<p>Own Id: OTP-9942</p>
</item>
+ <item>
+ <p>[agent] Improve error handling while reading agent config files.
+ Some files contain mandatory information and is therefor themself
+ mandatory. </p>
+ <p>Own Id: OTP-9943</p>
+ </item>
</list>
</section>
diff --git a/lib/snmp/src/agent/snmp_community_mib.erl b/lib/snmp/src/agent/snmp_community_mib.erl
index 77307aa7ad..d7d41aca31 100644
--- a/lib/snmp/src/agent/snmp_community_mib.erl
+++ b/lib/snmp/src/agent/snmp_community_mib.erl
@@ -28,6 +28,7 @@
-export([add_community/5, add_community/6, delete_community/1]).
-export([check_community/1]).
+-include("snmpa_internal.hrl").
-include("SNMP-COMMUNITY-MIB.hrl").
-include("SNMP-TARGET-MIB.hrl").
-include("SNMPv2-TC.hrl").
@@ -120,10 +121,17 @@ init_tabs(Comms) ->
read_community_config_files(Dir) ->
?vdebug("read community config file",[]),
- Gen = fun(_) -> ok end,
- Filter = fun(Comms) -> Comms end,
- Check = fun(Entry) -> check_community(Entry) end,
- [Comms] =
+ FileName = "community.conf",
+ Gen = fun(D, Reason) ->
+ warning_msg("failed reading config file ~s"
+ "~n Config Dir: ~s"
+ "~n Reason: ~p",
+ [FileName, D, Reason]),
+ ok
+ end,
+ Filter = fun(Comms) -> Comms end,
+ Check = fun(Entry) -> check_community(Entry) end,
+ [Comms] =
snmp_conf:read_files(Dir, [{Gen, Filter, Check, "community.conf"}]),
Comms.
@@ -601,5 +609,8 @@ set_sname(_) -> %% Keep it, if already set.
error(Reason) ->
throw({error, Reason}).
+warning_msg(F, A) ->
+ ?snmpa_warning("[COMMUNITY-MIB]: " ++ F, A).
+
config_err(F, A) ->
snmpa_error:config_err("[COMMUNITY-MIB]: " ++ F, A).
diff --git a/lib/snmp/src/agent/snmp_framework_mib.erl b/lib/snmp/src/agent/snmp_framework_mib.erl
index 0d7866d94d..cc191bd956 100644
--- a/lib/snmp/src/agent/snmp_framework_mib.erl
+++ b/lib/snmp/src/agent/snmp_framework_mib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -115,7 +115,9 @@ do_configure(Dir) ->
read_internal_config_files(Dir) ->
?vdebug("read context config file",[]),
- Gen = fun(D) -> convert_context(D) end,
+ Gen = fun(D, Reason) ->
+ convert_context(D, Reason)
+ end,
Filter = fun(Contexts) -> Contexts end,
Check = fun(Entry) -> check_context(Entry) end,
[Ctxs] = snmp_conf:read_files(Dir, [{Gen, Filter, Check, "context.conf"}]),
@@ -123,10 +125,17 @@ read_internal_config_files(Dir) ->
read_agent(Dir) ->
- ?vdebug("read agent config file",[]),
- Check = fun(Entry) -> check_agent(Entry) end,
- File = filename:join(Dir, "agent.conf"),
- Agent = snmp_conf:read(File, Check),
+ ?vdebug("read agent config file", []),
+ FileName = "agent.conf",
+ Check = fun(Entry) -> check_agent(Entry) end,
+ File = filename:join(Dir, FileName),
+ Agent =
+ try
+ snmp_conf:read(File, Check)
+ catch
+ throw:{error, Reason} ->
+ error({failed_reading_config_file, Dir, FileName, Reason})
+ end,
sort_agent(Agent).
@@ -146,9 +155,9 @@ sort_agent(L) ->
%%-----------------------------------------------------------------
%% Generate a context.conf file.
%%-----------------------------------------------------------------
-convert_context(Dir) ->
+convert_context(Dir, _Reason) ->
config_err("missing context.conf file => generating a default file", []),
- File = filename:join(Dir,"context.conf"),
+ File = filename:join(Dir, "context.conf"),
case file:open(File, [write]) of
{ok, Fid} ->
ok = io:format(Fid, "~s\n", [context_header()]),
@@ -165,7 +174,7 @@ context_header() ->
io_lib:format("%% This file was automatically generated by "
"snmp_config v~s ~w-~2.2.0w-~2.2.0w "
"~2.2.0w:~2.2.0w:~2.2.0w\n",
- [?version,Y,Mo,D,H,Mi,S]).
+ [?version, Y, Mo, D, H, Mi, S]).
%%-----------------------------------------------------------------
diff --git a/lib/snmp/src/agent/snmp_notification_mib.erl b/lib/snmp/src/agent/snmp_notification_mib.erl
index 720ac749b8..37e09f5d3e 100644
--- a/lib/snmp/src/agent/snmp_notification_mib.erl
+++ b/lib/snmp/src/agent/snmp_notification_mib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -27,6 +27,7 @@
-export([add_notify/3, delete_notify/1]).
-export([check_notify/1]).
+-include("snmpa_internal.hrl").
-include("SNMP-NOTIFICATION-MIB.hrl").
-include("SNMPv2-TC.hrl").
-include("snmp_tables.hrl").
@@ -104,7 +105,14 @@ do_reconfigure(Dir) ->
read_notify_config_files(Dir) ->
?vdebug("read notify config file",[]),
- Gen = fun(_) -> ok end,
+ FileName = "notify.conf",
+ Gen = fun(D, Reason) ->
+ info_msg("failed reading config file ~s"
+ "~n Config Dir: ~s"
+ "~n Reason: ~p",
+ [FileName, D, Reason]),
+ ok
+ end,
Filter = fun(Notifs) -> Notifs end,
Check = fun(Entry) -> check_notify(Entry) end,
[Notifs] =
@@ -112,7 +120,7 @@ read_notify_config_files(Dir) ->
Notifs.
check_notify({Name, Tag, Type}) ->
- snmp_conf:check_string(Name,{gt,0}),
+ snmp_conf:check_string(Name, {gt, 0}),
snmp_conf:check_string(Tag),
{ok, Val} = snmp_conf:check_atom(Type, [{trap, 1}, {inform, 2}]),
Notify = {Name, Tag, Val,
@@ -451,12 +459,15 @@ set_sname() ->
set_sname(get(sname)).
set_sname(undefined) ->
- put(sname,conf);
+ put(sname, conf);
set_sname(_) -> %% Keep it, if already set.
ok.
error(Reason) ->
throw({error, Reason}).
+info_msg(F, A) ->
+ ?snmpa_info("[NOTIFICATION-MIB]: " ++ F, A).
+
config_err(F, A) ->
snmpa_error:config_err("[NOTIFICATION-MIB]: " ++ F, A).
diff --git a/lib/snmp/src/agent/snmp_standard_mib.erl b/lib/snmp/src/agent/snmp_standard_mib.erl
index b6834d278c..7db94e7bd5 100644
--- a/lib/snmp/src/agent/snmp_standard_mib.erl
+++ b/lib/snmp/src/agent/snmp_standard_mib.erl
@@ -143,18 +143,24 @@ do_reconfigure(Dir) ->
%% Func: read_standard/1
%% Args: Dir is the directory with trailing dir_separator where
%% the configuration files can be found.
-%% Purpose: Reads th standard configuration file.
+%% Purpose: Reads the standard configuration file.
%% Returns: A list of standard variables
%% Fails: If an error occurs, the process will die with Reason
%% configuration_error.
+%% This file is mandatory, as it contains mandatory
+%% config options for which there are no default values.
%%-----------------------------------------------------------------
read_standard(Dir) ->
?vdebug("check standard config file",[]),
- Gen = fun(_) -> ok end,
- Filter = fun(Standard) -> sort_standard(Standard) end,
- Check = fun(Entry) -> check_standard(Entry) end,
+ FileName = "standard.conf",
+ Gen = fun(D, Reason) ->
+ throw({error, {failed_reading_config_file,
+ D, FileName, Reason}})
+ end,
+ Filter = fun(Standard) -> sort_standard(Standard) end,
+ Check = fun(Entry) -> check_standard(Entry) end,
[Standard] =
- snmp_conf:read_files(Dir, [{Gen, Filter, Check, "standard.conf"}]),
+ snmp_conf:read_files(Dir, [{Gen, Filter, Check, FileName}]),
Standard.
@@ -548,6 +554,7 @@ snmp_set_serial_no(set, NewVal) ->
snmp_generic:variable_func(set, (NewVal + 1) rem 2147483648,
{snmpSetSerialNo, volatile}).
+
%%-----------------------------------------------------------------
%% This is the instrumentation function for sysOrTable
%%-----------------------------------------------------------------
diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl
index a45db89c09..b01d536caa 100644
--- a/lib/snmp/src/agent/snmp_target_mib.erl
+++ b/lib/snmp/src/agent/snmp_target_mib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -132,12 +132,12 @@ do_reconfigure(Dir) ->
read_target_config_files(Dir) ->
- ?vdebug("check target address config file",[]),
- TAGen = fun(_D) -> ok end,
+ ?vdebug("check target address and parameter config file(s)",[]),
+ TAGen = fun(_D, _Reason) -> ok end,
TAFilter = fun(Addr) -> Addr end,
TACheck = fun(Entry) -> check_target_addr(Entry) end,
- TPGen = fun(_D) -> ok end,
+ TPGen = fun(_D, _Reason) -> ok end,
TPFilter = fun(Params) -> Params end,
TPCheck = fun(Entry) -> check_target_params(Entry) end,
diff --git a/lib/snmp/src/agent/snmp_user_based_sm_mib.erl b/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
index 69cebc858b..2e801622e7 100644
--- a/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
+++ b/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -136,7 +136,7 @@ do_reconfigure(Dir) ->
read_usm_config_files(Dir) ->
?vdebug("read usm config file",[]),
- Gen = fun(D) -> generate_usm(D) end,
+ Gen = fun(D, Reason) -> generate_usm(D, Reason) end,
Filter = fun(Usms) -> Usms end,
Check = fun(Entry) -> check_usm(Entry) end,
[Usms] =
@@ -144,7 +144,7 @@ read_usm_config_files(Dir) ->
Usms.
-generate_usm(Dir) ->
+generate_usm(Dir, _Reason) ->
info_msg("Incomplete configuration. Generating empty usm.conf.", []),
USMFile = filename:join(Dir, "usm.conf"),
ok = file:write_file(USMFile, list_to_binary([])).
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
index 2cee91b081..479a44795f 100644
--- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
+++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
@@ -115,7 +115,7 @@ do_reconfigure(Dir) ->
read_vacm_config_files(Dir) ->
?vdebug("read vacm config file",[]),
- Gen = fun(_) -> ok end,
+ Gen = fun(_D, _Reason) -> ok end,
Filter = fun(Vacms) ->
Sec2Group = [X || {vacmSecurityToGroup, X} <- Vacms],
Access = [X || {vacmAccess, X} <- Vacms],
diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src
index 14b87390c9..8b0946d319 100644
--- a/lib/snmp/src/app/snmp.appup.src
+++ b/lib/snmp/src/app/snmp.appup.src
@@ -24,6 +24,15 @@
[
{"4.21.7",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
@@ -40,6 +49,15 @@
},
{"4.21.6",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
@@ -56,6 +74,14 @@
},
{"4.21.5",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -63,7 +89,8 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
@@ -77,6 +104,13 @@
},
{"4.21.4",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -84,13 +118,15 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
@@ -101,6 +137,13 @@
},
{"4.21.3",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -108,13 +151,15 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
@@ -125,6 +170,13 @@
},
{"4.21.2",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -132,11 +184,13 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{load_module, snmpa_mpd, soft_purge, soft_purge, []},
{load_module, snmpa_set_lib, soft_purge, soft_purge, []},
@@ -151,6 +205,13 @@
},
{"4.21.1",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -158,11 +219,13 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{load_module, snmpa_mpd, soft_purge, soft_purge, []},
{load_module, snmpa_set_lib, soft_purge, soft_purge, []},
@@ -178,6 +241,13 @@
},
{"4.21",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -188,12 +258,14 @@
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{load_module, snmpa_mpd, soft_purge, soft_purge, []},
{load_module, snmpa_set_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
@@ -210,6 +282,15 @@
[
{"4.21.7",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
@@ -226,6 +307,15 @@
},
{"4.21.6",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
@@ -242,6 +332,14 @@
},
{"4.21.5",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -249,7 +347,8 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
@@ -263,6 +362,13 @@
},
{"4.21.4",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -270,13 +376,15 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
@@ -287,6 +395,13 @@
},
{"4.21.3",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -294,13 +409,15 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
@@ -311,6 +428,13 @@
},
{"4.21.2",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -318,11 +442,13 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{load_module, snmpa_mpd, soft_purge, soft_purge, []},
{load_module, snmpa_set_lib, soft_purge, soft_purge, []},
@@ -337,6 +463,13 @@
},
{"4.21.1",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -344,11 +477,13 @@
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{load_module, snmpa_mpd, soft_purge, soft_purge, []},
{load_module, snmpa_set_lib, soft_purge, soft_purge, []},
@@ -364,6 +499,13 @@
},
{"4.21",
[
+ {load_module, snmp_conf, soft_purge, soft_purge, []},
+ {load_module, snmp_community_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_framework_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_notification_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_standard_mib, soft_purge, soft_purge, [snmp_conf]},
+ {load_module, snmp_user_based_sm_mib, soft_purge, soft_purge, [snmp_conf]},
+
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
{load_module, snmp_log, soft_purge, soft_purge, []},
@@ -374,12 +516,14 @@
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge,
+ [snmp_conf]},
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{load_module, snmpa_mpd, soft_purge, soft_purge, []},
{load_module, snmpa_set_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
- {load_module, snmp_target_mib, soft_purge, soft_purge, []},
+ {load_module, snmp_target_mib, soft_purge, soft_purge,
+ [snmp_conf, snmpa_mib_lib]},
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
diff --git a/lib/snmp/src/misc/snmp_conf.erl b/lib/snmp/src/misc/snmp_conf.erl
index 7249def24e..e1e7fab57b 100644
--- a/lib/snmp/src/misc/snmp_conf.erl
+++ b/lib/snmp/src/misc/snmp_conf.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -71,6 +71,18 @@
%%-----------------------------------------------------------------
+%% read_files(Dir, Files) -> Configs
+%% Dir - string() - Full path to the config dir.
+%% Files - [{Gen, Filter, Check, FileName}]
+%% Gen - function/2 - In case of failure when reading the config file,
+%% this function is called to either generate a
+%% default file or issue the error.
+%% Filter - function/1 - Filters all the config entries read from the file
+%% Check - function/1 - Check each entry as they are read from the file.
+%% FileName - string() - Name of the config file.
+%% Configs - [config_entry()]
+%% config_entry() - term()
+
read_files(Dir, Files) when is_list(Dir) andalso is_list(Files) ->
read_files(Dir, Files, []).
@@ -90,7 +102,7 @@ read_files(Dir, [{Gen, Filter, Check, FileName}|Files], Res)
{error, R} ->
?vlog("failed reading file info for ~s: "
"~n ~p", [FileName, R]),
- Gen(Dir),
+ Gen(Dir, R),
read_files(Dir, Files, [Filter([])|Res])
end.
@@ -99,6 +111,7 @@ read_files(Dir, [{Gen, Filter, Check, FileName}|Files], Res)
read(File, Check) when is_function(Check) ->
?vdebug("read -> entry with"
"~n File: ~p", [File]),
+
Fd = open_file(File),
case loop(Fd, [], Check, 1, File) of