• This repository has been archived on 26/Mar/2021
  • Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED - The application that powers Gandi's Status website (status.gandi.net).

DEPRECATED.

This project is deprecated and will not receive new features or fixes. Use it at your own risks.

Gandi Baobab

The application that powers Gandi's Status website (status.gandi.net).

OVERVIEW

Baobab is a Python and web application divided into 3 parts:

  • a Django-powered back-end (./baobab/backoffice and ./baobab/translate)
  • a REST API (./baobab/apirest)
  • a web client that uses the REST API (./baobab.front)

It has 5 app namespaces that allow you to work (test, migrate, etc.) on specific parts: backoffice, apirest, rss, translate and socialnetwork.

Baobab requires a database and supports SQLite, PostgreSQL or MySQL.

Node.js and npm are required to build the web client app.

Cron jobs are used to publish Tweets and close events on a schedule.

DEVELOPMENT

INSTALLATION

Clone the repository and enter the local directory that was just created.

We recommend using virtualenv to manage local python environments.

$ virtualenv /some/directory/virtual
$ source /some/directory/virtual/bin/activate
$ python setup.py install

A $ baobab command should be available after install. Otherwise, please try to use it from the installation directory:

$ cd /some/directory/virtual/lib/python2.7/dist-packages/baobab/bin
$ ./cmd_baobab.py <...>

This can be caused by an error in django-tastypie's setup.py distributed in the Debian package.

Note for Gnome users: A "baobab" command can already exist in your system (Disk Usage Analyzer), so make sure you use virtualenv as recommended.

APPLICATION SETTINGS

The settings file is located in ./baobab/settings.py. Make sure you edit this file to setup your installation.

In it, you can define some default data such user and admin accounts, as well as important options such as the SECRET_KEY, default time zones or to change DEBUG=False when not in development.

For production (actually, whenever DEBUG is not True) you need to authorize your hosts by editing ALLOWED_HOSTS = [].

More information on Django settings can be found in the docs.

Using a custom settings file

For example, create a Python package at /etc/baobab/__init__.py and your settings module file at /etc/baobab/settings.py.

You can make sure your package will be in your Python's path by exporting it

$ export PYTHONPATH=/etc

Then you can use the --settings flag, like so:

$ baobab <command> --settings baobab.settings

Alternatively, you can set Django's buit-in environment variable

$ export DJANGO_SETTINGS_MODULE=baobab.settings
$ baobab <command>

BUILD THE WEB CLIENT

Install the web client's dependencies and build the app

$ npm install
$ npm run dev

SETUP THE DATABASE

Load the schema and create the default data

$ baobab setup-dev

By default, a SQLite database file will be created at ./baobab/default.db if it doesn't exist.

LAUNCH THE SERVER

To launch the web server with the admin interface and REST API :

$ baobab runserver

Or $ ./baobab/bin/cmd_baobab.py runserver if you've built the debian package.

Open your browser at http://localhost:8000/ to see the website. The admin page is accessible at http://localhost:8000/admin.

API USAGE

In addition to the web client, Baobab is also usable via a REST API that delivers content in JSON format.

The API is self-described, so you can start exploring it by making a simple request to the main endpoint.

Example:

$ curl http://localhost:8000/api | python -m json.tools

{
    "events": {
        "list_endpoint": "/api/events",
        "schema": "/api/events/schema"
    },
    "services": {
        "list_endpoint": "/api/services",
        "schema": "/api/services/schema"
    },
    "status": {
        "list_endpoint": "/api/status",
        "schema": "/api/status/schema"
    }
}

UPDATING THE DATABASE MODEL

Follow this simple process to modify the database structure. Migrations are managed with South.

  1. Modify the application's models
  2. Create schema migration files
  3. Create data migration files if necessary
  4. Apply the migrations

Changing the model

Update models.py in the appropriate app folder to add / remove fields and/or tables (for example ./baobab/backoffice/models.py).

Creating a schema migration

$ baobab schemamigration <namespace> --auto

Tip: Remember to use db.rename_column in a migration script to rename a field.

Creating a data migration

$ baobab datamigration <namespace> <data_migration_name>

Running migrations

$ baobab migrate  

