spurge / clique-connector

Library that wraps a RabbitMQ connection and creates a channel between Clique agents and APIs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clique Connector

Library that wraps a RabbitMQ connection and creates a channel between Clique agents and APIs.

Install

Locally

python setup.py install

Using Curdling

curd install git+git@bitbucket.org:bagis/clique-connector.git

Features

  • Send statistics
  • Listen for statistics
  • Ask for a virtual machine
  • Confirm a virtual machine job
  • Confirm with a virtual machine

How to test

  • Setup a RabbitMQ, preferably a docker container: docker run --name rabbitmq -p 25672:25672 -p 4369:4369 -p 5671-5672:5671-5672 rabbitmq
  • Then run all the tests: python setup.py test

How to use

from clique_connector import Connector

connector = Connector('127.0.0.1')

# Request a virtual machine
machine = await connector.create_machine(
    'some-random-machine', # Machine name
    'ubuntu-16.04', # Image name
    1, # CPU
    512, # Memory in MB
    128, # Disc in GB
    'your-public-ssh-key-as-string') # Public SSH key

# Response with a virtual machine
def callback(channel_close, name, cpu, mem, disc, pkey):
    return dict(host='127.0.0.1',
                username='root')

# Create listener
channel_close, observable = connector.wait_for_machines(callback)

# Start listening
machines = await observable \
    .take(3) # Create only three machines

# Clean up by closing channel
channel_close()

About

Library that wraps a RabbitMQ connection and creates a channel between Clique agents and APIs.

License:MIT License


Languages

Language:Python 100.0%