admin-guide.rst 123 KB
Newer Older
1 2 3 4 5 6 7 8
.. _admin-guide:

Synnefo Administrator's Guide

This is the complete Synnefo Administrator's Guide.

.. _syn+archip:

11 12 13
General Synnefo Architecture

14 15 16 17
The following figure shows a detailed view of the whole Synnefo architecture
and how it interacts with multiple Ganeti clusters. We hope that after reading
the Administrator's Guide you will be able to understand every component and
all the interactions between them.

.. image:: images/synnefo-arch2.png
   :width: 100%
   :target: _images/synnefo-arch2.png


24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Required system users and groups (synnefo, archipelago)

Since v0.16, Synnefo requires an Archipelago installation for the Pithos
backend. Archipelago on the other hand, supports both NFS and RADOS as
storage backends. This leads us to various components that have specific
access rights.

Synnefo ships its own configuration files under ``/etc/synnefo``. In
order those files not to be compromised, they are owned by
``root:synnefo`` with group read access (mode 640). Since Gunicorn,
which serves Synnefo by default, needs read access to the configuration
files and we don't want it to run as root, it must run with group

39 40 41 42 43 44
.. warning:: If you want to add your own configuration file, do not forget to
   declare the appropriate  encoding by adding the line
   ``## -*- coding: utf-8 -*-`` at the beggining of the file.

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
Cyclades and Pithos talk to Archipelago over some named pipes under
``/dev/shm/posixfd``. This directory is created by Archipelago, owned by
the user/group that Archipelago runs as, and at the same time it must be
accessible by Gunicorn. Therefore we let Gunicorn run as ``synnefo``
user and Archipelago as ``archipelago:synnefo`` (by default it rus as
``archipelago:archipelago``). Beware that the ``synnefo`` user and
group is created by snf-common package.

Archipelago must have a storage backend to physically store blocks, maps
and locks. This can be either an NFS or a RADOS cluster.

NFS backing store
In case of NFS, Archipelago must have permissions to write on the
exported dirs. We choose to have ``/srv/archip`` exported with
``blocks``, ``maps``, and ``locks`` subdirectories. They are owned by
``archipelago:synnefo`` and have ``g+ws`` access permissions. So
Archipelago will be able to read/write in these directories. We could
have the whole NFS isolated from Synnefo (owned by
``archipelago:archipelago`` with ``640`` access permissions) but we
choose not to (e.g. some future extension could require access to the
backing store directly from Synnefo).

Due to NFS restrictions, all Archipelago nodes must have common uid for
the ``archipelago`` user and common gid for the ``synnefo`` group. So
before any Synnefo installation, we create them here in advance. We
assume that ids 200 and 300 are available across all nodes.

.. code-block:: console

  # addgroup --system --gid 200 synnefo
  # adduser --system --uid 200 --gid 200 --no-create-home \
      --gecos Synnefo synnefo

  # addgroup --system --gid 300 archipelago
  # adduser --system --uid 300 --gid 300 --no-create-home \
      --gecos Archipelago archipelago

Normally the ``snf-common`` and ``archipelago`` packages are responsible
for creating the required system users and groups.

86 87
Identity Service (Astakos)
88 89

Authentication methods

Astakos supports multiple authentication methods:

95 96 97 98 99 100
 * local username/password
 * LDAP / Active Directory
 * SAML 2.0 (Shibboleth) federated logins
 * Google
 * Twitter
 * LinkedIn
101 102 103 104

.. _shibboleth-auth:

Shibboleth Authentication
106 107 108 109 110 111 112 113 114 115 116 117 118 119

Astakos can delegate user authentication to a Shibboleth federation.

To setup shibboleth, install package::

  apt-get install libapache2-mod-shib2

Change appropriately the configuration files in ``/etc/shibboleth``.

Add in ``/etc/apache2/sites-available/synnefo-ssl``::

  ShibConfig /etc/shibboleth/shibboleth2.xml
  Alias      /shibboleth-sp /usr/share/shibboleth

  <Location /ui/login/shibboleth>
121 122 123 124 125 126 127 128 129 130 131 132 133
    AuthType shibboleth
    ShibRequireSession On
    ShibUseHeaders On
    require valid-user

and before the line containing::

  ProxyPass        / http://localhost:8080/ retry=0


  ProxyPass /Shibboleth.sso !

135 136 137
Then, enable the shibboleth module::

  a2enmod shib2

139 140 141 142 143 144 145 146 147 148 149
After passing through the apache module, the following tokens should be
available at the destination::

  eppn # eduPersonPrincipalName

150 151 152
Astakos keeps a map of shibboleth users using the value of the ``REMOTE_USER``
header, passed by the ``mod_shib2`` module. This happens in order to be able to
identify the astakos account the shibboleth user is associated to, every time
the user logs in from an affiliate shibboleth IdP.
154 155 156 157 158 159 160

The shibboleth attribute which gets mapped to the ``REMOTE_USER`` header can be
changed in ``/etc/shibboleth/shibboleth2.xml`` configuration file.

.. code-block:: xml

    <!-- The ApplicationDefaults element is where most of Shibboleth's SAML bits are defined. -->
        <ApplicationDefaults entityID=""
162 163 164 165 166 167 168 169 170
         REMOTE_USER="eppn persistent-id targeted-id">

.. warning::

 Changing ``mod_shib2`` ``REMOTE_USER`` to map to different shibboleth
 attributes will probably invalidate any existing shibboleth enabled users in
 astakos database. Those users won't be able to login to their existing accounts.

171 172 173
Finally, add 'shibboleth' in ``ASTAKOS_IM_MODULES`` list. The variable resides
inside the file ``/etc/synnefo/20-snf-astakos-app-settings.conf``

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
Twitter Authentication
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
176 177 178 179 180 181 182 183

To enable twitter authentication while signed in under a Twitter account,

