80 lines
1.9 KiB
Nix
80 lines
1.9 KiB
Nix
# SPDX-FileCopyrightText: 2025 Lubin Bailly <lubin.bailly@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
{ lib, config, ... }:
|
|
let
|
|
inherit (lib)
|
|
concatMapAttrsStringSep
|
|
mkOption
|
|
optionalString
|
|
;
|
|
inherit (lib.types)
|
|
attrsOf
|
|
bool
|
|
enum
|
|
str
|
|
submodule
|
|
;
|
|
in
|
|
{
|
|
options = {
|
|
snmp = {
|
|
filter-interfaces.all-internal-interfaces = mkOption {
|
|
type = bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to filter internal interfaces.
|
|
'';
|
|
};
|
|
community = mkOption {
|
|
type = attrsOf (
|
|
submodule (
|
|
{ name, config, ... }:
|
|
{
|
|
options = {
|
|
authorization = mkOption {
|
|
type = enum [
|
|
"read-only"
|
|
"read-write"
|
|
];
|
|
description = ''
|
|
Authorization type.
|
|
'';
|
|
};
|
|
xml = mkOption {
|
|
type = str;
|
|
visible = false;
|
|
readOnly = true;
|
|
};
|
|
};
|
|
config.xml = ''
|
|
<community>
|
|
<name>${name}</name>
|
|
<authorization>${config.authorization}</authorization>
|
|
</community>
|
|
'';
|
|
}
|
|
)
|
|
);
|
|
default = { };
|
|
description = ''
|
|
Communities for SNMPv2 access.
|
|
'';
|
|
};
|
|
};
|
|
netconf.xmls.snmp = mkOption {
|
|
type = str;
|
|
visible = false;
|
|
readOnly = true;
|
|
};
|
|
};
|
|
config.netconf.xmls.snmp = ''
|
|
<snmp operation="replace">
|
|
<filter-interfaces>
|
|
${optionalString config.snmp.filter-interfaces.all-internal-interfaces "<all-internal-interfaces/>"}
|
|
</filter-interfaces>
|
|
${concatMapAttrsStringSep "" (_: comm: comm.xml) config.snmp.community}
|
|
</snmp>
|
|
'';
|
|
}
|