Statistics
| Branch: | Tag: | Revision:

root / doc / build / html / _sources / install.txt @ 6de88ee1

History | View | Annotate | Download (19.6 kB)

1 6de88ee1 Stauros Kroustouris
************
2 6de88ee1 Stauros Kroustouris
Installation
3 6de88ee1 Stauros Kroustouris
************
4 6de88ee1 Stauros Kroustouris
5 6de88ee1 Stauros Kroustouris
.. toctree::
6 6de88ee1 Stauros Kroustouris
    :maxdepth: 2
7 6de88ee1 Stauros Kroustouris
8 6de88ee1 Stauros Kroustouris
Debian Wheezy (x64) - Django 1.4.x
9 6de88ee1 Stauros Kroustouris
==================================
10 6de88ee1 Stauros Kroustouris
This guide assumes that installation is carried out in /srv/flowspy directory. If other directory is to be used, please change the corresponding configuration files. It is also assumed that the root user will perform every action.
11 6de88ee1 Stauros Kroustouris
12 6de88ee1 Stauros Kroustouris
13 6de88ee1 Stauros Kroustouris
Upgrading from v<1.1.x
14 6de88ee1 Stauros Kroustouris
----------------------
15 6de88ee1 Stauros Kroustouris
16 6de88ee1 Stauros Kroustouris
.. note::
17 6de88ee1 Stauros Kroustouris
    If PEER\_\*\_TABLE tables are set to FALSE in settings.py, you need to perform the south migrations per application:: 
18 6de88ee1 Stauros Kroustouris
    
19 6de88ee1 Stauros Kroustouris
        ./manage.py migrate longerusername
20 6de88ee1 Stauros Kroustouris
        ./manage.py migrate flowspec
21 6de88ee1 Stauros Kroustouris
        ./manage.py migrate accounts
22 6de88ee1 Stauros Kroustouris
        
23 6de88ee1 Stauros Kroustouris
        
24 6de88ee1 Stauros Kroustouris
25 6de88ee1 Stauros Kroustouris
If upgrading from flowspy version <1.1.x pay attention to settings.py changes. Also, do not forget to run if PEER\_\*\_TABLE tables are set to TRUE in settings.py::
26 6de88ee1 Stauros Kroustouris
    
27 6de88ee1 Stauros Kroustouris
    ./manage.py migrate 
28 6de88ee1 Stauros Kroustouris
    
29 6de88ee1 Stauros Kroustouris
to catch-up with latest database changes. 
30 6de88ee1 Stauros Kroustouris
31 6de88ee1 Stauros Kroustouris
Upgrading from v<1.0.x
32 6de88ee1 Stauros Kroustouris
----------------------
33 6de88ee1 Stauros Kroustouris
If upgrading from flowspy version <1.0.x pay attention to settings.py changes. Also, do not forget to run::
34 6de88ee1 Stauros Kroustouris
    
35 6de88ee1 Stauros Kroustouris
    ./manage.py migrate
36 6de88ee1 Stauros Kroustouris
    
37 6de88ee1 Stauros Kroustouris
to catch-up with latest database changes.
38 6de88ee1 Stauros Kroustouris
39 6de88ee1 Stauros Kroustouris
Required system packages
40 6de88ee1 Stauros Kroustouris
------------------------
41 6de88ee1 Stauros Kroustouris
Update and install the required packages::
42 6de88ee1 Stauros Kroustouris
43 6de88ee1 Stauros Kroustouris
    apt-get update
44 6de88ee1 Stauros Kroustouris
    apt-get upgrade
45 6de88ee1 Stauros Kroustouris
    apt-get install mysql-server apache2 memcached libapache2-mod-proxy-html gunicorn beanstalkd python-django python-django-south python-django-tinymce tinymce python-mysqldb python-yaml python-memcache python-django-registration python-ipaddr python-lxml mysql-client git python-django-celery python-paramiko python-gevent vim
46 6de88ee1 Stauros Kroustouris
47 6de88ee1 Stauros Kroustouris
.. note::
48 6de88ee1 Stauros Kroustouris
    Set username and password for mysql if used
49 6de88ee1 Stauros Kroustouris
50 6de88ee1 Stauros Kroustouris
.. note::
51 6de88ee1 Stauros Kroustouris
    If you wish to deploy an outgoing mail server, now it is time to do it. Otherwise you could set FoD to send out mails via a third party account
52 6de88ee1 Stauros Kroustouris
53 6de88ee1 Stauros Kroustouris
Create a database
54 6de88ee1 Stauros Kroustouris
-----------------
55 6de88ee1 Stauros Kroustouris
If you are using mysql, you should create a database::
56 6de88ee1 Stauros Kroustouris
57 6de88ee1 Stauros Kroustouris
    mysql -u root -p -e 'create database fod'
58 6de88ee1 Stauros Kroustouris
59 6de88ee1 Stauros Kroustouris
Required application packages
60 6de88ee1 Stauros Kroustouris
-----------------------------
61 6de88ee1 Stauros Kroustouris
Get the required packages and their dependencies and install them::
62 6de88ee1 Stauros Kroustouris
63 6de88ee1 Stauros Kroustouris
    apt-get install libxml2-dev libxslt-dev gcc python-dev
64 6de88ee1 Stauros Kroustouris
65 6de88ee1 Stauros Kroustouris
- ncclient: NETCONF python client::
66 6de88ee1 Stauros Kroustouris
67 6de88ee1 Stauros Kroustouris
    cd ~
68 6de88ee1 Stauros Kroustouris
    git clone https://github.com/leopoul/ncclient.git
69 6de88ee1 Stauros Kroustouris
    cd ncclient
70 6de88ee1 Stauros Kroustouris
    python setup.py install
71 6de88ee1 Stauros Kroustouris
72 6de88ee1 Stauros Kroustouris
- nxpy: Python Objects from/to XML proxy::
73 6de88ee1 Stauros Kroustouris
74 6de88ee1 Stauros Kroustouris
    cd ~
75 6de88ee1 Stauros Kroustouris
    git clone https://code.grnet.gr/git/nxpy
