pkgs/network-graphs: add up* to physical-graph

This commit is contained in:
Astro 2021-11-07 03:21:39 +01:00
parent f0c5f1d398
commit 733f04258d
2 changed files with 16 additions and 10 deletions

View File

@ -7,13 +7,10 @@ let
then "grey" then "grey"
else if net == "mgmt" else if net == "mgmt"
then "brown" then "brown"
else if net == "c3d2" else if builtins.elem net [ "c3d2" "serv" "cluster" ]
then "orange"
else if net == "serv"
then "orange2"
else if net == "pub"
then "green" then "green"
else if builtins.match "up.+" net != null else if builtins.match "up.+" net != null ||
builtins.match "anon.+" net != null
then "red" then "red"
else if builtins.match "priv.+" net != null else if builtins.match "priv.+" net != null
then "blue" then "blue"
@ -108,16 +105,25 @@ in rec {
lib.filterAttrs (_: { links, ... }: lib.filterAttrs (_: { links, ... }:
links != {} links != {}
) config.site.hosts ) config.site.hosts
) // builtins.mapAttrs (_: _: {
shape = "circle";
}) (
lib.filterAttrs (net: _:
builtins.match "up.*" net != null
) config.site.net
); );
links = links =
builtins.concatMap (hostName: builtins.concatMap (hostName:
map (link: { map (link: {
pair = [ hostName link ]; pair = [ hostName link ];
startLabel = lib.concatStringsSep "," startLabel = ( #lib.optionalString (config.site.hosts.${hostName}.links ? ${link}) (
config.site.hosts.${hostName}.links.${link}.ports; lib.concatStringsSep ","
config.site.hosts.${hostName}.links.${link}.ports
);
}) ( }) (
builtins.filter (link: builtins.filter (link:
config.site.hosts ? ${link} config.site.hosts ? ${link} ||
builtins.trace "link ${hostName} ${link}" (builtins.match "up.*" link != null)
) (builtins.attrNames config.site.hosts.${hostName}.links) ) (builtins.attrNames config.site.hosts.${hostName}.links)
) )
) (builtins.attrNames config.site.hosts); ) (builtins.attrNames config.site.hosts);

View File

@ -12,7 +12,7 @@ vlans:
cluster: 6 cluster: 6
bmx: 7 bmx: 7
# Modems # Modems
{%- for i in range(1, 9) %} {%- for i in range(1, 5) %}
up{{ i }}: {{ i + 9 }} up{{ i }}: {{ i + 9 }}
{%- endfor %} {%- endfor %}
# Neighbor subnets # Neighbor subnets