Skip to content

Tendrl/api

Repository files navigation

Tendrl API

  • Unit tests: Build Status

  • Functional tests: Build Status

Note
All the commands are run as a regular user that has sudo privileges. The commands are all assumed to be run from a single directory, which by default could be the user’s home directory. If different, the required current directory is indicated in [] before the shell prompt $.

Ensure that etcd is running on a node in the network and is reachable from the node you’re about to install tendrl-api on. Note it’s address and port. In most development setups, both etcd and tendrl-api would reside on the same host.

  1. Install the build toolchain.

    $ sudo yum groupinstall 'Development Tools'
  2. Install Ruby 2.0.0p598.

    $ sudo yum install ruby ruby-devel rubygem-bundler
  1. Clone tendrl-api.

    $ git clone https://github.com/Tendrl/tendrl-api.git
  2. Install the gem dependencies, either..

    $ cd tendrl-api
    1. everything,

      [tendrl-api] $ bundle install --path vendor/bundle --binstubs vendor/bin
    2. OR development setup only,

      [tendrl-api] $ bundle install --path vendor/bundle --binstubs vendor/bin \
                     --without production
    3. OR production setup only.

      [tendrl-api] $ bundle install --path vendor/bundle --binstubs vendor/bin \
                     --without development test documentation
Note
Using binstubs allows any of the executables to be executed directly from vendor/bin, instead of via bundle exec.

To configure the etcd connection information, copy the sample configuration file to the appropriate location and make the necessary changes based on your etcd configuration, as discussed in the Deployment Requirements section.

[tendrl-api] $ cp config/etcd.sample.yml config/etcd.yml
Note
All the commands below are assumed to be run from inside the git checkout directory.
  1. Tendrl Definitions:

    The API needs the proper Tendrl definitions yaml file to generate the attributes and actions. You can either download it or use the one from the fixtures to explore the API.

    [tendrl-api] $ cp spec/fixtures/sds/tendrl_definitions_gluster-3.8.3.yaml \
                   config/sds/tendrl_definitions_gluster-3.8.3.yaml
  2. Seed the etcd instance (optional):

    The script will seed the etcd instance with mock cluster data and print a cluster uuid which can be used to make API requests.

    [tendrl-api] $ vendor/bin/rake etcd:seed # Seed the local store with cluster
  3. Start the development server:

    This server will reload itself when any of the source files are updated.

    [tendrl-api] $ vendor/bin/shotgun
    Note
    This makes the development server to be queryable on localhost:9393 by default. Check vendor/bin/shotgun --help to change the ip:port binding.

The test environment does not need the local etcd instance to run the tests.

[tendrl-api] $ vendor/bin/rspec

Binding to port 80 requires root permissions. However, tendrl-api runs as a normal user. In order to make the application available on port 80, apache needs to be installed and configured.

  1. Install apache

    $ sudo yum install httpd
  2. Copy over the sample configuration file and validate it’s syntax.

    Important
    Update the file for your specific host details. The file is commented to point out the suggested changes. The file is configured to connect to the tendrl-api application server on port 9292.
    Important
    Running behind apache makes the API available at http://<hostname>:80/api/. Client applications' (including tendrl frontend’s) configuration needs to be updated to make all API queries behind this endpoint.
    [tendrl-api] $ sudo cp config/apache.vhost.sample \
                   /etc/httpd/conf.d/tendrl.conf
    $ sudo apachectl configtest
  3. Update the SELinux configuration to allow apache to make connections.

    $ sudo setsebool -P httpd_can_network_connect 1
  4. Run the application via the production server puma, daemonised, listening on port 9292.

    [tendrl-api] $ vendor/bin/puma -e development -d
    Note
    It is possible to run both the development and the production servers at the same time, with the production server behind apache. While the production server puma runs, by default, on port 9292; the development server shotgun listens on port 9393.
  5. Start apache.

    $ sudo systemctl start httpd.service