76 6de88ee1 Stauros Kroustouris
    cd nxpy
77 6de88ee1 Stauros Kroustouris
    python setup.py install
78 6de88ee1 Stauros Kroustouris
79 6de88ee1 Stauros Kroustouris
- flowspy: core application. Installation is done at /srv/flowspy::
80 6de88ee1 Stauros Kroustouris
81 6de88ee1 Stauros Kroustouris
    cd /srv
82 6de88ee1 Stauros Kroustouris
    git clone https://code.grnet.gr/git/flowspy
83 6de88ee1 Stauros Kroustouris
    cd flowspy
84 6de88ee1 Stauros Kroustouris
85 6de88ee1 Stauros Kroustouris
Application configuration
86 6de88ee1 Stauros Kroustouris
=========================
87 6de88ee1 Stauros Kroustouris
Copy settings.py.dist to settings.py::
88 6de88ee1 Stauros Kroustouris
    
89 6de88ee1 Stauros Kroustouris
    cd flowspy
90 6de88ee1 Stauros Kroustouris
    cp settings.py.dist settings.py
91 6de88ee1 Stauros Kroustouris
92 6de88ee1 Stauros Kroustouris
Edit settings.py file and set the following according to your configuration::
93 6de88ee1 Stauros Kroustouris
94 6de88ee1 Stauros Kroustouris
    ADMINS: set your admin name and email (assuming that your server can send notifications)
95 6de88ee1 Stauros Kroustouris
    DATABASES (to point to your local database). You could use views instead of tables for models: peer, peercontacts, peernetworks. For this to work we suggest MySQL with MyISAM db engine
96 6de88ee1 Stauros Kroustouris
    SECRET_KEY : Make this unique, and don't share it with anybody
97 6de88ee1 Stauros Kroustouris
    STATIC_ROOT: /srv/flowspy/static (or your installation directory)
98 6de88ee1 Stauros Kroustouris
    STATIC_URL (static media directory) . If you have followed the above this should be: /srv/flowspy/static
99 6de88ee1 Stauros Kroustouris
    TEMPLATE_DIRS : If you have followed the above this should be: /srv/flowspy/templates
100 6de88ee1 Stauros Kroustouris
    CACHE_BACKEND:  Enable Memcached for production or leave to DummyCache for development environments
101 6de88ee1 Stauros Kroustouris
    Alternatively you could go for redis with the corresponding Django client lib.
102 6de88ee1 Stauros Kroustouris
    NETCONF_DEVICE (tested with Juniper EX4200 but any BGP enabled Juniper should work). This is the flowspec capable device
103 6de88ee1 Stauros Kroustouris
    NETCONF_USER (enable ssh and netconf on device)
104 6de88ee1 Stauros Kroustouris
    NETCONF_PASS
105 6de88ee1 Stauros Kroustouris
    If beanstalk is selected the following should be left intact.
106 6de88ee1 Stauros Kroustouris
    BROKER_HOST (beanstalk host)
107 6de88ee1 Stauros Kroustouris
    BROKER_PORT (beanstalk port)
108 6de88ee1 Stauros Kroustouris
    SERVER_EMAIL
109 6de88ee1 Stauros Kroustouris
    EMAIL_SUBJECT_PREFIX
110 6de88ee1 Stauros Kroustouris
    If beanstalk is selected the following should be left intact.
111 6de88ee1 Stauros Kroustouris
    BROKER_URL (beanstalk url)
112 6de88ee1 Stauros Kroustouris
    SHIB_AUTH_ENTITLEMENT (if you go for Shibboleth authentication)
113 6de88ee1 Stauros Kroustouris
    NOTIFY_ADMIN_MAILS (bcc mail addresses)
114 6de88ee1 Stauros Kroustouris
    PROTECTED_SUBNETS (subnets for which source or destination address will prevent rule creation and notify the NOTIFY_ADMIN_MAILS)
115 6de88ee1 Stauros Kroustouris
    The whois client is meant to be used in case you have inserted peers with their ASes in the peers table and wish to get network info for each one in an automated manner.
116 6de88ee1 Stauros Kroustouris
    PRIMARY_WHOIS
117 6de88ee1 Stauros Kroustouris
    ALTERNATE_WHOIS
118 6de88ee1 Stauros Kroustouris
    If you wish to deploy FoD with Shibboleth change the following attributes according to your setup:
119 6de88ee1 Stauros Kroustouris
    SHIB_AUTH_ENTITLEMENT = 'urn:mace'
120 6de88ee1 Stauros Kroustouris
    SHIB_ADMIN_DOMAIN = 'example.com'
121 6de88ee1 Stauros Kroustouris
    SHIB_LOGOUT_URL = 'https://example.com/Shibboleth.sso/Logout'
122 6de88ee1 Stauros Kroustouris
    SHIB_USERNAME = ['HTTP_EPPN']
123 6de88ee1 Stauros Kroustouris
    SHIB_MAIL = ['mail', 'HTTP_MAIL', 'HTTP_SHIB_INETORGPERSON_MAIL']
124 6de88ee1 Stauros Kroustouris
    SHIB_FIRSTNAME = ['HTTP_SHIB_INETORGPERSON_GIVENNAME']
125 6de88ee1 Stauros Kroustouris
    SHIB_LASTNAME = ['HTTP_SHIB_PERSON_SURNAME']
126 6de88ee1 Stauros Kroustouris
    SHIB_ENTITLEMENT = ['HTTP_SHIB_EP_ENTITLEMENT']
127 6de88ee1 Stauros Kroustouris
128 6de88ee1 Stauros Kroustouris
If you have not installed an outgoing mail server you can always use your own account (either corporate or gmail, hotmail ,etc) by adding the following lines in settings.py::
129 6de88ee1 Stauros Kroustouris
130 6de88ee1 Stauros Kroustouris
    EMAIL_USE_TLS = True #(or False)
131 6de88ee1 Stauros Kroustouris
    EMAIL_HOST = 'smtp.example.com'
132 6de88ee1 Stauros Kroustouris
    EMAIL_HOST_USER = 'username'