Click Create an application.

Fill the necessary information and for callback URL give::

Efthymia Bika's avatar
Efthymia Bika committed
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed

Efthymia Bika's avatar
Efthymia Bika committed
186 187 188 189
Edit ``/etc/synnefo/20-snf-astakos-app-settings.conf`` and set the
corresponding variables ``ASTAKOS_TWITTER_TOKEN`` and
``ASTAKOS_TWITTER_SECRET`` to reflect your newly created pair.
Finally, add 'twitter' in ``ASTAKOS_IM_MODULES`` list.
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
190 191

Google Authentication
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
193 194 195 196 197 198

To enable google authentication while signed in under a Google account,

Under API Access select Create another client ID, select Web application,
expand more options in Your site or hostname section and in Authorized
Efthymia Bika's avatar
Efthymia Bika committed
Redirect URIs add::
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed

Efthymia Bika's avatar
Efthymia Bika committed
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed

Efthymia Bika's avatar
Efthymia Bika committed
203 204 205 206
Edit ``/etc/synnefo/20-snf-astakos-app-settings.conf`` and set the
corresponding variables ``ASTAKOS_GOOGLE_CLIENT_ID`` and
``ASTAKOS_GOOGLE_SECRET`` to reflect your newly created pair.
Finally, add 'google' in ``ASTAKOS_IM_MODULES`` list.
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed

208 209 210 211

Working with Astakos

212 213
User registration

When a new user signs up, he/she is not directly marked as active. You can see
his/her state by running (on the machine that runs the Astakos app):
217 218 219

.. code-block:: console

   $ snf-manage user-list

More detailed user status is provided in the `status` field of the `user-show`

.. code-block:: console

  $ snf-manage user-show <user-id>

229 230 231 232 233
  id                  : 6
  uuid                : 78661411-5eed-412f-a9ea-2de24f542c2e
  status              : Accepted/Active (accepted policy: manual)
  email               :

235 236 237
Based on the `astakos-app` configuration, there are several ways for a user to
get verified and activated in order to be able to login. We discuss the user
verification and activation flow in the following section.
238 239

User activation flow
240 241

242 243 244 245 246 247 248 249 250 251
A user can register for an account using the astakos signup form. Once the form
is submited successfully a user entry is created in astakos database. That entry
is passed through the astakos activation backend which handles whether the user
should be automatically verified and activated.

Email verification

The verification process takes place in order to ensure that the user owns the
email provided during the signup process. By default, after each successful
signup astakos notifies user with an verification url via email.
253 254 255

At this stage:

    * subsequent registrations invalidate and delete the previous registrations
257 258 259 260 261 262 263 264 265 266 267 268 269
      of the same email address.

    * in case user misses the initial notification, additional emails can be
      send either via the url which is prompted to the user if he tries to
      login, or by the administrator using the ``snf-manage user-activation-send
      <userid>`` command.

    * administrator may also enforce a user to get verified using the
      ``snf-manage user-modify --verify <userid>`` command.

Account activation

Once the user gets verified, it is time for Astakos to decide whether or not to
proceed through user activation process. If ``ASTAKOS_MODERATION_ENABLED``
setting is set to ``False`` (default value) user gets activated automatically.

In case the moderation is enabled Astakos may still automatically activate the
275 276 277 278 279
user in the following cases:

    * User email matches any of the regular expressions defined in
      ``ASTAKOS_RE_USER_EMAIL_PATTERNS`` (defaults to ``[]``)
    * User used a signup method (e.g. ``shibboleth``) for which automatic
      activation is enabled (see
281 282
      :ref:`authentication methods policies <auth_methods_policies>`).

If all of the above fail to trigger automatic activation, an email is sent to
284 285
the persons listed in ``ACCOUNT_NOTIFICATIONS_RECIPIENTS`` setting,
notifying that there is a new user pending for moderation and that it's up to
286 287 288
the administrator to decide if the user should be activated. The UI also shows
a corresponding 'pending moderation' message to the user. The administrator can
activate a user using the ``snf-manage user-modify`` command:
289 290 291 292 293 294 295 296 297

.. code-block:: console

    # command to activate a pending user
    $ snf-manage user-modify --accept <userid>

    # command to reject a pending user
    $ snf-manage user-modify --reject --reject-reason="spammer" <userid>

298 299
Once the activation process finishes, a greeting message is sent to the user
email address and a notification for the activation to the persons listed in
``ACCOUNT_NOTIFICATIONS_RECIPIENTS`` setting. Once activated the user is
able to login and access the Synnefo services.
302 303 304 305 306

Additional authentication methods

Astakos supports third party logins from external identity providers. This
can be usefull since it allows users to use their existing credentials to
308 309 310 311 312 313 314 315 316 317 318 319 320
login to astakos service.