Tip: when switching branches, you might forget to rollback or apply relevant migrations. You can avoid that by adding a git hook. See some examples in./misc/hooks/*.

OVERRIDING THE DEFAULT USER

You can override the default user login credentials by setting the DEFAULT_USER_LOGIN and DEFAULT_USER_PASSWORD variables.

If these variables are not set when the setup scripts are run, you will be prompted to create a default user.

Social network integrations: Twitter, IRC, etc.

Custom integrations

At the moment baobab can publish status updates to Twitter and IRC, but you can easily add your own integrations. You only need to create a new class in the socialnetwork app and inherit from the SocialNetworkBase class.

Each social network has its own configuration. Please take a look at the settings.py file for more information.

Upon the creation of an Event, a status update will be immediately published to each configured integration.

Maintenance

When the event is of the Maintenance type, baobab can publish a status update automatically at the estimated start date. Simply create a cron task to execute $ baobad social_network to achieve this.

TRANSLATIONS

You can easily translate content published with Baobab and retrieve translated content via the API.

Special user permissions can be granted for translators (add them into the "translate" group), and the translation interface is available in the backoffice at http://localhost:8000/admin/translate.`

Note: The "translate" group might be missing the real permissions: just add all the permissions about the "translate" app.

You can then retrieve translated content by adding the "Accept-Language" header to your API requests. If you don't, Baobab automatically falls back to English (the default language).

For example:

curl -H "Accept-Language: fr" http://localhost:8000/api/events

Please note that while the web client can consume translated content (browsers will automatically send the Accept-Language header according to the user's language), the web interface itself is not localised (nor localisable in the current state of the implementation).

TESTING

You can run unit tests on specific namespaces or the whole app. No configuration is necessary for this.

$ baobab test <namespace>

Note the translate namespace has no dedicated testing suite. The translation features are tested within the apirest namespace.

PRODUCTION USAGE

In a production environment, you'll want to use different settings and technologies to better serve your app securily at scale.

We use Gunicorn as the app server, along with Nginx to proxy HTTP requests, instead of just running Django's webserver.

An example Gunicorn config for Baobab could look like this:

CONFIG = {
    'working_dir': '/srv/baobab',
    'environment': {
        'DJANGO_SETTINGS_MODULE': 'myown.settings',
        'PYTHONPATH': '/etc/'
    },
    'args': (
        '--bind=127.0.0.1:8008',
        '--workers=4',
        '--timeout=10',
        'baobab.wsgi:application',
    ),
}

Your production-ready settings file would then reside in /etc/myown/settings.py, along with the Python package file /etc/myown/__init__.py.

Also check the nginx/sites-available/ folder for our sample Nginx configuration files.

You could also use MySQL or PostgreSQL as database backends instead of SQLite, for example.

Manual deploy

After copying the application files to the server, install the web client's dependencies and build it for release (repeat whenever these assets change)

$ npm install
$ NODE_ENV=production npm run release

Then, setup the database and run migrations (repeat whenever the model changes)

$ baobab syncdb

Now you can start or restart your chosen webserver solution.

Debian package

Baobab can also be built into a Debian package, which is useful for production deployments on compatible systems. Gandi's own packaging details can be found in the debian/ folder.

To build the package:

$ debuild -us -uc -b || dpkg-buildpackage -us -uc -b

You can then place it on a Production server and install it. All scripts will be automatically launched. You can then start or restart the app and web servers.

CONTRIBUTING

Create issues

Any major changes should be documented as a GitHub issue before you start working on it.

Proposing your changes

Don't hesitate -- we appreciate every contribution, no matter how small.

Create a git branch with your new feature or bugfix and either (in order of preference):

  • open a Pull Request on GitHub
  • mail the patch to [email protected],
  • send the URL for your branch and we will review/merge it if correct

We'll check your pull requests in the timeliest manner possible. If we can't accept your PR for some reason, we'll give you feedback and you're encouraged to try again!

Submission conventions

Fork the repository and make changes on your fork in a feature branch:

  • If it's a bug fix branch, name it XXXX-something where XXXX is the number of the issue.
  • If it's a feature branch, create an enhancement issue to announce your intentions, and name it XXXX-something where XXXX is the number of the issue.

Tests

Submit unit tests for your changes. Run the full test suite on your branch before submitting a pull request.

Documentation

Update the documentation when creating or modifying features.

Code status

Build Status Coverage Status

LICENSE

Please see the LICENSE file.

More Repositories

1

gandi.cli

âš  ARCHIVED - Command line interface to Gandi.net products using the public API
Python
347
star
2

packet-journey

DEPRECATED - Packet-journey, userland router which uses DPDK for its fastpath switching.
C
206
star
3

letsencrypt-gandi

Gandi plugin for Let's Encrypt
Python
91
star
4

api-examples

Scripts and snippets of code for using the Gandi API with any programming language.
PHP
40
star
5

dnsknife

DNS lookup tools
Python
30
star
6

bridge-utils

Linux bridge utils (obsolete and unmaintained)
C
29
star
7

ktrill

DEPRECATED - TRILL implementation in the Linux Kernel (obsolete and unmaintained)
C
23
star
8

awesome-gandi

😎 A curated list of the best resources related to Gandi
22
star
9

hubot-phabs

A hubot plugin for communication with a Phabricator instance.
CoffeeScript
21
star
10

jbod-rs

Rust
13
star
11

react-translate

I18N libraries and tools for your react application.
JavaScript
13
star
12

gandi-vm-config

Collection of script used to setup a virtual machine on first boot and to manage the dynamic resources during the life of the virtual machine: adding/removing memory or CPU, attaching/detaching disk or network interfaces
Shell
12
star
13

docker-machine-gandi

Docker machine driver for Gandi platform
Go
11
star
14

hieracles

Command-line tool for analysis and deep examination of Hiera paramaters in a Puppet setup
Ruby
11
star
15

zaxxon

A library to make isometric map in SVG
JavaScript
11
star
16

prometheus-linux-nfsdv4-exporter

Rust
10
star
17

wagtail-oauth2

A wagtail plugin to replace the login by an OAuth2.0 Authorization Server
Python
10
star
18

ganesha_exporter

Prometheus exporter for NFS-Ganesha
Go
9
star
19

fleece

fleece
C
9
star
20

hiring

Jobs at Gandi
8
star
21

whmcs_Gandi-module

Gandi Module for WHMCS
PHP
8
star
22

libvmod-unidirectors

vmod_unidirectors enables backend load balancing in Varnish.
C
8
star
23

gandi-swapsetup

Python script to setup virtual machines on Gandi IaaS hosting platform.
Python
7
star
24

babel-preset-gandi

JavaScript
6
star
25

linkognito

A Web Extension to open links in an incognito tab.
JavaScript
6
star
26

hubot-pager-v2

Pagerduty (APIv2) plugin for Hubot.
CoffeeScript
6
star
27

gandi-pyramid-prometheus

Pyramid Plugin for prometheus integration on multiprocess wsgi server
Python
5
star
28

xenlight_exporter

Prometheus exporter for Xen using xenlight library
Go
5
star
29

nfs-ganesha-kmod

C
5
star
30

hieraviz

DEPRECATED - Web and API server for accessing Puppet dev and prod data.
Ruby
5
star
31

pyramid_kvs

Key Value Store utiliites for the python Pyramid framework
Python
4
star
32

pyramid_htmlmin

htmlmin binding for pyramid
Python
4
star
33

celery-prometheus

Add you own metrics to your celery backend.
Python
4
star
34

python-zipkin

Zipkin tracer in python. Integrated in flask, pyramid, celery, requests, ...
Python
3
star
35

ctld_exporter

Prometheus exporter for FreeBSD CTL daemon
Go
3
star
36

rust-consul

Rust
3
star
37

zone-import

Imports RFC1035 zone files into your Gandi.net account
Python
3
star
38

hubot-cron-events

A hubot plugin to perform generic event emission scheduled using cron job.
CoffeeScript
3
star
39

hubot-es-logger

A plugin for Hubot to log channels activity on ElasticSearch, and serve logs via web.
CoffeeScript
3
star
40

breakpad-c-wrapper

C wrapper around google breakpad. We use it at Gandi in qemu.
C++
2
star
41

terraform-module-jitsi

Terraform module that installs a Jitsi instance on a newly created Openstack virtual machine on GandiCloud VPS infrastructure.
HCL
2
star
42

puppet-hiera-deep-merge

puppet' hiera_hash wrapper for deep merging on demand
Ruby
2
star
43

quagga

quagga with TRILL (obsolete and unmaintained)
C
2
star
44

dpdk-debian

Packaging Debian for dpdk
Makefile
2
star
45

OpenSearchPlugin

Firefox / OpenSearch plugin for searching available domain names on Gandi.net
2
star
46

hubot-statuspageio

StatusPage.io plugin for hubot
CoffeeScript
2
star
47

vanity-livedns

A simple script to print out information needed to configure a "vanity" set-up for Gandi LiveDNS
Python
1
star
48

smoking

Python
1
star
49

hubot-at-events

A hubot plugin to perform events emission at given time.
CoffeeScript
1
star
50

mod_fastcgi_handler

mod_fastcgi_handler
C
1
star
51

ecmp-lab

Shell
1
star
52

wagtail-localize-panel

Wagtail localize panel and notification
Python
1
star
53

piwik-TrackerHost

Piwik plugin to change the hostname displayed in the tracker code snippet.
PHP
1
star
54

hubot-restrict-ip

A hubot plugin registering an Express middleware for filtering who can access to http endpoints.
CoffeeScript
1
star
55

dj_sentry

A Django app to initialize Sentry client for your Django applications
Python
1
star
56

demo-private-networks-gandicloud

Deployment of an asciinema-server using either Terraform or OpenTofu, to demonstrate GandiCloud's private networks feature
HCL
1
star
57

pyramid_yards

Python
1
star