133 6de88ee1 Stauros Kroustouris
    EMAIL_HOST_PASSWORD = 'yourpassword'
134 6de88ee1 Stauros Kroustouris
    EMAIL_PORT = 587 #(outgoing)
135 6de88ee1 Stauros Kroustouris
136 6de88ee1 Stauros Kroustouris
It is strongly advised that you do not change the following to False values unless, you want to integrate FoD with you CRM or members database. This implies that you are able/have the rights to create database views between the two databases::
137 6de88ee1 Stauros Kroustouris
138 6de88ee1 Stauros Kroustouris
    PEER_MANAGED_TABLE = True
139 6de88ee1 Stauros Kroustouris
    PEER_RANGE_MANAGED_TABLE = True
140 6de88ee1 Stauros Kroustouris
    PEER_TECHC_MANAGED_TABLE = True   
141 6de88ee1 Stauros Kroustouris
142 6de88ee1 Stauros Kroustouris
By doing that the corresponding tables as defined in peers/models will not be created. As noted above, you have to create the views that the tables will rely on. 
143 6de88ee1 Stauros Kroustouris
144 6de88ee1 Stauros Kroustouris
.. note::
145 6de88ee1 Stauros Kroustouris
    Soon we will release a version with django-registration as a means to add users and Shibboleth will become an alternative
146 6de88ee1 Stauros Kroustouris
147 6de88ee1 Stauros Kroustouris
Let's move on with some copies and dir creations::
148 6de88ee1 Stauros Kroustouris
149 6de88ee1 Stauros Kroustouris
    mkdir /var/log/fod
150 6de88ee1 Stauros Kroustouris
    chown www-data.www-data /var/log/fod
151 6de88ee1 Stauros Kroustouris
    cp urls.py.dist urls.py
152 6de88ee1 Stauros Kroustouris
    cd ..
153 6de88ee1 Stauros Kroustouris
154 6de88ee1 Stauros Kroustouris
.. note::
155 6de88ee1 Stauros Kroustouris
    LOG_FILE_LOCATION in settings.py is set to **/var/log/fod**. Adjust the chown command above to your selected dir.
156 6de88ee1 Stauros Kroustouris
157 6de88ee1 Stauros Kroustouris
System configuration
158 6de88ee1 Stauros Kroustouris
====================
159 6de88ee1 Stauros Kroustouris
Apache operates as a gunicorn Proxy with WSGI and Shibboleth modules enabled.
160 6de88ee1 Stauros Kroustouris
Depending on the setup the apache configuration may vary::
161 6de88ee1 Stauros Kroustouris
162 6de88ee1 Stauros Kroustouris
    a2enmod rewrite
163 6de88ee1 Stauros Kroustouris
    a2enmod proxy
164 6de88ee1 Stauros Kroustouris
    a2enmod ssl
165 6de88ee1 Stauros Kroustouris
    a2enmod proxy_http
166 6de88ee1 Stauros Kroustouris
167 6de88ee1 Stauros Kroustouris
If shibboleth is to be used::
168 6de88ee1 Stauros Kroustouris
169 6de88ee1 Stauros Kroustouris
    apt-get install libapache2-mod-shib2
170 6de88ee1 Stauros Kroustouris
    a2enmod shib2
171 6de88ee1 Stauros Kroustouris
172 6de88ee1 Stauros Kroustouris
Now it is time to configure beanstalk, gunicorn, celery and apache.
173 6de88ee1 Stauros Kroustouris
174 6de88ee1 Stauros Kroustouris
beanstalkd
175 6de88ee1 Stauros Kroustouris
----------
176 6de88ee1 Stauros Kroustouris
Enable beanstalk by editting /etc/default/beanstalkd::
177 6de88ee1 Stauros Kroustouris
178 6de88ee1 Stauros Kroustouris
    vim /etc/default/beanstalkd
179 6de88ee1 Stauros Kroustouris
180 6de88ee1 Stauros Kroustouris
Uncomment the line **START=yes** to enable beanstalk
181 6de88ee1 Stauros Kroustouris
182 6de88ee1 Stauros Kroustouris
Start beanstalkd::
183 6de88ee1 Stauros Kroustouris
184 6de88ee1 Stauros Kroustouris
    service beanstalkd start
185 6de88ee1 Stauros Kroustouris
186 6de88ee1 Stauros Kroustouris
gunicorn.d
187 6de88ee1 Stauros Kroustouris
----------
188 6de88ee1 Stauros Kroustouris
Create and edit /etc/gunicorn.d/fod::
189 6de88ee1 Stauros Kroustouris
190 6de88ee1 Stauros Kroustouris
    vim /etc/gunicorn.d/fod
191 6de88ee1 Stauros Kroustouris
192 6de88ee1 Stauros Kroustouris
FoD is served via gunicorn and is then proxied by Apache. If the above directory conventions have been followed so far, then your configuration should be::
193 6de88ee1 Stauros Kroustouris
194 6de88ee1 Stauros Kroustouris
    CONFIG = {
195 6de88ee1 Stauros Kroustouris
          'mode': 'django',
196 6de88ee1 Stauros Kroustouris
          'working_dir': '/srv/flowspy',
197 6de88ee1 Stauros Kroustouris
          'args': (
198 6de88ee1 Stauros Kroustouris
               '--bind=127.0.0.1:8081',
199 6de88ee1 Stauros Kroustouris
               '--workers=1',
200 6de88ee1 Stauros Kroustouris
               '--worker-class=egg:gunicorn#gevent',
201 6de88ee1 Stauros Kroustouris
               '--timeout=30',
202 6de88ee1 Stauros Kroustouris
               '--debug',
203 6de88ee1 Stauros Kroustouris
               '--log-level=debug',
204 6de88ee1 Stauros Kroustouris
               '--log-file=/var/log/gunicorn/fod.log',
205 6de88ee1 Stauros Kroustouris
          ),
206 6de88ee1 Stauros Kroustouris
    }
