services: Add openvswitch-service-type.
* gnu/services/networking.scm (<openvswitch-configuration>): New record type. (openvswitch-activation, openvswitch-shepherd-service): New procedures. (openvswitch-service-type): New variable. * doc/guix.texi (Networking Services): Document it.
This commit is contained in:
parent
92ac2cff82
commit
c32d02fe7e
2 changed files with 80 additions and 1 deletions
|
@ -9264,6 +9264,23 @@ Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
|
||||||
sockets.
|
sockets.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@deffn {Scheme Variable} openvswitch-service-type
|
||||||
|
This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
|
||||||
|
service, whose value should be an @code{openvswitch-configuration}
|
||||||
|
object.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
|
@deftp {Data Type} openvswitch-configuration
|
||||||
|
Data type representing the configuration of Open vSwitch, a multilayer
|
||||||
|
virtual switch which is designed to enable massive network automation
|
||||||
|
through programmatic extension.
|
||||||
|
|
||||||
|
@table @asis
|
||||||
|
@item @code{package} (default: @var{openvswitch})
|
||||||
|
Package object of the Open vSwitch.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
@end deftp
|
||||||
|
|
||||||
@node X Window
|
@node X Window
|
||||||
@subsubsection X Window
|
@subsubsection X Window
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#:use-module (gnu packages linux)
|
#:use-module (gnu packages linux)
|
||||||
#:use-module (gnu packages tor)
|
#:use-module (gnu packages tor)
|
||||||
#:use-module (gnu packages messaging)
|
#:use-module (gnu packages messaging)
|
||||||
|
#:use-module (gnu packages networking)
|
||||||
#:use-module (gnu packages ntp)
|
#:use-module (gnu packages ntp)
|
||||||
#:use-module (gnu packages wicd)
|
#:use-module (gnu packages wicd)
|
||||||
#:use-module (gnu packages gnome)
|
#:use-module (gnu packages gnome)
|
||||||
|
@ -80,7 +81,10 @@
|
||||||
network-manager-service-type
|
network-manager-service-type
|
||||||
|
|
||||||
connman-service
|
connman-service
|
||||||
wpa-supplicant-service-type))
|
wpa-supplicant-service-type
|
||||||
|
|
||||||
|
openvswitch-service-type
|
||||||
|
openvswitch-configuration))
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
|
@ -885,4 +889,62 @@ configure networking."
|
||||||
(service-extension dbus-root-service-type list)
|
(service-extension dbus-root-service-type list)
|
||||||
(service-extension profile-service-type list)))))
|
(service-extension profile-service-type list)))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Open vSwitch
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define-record-type* <openvswitch-configuration>
|
||||||
|
openvswitch-configuration make-openvswitch-configuration
|
||||||
|
openvswitch-configuration?
|
||||||
|
(package openvswitch-configuration-package
|
||||||
|
(default openvswitch)))
|
||||||
|
|
||||||
|
(define openvswitch-activation
|
||||||
|
(match-lambda
|
||||||
|
(($ <openvswitch-configuration> package)
|
||||||
|
(let ((ovsdb-tool (file-append package "/bin/ovsdb-tool")))
|
||||||
|
(with-imported-modules '((guix build utils))
|
||||||
|
#~(begin
|
||||||
|
(use-modules (guix build utils))
|
||||||
|
(mkdir-p "/var/run/openvswitch")
|
||||||
|
(mkdir-p "/var/lib/openvswitch")
|
||||||
|
(let ((conf.db "/var/lib/openvswitch/conf.db"))
|
||||||
|
(unless (file-exists? conf.db)
|
||||||
|
(system* #$ovsdb-tool "create" conf.db)))))))))
|
||||||
|
|
||||||
|
(define openvswitch-shepherd-service
|
||||||
|
(match-lambda
|
||||||
|
(($ <openvswitch-configuration> package)
|
||||||
|
(let ((ovsdb-server (file-append package "/sbin/ovsdb-server"))
|
||||||
|
(ovs-vswitchd (file-append package "/sbin/ovs-vswitchd")))
|
||||||
|
(list
|
||||||
|
(shepherd-service
|
||||||
|
(provision '(ovsdb))
|
||||||
|
(documentation "Run the Open vSwitch database server.")
|
||||||
|
(start #~(make-forkexec-constructor
|
||||||
|
(list #$ovsdb-server "--pidfile"
|
||||||
|
"--remote=punix:/var/run/openvswitch/db.sock")
|
||||||
|
#:pid-file "/var/run/openvswitch/ovsdb-server.pid"))
|
||||||
|
(stop #~(make-kill-destructor)))
|
||||||
|
(shepherd-service
|
||||||
|
(provision '(vswitchd))
|
||||||
|
(requirement '(ovsdb))
|
||||||
|
(documentation "Run the Open vSwitch daemon.")
|
||||||
|
(start #~(make-forkexec-constructor
|
||||||
|
(list #$ovs-vswitchd "--pidfile")
|
||||||
|
#:pid-file "/var/run/openvswitch/ovs-vswitchd.pid"))
|
||||||
|
(stop #~(make-kill-destructor))))))))
|
||||||
|
|
||||||
|
(define openvswitch-service-type
|
||||||
|
(service-type
|
||||||
|
(name 'openvswitch)
|
||||||
|
(extensions
|
||||||
|
(list (service-extension activation-service-type
|
||||||
|
openvswitch-activation)
|
||||||
|
(service-extension profile-service-type
|
||||||
|
(compose list openvswitch-configuration-package))
|
||||||
|
(service-extension shepherd-root-service-type
|
||||||
|
openvswitch-shepherd-service)))))
|
||||||
|
|
||||||
;;; networking.scm ends here
|
;;; networking.scm ends here
|
||||||
|
|
Reference in a new issue