Giter Club home page Giter Club logo

contrib-python-qubell-client's Introduction

====================
Python-qubell-client
====================

Repository contains:

qubell.api/private - library to access qubell via dev api.

qubell.api/tests - tests in python unittests format. Primary goal is to test qubell platform functionality using different api's (now only private)


Pre-requisites
==============

- python2.7 or greater
- requests
- yaml
- testtools
- nose

::

    sudo pip install -r requirements.txt
or

::

    sudo easy_install `cat requirements.txt`
    

Configuration
=============

To configure tests, set up environment variables:
QUBELL_USER, QUBELL_PASSWORD - user to access qubell
QUBELL_API - url to qubell platform
QUBELL_ORG - name of organization to use. Will be created if not exists.

PROVIDER, REGION, JCLOUDS_IDENTITY, JCLOUDS_CREDENTIALS - credentials for amazon ec2. (will create provider)
QUBELL_NEW - if you want to create new environment while tests run

::

	export QUBELL_API="http://qubell.com"
	export QUBELL_USER="[email protected]"
	export QUBELL_PASSWORD="password"
	export QUBELL_ORG="my-org"

	export JCLOUDS_IDENTITY="FFFFFFFFF"
	export JCLOUDS_CREDENTIALS="FFFFFFFFFF"


Running tests
=============

Run single test::

    nosetests -s -v qubell.api.tests.instance.test_actions:BasicInstanceActionsTest.test_actions

Run all tests::

    nosetests -s -v qubell.api/tests/

or just::

    nosetests



Using client
============

Create environment
__________________
Working example could be found in qubell.api/create_env.py. To use it, setup environment variables (see below) and run it::

	python qubell.api/create_env.py


Building sandboxes
__________________
Sandboxes in qubell platform could be created on different levels. Maximum isolated sandbox could be achieved by separate organization (with it's own environments, users and application). 

Organization
____________
Creating organization is simple::

	from qubell.api.private.platform import QubellPlatform, Context

	context = Context(user="[email protected]", password="password", api="https://api.qubell.com")
	platform = QubellPlatform(context=context)
	org = platform.organization(name="test-org")

After executing this code, organization "test-org" would be created (if not exists) or initialized (if exists)

Now we need to create environment in organization.

Environment
___________

Usual environment consists of cloud account, keystore service and workflow service. So, we need to add theese services to our organization, then add them to our environment. By default we use "default" environment::

    access = {
      "provider": "aws-ec2",
      "usedEnvironments": [],
      "ec2SecurityGroup": "default",
      "providerCopy": "aws-ec2",
      "name": "test-provider",
      "jcloudsIdentity": KEY,
      "jcloudsCredential": SECRET_KEY,
      "jcloudsRegions": "us-east-1"
    }

	def prepare_env(org):

	    # Add services to organization
	    key_service = org.service(type='builtin:cobalt_secure_store', name='Keystore')
	    wf_service = org.service(type='builtin:workflow_service', name='Workflow', parameters='{}')
	    prov = org.provider(access)

	    # Add services to environment
	    env = org.environment(name='default')
	    env.clean()
	    env.serviceAdd(key_service)
	    env.serviceAdd(wf_service)
	    env.providerAdd(prov)

	    # Here we regenerate keypair
	    env.policyAdd(
	        {"action": "provisionVms",
	         "parameter": "publicKeyId",
	         "value": key_service.regenerate()['id']})

	    return org.organizationId

	prepare_env(org)


Now, platform ready to be used. We need only application with valid manifest.

Application
___________
We need manifest to create application::

	manifest = Manifest(url="https://raw.github.com/qubell/contrib-python-qubell-client/master/qm/hierarchical-main.yml")

	# Creating application
	app = org.application(manifest=manifest, name='first_app')


Application would be crated.
To launch it, use code::

	instance = app.launch()

	# This way we wait instance to came up in 15 minutes or break.
	assert instance.ready(15)


contrib-python-qubell-client's People

Contributors

chemikadze avatar dieu avatar vasichkin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.