207 6de88ee1 Stauros Kroustouris
208 6de88ee1 Stauros Kroustouris
209 6de88ee1 Stauros Kroustouris
celeryd
210 6de88ee1 Stauros Kroustouris
-------
211 6de88ee1 Stauros Kroustouris
Celery is used over beanstalkd to apply firewall rules in a serial manner so that locks are avoided on the flowspec capable device. In our setup celery runs via django. That is why the python-django-celery package was installed.
212 6de88ee1 Stauros Kroustouris
213 6de88ee1 Stauros Kroustouris
Create the celeryd daemon at /etc/init.d/celeryd **if it does not already exist**::
214 6de88ee1 Stauros Kroustouris
215 6de88ee1 Stauros Kroustouris
    vim /etc/init.d/celeryd
216 6de88ee1 Stauros Kroustouris
217 6de88ee1 Stauros Kroustouris
The configuration should be::
218 6de88ee1 Stauros Kroustouris
219 6de88ee1 Stauros Kroustouris
    #!/bin/sh -e
220 6de88ee1 Stauros Kroustouris
    # ============================================
221 6de88ee1 Stauros Kroustouris
    #  celeryd - Starts the Celery worker daemon.
222 6de88ee1 Stauros Kroustouris
    # ============================================
223 6de88ee1 Stauros Kroustouris
    #
224 6de88ee1 Stauros Kroustouris
    # :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}
225 6de88ee1 Stauros Kroustouris
    # :Configuration file: /etc/default/celeryd
226 6de88ee1 Stauros Kroustouris
    #
227 6de88ee1 Stauros Kroustouris
    # See http://docs.celeryq.org/en/latest/cookbook/daemonizing.html#init-script-celeryd
228 6de88ee1 Stauros Kroustouris
    
229 6de88ee1 Stauros Kroustouris
    
230 6de88ee1 Stauros Kroustouris
    ### BEGIN INIT INFO
231 6de88ee1 Stauros Kroustouris
    # Provides:              celeryd
232 6de88ee1 Stauros Kroustouris
    # Required-Start:     $network $local_fs $remote_fs
233 6de88ee1 Stauros Kroustouris
    # Required-Stop:       $network $local_fs $remote_fs
234 6de88ee1 Stauros Kroustouris
    # Default-Start:       2 3 4 5
235 6de88ee1 Stauros Kroustouris
    # Default-Stop:        0 1 6
236 6de88ee1 Stauros Kroustouris
    # Short-Description: celery task worker daemon
237 6de88ee1 Stauros Kroustouris
    # Description:          Starts the Celery worker daemon for a single project.
238 6de88ee1 Stauros Kroustouris
    ### END INIT INFO
239 6de88ee1 Stauros Kroustouris
    
240 6de88ee1 Stauros Kroustouris
    #set -e
241 6de88ee1 Stauros Kroustouris
    
242 6de88ee1 Stauros Kroustouris
    DEFAULT_PID_FILE="/var/run/celery/%n.pid"
243 6de88ee1 Stauros Kroustouris
    DEFAULT_LOG_FILE="/var/log/celery/%n.log"
244 6de88ee1 Stauros Kroustouris
    DEFAULT_LOG_LEVEL="INFO"
245 6de88ee1 Stauros Kroustouris
    DEFAULT_NODES="celery"
246 6de88ee1 Stauros Kroustouris
    DEFAULT_CELERYD="-m celery.bin.celeryd_detach"
247 6de88ee1 Stauros Kroustouris
    ENABLED="false"
248 6de88ee1 Stauros Kroustouris
    
249 6de88ee1 Stauros Kroustouris
    [ -r "$CELERY_DEFAULTS" ] && . "$CELERY_DEFAULTS"
250 6de88ee1 Stauros Kroustouris
    
251 6de88ee1 Stauros Kroustouris
    [ -r /etc/default/celeryd ] && . /etc/default/celeryd
252 6de88ee1 Stauros Kroustouris
    
253 6de88ee1 Stauros Kroustouris
    if [ "$ENABLED" != "true" ]; then
254 6de88ee1 Stauros Kroustouris
          echo "celery daemon disabled - see /etc/default/celeryd."
255 6de88ee1 Stauros Kroustouris
          exit 0
256 6de88ee1 Stauros Kroustouris
    fi
257 6de88ee1 Stauros Kroustouris
    
258 6de88ee1 Stauros Kroustouris
    
259 6de88ee1 Stauros Kroustouris
    CELERYD_PID_FILE=${CELERYD_PID_FILE:-${CELERYD_PIDFILE:-$DEFAULT_PID_FILE}}
260 6de88ee1 Stauros Kroustouris
    CELERYD_LOG_FILE=${CELERYD_LOG_FILE:-${CELERYD_LOGFILE:-$DEFAULT_LOG_FILE}}
261 6de88ee1 Stauros Kroustouris
    CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-$DEFAULT_LOG_LEVEL}}
262 6de88ee1 Stauros Kroustouris
    CELERYD_MULTI=${CELERYD_MULTI:-"celeryd-multi"}
263 6de88ee1 Stauros Kroustouris
    CELERYD=${CELERYD:-$DEFAULT_CELERYD}
264 6de88ee1 Stauros Kroustouris
    CELERYCTL=${CELERYCTL:="celeryctl"}
265 6de88ee1 Stauros Kroustouris
    CELERYD_NODES=${CELERYD_NODES:-$DEFAULT_NODES}
266 6de88ee1 Stauros Kroustouris
    
267 6de88ee1 Stauros Kroustouris
    export CELERY_LOADER
268 6de88ee1 Stauros Kroustouris
    
269 6de88ee1 Stauros Kroustouris
    if [ -n "$2" ]; then
270 6de88ee1 Stauros Kroustouris
          CELERYD_OPTS="$CELERYD_OPTS $2"
271 6de88ee1 Stauros Kroustouris
    fi
272 6de88ee1 Stauros Kroustouris
    
273 6de88ee1 Stauros Kroustouris
    CELERYD_LOG_DIR=`dirname $CELERYD_LOG_FILE`
274 6de88ee1 Stauros Kroustouris
    CELERYD_PID_DIR=`dirname $CELERYD_PID_FILE`
