formatting/retab

This commit is contained in:
Chris Farmiloe 2014-06-12 16:08:49 +02:00 committed by Michael Raskin
parent 8ef11bb0ee
commit 76a4de68c1
2 changed files with 138 additions and 140 deletions

View file

@ -5,116 +5,113 @@
with lib; with lib;
let let
cfg = config.virtualisation.vswitch; cfg = config.virtualisation.vswitch;
in in
{ {
# ------------------------------------------------------------
options = { options = {
virtualisation.vswitch.enable = mkOption { virtualisation.vswitch.enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = description =
'' ''
Enable Open vSwitch. A configuration Enable Open vSwitch. A configuration
daemon (ovs-server) will be started. daemon (ovs-server) will be started.
''; '';
}; };
virtualisation.vswitch.package = mkOption { virtualisation.vswitch.package = mkOption {
type = types.package; type = types.package;
default = pkgs.openvswitch; default = pkgs.openvswitch;
description = description =
'' ''
Open vSwitch package to use. Open vSwitch package to use.
''; '';
}; };
};
config = mkIf cfg.enable (let
# Where the communication sockets live
runDir = "/var/run/openvswitch";
# Where the config database live (can't be in nix-store)
stateDir = "/var/db/openvswitch";
# The path to the an initialized version of the database
db = pkgs.stdenv.mkDerivation {
name = "vswitch.db";
unpackPhase = "true";
buildPhase = "true";
buildInputs = with pkgs; [
cfg.package
];
installPhase =
''
ensureDir $out/
'';
};
in {
environment.systemPackages = [ cfg.package ];
boot.kernelModules = [ "tun" "openvswitch" ];
boot.extraModulePackages = [ cfg.package ];
systemd.services.ovsdb = {
description = "Open_vSwitch Database Server";
wantedBy = [ "multi-user.target" ];
after = [ "systemd-udev-settle.service" ];
wants = [ "vswitchd.service" ];
path = [ cfg.package ];
restartTriggers = [ db cfg.package ];
# Create the config database
preStart =
''
mkdir -p ${runDir}
mkdir -p /var/db/openvswitch
chmod +w /var/db/openvswitch
if [[ ! -e /var/db/openvswitch/conf.db ]]; then
${cfg.package}/bin/ovsdb-tool create \
"/var/db/openvswitch/conf.db" \
"${cfg.package}/share/openvswitch/vswitch.ovsschema"
fi
chmod -R +w /var/db/openvswitch
'';
serviceConfig.ExecStart =
''
${cfg.package}/bin/ovsdb-server \
--remote=punix:${runDir}/db.sock \
--private-key=db:Open_vSwitch,SSL,private_key \
--certificate=db:Open_vSwitch,SSL,certificate \
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
--unixctl=ovsdb.ctl.sock \
/var/db/openvswitch/conf.db
'';
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 3;
postStart =
''
${cfg.package}/bin/ovs-vsctl --timeout 3 --retry --no-wait init
'';
}; };
# ------------------------------------------------------------ systemd.services.vswitchd = {
description = "Open_vSwitch Daemon";
bindsTo = [ "ovsdb.service" ];
after = [ "ovsdb.service" ];
path = [ cfg.package ];
serviceConfig.ExecStart = ''${cfg.package}/bin/ovs-vswitchd'';
};
config = mkIf cfg.enable (let });
# Where the communication sockets live
runDir = "/var/run/openvswitch";
# Where the config database live (can't be in nix-store)
stateDir = "/var/db/openvswitch";
# The path to the an initialized version of the database
db = pkgs.stdenv.mkDerivation {
name = "vswitch.db";
unpackPhase = "true";
buildPhase = "true";
buildInputs = with pkgs; [
cfg.package
];
installPhase =
''
ensureDir $out/
'';
};
in {
environment.systemPackages = [ cfg.package ];
boot.kernelModules = [ "tun" "openvswitch" ];
boot.extraModulePackages = [ cfg.package ];
systemd.services.ovsdb = {
description = "Open_vSwitch Database Server";
wantedBy = [ "multi-user.target" ];
after = [ "systemd-udev-settle.service" ];
wants = [ "vswitchd.service" ];
path = [ cfg.package ];
restartTriggers = [ db cfg.package ];
# Create the config database
preStart =
''
mkdir -p ${runDir}
mkdir -p /var/db/openvswitch
chmod +w /var/db/openvswitch
if [[ ! -e /var/db/openvswitch/conf.db ]]; then
${cfg.package}/bin/ovsdb-tool create \
"/var/db/openvswitch/conf.db" \
"${cfg.package}/share/openvswitch/vswitch.ovsschema"
fi
chmod -R +w /var/db/openvswitch
'';
serviceConfig.ExecStart =
''
${cfg.package}/bin/ovsdb-server \
--remote=punix:${runDir}/db.sock \
--private-key=db:Open_vSwitch,SSL,private_key \
--certificate=db:Open_vSwitch,SSL,certificate \
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
--unixctl=ovsdb.ctl.sock \
/var/db/openvswitch/conf.db
'';
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 3;
postStart =
''
${cfg.package}/bin/ovs-vsctl --timeout 3 --retry --no-wait init
'';
};
systemd.services.vswitchd = {
description = "Open_vSwitch Daemon";
bindsTo = [ "ovsdb.service" ];
after = [ "ovsdb.service" ];
path = [ cfg.package ];
serviceConfig.ExecStart = ''${cfg.package}/bin/ovs-vswitchd'';
};
});
} }

