mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-09-29 15:43:00 +00:00
nixos/tests/systemd-networkd-vrf: clean up
* Removed unused variables * Deduplicate config for `node{1..3}`
This commit is contained in:
parent
8ccfd7a659
commit
501d0a65d4
@ -1,5 +1,26 @@
|
|||||||
import ./make-test-python.nix ({ pkgs, lib, ... }: let
|
import ./make-test-python.nix ({ pkgs, lib, ... }: let
|
||||||
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
|
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
|
||||||
|
|
||||||
|
mkNode = vlan: id: {
|
||||||
|
virtualisation.vlans = [ vlan ];
|
||||||
|
networking = {
|
||||||
|
useDHCP = false;
|
||||||
|
useNetworkd = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.network = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
networks."10-eth${toString vlan}" = {
|
||||||
|
matchConfig.Name = "eth${toString vlan}";
|
||||||
|
linkConfig.RequiredForOnline = "no";
|
||||||
|
networkConfig = {
|
||||||
|
Address = "192.168.${toString vlan}.${toString id}/24";
|
||||||
|
IPForward = "yes";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
name = "systemd-networkd-vrf";
|
name = "systemd-networkd-vrf";
|
||||||
meta.maintainers = with lib.maintainers; [ ma27 ];
|
meta.maintainers = with lib.maintainers; [ ma27 ];
|
||||||
@ -70,71 +91,16 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
node1 = { pkgs, ... }: {
|
node1 = lib.mkMerge [
|
||||||
virtualisation.vlans = [ 1 ];
|
(mkNode 1 2)
|
||||||
networking = {
|
{
|
||||||
useDHCP = false;
|
services.openssh.enable = true;
|
||||||
useNetworkd = true;
|
users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
|
||||||
};
|
}
|
||||||
|
];
|
||||||
|
|
||||||
services.openssh.enable = true;
|
node2 = mkNode 2 3;
|
||||||
users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
|
node3 = mkNode 2 4;
|
||||||
|
|
||||||
systemd.network = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
networks."10-eth1" = {
|
|
||||||
matchConfig.Name = "eth1";
|
|
||||||
linkConfig.RequiredForOnline = "no";
|
|
||||||
networkConfig = {
|
|
||||||
Address = "192.168.1.2/24";
|
|
||||||
IPForward = "yes";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
node2 = { pkgs, ... }: {
|
|
||||||
virtualisation.vlans = [ 2 ];
|
|
||||||
networking = {
|
|
||||||
useDHCP = false;
|
|
||||||
useNetworkd = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.network = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
networks."10-eth2" = {
|
|
||||||
matchConfig.Name = "eth2";
|
|
||||||
linkConfig.RequiredForOnline = "no";
|
|
||||||
networkConfig = {
|
|
||||||
Address = "192.168.2.3/24";
|
|
||||||
IPForward = "yes";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
node3 = { pkgs, ... }: {
|
|
||||||
virtualisation.vlans = [ 2 ];
|
|
||||||
networking = {
|
|
||||||
useDHCP = false;
|
|
||||||
useNetworkd = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.network = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
networks."10-eth2" = {
|
|
||||||
matchConfig.Name = "eth2";
|
|
||||||
linkConfig.RequiredForOnline = "no";
|
|
||||||
networkConfig = {
|
|
||||||
Address = "192.168.2.4/24";
|
|
||||||
IPForward = "yes";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
@ -159,22 +125,6 @@ in {
|
|||||||
node2.wait_for_unit("network.target")
|
node2.wait_for_unit("network.target")
|
||||||
node3.wait_for_unit("network.target")
|
node3.wait_for_unit("network.target")
|
||||||
|
|
||||||
client_ipv4_table = """
|
|
||||||
192.168.1.2 dev vrf1 proto static metric 100\x20
|
|
||||||
192.168.2.3 dev vrf2 proto static metric 100
|
|
||||||
""".strip()
|
|
||||||
vrf1_table = """
|
|
||||||
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.1\x20
|
|
||||||
local 192.168.1.1 dev eth1 proto kernel scope host src 192.168.1.1\x20
|
|
||||||
broadcast 192.168.1.255 dev eth1 proto kernel scope link src 192.168.1.1
|
|
||||||
""".strip()
|
|
||||||
vrf2_table = """
|
|
||||||
192.168.2.0/24 dev eth2 proto kernel scope link src 192.168.2.1\x20
|
|
||||||
local 192.168.2.1 dev eth2 proto kernel scope host src 192.168.2.1\x20
|
|
||||||
broadcast 192.168.2.255 dev eth2 proto kernel scope link src 192.168.2.1
|
|
||||||
""".strip()
|
|
||||||
# editorconfig-checker-enable
|
|
||||||
|
|
||||||
# Check that networkd properly configures the main routing table
|
# Check that networkd properly configures the main routing table
|
||||||
# and the routing tables for the VRF.
|
# and the routing tables for the VRF.
|
||||||
with subtest("check vrf routing tables"):
|
with subtest("check vrf routing tables"):
|
||||||
|
Loading…
Reference in New Issue
Block a user