275 6de88ee1 Stauros Kroustouris
    if [ ! -d "$CELERYD_LOG_DIR" ]; then
276 6de88ee1 Stauros Kroustouris
          mkdir -p $CELERYD_LOG_DIR
277 6de88ee1 Stauros Kroustouris
    fi
278 6de88ee1 Stauros Kroustouris
    if [ ! -d "$CELERYD_PID_DIR" ]; then
279 6de88ee1 Stauros Kroustouris
          mkdir -p $CELERYD_PID_DIR
280 6de88ee1 Stauros Kroustouris
    fi
281 6de88ee1 Stauros Kroustouris
    
282 6de88ee1 Stauros Kroustouris
    # Extra start-stop-daemon options, like user/group.
283 6de88ee1 Stauros Kroustouris
    if [ -n "$CELERYD_USER" ]; then
284 6de88ee1 Stauros Kroustouris
          DAEMON_OPTS="$DAEMON_OPTS --uid=$CELERYD_USER"
285 6de88ee1 Stauros Kroustouris
          chown "$CELERYD_USER" $CELERYD_LOG_DIR $CELERYD_PID_DIR
286 6de88ee1 Stauros Kroustouris
    fi
287 6de88ee1 Stauros Kroustouris
    if [ -n "$CELERYD_GROUP" ]; then
288 6de88ee1 Stauros Kroustouris
          DAEMON_OPTS="$DAEMON_OPTS --gid=$CELERYD_GROUP"
289 6de88ee1 Stauros Kroustouris
          chgrp "$CELERYD_GROUP" $CELERYD_LOG_DIR $CELERYD_PID_DIR
290 6de88ee1 Stauros Kroustouris
    fi
291 6de88ee1 Stauros Kroustouris
    
292 6de88ee1 Stauros Kroustouris
    if [ -n "$CELERYD_CHDIR" ]; then
293 6de88ee1 Stauros Kroustouris
          DAEMON_OPTS="$DAEMON_OPTS --workdir=\"$CELERYD_CHDIR\""
294 6de88ee1 Stauros Kroustouris
    fi
295 6de88ee1 Stauros Kroustouris
    
296 6de88ee1 Stauros Kroustouris
    
297 6de88ee1 Stauros Kroustouris
    check_dev_null() {
298 6de88ee1 Stauros Kroustouris
          if [ ! -c /dev/null ]; then
299 6de88ee1 Stauros Kroustouris
               echo "/dev/null is not a character device!"
300 6de88ee1 Stauros Kroustouris
               exit 1
301 6de88ee1 Stauros Kroustouris
          fi
302 6de88ee1 Stauros Kroustouris
    }
303 6de88ee1 Stauros Kroustouris
    
304 6de88ee1 Stauros Kroustouris
    
305 6de88ee1 Stauros Kroustouris
    export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
306 6de88ee1 Stauros Kroustouris
    
307 6de88ee1 Stauros Kroustouris
    
308 6de88ee1 Stauros Kroustouris
    stop_workers () {
309 6de88ee1 Stauros Kroustouris
          $CELERYD_MULTI stop $CELERYD_NODES --pidfile="$CELERYD_PID_FILE"
310 6de88ee1 Stauros Kroustouris
    }
311 6de88ee1 Stauros Kroustouris
    
312 6de88ee1 Stauros Kroustouris
    
313 6de88ee1 Stauros Kroustouris
    start_workers () {
314 6de88ee1 Stauros Kroustouris
          $CELERYD_MULTI start $CELERYD_NODES $DAEMON_OPTS           \
315 6de88ee1 Stauros Kroustouris
                                        --pidfile="$CELERYD_PID_FILE"        \
316 6de88ee1 Stauros Kroustouris
                                        --logfile="$CELERYD_LOG_FILE"        \
317 6de88ee1 Stauros Kroustouris
                                        --loglevel="$CELERYD_LOG_LEVEL"     \
318 6de88ee1 Stauros Kroustouris
                                        --cmd="$CELERYD"                           \
319 6de88ee1 Stauros Kroustouris
                                        $CELERYD_OPTS
320 6de88ee1 Stauros Kroustouris
    }
321 6de88ee1 Stauros Kroustouris
    
322 6de88ee1 Stauros Kroustouris
    
323 6de88ee1 Stauros Kroustouris
    restart_workers () {
324 6de88ee1 Stauros Kroustouris
          $CELERYD_MULTI restart $CELERYD_NODES $DAEMON_OPTS        \
325 6de88ee1 Stauros Kroustouris
                                           --pidfile="$CELERYD_PID_FILE"     \
326 6de88ee1 Stauros Kroustouris
                                           --logfile="$CELERYD_LOG_FILE"     \
327 6de88ee1 Stauros Kroustouris
                                           --loglevel="$CELERYD_LOG_LEVEL"  \
328 6de88ee1 Stauros Kroustouris
                                           --cmd="$CELERYD"                        \
329 6de88ee1 Stauros Kroustouris
                                           $CELERYD_OPTS
330 6de88ee1 Stauros Kroustouris
    }
331 6de88ee1 Stauros Kroustouris
    
332 6de88ee1 Stauros Kroustouris
    
333 6de88ee1 Stauros Kroustouris
    
334 6de88ee1 Stauros Kroustouris
    case "$1" in
335 6de88ee1 Stauros Kroustouris
          start)
336 6de88ee1 Stauros Kroustouris
               check_dev_null
337 6de88ee1 Stauros Kroustouris
               start_workers
338 6de88ee1 Stauros Kroustouris
          ;;
339 6de88ee1 Stauros Kroustouris
    
340 6de88ee1 Stauros Kroustouris
          stop)
341 6de88ee1 Stauros Kroustouris
               check_dev_null
342 6de88ee1 Stauros Kroustouris
               stop_workers
343 6de88ee1 Stauros Kroustouris
          ;;
344 6de88ee1 Stauros Kroustouris
    
345 6de88ee1 Stauros Kroustouris
          reload|force-reload)
346 6de88ee1 Stauros Kroustouris
               echo "Use restart"
