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
-
aeriscloud.project.
all
()[source]¶ Return every projects available on the local host :return: list[Project]
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
-
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
-
network
()[source]¶ Return the information for every network interfaces on the VM (kinda slow)
Returns: list[map[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
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
-
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
-
aeriscloud.cli.helpers
¶
-
class
aeriscloud.cli.helpers.
CLITable
(*cols)[source]¶ Helps displaying a dynamically sized table a la docker ps