Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-02-25 14:12:23 +01:00
parent 15b0fe3dc9
commit cc9e5905eb
5 changed files with 52 additions and 68 deletions

View file

@ -9,6 +9,16 @@ vmuuid=$(http nicocustomer
http -a nicocustomer:xxx http://uncloud.ch/vm/create_snapshot uuid= http -a nicocustomer:xxx http://uncloud.ch/vm/create_snapshot uuid=
password=... password=...
``` ```
** backend realisation
*** list snapshots
- have them in the DB
- create an entry on create
*** creating snapshots
- vm sync / fsync?
- rbd snapshot
- host/cluster mapping?
- need image(s)
* steps * steps
** DONE authenticate via ldap ** DONE authenticate via ldap
CLOSED: [2020-02-20 Thu 19:05] CLOSED: [2020-02-20 Thu 19:05]
@ -50,16 +60,8 @@ password=...
** viewset: .list and .create ** viewset: .list and .create
** view: .get .post ** view: .get .post
* TODO register CC * TODO register CC
* TODO list products * DONE list products
* ahmed CLOSED: [2020-02-24 Mon 20:15]
** schemas
*** field: is_valid? - used by schemas
*** definition of a "schema"
* penguin pay
## How to place a order with penguin pay
### Requirements
* An ungleich account - can be registered for free on * An ungleich account - can be registered for free on
https://account.ungleich.ch https://account.ungleich.ch
* httpie installed (provides the http command) * httpie installed (provides the http command)

View file

@ -170,29 +170,29 @@ STATIC_URL = '/static/'
stripe.api_key = secrets.STRIPE_KEY stripe.api_key = secrets.STRIPE_KEY
# FIXME: not sure if we really need this # FIXME: not sure if we really need this
LOGGING = { # LOGGING = {
'version': 1, # 'version': 1,
'disable_existing_loggers': False, # 'disable_existing_loggers': False,
'handlers': { # 'handlers': {
'file': { # 'file': {
'level': 'DEBUG', # 'level': 'DEBUG',
'class': 'logging.FileHandler', # 'class': 'logging.FileHandler',
'filename': 'debug.log', # 'filename': 'debug.log',
}, # },
}, # },
'loggers': { # 'loggers': {
'django': { # 'django': {
'handlers': ['file'], # 'handlers': ['file'],
'level': 'DEBUG', # 'level': 'DEBUG',
'propagate': True, # 'propagate': True,
}, # },
'django_auth_ldap': { # 'django_auth_ldap': {
'handlers': ['file'], # 'handlers': ['file'],
'level': 'DEBUG', # 'level': 'DEBUG',
'propagate': True # 'propagate': True
} # }
}, # },
} # }
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = { DATABASES = {

View file

@ -23,7 +23,6 @@ from opennebula import views as oneviews
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet) router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
router.register(r'opennebula', oneviews.VMViewSet, basename='opennebula') router.register(r'opennebula', oneviews.VMViewSet, basename='opennebula')
router.register(r'opennebula_raw', oneviews.RawVMViewSet) router.register(r'opennebula_raw', oneviews.RawVMViewSet)

View file

@ -51,6 +51,7 @@ class Product(models.Model):
default='pending' default='pending'
) )
# This is calculated by each product and saved in the DB
recurring_price = models.FloatField() recurring_price = models.FloatField()
one_time_price = models.FloatField() one_time_price = models.FloatField()
@ -67,6 +68,15 @@ class VMSnapshotProduct(Product):
price_per_gb_ssd = 0.35 price_per_gb_ssd = 0.35
price_per_gb_hdd = 1.5/100 price_per_gb_hdd = 1.5/100
# This we need to get from the VM
gb_ssd = models.FloatField()
gb_hdd = models.FloatField()
vm_uuid = models.UUIDField()
# Need to setup recurring_price and one_time_price and recurring period
sample_ssd = 10 sample_ssd = 10
sample_hdd = 100 sample_hdd = 100
@ -97,8 +107,10 @@ Sample price for a VM with {} GB SSD and {} GB HDD VM is: {}.
""".format(cls.price_per_gb_ssd, cls.price_per_gb_hdd, """.format(cls.price_per_gb_ssd, cls.price_per_gb_hdd,
cls.sample_ssd, cls.sample_hdd, cls.sample_price()) cls.sample_ssd, cls.sample_hdd, cls.sample_price())
gb_ssd = models.FloatField()
gb_hdd = models.FloatField()

View file

@ -7,17 +7,9 @@ from .serializers import UserSerializer, GroupSerializer
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
import inspect
class CreditCardViewSet(viewsets.ModelViewSet): import sys
import re
"""
API endpoint that allows credit cards to be listed
"""
queryset = get_user_model().objects.all().order_by('-date_joined')
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
class UserViewSet(viewsets.ModelViewSet): class UserViewSet(viewsets.ModelViewSet):
@ -29,24 +21,6 @@ class UserViewSet(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticated] permission_classes = [permissions.IsAuthenticated]
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = [permissions.IsAuthenticated]
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = [permissions.IsAuthenticated]
# POST /vm/snapshot/ vmuuid=... => create snapshot, returns snapshot uuid # POST /vm/snapshot/ vmuuid=... => create snapshot, returns snapshot uuid
# GET /vm/snapshot => list # GET /vm/snapshot => list
@ -57,9 +31,6 @@ class VMSnapshotView(generics.ListCreateAPIView):
#lookup_field = 'uuid' #lookup_field = 'uuid'
permission_classes = [permissions.IsAuthenticated] permission_classes = [permissions.IsAuthenticated]
import inspect
import sys
import re
# Next: create /order/<productname> urls # Next: create /order/<productname> urls
# Next: strip off "Product" at the end # Next: strip off "Product" at the end