347 6de88ee1 Stauros Kroustouris
          ;;
348 6de88ee1 Stauros Kroustouris
    
349 6de88ee1 Stauros Kroustouris
          status)
350 6de88ee1 Stauros Kroustouris
               $CELERYCTL status $CELERYCTL_OPTS
351 6de88ee1 Stauros Kroustouris
          ;;
352 6de88ee1 Stauros Kroustouris
    
353 6de88ee1 Stauros Kroustouris
          restart)
354 6de88ee1 Stauros Kroustouris
               check_dev_null
355 6de88ee1 Stauros Kroustouris
               restart_workers
356 6de88ee1 Stauros Kroustouris
          ;;
357 6de88ee1 Stauros Kroustouris
    
358 6de88ee1 Stauros Kroustouris
          try-restart)
359 6de88ee1 Stauros Kroustouris
               check_dev_null
360 6de88ee1 Stauros Kroustouris
               restart_workers
361 6de88ee1 Stauros Kroustouris
          ;;
362 6de88ee1 Stauros Kroustouris
    
363 6de88ee1 Stauros Kroustouris
          *)
364 6de88ee1 Stauros Kroustouris
               echo "Usage: /etc/init.d/celeryd {start|stop|restart|try-restart|kill}"
365 6de88ee1 Stauros Kroustouris
               exit 1
366 6de88ee1 Stauros Kroustouris
          ;;
367 6de88ee1 Stauros Kroustouris
    esac
368 6de88ee1 Stauros Kroustouris
    
369 6de88ee1 Stauros Kroustouris
    exit 0
370 6de88ee1 Stauros Kroustouris
371 6de88ee1 Stauros Kroustouris
celeryd configuration
372 6de88ee1 Stauros Kroustouris
---------------------
373 6de88ee1 Stauros Kroustouris
celeryd requires a /etc/default/celeryd file to be in place.
374 6de88ee1 Stauros Kroustouris
Thus we are going to create this file (/etc/default/celeryd)::
375 6de88ee1 Stauros Kroustouris
376 6de88ee1 Stauros Kroustouris
    vim /etc/default/celeryd
377 6de88ee1 Stauros Kroustouris
378 6de88ee1 Stauros Kroustouris
Again if the directory conventions have been followed the file is (pay attention to the CELERYD_USER, CELERYD_GROUP and change accordingly)  ::
379 6de88ee1 Stauros Kroustouris
380 6de88ee1 Stauros Kroustouris
    # Default: false
381 6de88ee1 Stauros Kroustouris
    ENABLED="true"
382 6de88ee1 Stauros Kroustouris
    
383 6de88ee1 Stauros Kroustouris
    # Name of nodes to start, here we have a single node
384 6de88ee1 Stauros Kroustouris
    CELERYD_NODES="w1"
385 6de88ee1 Stauros Kroustouris
    # or we could have three nodes:
386 6de88ee1 Stauros Kroustouris
    #CELERYD_NODES="w1 w2 w3"
387 6de88ee1 Stauros Kroustouris
    
388 6de88ee1 Stauros Kroustouris
    # Where to chdir at start.
389 6de88ee1 Stauros Kroustouris
    CELERYD_CHDIR="/srv/flowspy"
390 6de88ee1 Stauros Kroustouris
    # How to call "manage.py celeryd_multi"
391 6de88ee1 Stauros Kroustouris
    CELERYD_MULTI="python $CELERYD_CHDIR/manage.py celeryd_multi"
392 6de88ee1 Stauros Kroustouris
    
393 6de88ee1 Stauros Kroustouris
    # How to call "manage.py celeryctl"
394 6de88ee1 Stauros Kroustouris
    CELERYCTL="python $CELERYD_CHDIR/manage.py celeryctl"
395 6de88ee1 Stauros Kroustouris
    
396 6de88ee1 Stauros Kroustouris
    # Extra arguments to celeryd
397 6de88ee1 Stauros Kroustouris
    #CELERYD_OPTS="--time-limit=300 --concurrency=8"
398 6de88ee1 Stauros Kroustouris
    CELERYD_OPTS="-E -B --schedule=/var/run/celery/celerybeat-schedule --concurrency=1 --soft-time-limit=180 --time-limit=1800"
399 6de88ee1 Stauros Kroustouris
    # Name of the celery config module.
400 6de88ee1 Stauros Kroustouris
    CELERY_CONFIG_MODULE="celeryconfig"
401 6de88ee1 Stauros Kroustouris
    
402 6de88ee1 Stauros Kroustouris
    # %n will be replaced with the nodename.
403 6de88ee1 Stauros Kroustouris
    CELERYD_LOG_FILE="/var/log/celery/fod_%n.log"
404 6de88ee1 Stauros Kroustouris
    CELERYD_PID_FILE="/var/run/celery/%n.pid"
405 6de88ee1 Stauros Kroustouris
    
406 6de88ee1 Stauros Kroustouris
    CELERYD_USER="root"
407 6de88ee1 Stauros Kroustouris
    CELERYD_GROUP="root"
408 6de88ee1 Stauros Kroustouris
    
409 6de88ee1 Stauros Kroustouris
    # Name of the projects settings module.
410 6de88ee1 Stauros Kroustouris
    export DJANGO_SETTINGS_MODULE="flowspy.settings"
411 6de88ee1 Stauros Kroustouris
412 6de88ee1 Stauros Kroustouris
Apache
413 6de88ee1 Stauros Kroustouris
------
414 6de88ee1 Stauros Kroustouris
Apache proxies gunicorn. Things are more flexible here as you may follow your own configuration and conventions. Create and edit /etc/apache2/sites-available/fod. You should set <server_name> and <admin_mail> along with your certificates. If under testing environment, you can use the provided snakeoil certs. If you do not intent to use Shibboleth delete or comment the corresponding configuration parts inside **Shibboleth configuration** ::
415 6de88ee1 Stauros Kroustouris
416 6de88ee1 Stauros Kroustouris
    vim /etc/apache2/sites-available/fod
