feat(netaccess01): Add

This commit is contained in:
catvayor 2024-05-22 13:33:28 +02:00
parent cc9c057529
commit 0481eeb9c6
5 changed files with 118 additions and 52 deletions

View file

@ -3,7 +3,15 @@
}:
let
lib = pkgs.lib;
hive_mod = { lib, config, name, ... }: with lib; {
hive_mod =
{
lib,
config,
name,
...
}:
with lib;
{
options.deployment = {
targetHost = mkOption { type = types.str; };
rpc = mkOption {
@ -16,8 +24,7 @@ let
};
};
config.deployment = rec {
rpc =
pkgs.writeText "config-${name}_rpc.xml" ''
rpc = pkgs.writeText "config-${name}_rpc.xml" ''
<rpc>
<edit-config>
<config>

View file

@ -9,7 +9,9 @@ let
{ name, config, ... }:
{
options = {
enable = mkEnableOption "the logical interface ${intf-name}.${name}" // { default = true; };
enable = mkEnableOption "the logical interface ${intf-name}.${name}" // {
default = true;
};
family = {
ethernet-switching = {
enable = mkEnableOption "the ethernet on the logical interface ${intf-name}.${name}";
@ -89,7 +91,10 @@ let
{
options = {
enable = mkEnableOption "the physical interface ${intf-name}";
unit = mkOption { type = types.attrsOf (types.submodule unit); default = {}; };
unit = mkOption {
type = types.attrsOf (types.submodule unit);
default = { };
};
xml = mkOption {
type = types.str;
visible = false;
@ -120,9 +125,7 @@ in
};
config.netconf.xmls.interfaces = ''
<interfaces operation="replace">
${
builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.interfaces)
}
${builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.interfaces)}
</interfaces>
'';
}

View file

@ -44,7 +44,9 @@ let
config.xml =
let
id = optionalString (!isNull config.id) "<vlan-id>${toString config.id}</vlan-id>";
id-list = concatStringsSep "" (map (vlan: "<vlan-id-list>${toString vlan}</vlan-id-list>") config.id-list);
id-list = concatStringsSep "" (
map (vlan: "<vlan-id-list>${toString vlan}</vlan-id-list>") config.id-list
);
l3-intf = optionalString (
!isNull config.l3-interface
) "<l3-interface>${config.l3-interface}</l3-interface>";

View file

@ -1,7 +1,6 @@
let
vlansPlan = {
"uplink-cri".id = 223;
"uplink-interne".id = 403;
"admin-core" = {
id = 3000;
@ -39,9 +38,21 @@ let
in
{
netcore02 = {
deployment.targetHost = "jourdan01.dgn";
deployment.targetHost = "netcore02.dgn";
vlans = vlansPlan;
protocols.rstp = [
"ge-0/0/0"
"ge-0/0/1"
"ge-0/0/2"
"ge-0/0/3"
"ge-0/0/4"
"ge-0/0/5"
"ge-0/0/6"
"ge-0/0/7"
"ge-0/0/8"
"ge-0/0/9"
"ge-0/0/10"
"ge-0/0/11"
"ge-0/0/12"
"ge-0/0/13"
"ge-0/0/14"
@ -57,12 +68,24 @@ in
"ge-0/1/3"
];
interfaces = {
"ge-0/0/12" = AP;
"ge-0/0/13" = AP;
"ge-0/0/14" = AP;
"ge-0/0/15" = AP;
"ge-0/0/16" = AP;
"ge-0/0/17" = AP;
"ge-0/0/0" = AP-staging;
"ge-0/0/1" = AP-staging;
"ge-0/0/2" = AP-staging;
"ge-0/0/3" = AP-staging;
"ge-0/0/4" = AP-staging;
"ge-0/0/5" = AP-staging;
"ge-0/0/6" = AP-staging;
"ge-0/0/7" = AP-staging;
"ge-0/0/8" = AP-staging;
"ge-0/0/9" = AP-staging;
"ge-0/0/10" = AP-staging;
"ge-0/0/11" = AP-staging;
"ge-0/0/12" = AP-staging;
"ge-0/0/13" = AP-staging;
"ge-0/0/14" = AP-staging;
"ge-0/0/15" = AP-staging;
"ge-0/0/16" = AP-staging;
"ge-0/0/17" = AP-staging;
"ge-0/0/42" = {
enable = true;
@ -108,7 +131,7 @@ in
unit."0".family.ethernet-switching = {
enable = true;
interface-mode = "trunk";
vlans = [ "uplink-cri" "uplink-interne" ];
vlans = [ "uplink-cri" ];
};
};
@ -129,22 +152,53 @@ in
};
};
};
# netaccess01 = {
# deployement.targetHost = "root@192.168.42.6";
netaccess01 = {
deployment.targetHost = "netaccess01.dgn";
# vlans = vlansPlan "fd26:baf9:d250:8000::2001/64";
# interfaces = {
# "xe-0/1/0" = {
# enable = true;
# interface-mode = "trunk";
# vlans = [ "all" ];
# dhcp_trusted = true;
# };
vlans = vlansPlan;
# "me0" = {
# enable = true;
# management = "192.168.42.6/24";
# };
# };
# };
protocols.rstp = [
"ge-0/0/0"
"ge-0/0/1"
"ge-0/0/2"
"ge-0/0/3"
"ge-0/0/4"
"ge-0/0/5"
"xe-0/1/0"
];
interfaces = {
"ge-0/0/0" = AP-staging;
"ge-0/0/1" = AP-staging;
"ge-0/0/2" = AP-staging;
"ge-0/0/3" = AP-staging;
"ge-0/0/4" = AP-staging;
"ge-0/0/5" = AP-staging;
"xe-0/1/0" = {
enable = true;
unit."0".family.ethernet-switching = {
enable = true;
interface-mode = "trunk";
vlans = [ "all" ];
};
};
"me0" = {
enable = true;
unit."0".family.inet = {
enable = true;
address = [ "192.168.42.6/24" ];
};
};
"irb" = {
enable = true;
unit."0".family.inet6 = {
enable = true;
address = [ "fd26:baf9:d250:8000::2001/64" ];
};
};
};
};
}