Thursday, October 13, 2016

Running FAUCET as a systemd controlled service in Ubuntu 16

Ubuntu 16 pushes us towards systemd ( to manage services. In a recent installation I used this process to have FAUCET run as a service and have it automatically start on boot. 

There's more than one way to do this (in particular, you can systemd to directly start FAUCET as the correct user, rather than via sudo). We're also working on making this easier.

1. Create a user to run FAUCET as. On my system, I created a user "faucet". 

# useradd faucet

2. Install FAUCET itself. You have a few choices - here are two (pip is the easiest; the git clone will get you the latest development version).
  • pip
# pip install ryu-faucet
  • git
# cd /home/faucet/
# git clone

3. Identify the root of the FAUCET installation is in your installation. 

# find / -name

In my case, it's /home/faucet/faucet

4. Create a file,/etc/default/faucet,  containing the following. Substitute in the correct values for your FAUCET installation path, and where you want your config files and logs. Don't forget that the log files will need to be writable by the faucet user, so make sure there's a directory faucet can write to.

# path to Ryu manager (likely local)
# user to run FAUCET as (must already exist)
# directory containing FAUCET application code
# file containing Gauge's custom ryu.conf
# host address FAUCET controller should listen on for OpenFlow switch
# TCP port FAUCET controller should listen on for OpenFlow switch
# location of FAUCET's configuration file.
# where FAUCET should log to (directory must exist and be writable by FAUCET_USER)
# where FAUCET should log exceptions to (directory must exist as above)

5. Create another file, /home/faucet/, that will start FAUCET (and don't forget to make it executable):

sudo -E -u $FAUCET_USER $RYU_MANAGER --config-file=$FAUCET_RYU_CONF --ofp-listen-host=$FAUCET_LISTEN_HOST --ofp-tcp-listen-port=$FAUCET_LISTEN_PORT $FAUCET_APP_DIR/

6. Create the last file, /etc/systemd/system/faucet.service that defines the FAUCET service:

description="FAUCET OpenFlow switch controller"



7. Enable the systemd-networkd-wait-online.service service. This has systemd wait for the network to come up, before trying to start FAUCET:

# systemctl enable systemd-networkd-wait-online.service

8. Enable the FAUCET service you just created:

# systemctl enable faucet

9. Start FAUCET and view its status:

# systemctl start faucet
# systemctl status faucet

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.