View file

@ -1,49 +1,50 @@
{ stdenv, fetchurl, openssl, python27, iproute, perl510, kernel ? null}: { stdenv, fetchurl, openssl, python27, iproute, perl510, kernel ? null}:
let let
version = "2.1.2"; version = "2.1.2";
skipKernelMod = kernel == null; skipKernelMod = kernel == null;
in in
stdenv.mkDerivation { stdenv.mkDerivation {
version = "2.1.2"; version = "2.1.2";
name = "openvswitch-${version}"; name = "openvswitch-${version}";
src = fetchurl { src = fetchurl {
url = "http://openvswitch.org/releases/openvswitch-2.1.2.tar.gz"; url = "http://openvswitch.org/releases/openvswitch-2.1.2.tar.gz";
sha256 = "16q7faqrj2pfchhn0x5s9ggi5ckcg9n62f6bnqaih064aaq2jm47"; sha256 = "16q7faqrj2pfchhn0x5s9ggi5ckcg9n62f6bnqaih064aaq2jm47";
}; };
kernel = if skipKernelMod then null else kernel.dev; kernel = if skipKernelMod then null else kernel.dev;
buildInputs = [ buildInputs = [
openssl openssl
python27 python27
perl510 perl510
]; ];
configureFlags = [ configureFlags = [
"--localstatedir=/var" "--localstatedir=/var"
"--sharedstatedir=/var" "--sharedstatedir=/var"
"--sbindir=$(out)/bin" "--sbindir=$(out)/bin"
] ++ (if skipKernelMod then [] else ["--with-linux"]); ] ++ (if skipKernelMod then [] else ["--with-linux"]);
# Leave /var out of this! # Leave /var out of this!
installFlags = [ installFlags = [
"LOGDIR=$(TMPDIR)/dummy" "LOGDIR=$(TMPDIR)/dummy"
"RUNDIR=$(TMPDIR)/dummy" "RUNDIR=$(TMPDIR)/dummy"
"PKIDIR=$(TMPDIR)/dummy" "PKIDIR=$(TMPDIR)/dummy"
]; ];
meta = { meta = {
platforms = stdenv.lib.platforms.linux; platforms = stdenv.lib.platforms.linux;
description = "A multilayer virtual switch"; description = "A multilayer virtual switch";
longDescription = '' longDescription =
Open vSwitch is a production quality, multilayer virtual switch ''
licensed under the open source Apache 2.0 license. It is Open vSwitch is a production quality, multilayer virtual switch
designed to enable massive network automation through licensed under the open source Apache 2.0 license. It is
programmatic extension, while still supporting standard designed to enable massive network automation through
management interfaces and protocols (e.g. NetFlow, sFlow, SPAN, programmatic extension, while still supporting standard
RSPAN, CLI, LACP, 802.1ag). In addition, it is designed to management interfaces and protocols (e.g. NetFlow, sFlow, SPAN,
support distribution across multiple physical servers similar RSPAN, CLI, LACP, 802.1ag). In addition, it is designed to
to VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V. support distribution across multiple physical servers similar
''; to VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V.
homepage = "http://openvswitch.org/"; '';
licence = "Apache 2.0"; homepage = "http://openvswitch.org/";
}; licence = "Apache 2.0";
};
} }