QoL module improvement && addresses instead of address
This commit is contained in:
parent
681db54504
commit
e8c9d47754
4 changed files with 100 additions and 113 deletions
|
@ -55,7 +55,7 @@ let
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
./junos
|
./junos
|
||||||
./ex2300.nix
|
./dgn-module.nix
|
||||||
hive_mod
|
hive_mod
|
||||||
module_inst
|
module_inst
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,36 +2,67 @@
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
intf-mod =
|
intf-mod =
|
||||||
{ name, ... }:
|
{ name, config, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
enable = mkEnableOption "The interface ${name}.";
|
enable = mkEnableOption "this interface" // {
|
||||||
poe = mkEnableOption "The PoE on interface ${name}.";
|
default = config.inet.enable || config.inet6.enable || config.ethernet-switching.enable;
|
||||||
|
defaultText = ''config.inet.enable || config.inet6.enable || config.ethernet-switching.enable'';
|
||||||
|
};
|
||||||
|
poe = mkEnableOption "the PoE on this interface";
|
||||||
ethernet-switching = {
|
ethernet-switching = {
|
||||||
enable = mkEnableOption "The ethernet switching on interface ${name}.";
|
enable = mkEnableOption "the ethernet switching on this interface" // {
|
||||||
|
default = config.ethernet-switching.interface-mode != null;
|
||||||
|
defaultText = ''config.ethernet-switching.interface-mode != null'';
|
||||||
|
};
|
||||||
interface-mode = mkOption {
|
interface-mode = mkOption {
|
||||||
type = types.enum [
|
type = types.nullOr (
|
||||||
"trunk"
|
types.enum [
|
||||||
"access"
|
"trunk"
|
||||||
];
|
"access"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Mode of operation for vlan addressing of this interface.
|
||||||
|
"trunk" means that the traffic is tagged, "access" means the
|
||||||
|
traffic is tagged by the switch.
|
||||||
|
Use null to desactivate the switching.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
vlans = mkOption {
|
vlans = mkOption {
|
||||||
type = types.listOf (types.either types.str types.ints.unsigned);
|
type = types.listOf (types.either types.str types.ints.unsigned);
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
Vlans that can be used on this interface.
|
||||||
|
Only one ID should be here for "access" mode of operation.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
inet = {
|
inet = {
|
||||||
enable = mkEnableOption "The ipv4 on the interface ${name}.";
|
enable = mkEnableOption "the ipv4 on this interface" // {
|
||||||
address = mkOption {
|
default = config.inet.addresses != [ ];
|
||||||
|
defaultText = ''config.inet.addresses != [ ]'';
|
||||||
|
};
|
||||||
|
addresses = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
ipv4 addresses of this interface.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
inet6 = {
|
inet6 = {
|
||||||
enable = mkEnableOption "The ipv6 on the interface ${name}.";
|
enable = mkEnableOption "the ipv6 on this interface" // {
|
||||||
address = mkOption {
|
default = config.inet6.addresses != [ ];
|
||||||
|
defaultText = ''config.inet6.addresses != [ ]'';
|
||||||
|
};
|
||||||
|
addresses = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
ipv6 addresses of this interface.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -44,12 +75,20 @@ in
|
||||||
options.dgn-interfaces = mkOption {
|
options.dgn-interfaces = mkOption {
|
||||||
type = types.attrsOf (types.submodule intf-mod);
|
type = types.attrsOf (types.submodule intf-mod);
|
||||||
default = { };
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Unified configuration of interfaces adapted to DGNum usage:
|
||||||
|
- each interfaces have only one logical subinterface;
|
||||||
|
- enabling ethernet-switching also enable RSTP;
|
||||||
|
- automatic enabling interface and relevant config family when configuring;
|
||||||
|
- allows enabling PoE along other configurations.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
interfaces = mapAttrs (_: intf: {
|
interfaces = mapAttrs (_: intf: {
|
||||||
inherit (intf) enable;
|
inherit (intf) enable;
|
||||||
unit."0".family = {
|
unit."0".family = {
|
||||||
inherit (intf) inet inet6 ethernet-switching;
|
inherit (intf) inet inet6;
|
||||||
|
ethernet-switching = mkIf intf.ethernet-switching.enable intf.ethernet-switching;
|
||||||
};
|
};
|
||||||
}) cfg;
|
}) cfg;
|
||||||
poe.interfaces = filterAttrs (
|
poe.interfaces = filterAttrs (
|
||||||
|
|
|
@ -40,7 +40,7 @@ let
|
||||||
#TODO : DHCP
|
#TODO : DHCP
|
||||||
inet = {
|
inet = {
|
||||||
enable = mkEnableOption "the IPv4 configuration of this logical interface";
|
enable = mkEnableOption "the IPv4 configuration of this logical interface";
|
||||||
address = mkOption {
|
addresses = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -50,7 +50,7 @@ let
|
||||||
};
|
};
|
||||||
inet6 = {
|
inet6 = {
|
||||||
enable = mkEnableOption "the IPv6 configuration of this logical interface";
|
enable = mkEnableOption "the IPv6 configuration of this logical interface";
|
||||||
address = mkOption {
|
addresses = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -78,14 +78,14 @@ let
|
||||||
</ethernet-switching>
|
</ethernet-switching>
|
||||||
'';
|
'';
|
||||||
|
|
||||||
addr4 = map (addr: "<name>${addr}</name>") config.family.inet.address;
|
addr4 = map (addr: "<name>${addr}</name>") config.family.inet.addresses;
|
||||||
inet = optionalString config.family.inet.enable ''
|
inet = optionalString config.family.inet.enable ''
|
||||||
<inet>
|
<inet>
|
||||||
<address>${builtins.concatStringsSep "" addr4}</address>
|
<address>${builtins.concatStringsSep "" addr4}</address>
|
||||||
</inet>
|
</inet>
|
||||||
'';
|
'';
|
||||||
|
|
||||||
addr6 = map (addr: "<name>${addr}</name>") config.family.inet6.address;
|
addr6 = map (addr: "<name>${addr}</name>") config.family.inet6.addresses;
|
||||||
inet6 = optionalString config.family.inet6.enable ''
|
inet6 = optionalString config.family.inet6.enable ''
|
||||||
<inet6>
|
<inet6>
|
||||||
<address>${builtins.concatStringsSep "" addr6}</address>
|
<address>${builtins.concatStringsSep "" addr6}</address>
|
||||||
|
|
138
netconf-hive.nix
138
netconf-hive.nix
|
@ -17,9 +17,8 @@ let
|
||||||
"ap-staging".id = 2000;
|
"ap-staging".id = 2000;
|
||||||
};
|
};
|
||||||
AP = {
|
AP = {
|
||||||
enable = true;
|
poe = true;
|
||||||
ethernet-switching = {
|
ethernet-switching = {
|
||||||
enable = true;
|
|
||||||
interface-mode = "trunk";
|
interface-mode = "trunk";
|
||||||
vlans = [
|
vlans = [
|
||||||
"users"
|
"users"
|
||||||
|
@ -28,10 +27,8 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
AP-staging = {
|
AP-staging = {
|
||||||
enable = true;
|
|
||||||
poe = true;
|
poe = true;
|
||||||
ethernet-switching = {
|
ethernet-switching = {
|
||||||
enable = true;
|
|
||||||
interface-mode = "access";
|
interface-mode = "access";
|
||||||
vlans = [ "ap-staging" ];
|
vlans = [ "ap-staging" ];
|
||||||
};
|
};
|
||||||
|
@ -40,7 +37,7 @@ in
|
||||||
{
|
{
|
||||||
netcore02 = {
|
netcore02 = {
|
||||||
deployment.targetHost = "netcore02.dgn";
|
deployment.targetHost = "netcore02.dgn";
|
||||||
imports = [ ./dgn-module.nix ];
|
imports = [ ./ex2300.nix ];
|
||||||
vlans = vlansPlan;
|
vlans = vlansPlan;
|
||||||
dgn-interfaces = {
|
dgn-interfaces = {
|
||||||
# "ge-0/0/0" = AP-staging;
|
# "ge-0/0/0" = AP-staging;
|
||||||
|
@ -62,88 +59,54 @@ in
|
||||||
# "ge-0/0/16" = AP-staging;
|
# "ge-0/0/16" = AP-staging;
|
||||||
# "ge-0/0/17" = AP-staging;
|
# "ge-0/0/17" = AP-staging;
|
||||||
|
|
||||||
"ge-0/0/42" = {
|
# oob
|
||||||
enable = true;
|
"ge-0/0/42".ethernet-switching = {
|
||||||
ethernet-switching = {
|
interface-mode = "trunk";
|
||||||
enable = true;
|
vlans = [ "all" ];
|
||||||
interface-mode = "trunk";
|
|
||||||
vlans = [ "all" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
# AP de test
|
||||||
"ge-0/0/43" = AP-staging;
|
"ge-0/0/43" = AP-staging;
|
||||||
"ge-0/0/46" = {
|
# uplink oob
|
||||||
# uplink oob
|
"ge-0/0/46".ethernet-switching = {
|
||||||
enable = true;
|
interface-mode = "access";
|
||||||
ethernet-switching = {
|
vlans = [ 500 ];
|
||||||
enable = true;
|
|
||||||
interface-mode = "access";
|
|
||||||
vlans = [ 500 ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
"ge-0/0/47" = {
|
# ilo
|
||||||
# ilo
|
"ge-0/0/47".ethernet-switching = {
|
||||||
enable = true;
|
interface-mode = "access";
|
||||||
ethernet-switching = {
|
vlans = [ "admin-core" ];
|
||||||
enable = true;
|
|
||||||
interface-mode = "access";
|
|
||||||
vlans = [ "admin-core" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
"xe-0/1/0" = {
|
# router
|
||||||
# router
|
"xe-0/1/0".ethernet-switching = {
|
||||||
enable = true;
|
interface-mode = "trunk";
|
||||||
ethernet-switching = {
|
vlans = [ "all" ];
|
||||||
enable = true;
|
|
||||||
interface-mode = "trunk";
|
|
||||||
vlans = [ "all" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
"xe-0/1/1" = {
|
# netaccess01
|
||||||
# netaccess01
|
"xe-0/1/1".ethernet-switching = {
|
||||||
enable = true;
|
interface-mode = "trunk";
|
||||||
ethernet-switching = {
|
vlans = [
|
||||||
enable = true;
|
"users"
|
||||||
interface-mode = "trunk";
|
"ap-staging"
|
||||||
vlans = [
|
"admin-ap"
|
||||||
"users"
|
"admin-core"
|
||||||
"ap-staging"
|
];
|
||||||
"admin-ap"
|
|
||||||
"admin-core"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
"ge-0/1/3" = {
|
# uplink
|
||||||
# uplink
|
"ge-0/1/3".ethernet-switching = {
|
||||||
enable = true;
|
interface-mode = "trunk";
|
||||||
ethernet-switching = {
|
vlans = [ "uplink-cri" ];
|
||||||
enable = true;
|
|
||||||
interface-mode = "trunk";
|
|
||||||
vlans = [ "uplink-cri" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
"me0" = {
|
# management
|
||||||
enable = true;
|
"me0".inet.addresses = [ "192.168.42.6/24" ];
|
||||||
inet = {
|
"irb".inet6.addresses = [ "fd26:baf9:d250:8000::1001/64" ];
|
||||||
enable = true;
|
|
||||||
address = [ "192.168.42.6/24" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
"irb" = {
|
|
||||||
enable = true;
|
|
||||||
inet6 = {
|
|
||||||
enable = true;
|
|
||||||
address = [ "fd26:baf9:d250:8000::1001/64" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
netaccess01 = {
|
netaccess01 = {
|
||||||
deployment.targetHost = "netaccess01.dgn";
|
deployment.targetHost = "netaccess01.dgn";
|
||||||
|
|
||||||
imports = [ ./dgn-module.nix ];
|
imports = [ ./ex2300.nix ];
|
||||||
vlans = vlansPlan;
|
vlans = vlansPlan;
|
||||||
|
|
||||||
dgn-interfaces = {
|
dgn-interfaces = {
|
||||||
|
@ -154,30 +117,15 @@ in
|
||||||
# "ge-0/0/4" = AP-staging;
|
# "ge-0/0/4" = AP-staging;
|
||||||
# "ge-0/0/5" = AP-staging;
|
# "ge-0/0/5" = AP-staging;
|
||||||
|
|
||||||
"xe-0/1/0" = {
|
# netcore02
|
||||||
enable = true;
|
"xe-0/1/0".ethernet-switching = {
|
||||||
ethernet-switching = {
|
interface-mode = "trunk";
|
||||||
enable = true;
|
vlans = [ "all" ];
|
||||||
interface-mode = "trunk";
|
|
||||||
vlans = [ "all" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
"me0" = {
|
# management
|
||||||
enable = true;
|
"me0".inet.addresses = [ "192.168.42.6/24" ];
|
||||||
inet = {
|
"irb".inet6.addresses = [ "fd26:baf9:d250:8000::2001/64" ];
|
||||||
enable = true;
|
|
||||||
address = [ "192.168.42.6/24" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
"irb" = {
|
|
||||||
enable = true;
|
|
||||||
inet6 = {
|
|
||||||
enable = true;
|
|
||||||
address = [ "fd26:baf9:d250:8000::2001/64" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue