The source code for the contrail network virtualization system uses several code repositories, currently hosted in GitHub. The source code for the configuration server, control-plane, analytics and compute-node agent is located in github.com/Juniper/contrail-controller. The source code for the dataplane component is located in github.com/Juniper/contrail-vrouter. Several other repositories that contain build tools and code generators are also used.

In order to create a sandbox that can be used to build the complete system there are several steps. Overview:

  1. Obtain a suitable machine to use, likely a VM running a supported Linux distribution like Ubuntu or Redhat.
  2. Make sure basic repository tools (i.e., git and android repo) are installed.
  3. Create a sandbox.
  4. Satisfy build tool requirements (distro-specific).
  5. Download source for additional 3rd party software used in the build.
  6. Build it.
Details for this list are in the following sections.

1. Linux Build Machine

Several distributions are supported:

You will also need to have a ssh keypair, and should be familiar with using ssh (hint: ssh-agent).

2. Repository Tools

The tools repo and git should be installed to pull a development sandbox.

We use the google multiple repository tool, the andoid repo. Here's the download/install link.

apt-get install git should install git.

Before you can create a sandbox you will need a github account, and you will need to set up ssh access to github.

3. Create Sandbox

To create a development sandbox you can use the following steps:

4. Build Tool Requirements

The build depends on several tools which are listed in the following distribution specific sections.

4.1 CentOS, RedHat Enterprise Linux based distros

On RHEL/CentOS/Scientific 6.4 the basic build dependencies can be installed by the following command:

yum install -y scons git python-lxml wget gcc patch make unzip flex bison gcc-c++ openssl-devel autoconf automake vim python-devel python-setuptools protobuf protobuf-devel protobuf-compiler net-snmp-python

In addition to the above, contrail build requires the following:

libipfix: this needs to be installed manually by downloading from http://sourceforge.net/projects/libipfix/files/libipfix/libipfix_110209.tgz

librdkafka: this needs to be installed manually by downloading from https://github.com/edenhill/librdkafka/librdkafka-0.8.5.tar.gz

The following sections provide additional info for specific CentOS releases

4.1.1 CentOS 6.6

On CentOS 6.6, there are a few additional build dependencies:

The first two are handled by the following command:

yum install -y libtool kernel-devel

The newer automake requires more fiddling, as most yum repositories for Centos 6.x will have v2.63 automake. Here is a link to automake-2.69 for CentOS 6.x.

The up-to-date build dependency list can be found in your sandbox. See the sandbox file tools/packages/rpm/contrail/contrail.spec for BuildRequires entries.

4.1.2 CentOS 7

The ability to build on CentOS 7 is a work in progress, so all caveats apply.

Like CentOS 6.6, these packages are also required by CentOS 7, and can be installed using the same yum command as for CentOS 6.6 (see above).

Centos 7 has some additional complexity due to build dependencies on the following:

  1. bzip2
  2. boost-devel
  3. tbb-devel
  4. libcurl-devel
  5. libxml2-devel
  6. zlib-devel
  7. scons
  8. protobuf
  9. protobuf-devel
  10. protobuf-compiler

Packages (1) through (6) can be installed with this yum command:

yum install -y bzip2 boost-devel tbb-devel libcurl-devel libxml2-devel zlib-devel

The packages (7) through (10) are not in the default CentOS 7 repository, but they can be installed from the epel repository. To install access to the epel repository, run these two commands:

yum install -y epel-release
sed -i -e 's/enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo

After installing and enabling epel access, packages (6) through (9) can be installed:

yum install -y --enablerepo="epel" scons protobuf protobuf-devel protobuf-compiler

As stated, configuring CentOS 7 to build Contrail is currently a work in progress. To make it a bit less tedious, Flavio Fernandes has provided a provisioning script that adds epel repository access and also installs all needed packages (i.e., a one-step configure script). Here is a link to the github-hosted provisioning script.

4.2 Debian-based distros

On Ubuntu both 12.04 and 14.04 the basic build dependencies are specified in the sandbox file tools/packages/debian/contrail/debian/control, look for the Build-Depends: list. There are some packages in the Build-Depends list that come from opencontrail PPA. Hence the following need to be done.

apt-add-repository ppa:opencontrail/ppa
apt-get update
The current common list is as below, but it's recommended to pick the latest list from the file tools/packages/debian/contrail/debian/control.
apt-get install -y autoconf automake bison debhelper flex libcurl4-openssl-dev libexpat-dev libgettextpo0 libprotobuf-dev libtool libxml2-utils make protobuf-compiler python-all python-dev python-lxml python-setuptools python-sphinx ruby-ronn scons unzip vim-common libsnmp-python libipfix-dev librdkafka-dev librdkafka1

On Ubuntu 14.04 these additional build dependencies are required: See the sandbox file tools/packages/debian/contrail/debian/builddep.trusty for up-to-date list. The current list is as below, but it's recommended to pick the latest from the builddep.trusty file.

apt-get install -y libboost-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libcurl4-openssl-dev google-mock libgoogle-perftools-dev liblog4cplus-dev libtbb-dev libhttp-parser-dev libxml2-dev libicu-dev

Following are also required that need to be downloaded and installed
wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra-cpp-driver_2.2.0-1_amd64.deb
wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/cassandra-cpp-driver-dev_2.2.0-1_amd64.deb
wget http://downloads.datastax.com/cpp-driver/ubuntu/14.04/libuv_1.7.5-1_amd64.deb

dpkg -i libuv_1.7.5-1_amd64.deb cassandra-cpp-driver_2.2.0-1_amd64.deb cassandra-cpp-driver-dev_2.2.0-1_amd64.deb

5. Third-Party Source

Before building the software you will need to download other open source software libraries used by the controller repository. The python script third_party/fetch_packages.py automates this process and automatically applies patches to some of these libraries.

6. Build with scons

Contrail uses SCons as its build tool. You should have installed it on your system in step (4). To build, execute the command scons at the top-level sandbox directory.

7. Run unit tests with scons

A few more packages are required to run unit tests and they need to be installed as below.

apt-get install python-virtualenv python-libxml2 libxslt1-dev

Additionally make sure ping `hostname` works.

To run unit tests, execute the command scons test at the top-level sandbox directory.

8. Contact list

Please report build issues in the developers mailing list.