417 6de88ee1 Stauros Kroustouris
418 6de88ee1 Stauros Kroustouris
Again if the directory conventions have been followed the file should be::
419 6de88ee1 Stauros Kroustouris
420 6de88ee1 Stauros Kroustouris
    <VirtualHost *:80>
421 6de88ee1 Stauros Kroustouris
        ServerAdmin webmaster@localhost
422 6de88ee1 Stauros Kroustouris
        ServerName  fod.example.com
423 6de88ee1 Stauros Kroustouris
        DocumentRoot /var/www
424 6de88ee1 Stauros Kroustouris
    
425 6de88ee1 Stauros Kroustouris
        ErrorLog ${APACHE_LOG_DIR}/fod_error.log
426 6de88ee1 Stauros Kroustouris
    
427 6de88ee1 Stauros Kroustouris
        # Possible values include: debug, info, notice, warn, error, crit,
428 6de88ee1 Stauros Kroustouris
        # alert, emerg.
429 6de88ee1 Stauros Kroustouris
        LogLevel debug
430 6de88ee1 Stauros Kroustouris
        
431 6de88ee1 Stauros Kroustouris
        CustomLog ${APACHE_LOG_DIR}/fod_access.log combined
432 6de88ee1 Stauros Kroustouris
    
433 6de88ee1 Stauros Kroustouris
        Alias /static       /srv/flowspy/static
434 6de88ee1 Stauros Kroustouris
          RewriteEngine On
435 6de88ee1 Stauros Kroustouris
          RewriteCond %{HTTPS} off
436 6de88ee1 Stauros Kroustouris
          RewriteRule ^/(.*) https://fod.example.com/$1 [L,R]
437 6de88ee1 Stauros Kroustouris
    </VirtualHost>
438 6de88ee1 Stauros Kroustouris
    
439 6de88ee1 Stauros Kroustouris
    <VirtualHost *:443>
440 6de88ee1 Stauros Kroustouris
        ServerName    fod.example.com
441 6de88ee1 Stauros Kroustouris
        ServerAdmin     webmaster@localhost
442 6de88ee1 Stauros Kroustouris
        ServerSignature        On
443 6de88ee1 Stauros Kroustouris
        
444 6de88ee1 Stauros Kroustouris
        SSLEngine on
445 6de88ee1 Stauros Kroustouris
        SSLCertificateFile    /etc/ssl/certs/fod.example.com.crt
446 6de88ee1 Stauros Kroustouris
        SSLCertificateChainFile /etc/ssl/certs/example-chain.pem
447 6de88ee1 Stauros Kroustouris
        SSLCertificateKeyFile    /etc/ssl/private/fod.example.com.key
448 6de88ee1 Stauros Kroustouris
    
449 6de88ee1 Stauros Kroustouris
        AddDefaultCharset UTF-8
450 6de88ee1 Stauros Kroustouris
        IndexOptions        +Charset=UTF-8
451 6de88ee1 Stauros Kroustouris
    
452 6de88ee1 Stauros Kroustouris
        ShibConfig       /etc/shibboleth/shibboleth2.xml
453 6de88ee1 Stauros Kroustouris
        Alias          /shibboleth-sp /usr/share/shibboleth
454 6de88ee1 Stauros Kroustouris
    
455 6de88ee1 Stauros Kroustouris
    
456 6de88ee1 Stauros Kroustouris
        <Location /login>
457 6de88ee1 Stauros Kroustouris
             AuthType shibboleth
458 6de88ee1 Stauros Kroustouris
             ShibRequireSession On
459 6de88ee1 Stauros Kroustouris
             ShibUseHeaders On
460 6de88ee1 Stauros Kroustouris
             ShibRequestSetting entityID https://idp.example.com/idp/shibboleth
461 6de88ee1 Stauros Kroustouris
             require valid-user
462 6de88ee1 Stauros Kroustouris
        </Location>
463 6de88ee1 Stauros Kroustouris
        
464 6de88ee1 Stauros Kroustouris
        # Shibboleth debugging CGI script
465 6de88ee1 Stauros Kroustouris
        ScriptAlias /shibboleth/test /usr/lib/cgi-bin/shibtest.cgi
466 6de88ee1 Stauros Kroustouris
        <Location /shibboleth/test>
467 6de88ee1 Stauros Kroustouris
             AuthType shibboleth
468 6de88ee1 Stauros Kroustouris
             ShibRequireSession On
469 6de88ee1 Stauros Kroustouris
             ShibUseHeaders On
470 6de88ee1 Stauros Kroustouris
             require valid-user
471 6de88ee1 Stauros Kroustouris
        </Location>
472 6de88ee1 Stauros Kroustouris
    
473 6de88ee1 Stauros Kroustouris
        <Location /Shibboleth.sso>
474 6de88ee1 Stauros Kroustouris
             SetHandler shib
475 6de88ee1 Stauros Kroustouris
        </Location>
476 6de88ee1 Stauros Kroustouris
    
477 6de88ee1 Stauros Kroustouris
        # Shibboleth SP configuration
478 6de88ee1 Stauros Kroustouris
    
479 6de88ee1 Stauros Kroustouris
        #SetEnv                       proxy-sendchunked
480 6de88ee1 Stauros Kroustouris
        
481 6de88ee1 Stauros Kroustouris
              <Proxy *>
482 6de88ee1 Stauros Kroustouris
               Order allow,deny
483 6de88ee1 Stauros Kroustouris
               Allow from all
484 6de88ee1 Stauros Kroustouris
               </Proxy>
485 6de88ee1 Stauros Kroustouris
    
486 6de88ee1 Stauros Kroustouris
               SSLProxyEngine           off
487 6de88ee1 Stauros Kroustouris
               ProxyErrorOverride     off
488 6de88ee1 Stauros Kroustouris
          ProxyTimeout     28800
489 6de88ee1 Stauros Kroustouris
             ProxyPass        /static !
490 6de88ee1 Stauros Kroustouris
             ProxyPass          /shibboleth !
491 6de88ee1 Stauros Kroustouris
             ProxyPass        /Shibboleth.sso !
