feat(netconf/junos): allow snmp management
This commit is contained in:
parent
4dbd5ac6b1
commit
a0596d022a
2 changed files with 82 additions and 0 deletions
|
@ -41,6 +41,7 @@ in
|
|||
./system.nix
|
||||
./vlans.nix
|
||||
./routing-options.nix
|
||||
./snmp.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
|
@ -102,6 +103,7 @@ in
|
|||
${poe}
|
||||
${access}
|
||||
${routing-options}
|
||||
${snmp}
|
||||
</configuration>
|
||||
'';
|
||||
rpc = pkgs.writeText "${name}.rpc" ''
|
||||
|
|
80
lib/netconf-junos/snmp.nix
Normal file
80
lib/netconf-junos/snmp.nix
Normal file
|
@ -0,0 +1,80 @@
|
|||
# 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>
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue