feat(netconf): toplevel rpc drv
This commit is contained in:
parent
9601caba4f
commit
e8cdd06706
2 changed files with 74 additions and 39 deletions
5
hive.nix
5
hive.nix
|
@ -126,11 +126,14 @@ in
|
|||
};
|
||||
|
||||
netconf = {
|
||||
evalConfig = (import nixpkgs.nixos.unstable.path { }).lib.evalModules;
|
||||
evalConfig = nixpkgs.nixos.unstable.lib.evalModules;
|
||||
|
||||
defaults =
|
||||
{ nodeMeta, nodePath, ... }:
|
||||
{
|
||||
_module.args = {
|
||||
pkgs = nixpkgs.nixos.unstable;
|
||||
};
|
||||
# Import the default modules
|
||||
imports = [
|
||||
# Import the base configuration for each node
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
name,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mapAttrs mkOption;
|
||||
|
@ -9,6 +15,7 @@ let
|
|||
str
|
||||
any
|
||||
submodule
|
||||
package
|
||||
;
|
||||
|
||||
mandatory.options = {
|
||||
|
@ -36,14 +43,15 @@ in
|
|||
type = attrsOf any;
|
||||
default = { };
|
||||
};
|
||||
netconf.xmls.configuration = mkOption {
|
||||
netconf = {
|
||||
xmls.configuration = mkOption {
|
||||
type = str;
|
||||
readOnly = true;
|
||||
description = ''
|
||||
The full configuration to send to a JunOS.
|
||||
'';
|
||||
};
|
||||
netconf.mandatoryInterfaces = mkOption {
|
||||
mandatoryInterfaces = mkOption {
|
||||
type = attrsOf (submodule mandatory);
|
||||
example = {
|
||||
"ge-0/0/0" = {
|
||||
|
@ -62,13 +70,20 @@ in
|
|||
with some information about it (only if it supports PoE for now).
|
||||
'';
|
||||
};
|
||||
rpc = mkOption {
|
||||
type = package;
|
||||
readOnly = true;
|
||||
};
|
||||
config.interfaces =
|
||||
};
|
||||
};
|
||||
config = {
|
||||
interfaces =
|
||||
let
|
||||
mkIntf = _: _: { };
|
||||
in
|
||||
mapAttrs mkIntf config.netconf.mandatoryInterfaces;
|
||||
config.netconf.xmls.configuration = with config.netconf.xmls; ''
|
||||
netconf = {
|
||||
xmls.configuration = with config.netconf.xmls; ''
|
||||
<configuration>
|
||||
${system}
|
||||
${interfaces}
|
||||
|
@ -77,4 +92,21 @@ in
|
|||
${poe}
|
||||
</configuration>
|
||||
'';
|
||||
rpc = pkgs.writeText "${name}.rpc" ''
|
||||
<rpc>
|
||||
<edit-config>
|
||||
<config>
|
||||
${config.netconf.xmls.configuration}
|
||||
</config>
|
||||
<target>
|
||||
<candidate/>
|
||||
</target>
|
||||
</edit-config>
|
||||
</rpc>
|
||||
<rpc>
|
||||
<commit/>
|
||||
</rpc>
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue