Skip to content

Commit

Permalink
Added documentation and recreated migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwang committed Oct 7, 2017
1 parent c55fd32 commit 7dee408
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
64 changes: 63 additions & 1 deletion README.rst
Expand Up @@ -15,7 +15,10 @@ djcloudbridge
:alt: Test Coverage Report


A ReSTful web api backed by cloudbridge for interacting with cloud providers
A reusable Django app that exposes a ReSTful Web API for interacting with
CloudBridge_ providers. The structure of the API mirrors the organisation
of CloudBridge's API and allows for creating, retrieving and updating
CloudBridge resources.

Documentation
-------------
Expand Down Expand Up @@ -51,6 +54,64 @@ Add djcloudbridge's URL patterns:
url(r'^', include(djcloudbridge_urls)),
...
]
And finally, the following settings are recommended in your settings.py

.. code-block:: python
REST_FRAMEWORK = {
'PAGE_SIZE': 50,
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication'
)
}
REST_AUTH_SERIALIZERS = {
'USER_DETAILS_SERIALIZER': 'djcloudbridge.serializers.UserSerializer'
}
REST_SESSION_LOGIN = True
# **Make sure to change** the value for ``FERNET_KEYS`` variable
# because it is used to encrypt sensitive database fields.
FERNET_KEYS = [
'new key for encrypting'
]
Running the API Locally
-----------------------

You can run a test server to browse the API endpoints locally. DJCloudBridge
is based on Python 3.6 and although it may work on older Python
versions, 3.6 is the only supported version. Use of virtualenv is also
highly advised.

To get started, simply register the provider connection information under the
relevant cloud model (e.g. AWS, Azure, GCE, OpenStack) in Django Admin.
Then create a User Profile under the User Profile model. Finally, use the API
browser at http://localhost:8000/clouds to view the cloud you registered and
interact with cloud resources for that provider.


1. Checkout djcloudbridge and create environment

.. code-block:: bash
$ mkdir djcloudbridge && cd djcloudbridge
$ virtualenv -p python3.6 venv --prompt "(djcloudbridge)" && source venv/bin/activate
$ git clone https://github.com/cloudve/djcloudbridge.git
$ cd djcloudbridge
$ pip install -r requirements.txt
$ cd djcloudbridge
$ python manage.py migrate
$ python manage.py runserver
$ python manage.py createsuperuser
2. Visit http://127.0.0.1:8000/admin/ to define your cloud connection settings.

3. Visit http://127.0.0.1:8000/clouds/ to explore the API.

Features
--------
Expand All @@ -76,5 +137,6 @@ Tools used in rendering this package:
* Cookiecutter_
* `cookiecutter-djangopackage`_

.. _CloudBridge: https://github.com/gvlproject/cloudbridge
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage
14 changes: 9 additions & 5 deletions djcloudbridge/migrations/0001_initial.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-05 16:15
# Generated by Django 1.11.6 on 2017-10-07 12:28
from __future__ import unicode_literals

from django.conf import settings
Expand Down Expand Up @@ -84,6 +84,10 @@ class Migration(migrations.Migration):
('slug', models.SlugField(editable=False, primary_key=True, serialize=False, unique=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'User Profile',
'verbose_name_plural': 'User Profiles',
},
),
migrations.CreateModel(
name='AWS',
Expand All @@ -106,7 +110,7 @@ class Migration(migrations.Migration):
('secret_key', fernet_fields.fields.EncryptedCharField(max_length=50)),
],
options={
'verbose_name': 'AWS Credentials',
'verbose_name': 'AWS Credential',
'verbose_name_plural': 'AWS Credentials',
},
bases=('djcloudbridge.credentials',),
Expand Down Expand Up @@ -136,7 +140,7 @@ class Migration(migrations.Migration):
('tenant', models.CharField(blank=True, max_length=50, null=True)),
],
options={
'verbose_name': 'Azure Credentials',
'verbose_name': 'Azure Credential',
'verbose_name_plural': 'Azure Credentials',
},
bases=('djcloudbridge.credentials',),
Expand All @@ -161,7 +165,7 @@ class Migration(migrations.Migration):
('credentials', fernet_fields.fields.EncryptedTextField()),
],
options={
'verbose_name': 'GCE Credentials',
'verbose_name': 'GCE Credential',
'verbose_name_plural': 'GCE Credentials',
},
bases=('djcloudbridge.credentials',),
Expand Down Expand Up @@ -191,7 +195,7 @@ class Migration(migrations.Migration):
('user_domain_name', models.CharField(blank=True, max_length=50, null=True)),
],
options={
'verbose_name': 'OpenStack Credentials',
'verbose_name': 'OpenStack Credential',
'verbose_name_plural': 'OpenStack Credentials',
},
bases=('djcloudbridge.credentials',),
Expand Down

0 comments on commit 7dee408

Please sign in to comment.