Currently astakos supports the following identity providers:

    * `Shibboleth <>`_ (module name
    * `Google <>`_ (module
      name ``google``)
    * `Twitter <>`_ (module name ``twitter``)
    * `LinkedIn <>`_
      (module name ``linkedin``)

To enable any of the above modules (by default only ``local`` accounts are
Efthymia Bika's avatar
Efthymia Bika committed
321 322 323 324 325
allowed) you have to install oauth2 package. To do so run::

    apt-get install python-oauth2

Then retrieve and set the required provider settings and append the
326 327 328 329 330 331 332
module name in ``ASTAKOS_IM_MODULES``.

.. code-block:: python

    # settings from

334 335 336 337 338 339 340 341
    # let users signup and login using their google account
    ASTAKOS_IM_MODULES = ['local', 'google']

.. _auth_methods_policies:

Authentication method policies

342 343
Astakos allows you to override the default policies for each enabled provider
separately by adding the approriate settings in your ``.conf`` files in the
344 345 346 347 348 349
following format:


Available policies are:

350 351
    * **CREATE** Users can signup using that provider (default: ``True``)
    * **REMOVE/ADD** Users can remove/add login method from their profile
352 353 354 355 356 357
      (default: ``True``)
    * **AUTOMODERATE** Automatically activate users that signup using that
      provider (default: ``False``)
    * **LOGIN** Whether or not users can use the provider to login (default:

e.g. to enable automatic activation for your academic users, while keeping
359 360 361 362 363 364 365
locally signed up users under moderation you can apply the following settings.

.. code-block:: python


366 367 368 369 370 371 372 373 374 375 376 377 378 379
User login

During the logging procedure, the user is authenticated by the respective
identity provider.

If ``ASTAKOS_RECAPTCHA_ENABLED`` is set and the user fails several times
(``ASTAKOS_RATELIMIT_RETRIES_ALLOWED`` setting) to provide the correct
credentials for a local account, he/she is then prompted to solve a captcha

Upon success, the system renews the token (if it has expired), logins the user
and sets the cookie, before redirecting the user to the ``next`` parameter

381 382
Projects and quota

384 385 386 387 388 389
Synnefo supports granting resources and controling their quota through the
mechanism of *projects*. A project is considered as a pool of finite
resources. Every actual resources allocated by a user (e.g. a Cyclades VM or
a Pithos container) is also assigned to a project where the user is a
member to. For each resource a project specifies the maximum amount that can
be assigned to it and the maximum amount that a single member can assign to it.

391 392
Default quota

Upon user creation, a special purpose user-specific project is automatically
created in order to hold the quota provided by the system. These *system*
projects are identified with the same UUID as the user.

To inspect the quota that future users will receive by default through their
base projects, check column ``system_default`` in::

   # snf-manage resource-list

You can modify the default system quota limit for all future users with::

   # snf-manage resource-modify <resource_name> --system-default <value>

407 408 409 410 411 412 413 414 415 416
You can also control the default quota a new project offers to its members
if a limit is not specified in the project application (`project default`).
In particular, if a resource is not meant to be visible to the end user,
then it's best to set its project default to infinite.

.. code-block:: console

    # snf-manage resource-modify cyclades.total_ram --project-default inf

417 418
Grant extra quota through projects

420 421 422
A user can apply for a new project through the web interface or the API.
Once it is approved by the administrators, the applicant can join the
project and let other users in too.

424 425
A project member can make use of the quota granted by the project by
specifying this particular project when creating a new quotable entity.

427 428 429 430 431
Note that quota are not accumulative: in order to allocate a 100GB disk,
one must be in a project that grants at least 100GB; it is not possible to
add up quota from different projects. Note also that if allocating an entity
requires multiple resources (e.g. cpu and ram for a Cyclades VM) these must
be all assigned to a single project.

433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
Reclaiming resources

When a project is deactivated or a user is removed from a project, the quota
that have been granted to the user are revoked. If the user still owns
resources assigned to the project, the user quota appear overlimit on that
project. The services are responsible to inspect the overquota state of
users and reclaim their resources. For instance, cyclades provides
the management command ``enforce-resources-cyclades`` to reclaim VMs,
volumes, and floating IPs.

When a user is deactivated, their system project, owned projects and project
memberships are suspended. Subsequently, the user's resources can be
reclaimed as explained above.

449 450
Control projects
451 452 453 454 455 456 457 458 459 460 461 462 463 464

To list pending project applications in astakos::

    # snf-manage project-list --pending

Note the last column, the application id. To approve it::

    # <app id> from the last column of project-list
    # snf-manage project-control --approve <app id>

To deny an application::

    # snf-manage project-control --deny <app id>

465 466 467 468 469 470 471 472 473
Before taking an action, on can inspect project status, settings and quota
limits with::

   # snf-manage project-show <project-uuid>

For an initialized project, option ``--quota`` also reports the resource

Users designated as *project admins* can approve or deny
474 475 476 477 478
an application through the web interface. In
``20-snf-astakos-app-settings.conf`` set::

    # UUIDs of users that can approve or deny project applications from the web.
    ASTAKOS_PROJECT_ADMINS = [<uuid>, ...]

480 481 482 483 484 485 486
Set quota limits

One can change the quota limits of an initialized project with::

   # snf-manage project-modify <project-uuid> --limit <resource_name> <member_limit> <project_limit>

487 488
One can set system quota for all accepted users (that is, set limits for system
projects), with possible exceptions, with::

   # snf-manage project-modify --all-system-projects --exclude <uuid1>,<uuid2> --limit ...
491 492 493 494 495 496 497

Quota for a given resource are reported for all projects that the user is
member in with::

   # snf-manage user-show <user-uuid> --quota

With option ``--projects``, owned projects and memberships are also reported.

499 500 501 502 503 504 505 506 507 508 509 510
Astakos advanced operations

Adding "Terms of Use"

Astakos supports versioned terms-of-use. First of all you need to create an
html file that will contain your terms. For example, create the file
``/usr/share/synnefo/sample-terms.html``, which contains the following:

.. code-block:: console

   <h1>My cloud service terms</h1>

   These are the example terms for my cloud service
514 515 516 517 518 519 520 521 522 523

Then, add those terms-of-use with the snf-manage command:

.. code-block:: console

   $ snf-manage term-add /usr/share/synnefo/sample-terms.html

Your terms have been successfully added and you will see the corresponding link
appearing in the Astakos web pages' footer.

524 525 526 527 528 529 530 531 532
During the account registration, if there are approval terms, the user is
presented with an "I agree with the Terms" checkbox that needs to get checked
in order to proceed.

In case there are new approval terms that the user has not signed yet, the
``signed_terms_required`` view decorator redirects to the ``approval_terms``
view, so the user will be presented with the new terms the next time he/she

533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
Enabling reCAPTCHA

Astakos supports the `reCAPTCHA <>`_ feature.
If enabled, it protects the Astakos forms from bots. To enable the feature, go
to and create your own reCAPTCHA
key pair. Then edit ``/etc/synnefo/20-snf-astakos-app-settings.conf`` and set
the corresponding variables to reflect your newly created key pair. Finally, set
the ``ASTAKOS_RECAPTCHA_ENABLED`` variable to ``True``:

.. code-block:: console

   ASTAKOS_RECAPTCHA_PUBLIC_KEY = 'example_recaptcha_public_key!@#$%^&*('
   ASTAKOS_RECAPTCHA_PRIVATE_KEY = 'example_recaptcha_private_key!@#$%^&*('


Restart the service on the Astakos node(s) and you are ready:

.. code-block:: console

   # /etc/init.d/gunicorn restart

Checkout your new Sign up page. If you see the reCAPTCHA box, you have setup
everything correctly.


560 561 562 563 564 565 566 567 568
Astakos internals


Alice requests a specific resource from a cloud service e.g.: Pithos. In the
request she supplies the `X-Auth-Token` to identify whether she is eligible to
perform the specific task. The service contacts Astakos through its
``/account/v1.0/authenticate`` api call
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
providing the specific ``X-Auth-Token``. Astakos checkes whether the token
belongs to an active user and it has not expired and returns a dictionary
containing user related information. Finally the service uses the ``uniq``
field included in the dictionary as the account string to identify the user
accessible resources.

.. _authentication-label:

Django Auth methods and Backends

Astakos incorporates Django user authentication system and extends its User model.

Since username field of django User model has a limitation of 30 characters,
AstakosUser is **uniquely** identified by the ``email`` instead. Therefore,
```` is served to authenticate a
user using email if the first argument is actually an email, otherwise tries
the username.

A new AstakosUser instance is assigned with a uui as username and also with a
``auth_token`` used by the cloud services to authenticate the user.
```` is also specified in order
to authenticate the user using the email and the token fields.

Logged on users can perform a number of actions:

 * access and edit their profile via: ``/im/profile``.
 * change their password via: ``/im/password``
 * send feedback for grnet services via: ``/im/send_feedback``
 * logout (and delete cookie) via: ``/im/logout``

Internal Astakos requests are handled using cookie-based Django user sessions.

External systems should forward to the ``/login`` URI. The server,
depending on its configuration will redirect to the appropriate login page.
When done with logging in, the service's login URI should redirect to the URI
provided with next, adding user and token parameters, which contain the email
and token fields respectively.

The login URI accepts the following parameters:

======================  =========================
Request Parameter Name  Value
======================  =========================
next                    The URI to redirect to when the process is finished
renew                   Force token renewal (no value parameter)
force                   Force logout current user (no value parameter)
======================  =========================

External systems inside the ``ASTAKOS_COOKIE_DOMAIN`` scope can acquire the
user information by the cookie identified by ``ASTAKOS_COOKIE_NAME`` setting
(set during the login procedure).

Finally, backend systems having acquired a token can use the
'authenticate-api-label' API call from a private network or through HTTPS.
625 626

File/Object Storage Service (Pithos+)
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696

Pithos+ is the Synnefo component that implements a storage service and exposes
the associated OpenStack REST APIs with custom extensions.

Pithos+ advanced operations

Enable separate domain for serving user content

Since Synnefo v0.15, there is a possibility to serve untrusted user content
in an isolated domain.

Enabling this feature consists of the following steps:

#. **Declare new domain in apache server**

   In order to enable the apache server to serve several domains it is required
   to setup several virtual hosts.
   Therefore, for adding the new domain e.g. "", append
   the following in ``/etc/apache2/sites-available/synnefo-ssl``:

    .. code-block:: console

        <VirtualHost _default_:443>

            Alias /static "/usr/share/synnefo/static"

            #  SetEnv no-gzip
            #  SetEnv dont-vary

           AllowEncodedSlashes On

           RequestHeader set X-Forwarded-Protocol "https"

        <Proxy * >
            Order allow,deny
            Allow from all

            SetEnv                proxy-sendchunked
            SSLProxyEngine        off
            ProxyErrorOverride    off

            ProxyPass        /static !
            ProxyPass        / http://localhost:8080/ retry=0
            ProxyPassReverse / http://localhost:8080/

            RewriteEngine On
            RewriteCond %{THE_REQUEST} ^.*(\\r|\\n|%0A|%0D).* [NC]
            RewriteRule ^(.*)$ - [F,L]

            SSLEngine on
            SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
            SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

    .. note:: Consider also to purchase and install a certificate for the new

    Finally, restart the apache server::

        pithos-host$ /etc/init.d/apache2 restart

#. **Register Pithos+ as an OAuth2 client in Astakos**

   Starting from Synnefo version 0.15, in order to view the content of a
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742
   protected resource, Pithos+ (on behalf of the user) has to be granted
   authorization for the specific resource by Astakos.

   During the authorization grant procedure, Pithos+ has to authenticate
   itself with Astakos since the latter has to prevent serving requests by
   unknown/unauthorized clients.

   Therefore, in the installation guide you were guided to register Pithos+
   as an OAuth2 client in Astakos.

   .. note:: You can see the registered clients by running::
    astakos-host$ snf-manage oauth2-client-list -o identifier,redirect_urls,is_trusted

   However, requests originated from the new domain will be rejected since
   Astakos is ignorant about the new domain.

   Therefore, you need to register a new client pointing to the unsafe domain.
   To do so, use the following command::

        astakos-host$ snf-manage oauth2-client-add pithos-unsafe-domain --secret=<secret> --is-trusted --url

   .. note:: You can also unregister the client pointing to the safe domain,
       since it will no longer be useful.
       To do so, run the following::

        astakos-host$ snf-manage oauth2-client-remove pithos-view

#. **Update Pithos+ configuration**

   Respectively, the ``PITHOS_OAUTH2_CLIENT_CREDENTIALS`` setting should be
   updated to contain the credentials of the client registered in the previous

   Furthermore, you need to restrict all the requests for user content
   to be served exclusively by the unsafe domain.

   To enable this, set the ``PITHOS_UNSAFE_DOMAIN`` setting to the value
   of the new domain e.g. ""

   Finally, restart the gunicorn server::

        pithos-host$ /etc/init.d/gunicorn restart

743 744
.. _select_pithos_storage:

745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
Pithos storage backend

Starting from Synnefo version 0.16, we introduce Archipelago as the new storage
backend. Archipelago will act as a storage abstraction layer between Pithos and
NFS, RADOS or any other storage backend driver that Archipelago supports. For
more information about backend drivers please check Archipelago documentation.

Since this version care must be taken when restarting Archipelago on a Pithos
worker node. Pithos acts as an Archipelago peer and must be stopped first
before trying to restart Archipelago for any reason.

If you need to restart Archipelago on a running Pithos worker follow the
procedure below::

    pithos-host$ /etc/init.d/gunicorn stop
    pithos-host$ /etc/init.d/archipelago restart
    pithos-host$ /etc/init.d/gunicorn start


765 766 767
Compute/Network/Image Service (Cyclades)

768 769 770 771 772 773 774 775 776

Cyclades is the Synnefo component that implements Compute, Network and Image
services and exposes the associated OpenStack REST APIs. By running Cyclades
you can provide a cloud that can handle thousands of virtual servers and

Cyclades does not include any virtualization software and knows nothing about
Alex Pyrgiotis's avatar
Alex Pyrgiotis committed
the low-level VM management operations, e.g. the handling of VM creation or
778 779 780 781 782 783 784 785 786 787 788 789 790 791
migrations among physical nodes. Instead, Cyclades is the component that
handles multiple Ganeti backends and exposes the REST APIs. The administrator
can expand the infrastructure dynamically either by adding more Ganeti nodes
or by adding new Ganeti clusters. Cyclades issue VM control commands to Ganeti
via Ganeti's remote API and receive asynchronous notifications from Ganeti
backends whenever the state of a VM changes, due to Synnefo- or
administrator-initiated commands.

Cyclades is the action orchestrator and the API layer on top of multiple Ganeti
clusters. By this decoupled design, Ganeti cluster are self-contained and
the administrator has complete control on them without Cyclades knowing about
it. For example a VM migration to a different physical node is transparent
to Cyclades.

792 793 794
Working with Cyclades

795 796
Flavors and Volume Types
797 798 799 800 801 802 803 804

When creating a VM, the user must specify the `flavor` of the virtual server.
Flavors are the virtual hardware templates, and provide a description about
the number of CPUs, the amount of RAM, and the size of the disk of the VM.
Besides the size of the disk, Cyclades flavors describe the storage backend
that will be used for the virtual server.

Flavors are created by the administrator and the user can select one of the
805 806
available flavors. After VM creation, the user can resize his VM, by
adding/removing CPU and RAM.

808 809 810
Cyclades support different storage backends that are described by the `volume
type` of the flavor. Each volume type contains a `disk template` attribute
which is mapped to Ganeti's instance `disk template`.
811 812 813 814 815 816 817 818 819 820 821 822
Currently the available disk templates are the following:

* `file`: regulars file
* `sharedfile`: regular files on a shared directory, e.g. NFS
* `plain`: logical volumes
* `drbd`: drbd on top of lvm volumes
* `rbd`: rbd volumes residing inside a RADOS cluster
* `ext`: disks provided by an external shared storage.

  - `ext_archipelago`: External shared storage provided by
    `Archipelago <>`_.

823 824 825 826 827 828 829 830
Volume types are created by the administrator using the `snf-manage
volume-type-create` command and providing the `disk template` and a
human-friendly name:

.. code-block:: console

 $ snf-manage volume-type-create --disk-template=drbd --name=DRBD

831 832
Flavors are created by the administrator using `snf-manage flavor-create`
command. The command takes as argument number of CPUs, amount of RAM, the size
of the disks and the volume type IDs and creates the flavors that belong to the
cartesian product of the specified arguments. For example, the following
command will create two flavors of `40G` disk size of volume type with ID `1`,
836 837 838 839
`4G` RAM and `2` or `4` CPUs.

.. code-block:: console

  $ snf-manage flavor-create 2,4 4096 40 1

842 843
To see the available flavors, run `snf-manage flavor-list` command. The
administrator can delete a flavor by using `flavor-modify` command:
844 845 846

.. code-block:: console

  $ snf-manage flavor-modify --deleted=True <flavor_id>

849 850 851 852 853 854 855 856 857 858 859
Finally, the administrator can set if new servers can be created from a flavor
or not, by setting the `allow_create` attribute:

.. code-block:: console

  $ snf-manage flavor-modify --allow-create=False <flavor_id>

Flavors that are marked with `allow_create=False` cannot be used by users to
create new servers. However, they can still be used to resize existing VMs.

860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875

When creating a VM the user must also specify the `image` of the virtual
server. Images are the static templates from which VM instances are
initiated. Cyclades uses Pithos to store system and user-provided images,
taking advantage of all Pithos features, like deduplication and syncing
protocol. An image is a file stored to Pithos with additional metadata that
are describing the image, e.g. the OS family or the root partition. To create
a new image, the administrator or the user has to upload it a file to Pithos,
and then register it as an Image with Cyclades. Then the user can use this
image to spawn new VMs from it.

Images can be private, public or shared between users, exactly like Pithos
files. Since user-provided public images can be untrusted, the administrator
can denote which users are trusted by adding them to the
``UI_SYSTEM_IMAGES_OWNERS`` setting in the
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898
`/etc/synnefo/20-snf-cyclades-app-ui.conf` file. Images of those users are
properly displayed in the UI.

When creating a new VM, Cyclades pass the location of the image and it's
metadata to Ganeti. After Ganeti creates the instance's disk, `snf-image`
will copy the image to the new disk and perform the image customization
phase. During the phase, `snf-image` sends notifications to Cyclades about
the progress of the image deployment and customization. Customization includes
resizing the root file system, file injection (e.g. SSH keys) and setting
a custom hostname. For better understanding of `snf-image` read the
corresponding `documentation

For passing sensitive data about the image to Ganeti, like the VMs password,
Cyclades keeps all sensitive data in memory caches (memcache) and never allows
them to hit the disk. The data are exposed to `snf-image` via an one-time URL
that is exposed from the `vmapi` application. So, instead of passing sensitive
data to `snf-image` via Ganeti, Cyclades pass an one-time configuration URL
that contains a random UUID. After `snf-image` gets the sensitive data, the
URL is invalidated so no one else can access them.

The administrator can register images, exactly like users, using a system user
(a user that is defined in the ``UI_SYSTEM_IMAGES_OWNERS`` setting). For
900 901 902 903 904 905
example, the following command will register the
`pithos://u53r-un1qu3-1d/images/debian_base-6.0-7-x86_64.diskdump` as an
image to Cyclades:

.. code-block:: console

 $ kamaki image register --name="Debian Base" \
        --location=pithos://u53r-un1qu3-1d/images/debian_base-6.0-7-x86_64.diskdump \
908 909 910 911 912 913 914 915 916 917
        --public \
        --disk-format=diskdump \
        --property OSFAMILY=linux --property ROOT_PARTITION=1 \
        --property description="Debian Squeeze Base System" \
        --property size=451 --property kernel=2.6.32 --property GUI="No GUI" \
        --property sortorder=1 --property USERS=root --property OS=debian

Deletion of an image is done via `kamaki image unregister` command, which will
delete the Cyclades Images but will leave the Pithos file as is (unregister).

Apart from using `kamaki` to see and handle the available images, the
administrator can use `snf-manage image-list` and `snf-manage image-show`
commands to list and inspect the available public images. Also, the `--user`
921 922
option can be used the see the images of a specific user.

923 924 925 926 927 928 929 930 931 932 933
Custom image listing sections

Since Synnefo 0.16.2, the installation wizard supports custom image listing
sections. Images with the ``LISTING_SECTION`` image property set, and whose
owner uuid is listed in the ``UI_IMAGE_LISTING_USERS`` Cyclades setting (in
``/etc/synnefo/20-snf-cyclades-app-ui.conf``) will be displayed in a separate
section in the installation wizard. The name of the new section will be the
value of the ``LISTING_SECTION`` image property.

934 935 936 937 938 939 940 941 942 943 944 945
Virtual Servers

As mentioned, Cyclades uses Ganeti for management of VMs. The administrator can
handle Cyclades VMs just like any other Ganeti instance, via `gnt-instance`
commands. All Ganeti instances that belong to Synnefo, are separated from
others, by a prefix in their names. This prefix is defined in
``BACKEND_PREFIX_ID`` setting in

Apart from handling Cyclades VM at the Ganeti level, the administrator can
also use the `snf-manage server-*` commands. These command cover the most
jbd's avatar
jbd committed
common tasks that are relative with VM handling. Below we describe some
947 948 949 950 951 952 953 954 955 956 957
of them, but for more information you can use the `--help` option of all
`snf-manage server-* commands`. These command cover the most

The `snf-manage server-create` command can be used to create a new VM for some
user. This command can be useful when the administrator wants to test Cyclades
functionality without starting the API service, e.g. after an upgrade. Also, by
using `--backend-id` option, the VM will be created in the specified backend,
bypassing automatic VM allocation.

.. code-block:: console

958 959
 $ snf-manage server-create --flavor=1 --image=fc0f6858-f962-42ce-bf9a-1345f89b3d5e \
    --user=7cf4d078-67bf-424d-8ff2-8669eb4841ea --backend-id=2 \
960 961
    --password='example_passw0rd' --name='test_vm'

The above command will create a new VM for user
963 964 965 966 967 968 969 970 971 972 973 974 975 976
`7cf4d078-67bf-424d-8ff2-8669eb4841ea` in the Ganeti backend with ID 2. By
default this command will issue a Ganeti job to create the VM
(`OP_INSTANCE_CREATE`) and return. As in other commands, the `--wait=True`
option can be used in order to wait for the successful completion of the job.

`snf-manage server-list` command can be used to list all the available servers.
The command supports some useful options, like listing servers of a user,
listing servers that exist in a Ganeti backend and listing deleted servers.
Also, as in most of `*-list` commands, the `--filter-by` option can be used to
filter the results. For example, the following command will only display the
started servers of a specific flavor:

.. code-block:: console

 $ snf-manage server-list --filter-by="operstate=STARTED,flavor=<flavor_id>"
978 979 980 981 982 983 984 985 986 987 988

Another very useful command is the `server-inspect` command which will display
all available information about the state of the server in DB and the state
of the server in the Ganeti backend. The output will give you an easy overview
about the state of the VM which can be useful for debugging.

Also the administrator can `suspend` a user's VM, using the `server-modify`

.. code-block:: console

 $ snf-manage server-modify --suspended=True <server_id>
990 991 992 993 994 995

The user is forbidden to do any action on an administratively suspended VM,
which is useful for abuse cases.

Ganeti backends

997 998 999
Since v0.11, Synnefo is able to manage multiple Ganeti clusters (backends)
making it capable to scale linearly to tens of thousands of VMs. Backends
can be dynamically added or removed via `snf-manage` commands.

1001 1002 1003 1004
Each newly created VM is allocated to a Ganeti backend by the Cyclades backend
allocator. The VM is "pinned" to this backend, and can not change through its
lifetime. The backend allocator decides in which backend to spawn the VM based
on the available resources of each backend, trying to balance the load between
1005 1006
them. Also, Networks are created to all Ganeti backends, in order to ensure
that VMs residing on different backends can be connected to the same networks.

1008 1009 1010 1011 1012 1013 1014
A backend can be marked as `drained` in order to be excluded from automatic
servers allocation and not receive new servers. Also, a backend can be marked
as `offline` to denote that the backend is not healthy (e.g. broken master)
and avoid the penalty of connection timeouts.

Finally, Cyclades is able to manage Ganeti backends with different enabled
hypervisors (`kvm`, `xen`), and different enabled disk templates.

1016 1017 1018
Listing existing backends
To list all the Ganeti backends known to Synnefo, we run:
Christos Stavrakakis's avatar
Christos Stavrakakis committed

1020 1021 1022 1023 1024
.. code-block:: console

   $ snf-manage backend-list

Adding a new Ganeti backend
Christos Stavrakakis's avatar
Christos Stavrakakis committed
1026 1027
Backends are dynamically added under the control of Synnefo with `snf-manage
backend-add` command. In this section it is assumed that a Ganeti cluster,
1028 1029
named ```` is already up and running and configured to be
able to host Synnefo VMs.

To add this Ganeti cluster, we run:
Christos Stavrakakis's avatar
Christos Stavrakakis committed

1033 1034 1035 1036
.. code-block:: console

   $ snf-manage backend-add --user="synnefo_user" --pass="synnefo_pass"

1037 1038
where ``clustername`` is the Cluster hostname of the Ganeti cluster, and
``user`` and ``pass`` are the credentials for the `Ganeti RAPI user
<>`_.  All
1040 1041
backend attributes can be also changed dynamically using the `snf-manage
backend-modify` command.

``snf-manage backend-add`` will also create all existing public networks to
1044 1045
the new backend. You can verify that the backend is added, by running
`snf-manage backend-list`.

Note that no VMs will be spawned to this backend, since by default it is in a
1048 1049
``drained`` state after addition in order to manually verify the state of the

1051 1052
So, after making sure everything works as expected, make the new backend active
by un-setting the ``drained`` flag. You can do this by running:
1053 1054 1055

.. code-block:: console

   $ snf-manage backend-modify --drained=False <backend_id>

1058 1059 1060 1061 1062 1063
Allocation of VMs in Ganeti backends
As already mentioned, the Cyclades backend allocator is responsible for
allocating new VMs to backends. This allocator does not choose the exact Ganeti
node that will host the VM but just the Ganeti backend. The exact node is
chosen by the Ganeti cluster's allocator (hail).
1064 1065 1066 1067

The decision about which backend will host a VM is based on the available
resources. The allocator computes a score for each backend, that shows its load
factor, and the one with the minimum score is chosen. The admin can exclude
backends from the allocation phase by marking them as ``drained`` by running:
Christos Stavrakakis's avatar
Christos Stavrakakis committed

1070 1071
.. code-block:: console

   $ snf-manage backend-modify --drained=True <backend_id>
1073 1074

The backend resources are periodically updated, at a period defined by
1075 1076 1077 1078
the ``BACKEND_REFRESH_MIN`` setting, or by running `snf-manage
backend-update-status` command. It is advised to have a cron job running this
command at a smaller interval than ``BACKEND_REFRESH_MIN`` in order to remove
the load of refreshing the backends stats from the VM creation phase.

1080 1081 1082
Finally, the admin can decide to have a user's VMs being allocated to a
specific backend, with the ``BACKEND_PER_USER`` setting. This is a mapping
between users and backends. If the user is found in ``BACKEND_PER_USER``, then
1083 1084
Synnefo allocates all his/hers VMs to the specific backend in the variable,
even if is marked as drained (useful for testing).

1086 1087
.. _alloc_disk_templates:

1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
Allocation based on disk-templates

Besides the available resources of each Ganeti backend, the allocator takes
into consideration the disk template of the instance when trying to allocate it
to a Ganeti backend. Specifically, the allocator checks if the flavor of the
instance belongs to the available disk templates of each Ganeti backend.

A Ganeti cluster has a list of enabled disk templates
(`--enabled-disk-templates`) and a list of allowed disk templates for new
instances (`--ipolicy-disk-templates`). See the `gnt-cluster` manpage for more
details about these options.

When Synnefo allocates an instance, it checks whether the disk template of the
new instance belongs both in the enabled and ipolicy disk templates. You can
see the list of the available disk-templates by running `snf-manage
backend-list`. This list should be updated automatically after changing
these options in Ganeti and it can also be updated by running `snf-manage

So the administrator, can route instances on different backends based on their
flavor disk template, by modifying the enabled or ipolicy disk templates of
each backend.  Also, the administrator can route instances between different
nodes of the same Ganeti backend, by modifying the same options at the
nodegroup level (see `gnt-group` manpage for mor details).

1114 1115 1116 1117 1118 1119
Allocation based on custom allocator

In order to determine which ganeti cluster is best for allocating a
virtual machine, the allocator uses two methods:

1120 1121
- `filter_backends`
- `allocate`
1122 1123 1124 1125

The `filter_backends` method is used to filter the backends that the allocator
shouldn't even consider. It takes two arguements:

1126 1127 1128
1. A list of the available backends. A backend is available if it is not drained
   or offline. Each backend is a django object and an instance of the `Backend`

1130 1131 1132 1133 1134
2. A map with 3 keys:

   - `ram`: The size of the memory we want to allocate on the backend.
   - `disk`: The size of the disk we want to allocate on the backend.
   - `cpu`: The size of the CPU we want to allocate on the backend.
1135 1136 1137 1138 1139

The `allocate` method returns the backend that will be used to allocate the virtual
machine. It takes two arguements:

1140 1141 1142 1143 1144
1. A list of the available backends. A backend is available if it is not
   drained or offline. Each backend is a django object and is an instance of
   the `Backend` model.

2. A map with 3 keys:

1146 1147 1148
    - `ram`: The size of the memory we want to allocate on the backend.
    - `disk`: The size of the disk we want to allocate on the backend.
    - `cpu`: The size of the CPU we want to allocate on the backend.
1149 1150 1151 1152 1153 1154 1155 1156

So the administrator can create his own allocation algorithm by creating a class
that inherits the `AllocatorBase` located at `synnefo.logic.allocators.base`,
and implements the above methods.

If the administrator wants synnefo to use his allocation algorithm he just has to change
the `BACKEND_ALLOCATOR_MODULE` setting to the path of his allocator class.

1157 1158 1159 1160 1161 1162 1163
Removing an existing Ganeti backend
In order to remove an existing backend from Synnefo, you must first make
sure that there are not active servers in the backend, and then run:

.. code-block:: console

   $ snf-manage backend-remove <backend_id>
1165 1166

1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
Virtual Networks

Cyclades also implements the Network service and exposes the Quantum Openstack
API. Cyclades supports full IPv4 and IPv6 connectivity to the public internet
for it's VMs. Also, Cyclades provides L2 and L3 virtual private networks,
giving the user freedom to create arbitraty network topologies of
interconnected VMs.

Public networking is desployment specific and must be customized based on the
specific needs of the system administrator. Private virtual networks can be
provided by different network technologies which are exposed as different
network flavors. For better understanding of networking please refer to the
:ref:`Network <networks>` section.

A Cyclades virtual network is an isolated Layer-2 broadcast domain. A network
can also have an associated IPv4 and IPv6 subnet representing the Layer-3
characteristics of the network. Each subnet represents an IP address block
that is used in order to assign addresses to VMs.

To connect a VM to a network, a port must be created, which represent a virtual
port on a network switch. VMs are connected to networks by attaching a virtual
interface to a port.

Cyclades also supports `floating IPs`, which are public IPv4 addresses that
can dynamically(hotplug-able) be added and removed to VMs. Floating IPs are
a quotable resource that is allocated to each user. Unlike other cloud
platforms, floating IPs are not implemented using 1-1 NAT to a ports private
IP. Instead, floating IPs are directly assigned to virtual interfaces of VMs.

Exactly like VMS, networks can be handled as Ganeti networks via `gnt-network`
commands. All Ganeti networks that belong to Synnefo are named with the prefix
`${BACKEND_PREFIX_ID}-net-`. Also, there are a number of `snf-manage` commands
Alex Pyrgiotis's avatar
Alex Pyrgiotis committed
1200 1201 1202
that can be used to handle `networks`, `subnets`, `ports` and `floating IPs`.
Below we will present a use case scenario using some of these commands. For
better understanding of these commands, refer to their help messages.
1203 1204 1205

Create a virtual private network for user
`7cf4d078-67bf-424d-8ff2-8669eb4841ea` using the `PHYSICAL_VLAN` flavor, which
jbd's avatar
jbd committed
means that the network will be uniquely assigned a physical VLAN. The network
is assigned an IPv4 subnet, described by it's CIDR and gateway. Also,
the `--dhcp=True` option is used, to make `nfdhcpd` response to DHCP queries
from VMs.

.. code-block:: console

 $ snf-manage network-create --user=7cf4d078-67bf-424d-8ff2-8669eb4841ea --name=prv_net-1 \
    --subnet= --gateway= --dhcp=True --flavor=PHYSICAL_VLAN

Inspect the state of the network in Cyclades DB and in all the Ganeti backends:

.. code-block:: console

  $ snf-manage network-inspect <network_id>

1222 1223 1224 1225 1226
Inspect the state of the network's subnet, containg an overview of the
subnet's IPv4 address allocation pool:

.. code-block:: console

  $ snf-manage subnet-inspect <subnet_id>

Connect a VM to the created private network. The port will automatically
1230 1231 1232
be assigned an IPv4 address from one of the network's available IPs. This
command will result in sending an `OP_INSTANCE_MODIFY` Ganeti command and
attaching a NIC to the specified Ganeti instance.

1234 1235
.. code-block:: console

 $ snf-manage port-create --network=<network_id> --server=<server_id>

Inspect the state of the the port in Cyclades DB and in the Ganeti backend:

.. code-block:: console

 $ snf-manage port-inspect <port_id>
1243 1244 1245 1246 1247

Disconnect the VM from the network and delete the network:

.. code-block:: console

1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
 $ snf-manage port-remove <port_id>
 $ snf-manage network-remove <network_id>

Enabling DHCP

When connecting a VM to a network, Cyclades will automatically assign an IPv4
address from the IPv4 or/and IPv6 subnets of the network. If the network has
no subnets, then it will not be assigned any IP address.

If the network has DHCP enabled, then `nfdhcpd` daemon, which must be running
on all Ganeti nodes, will respond to DHCP queries from VMs and assign to them
the IP address that was allocated by Cyclades. DCHP can be enabled/disabled
using the `--dhcp` option of `network-create` command.

Public network connectivity

Since v0.14, users are able to dynamically connect and disconnect their VMs
from public networks. In order to do that, they have to use a `floating IP`.
Floating IPs are basically public IPv4 addresses that can be dynamically
attached and detached from VMs. The user creates a floating IP address from a
network that has set the `floating_ip_pool` attribute. The floating IP is
accounted to the user, who can then connect his VMs to public networks by
creating ports that they are using this floating IP. Performing this work-flow
from `snf-manage` would look like this:

.. code-block:: console

 $ snf-manage network-list --filter-by="floating_ip_pool=True"
 id      name  user.uuid   state  public  subnet.ipv4  gateway.ipv4  drained  floating_ip_pool
  1  Internet       None  ACTIVE    True    False              True

 $ snf-manage floating-ip-create --user=7cf4d078-67bf-