1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-19 04:02:10 +00:00

nixos/incus: add openvswitch support

1. Added openvswitch integration to incus service.
2. Added tests to test openvswitch functionality with incus.
This commit is contained in:
cmspam 2024-03-10 23:48:22 +09:00
parent 80226b1d65
commit 701fcd7982
3 changed files with 75 additions and 4 deletions

View file

@ -164,19 +164,24 @@ in
"network-online.target"
"lxcfs.service"
"incus.socket"
];
]
++ lib.optional config.virtualisation.vswitch.enable "ovs-vswitchd.service";
requires = [
"lxcfs.service"
"incus.socket"
];
]
++ lib.optional config.virtualisation.vswitch.enable "ovs-vswitchd.service";
wants = [
"network-online.target"
];
path = lib.mkIf config.boot.zfs.enabled [
path = lib.optional config.boot.zfs.enabled [
config.boot.zfs.package
"${config.boot.zfs.package}/lib/udev"
];
]
++ lib.optional config.virtualisation.vswitch.enable config.virtualisation.vswitch.package;
environment = lib.mkMerge [ {
# Override Path to the LXC template configuration directory

View file

@ -11,6 +11,7 @@
boot.initrd.systemd.enable = true;
}; };
lxd-to-incus = import ./lxd-to-incus.nix { inherit system pkgs; };
openvswitch = import ./openvswitch.nix { inherit system pkgs; };
preseed = import ./preseed.nix { inherit system pkgs; };
socket-activated = import ./socket-activated.nix { inherit system pkgs; };
ui = import ./ui.nix {inherit system pkgs;};

View file

@ -0,0 +1,65 @@
import ../make-test-python.nix ({ pkgs, lib, ... } :
{
name = "incus-openvswitch";
meta = {
maintainers = lib.teams.lxc.members;
};
nodes.machine = { lib, ... }: {
virtualisation = {
incus.enable = true;
vswitch.enable = true;
incus.preseed = {
networks = [
{
name = "nixostestbr0";
type = "bridge";
config = {
"bridge.driver" = "openvswitch";
"ipv4.address" = "10.0.100.1/24";
"ipv4.nat" = "true";
};
}
];
profiles = [
{
name = "nixostest_default";
devices = {
eth0 = {
name = "eth0";
network = "nixostestbr0";
type = "nic";
};
root = {
path = "/";
pool = "default";
size = "35GiB";
type = "disk";
};
};
}
];
storage_pools = [
{
name = "nixostest_pool";
driver = "dir";
}
];
};
};
networking.nftables.enable = true;
};
testScript = ''
machine.wait_for_unit("incus.service")
machine.wait_for_unit("incus-preseed.service")
with subtest("Verify openvswitch bridge"):
machine.succeed("incus network info nixostestbr0")
with subtest("Verify openvswitch bridge"):
machine.succeed("ovs-vsctl br-exists nixostestbr0")
'';
})