forked from uncloud/uncloud
update readme + api
This commit is contained in:
parent
f588691f0d
commit
fc4ec7b0f8
6 changed files with 61 additions and 37 deletions
|
@ -5,7 +5,7 @@
|
||||||
Alpine:
|
Alpine:
|
||||||
|
|
||||||
```
|
```
|
||||||
apk add openldap-dev
|
apk add openldap-dev postgresql-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Python requirements
|
### Python requirements
|
||||||
|
@ -22,3 +22,26 @@ Then install the requirements
|
||||||
```
|
```
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Database requirements
|
||||||
|
|
||||||
|
Due to the use of the JSONField, postgresql is required.
|
||||||
|
|
||||||
|
First create a role to be used:
|
||||||
|
|
||||||
|
```
|
||||||
|
postgres=# create role nico login;
|
||||||
|
```
|
||||||
|
|
||||||
|
Then create the database owner by the new role:
|
||||||
|
|
||||||
|
```
|
||||||
|
postgres=# create database uncloud owner nico;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Secrets
|
||||||
|
|
||||||
|
cp `uncloud/secrets_sample.py` to `uncloud/secrets.py` and replace the
|
||||||
|
sample values with real values.
|
||||||
|
|
|
@ -3,3 +3,4 @@ djangorestframework
|
||||||
django-auth-ldap
|
django-auth-ldap
|
||||||
stripe
|
stripe
|
||||||
xmltodict
|
xmltodict
|
||||||
|
psycopg2
|
||||||
|
|
|
@ -1,12 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Live/test key from stripe
|
# Live/test key from stripe
|
||||||
STRIPE_KEY=""
|
STRIPE_KEY=""
|
||||||
|
|
||||||
|
@ -15,3 +6,5 @@ OPENNEBULA_URL='https://opennebula.ungleich.ch:2634/RPC2'
|
||||||
|
|
||||||
# user:pass for accessing opennebula
|
# user:pass for accessing opennebula
|
||||||
OPENNEBULA_USER_PASS='user:password'
|
OPENNEBULA_USER_PASS='user:password'
|
||||||
|
|
||||||
|
POSTGRESQL_DB_NAME="uncloud"
|
||||||
|
|
|
@ -74,15 +74,6 @@ TEMPLATES = [
|
||||||
WSGI_APPLICATION = 'uncloud.wsgi.application'
|
WSGI_APPLICATION = 'uncloud.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
|
@ -159,8 +150,16 @@ USE_TZ = True
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
|
||||||
# Uncommitted file
|
# Uncommitted file with secrets
|
||||||
# import uncloud.secrets
|
import uncloud.secrets
|
||||||
#
|
|
||||||
# import stripe
|
|
||||||
# stripe.api_key = uncloud.secrets.STRIPE_KEY
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'NAME': uncloud.secrets.POSTGRESQL_DB_NAME,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,5 +2,5 @@ from django.contrib import admin
|
||||||
|
|
||||||
from .models import Product, Feature
|
from .models import Product, Feature
|
||||||
|
|
||||||
admin.site.register(Product)
|
#admin.site.register(Product)
|
||||||
admin.site.register(Feature)
|
#admin.site.register(Feature)
|
||||||
|
|
|
@ -32,7 +32,12 @@ from django.contrib.auth import get_user_model
|
||||||
# Should have a log = ... => 1:n field for most models!
|
# Should have a log = ... => 1:n field for most models!
|
||||||
|
|
||||||
class Product(models.Model):
|
class Product(models.Model):
|
||||||
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
owner = models.ForeignKey(get_user_model(),
|
||||||
|
on_delete=models.CASCADE)
|
||||||
|
|
||||||
# override these fields by default
|
# override these fields by default
|
||||||
|
|
||||||
description = ""
|
description = ""
|
||||||
recurring_period = "not_recurring"
|
recurring_period = "not_recurring"
|
||||||
|
|
||||||
|
@ -42,9 +47,13 @@ class Product(models.Model):
|
||||||
('being_created', 'Being created'),
|
('being_created', 'Being created'),
|
||||||
('created_active', 'Created'),
|
('created_active', 'Created'),
|
||||||
('deleted', 'Deleted')
|
('deleted', 'Deleted')
|
||||||
)
|
),
|
||||||
|
default='pending'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{}".format(self.name)
|
return "{}".format(self.name)
|
||||||
|
|
||||||
|
@ -106,19 +115,18 @@ class Feature(models.Model):
|
||||||
# value_str
|
# value_str
|
||||||
# value_float
|
# value_float
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "'{}' - '{}'".format(self.product, self.name)
|
return "'{}' - '{}'".format(self.product, self.name)
|
||||||
|
|
||||||
|
|
||||||
class Order(models.Model):
|
# class Order(models.Model):
|
||||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
# uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
|
||||||
owner = models.ForeignKey(get_user_model(),
|
# owner = models.ForeignKey(get_user_model(),
|
||||||
on_delete=models.CASCADE)
|
# on_delete=models.CASCADE)
|
||||||
|
|
||||||
product = models.ForeignKey(Product,
|
# product = models.ForeignKey(Product,
|
||||||
on_delete=models.CASCADE)
|
# on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
||||||
class VMSnapshotOrder(Order):
|
|
||||||
pass
|
|
||||||
|
|
Loading…
Reference in a new issue