lib/config/options+legacy: add bgp

This commit is contained in:
Astro 2021-04-13 00:11:42 +02:00
parent 8013241d6c
commit aed29a54ce
2 changed files with 41 additions and 4 deletions

View File

@ -121,14 +121,25 @@ in
ospf =
let
hostPillar = self.lib.saltPillarFor name;
ospfConf = hostPillar.ospf;
in lib.optionalAttrs (hostPillar ? ospf && ospfConf ? stubnets-inet) {
ospfConf = ctPillar.ospf;
in lib.optionalAttrs (ctPillar ? ospf && ospfConf ? stubnets-inet) {
stubNets4 = ospfConf.stubnets-inet;
} // lib.optionalAttrs (hostPillar ? ospf && ospfConf ? stubnets-inet6) {
} // lib.optionalAttrs (ctPillar ? ospf && ospfConf ? stubnets-inet6) {
stubNets6 = ospfConf.stubnets-inet6;
};
bgp =
if ctPillar ? bgp
then
let
bgpConf = ctPillar.bgp;
in {
inherit (bgpConf) asn;
peers4 = bgpConf.peers-inet;
peers6 = bgpConf.peers-inet6;
}
else null;
forwardPorts =
if ctPillar ? port-forwarding
then map ({ proto, port, to }: {

View File

@ -221,6 +221,32 @@ let
}
));
};
bgp = mkOption {
default = null;
type = with types; nullOr (submodule {
options = bgpOpts;
});
};
};
};
bgpPeerOpts = { name, ... }: {
options = {
asn = mkOption {
type = types.int;
};
};
};
bgpOpts = {
asn = mkOption {
type = types.int;
};
peers4 = mkOption {
type = with types; attrsOf (submodule bgpPeerOpts);
default = {};
};
peers6 = mkOption {
type = with types; attrsOf (submodule bgpPeerOpts);
default = {};
};
};
in