From 0481eeb9c669b9636e67e3b32fbf6ac3d3d668b4 Mon Sep 17 00:00:00 2001 From: catvayor Date: Wed, 22 May 2024 13:33:28 +0200 Subject: [PATCH] feat(netaccess01): Add --- default.nix | 37 ++++++++------- junos/default.nix | 12 ++--- junos/interfaces.nix | 13 +++--- junos/vlans.nix | 4 +- netconf-hive.nix | 104 ++++++++++++++++++++++++++++++++----------- 5 files changed, 118 insertions(+), 52 deletions(-) diff --git a/default.nix b/default.nix index fb4a671..a479d6b 100644 --- a/default.nix +++ b/default.nix @@ -3,21 +3,28 @@ }: let lib = pkgs.lib; - hive_mod = { lib, config, name, ... }: with lib; { - options.deployment = { - targetHost = mkOption { type = types.str; }; - rpc = mkOption { - type = types.package; - readOnly = true; + hive_mod = + { + lib, + config, + name, + ... + }: + with lib; + { + options.deployment = { + targetHost = mkOption { type = types.str; }; + rpc = mkOption { + type = types.package; + readOnly = true; + }; + cmd = mkOption { + type = types.package; + readOnly = true; + }; }; - cmd = mkOption { - type = types.package; - readOnly = true; - }; - }; - config.deployment = rec { - rpc = - pkgs.writeText "config-${name}_rpc.xml" '' + config.deployment = rec { + rpc = pkgs.writeText "config-${name}_rpc.xml" '' @@ -38,7 +45,7 @@ let text = ''ssh "${config.deployment.targetHost}" -p 830 -s netconf < ${rpc}''; }; }; - }; + }; evaluator = name: module_inst: let diff --git a/junos/default.nix b/junos/default.nix index a8e2e45..a3e9d20 100644 --- a/junos/default.nix +++ b/junos/default.nix @@ -27,10 +27,10 @@ with lib; in listToAttrs (map mkIntf config.netconf.mandatoryInterfaces); config.netconf.xmls.configuration = '' - - ${config.netconf.xmls.interfaces} - ${config.netconf.xmls.protocols} - ${config.netconf.xmls.vlans} - - ''; + + ${config.netconf.xmls.interfaces} + ${config.netconf.xmls.protocols} + ${config.netconf.xmls.vlans} + + ''; } diff --git a/junos/interfaces.nix b/junos/interfaces.nix index f5094a8..9872378 100644 --- a/junos/interfaces.nix +++ b/junos/interfaces.nix @@ -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 = '' - ${ - builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.interfaces) - } + ${builtins.concatStringsSep "" (attrsets.mapAttrsToList (_: intf: intf.xml) config.interfaces)} ''; } diff --git a/junos/vlans.nix b/junos/vlans.nix index 805c7fb..f98c3b9 100644 --- a/junos/vlans.nix +++ b/junos/vlans.nix @@ -44,7 +44,9 @@ let config.xml = let id = optionalString (!isNull config.id) "${toString config.id}"; - id-list = concatStringsSep "" (map (vlan: "${toString vlan}") config.id-list); + id-list = concatStringsSep "" ( + map (vlan: "${toString vlan}") config.id-list + ); l3-intf = optionalString ( !isNull config.l3-interface ) "${config.l3-interface}"; diff --git a/netconf-hive.nix b/netconf-hive.nix index b8d4974..ef8ec55 100644 --- a/netconf-hive.nix +++ b/netconf-hive.nix @@ -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" ]; + }; + }; + }; + }; }