492 6de88ee1 Stauros Kroustouris
             
493 6de88ee1 Stauros Kroustouris
               ProxyPass           / http://localhost:8081/ retry=0
494 6de88ee1 Stauros Kroustouris
               ProxyPassReverse / http://localhost:8081/
495 6de88ee1 Stauros Kroustouris
    
496 6de88ee1 Stauros Kroustouris
          Alias /static          /srv/flowspy/static
497 6de88ee1 Stauros Kroustouris
    
498 6de88ee1 Stauros Kroustouris
        LogLevel warn
499 6de88ee1 Stauros Kroustouris
        
500 6de88ee1 Stauros Kroustouris
        ErrorLog ${APACHE_LOG_DIR}/fod_error.log
501 6de88ee1 Stauros Kroustouris
          CustomLog ${APACHE_LOG_DIR}/fod_access.log combined
502 6de88ee1 Stauros Kroustouris
    
503 6de88ee1 Stauros Kroustouris
    </VirtualHost>
504 6de88ee1 Stauros Kroustouris
505 6de88ee1 Stauros Kroustouris
Now, enable your site. You might want to disable the default site if fod is the only site you host on your server::
506 6de88ee1 Stauros Kroustouris
507 6de88ee1 Stauros Kroustouris
    a2dissite default
508 6de88ee1 Stauros Kroustouris
    a2ensite fod
509 6de88ee1 Stauros Kroustouris
510 6de88ee1 Stauros Kroustouris
You are not far away from deploying FoD. When asked for a super user, create one::
511 6de88ee1 Stauros Kroustouris
512 6de88ee1 Stauros Kroustouris
    cd /srv/flowspy
513 6de88ee1 Stauros Kroustouris
    python manage.py syncdb
514 6de88ee1 Stauros Kroustouris
    python manage.py migrate longerusername
515 6de88ee1 Stauros Kroustouris
    python manage.py migrate flowspec
516 6de88ee1 Stauros Kroustouris
    python manage.py migrate djcelery
517 6de88ee1 Stauros Kroustouris
    python manage.py migrate accounts
518 6de88ee1 Stauros Kroustouris
519 6de88ee1 Stauros Kroustouris
If you have not changed the values of the PEER\_\*\_TABLE variables to False and thus you are going for a default installation (that is PEER\_\*\_TABLE variables are set to True) , then run::
520 6de88ee1 Stauros Kroustouris
    
521 6de88ee1 Stauros Kroustouris
    python manage.py migrate peers
522 6de88ee1 Stauros Kroustouris
523 6de88ee1 Stauros Kroustouris
If however you have set the PEER\_\*\_TABLE variables to False and by accident you have ran the command above, then you have to cleanup you database manually by dropping the peer\* tables plus the techc_email table. For MySQL the command is::
524 6de88ee1 Stauros Kroustouris
    
525 6de88ee1 Stauros Kroustouris
    DROP TABLE `peer`, `peer_networks`, `peer_range`, `peer_techc_emails`, techc_email;  
526 6de88ee1 Stauros Kroustouris
527 6de88ee1 Stauros Kroustouris
Restart, gunicorn and apache::
528 6de88ee1 Stauros Kroustouris
529 6de88ee1 Stauros Kroustouris
    service gunicorn restart && service apache2 restart
530 6de88ee1 Stauros Kroustouris
531 6de88ee1 Stauros Kroustouris
532 6de88ee1 Stauros Kroustouris
Propagate the flatpages
533 6de88ee1 Stauros Kroustouris
=======================
534 6de88ee1 Stauros Kroustouris
Inside the initial_data/fixtures_manual.xml file we have placed 4 flatpages (2 for Greek, 2 for English) with Information and Terms of Service about the service. 
535 6de88ee1 Stauros Kroustouris
To import the flatpages, run from root folder::
536 6de88ee1 Stauros Kroustouris
537 6de88ee1 Stauros Kroustouris
    python manage.py loaddata initial_data/fixtures_manual.xml
538 6de88ee1 Stauros Kroustouris
539 6de88ee1 Stauros Kroustouris
540 6de88ee1 Stauros Kroustouris
541 6de88ee1 Stauros Kroustouris
Testing the platform
542 6de88ee1 Stauros Kroustouris
====================
543 6de88ee1 Stauros Kroustouris
Log in to the admin interface via https:\/\/<hostname>\/admin. Go to Peer ranges and add a new range (part of/or a complete subnet), eg. 10.20.0.0/19
544 6de88ee1 Stauros Kroustouris
Go to Peers and add a new peer, eg. id: 1, name: Test, AS: 16503, tag: TEST and move the network you have created from Avalable to Chosen. From the admin front, go to User, and edit your user. From the bottom of the page, select the TEST peer and save.
545 6de88ee1 Stauros Kroustouris
Last but not least, modify as required the existing (example.com) Site instance (admin home->Sites). You are done. As you are logged-in via the admin, there is no need to go through Shibboleth at this time. Go to https:\/\/<hostname>\/ and create a new rule. Your rule should be applied on the flowspec capable device after aprox. 10 seconds. If no Shibboleth authentication is available, a https:\/\/<hostname>\/altlogin is provided.
546 6de88ee1 Stauros Kroustouris
547 6de88ee1 Stauros Kroustouris
Branding
548 6de88ee1 Stauros Kroustouris
========
549 6de88ee1 Stauros Kroustouris
Via the admin interface you can modify flatpages to suit your needs
550 6de88ee1 Stauros Kroustouris
551 6de88ee1 Stauros Kroustouris
Footer
552 6de88ee1 Stauros Kroustouris
------
553 6de88ee1 Stauros Kroustouris
Under the templates folder (templates), you can alter the footer.html file to include your own footer messages, badges, etc.
554 6de88ee1 Stauros Kroustouris
555 6de88ee1 Stauros Kroustouris
Welcome Page
556 6de88ee1 Stauros Kroustouris
------------
557 6de88ee1 Stauros Kroustouris
Under the templates folder (templates), you can alter the welcome page - welcome.html with your own images, carousel, videos, etc.