Contributing

Want to contribute to AerisCloud? This page describes the development flow and the code organization.

AerisCloud is written in Python and is targeted at 2.7 as it is the most available version and the one provided by default on OSX.

Documentation

If you’re looking to help document AerisCloud, you will need first to install sphinx and optionally sphinx-autobuild. The easiest way is to install it in the AerisCloud virtualenv:

# Setup virtual environment
source venv/bin/activate
# Install Sphinx and Sphinx Autobuild
pip install sphinx sphinx-autobuild
# Go to documentation directory
cd docs
# Run autobuild
sphinx-autobuild . _build/html

Running make docs will install the basic requirements and build the current version of the documentation. make publish-docs can then be used to publish to the gh-pages branch.

Working on the Source

Most of the code is located in the aeriscloud subfolder as python files. The recommended way to work on the project is to fork it on GitHub, clone it to a folder of your choice then run the manual installation steps. When sourcing scripts/env.sh the aeris and cloud commands will point to your fork, then you can just start hacking at the Python source.

Coding Standards

AerisCloud uses flake8 to validate it’s code, you can run the linters with aeris-test, indentation is 4 spaces and line length is 80 characters.

Adding New Commands

Commands are stored in the aeriscloud/cli/<command> folders and are simple python files exporting at least a cli function that is a valid click command.

Here is a very basic example:

#!/usr/bin/env python
# aerisclound/cli/aeris/debug.py

import click

# The Command class in cli.helpers sets a few default shared
# between all AerisCloud commands
from aeriscloud.cli.helpers import Command

@click.command(cls=Command)
def cli():
      # click.echo should be used instead of print()
      click.echo("hello world")

This command would then be available as aeris debug, also several decorators are available in aeriscloud/cli/helpers.py to make your life easier and are documented in the API doc.

Submitting Code

Code should be done in a branch on your fork, then submitted as a PR to the main repo. Make sure that your PR describe what you are changing in details, linking back to issues if necessary.

API

aeriscloud.project

class aeriscloud.project.Project(folder)[source]

Represents an AerisCloud project

Parameters:folder – str The folder where the project is stored
box(name='')[source]

Retrieve a box by name :param name: str :return: Box|None

boxes()[source]

Return the list of boxes available for this project :return: BoxList[Box]

name()[source]

Return the name of the project :return: str

aeriscloud.project.all()[source]

Return every projects available on the local host :return: list[Project]

aeriscloud.project.from_path(path)[source]

Return the project stored in the given folder if any

Returns:Project|None
aeriscloud.project.get(name)[source]

Return the project corresponding to the given project name or directory

Parameters:name – str
Returns:Project|None

aeriscloud.box

class aeriscloud.box.Box(project, data)[source]

Represents an AerisCloud VM, might or might not be running, take a Project instance and an entry from the .aeriscloud.yml infra configuration

Parameters:
  • project – project.Project
  • data – dict[str,str]
browse(endpoint='', ip=False)[source]

Given an endpoint, returns the URI to that endpoint

Parameters:
  • endpoint – str
  • ip – bool
Returns:

str

info()[source]

Return all the information about a box, kinda messy

Returns:dict[str,str]
ip(id=1)[source]

Return the IP of a box for the given interface, by default aeriscloud VMs have 2 interfaces: * id 0: NAT interface, on the 10.0.0.0 network * id 1: Host Only interface on the 172.16.0.0 network

Parameters:id – int
Returns:str
is_running()[source]

Return whether or not the VM is currently running

Returns:bool
name()[source]

Return the name of the box in the project’s infra

Returns:str
network()[source]

Return the information for every network interfaces on the VM (kinda slow)

Returns:list[map[str,str]]
resume()[source]

Resume a suspended box

Returns:bool
services()[source]

List the services running on the box

Returns:dict[str,str,str,str]
ssh(**kwargs)[source]

Return a pre-baked ssh client method to be used for calling commands on the distant server. Each command called will be in a different connection.

Returns:sh.Command
ssh_client()[source]

When needing a more precise SSH client, returns a paramiko SSH client

Returns:paramiko.SSHClient
ssh_shell(cmd=None, cd=True, popen=False, **kwargs)[source]

Create an interactive ssh shell on the remote VM

Returns:subprocess32.Popen
status()[source]

Return the current status of the VM

Returns:str
suspend()[source]

Save the state of a running box

Returns:bool
vagrant(*args, **kwargs)[source]

Runs a vagrant command

vm_name()[source]

Return the VM name

Returns:str

aeriscloud.config

class aeriscloud.config.Config[source]

Wrapper around ConfigParser that provides a way to check for existence as well as a default kwargs for get that provides a default value

complete()[source]

Checks if the configuration has all basic config items set

Returns:bool
get(section, option, **kwargs)[source]

Get an option from the configuration, if the option does not exists and no default is set, raises a configparser.Error

Parameters:
  • section – str
  • option – str
  • default – any
Returns:

str

has(section, option)[source]

Checks if the given section and option exists

Parameters:
  • section – str
  • option – str
Returns:

bool

save()[source]

Save the config file

Returns:bool
set(section, option, value)[source]

Set an option in the configuration, does not save the config

Parameters:
  • section – str
  • option – str
  • value – any
Returns:

unset(section, option)[source]

Unset an option in the configuration, does not save the config

Parameters:
  • section – str
  • option – str
Returns:

bool

aeriscloud.config.inventory_path()[source]

Return the path to the ansible inventory files

Returns:

aeriscloud.cli.helpers

class aeriscloud.cli.helpers.CLITable(*cols)[source]

Helps displaying a dynamically sized table a la docker ps

aeriscloud.cli.helpers.move_shell_to(path)[source]

If the process is called through the function set in scripts/env.sh, will move the user to the given path on successful exit

Parameters:path – str
aeriscloud.cli.helpers.standard_options(multiple=False, start_prompt=True)[source]

Add the standard –project and –box options to a command :param multiple: Whether to find a single or multiple boxes :param start_prompt: When using single boxes, ask the user to start it if

offline