networking module: vswitches: re-structure dependencies to systemd units

This commit is contained in:
Thomas Strobel 2015-10-05 13:23:58 +02:00
parent 7a8980193d
commit 881ec1efb8
2 changed files with 6 additions and 22 deletions

View File

@ -222,21 +222,15 @@ in
createVswitchDevice = n: v: nameValuePair "${n}-netdev" createVswitchDevice = n: v: nameValuePair "${n}-netdev"
(let (let
managedInterfaces = filter (x: hasAttr x cfg.interfaces) v.interfaces;
managedInterfaceServices = concatMap (i: [ "network-addresses-${i}.service" "network-link-${i}.service" ]) managedInterfaces;
virtualInterfaces = filter (x: (hasAttr x cfg.interfaces) && cfg.interfaces.${x}.virtual) v.interfaces;
virtualInterfaceServices = concatMap (i: [ "${i}-netdev.service" ]) virtualInterfaces;
deps = map subsystemDevice v.interfaces; deps = map subsystemDevice v.interfaces;
ofRules = pkgs.writeText "vswitch-${n}-openFlowRules" v.openFlowRules; ofRules = pkgs.writeText "vswitch-${n}-openFlowRules" v.openFlowRules;
in in
{ description = "Open vSwitch Interface ${n}"; { description = "Open vSwitch Interface ${n}";
wantedBy = [ "network.target" "vswitchd.service" (subsystemDevice n) ]; wantedBy = [ "network.target" "vswitchd.service" ] ++ deps;
requires = optionals v.bindInterfaces (deps ++ managedInterfaceServices ++ virtualInterfaceServices); bindsTo = [ "vswitchd.service" (subsystemDevice n) ] ++ deps;
requiredBy = optionals v.bindInterfaces (managedInterfaceServices ++ virtualInterfaceServices);
bindsTo = deps ++ [ "vswitchd.service" ];
partOf = [ "vswitchd.service" ]; partOf = [ "vswitchd.service" ];
after = [ "network-pre.target" "vswitchd.service" ] ++ deps ++ managedInterfaceServices ++ virtualInterfaceServices; after = [ "network-pre.target" "vswitchd.service" ] ++ deps;
before = [ "network-interfaces.target" (subsystemDevice n) ]; before = [ "network-interfaces.target" ];
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true; serviceConfig.RemainAfterExit = true;
path = [ pkgs.iproute config.virtualisation.vswitch.package ]; path = [ pkgs.iproute config.virtualisation.vswitch.package ];

View File

@ -381,8 +381,8 @@ in
description = description =
'' ''
This option allows you to define Open vSwitches that connect This option allows you to define Open vSwitches that connect
physical networks together. The value of this option is an physical networks together. The value of this option is an
attribute set. Each attribute specifies a vswitch, with the attribute set. Each attribute specifies a vswitch, with the
attribute name specifying the name of the vswitch's network attribute name specifying the name of the vswitch's network
interface. interface.
''; '';
@ -398,16 +398,6 @@ in
"The physical network interfaces connected by the vSwitch."; "The physical network interfaces connected by the vSwitch.";
}; };
bindInterfaces = mkOption {
type = types.bool;
default = false;
description = ''
If true, then the interfaces of the vSwitch are brought 'up' and especially
also 'down' together with the vSwitch. That requires that every interfaces
is configured as a systemd network services.
'';
};
controllers = mkOption { controllers = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];