From cc9e5905eb5bdd6733ca35c6563e6eb2bf54703d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 25 Feb 2020 14:12:23 +0100 Subject: [PATCH] update Signed-off-by: Nico Schottelius --- notes-nico.org | 22 +++++++++-------- uncloud/uncloud/settings.py | 46 +++++++++++++++++------------------ uncloud/uncloud/urls.py | 1 - uncloud/uncloud_api/models.py | 16 ++++++++++-- uncloud/uncloud_api/views.py | 35 +++----------------------- 5 files changed, 52 insertions(+), 68 deletions(-) diff --git a/notes-nico.org b/notes-nico.org index 03c1b97..811fbff 100644 --- a/notes-nico.org +++ b/notes-nico.org @@ -9,6 +9,16 @@ vmuuid=$(http nicocustomer http -a nicocustomer:xxx http://uncloud.ch/vm/create_snapshot uuid= 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 ** DONE authenticate via ldap CLOSED: [2020-02-20 Thu 19:05] @@ -50,16 +60,8 @@ password=... ** viewset: .list and .create ** view: .get .post * TODO register CC -* TODO list products -* ahmed -** schemas -*** field: is_valid? - used by schemas -*** definition of a "schema" -* penguin pay -## How to place a order with penguin pay - -### Requirements - +* DONE list products + CLOSED: [2020-02-24 Mon 20:15] * An ungleich account - can be registered for free on https://account.ungleich.ch * httpie installed (provides the http command) diff --git a/uncloud/uncloud/settings.py b/uncloud/uncloud/settings.py index 5ce8e92..f671dc5 100644 --- a/uncloud/uncloud/settings.py +++ b/uncloud/uncloud/settings.py @@ -170,29 +170,29 @@ STATIC_URL = '/static/' stripe.api_key = secrets.STRIPE_KEY # FIXME: not sure if we really need this -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'handlers': { - 'file': { - 'level': 'DEBUG', - 'class': 'logging.FileHandler', - 'filename': 'debug.log', - }, - }, - 'loggers': { - 'django': { - 'handlers': ['file'], - 'level': 'DEBUG', - 'propagate': True, - }, - 'django_auth_ldap': { - 'handlers': ['file'], - 'level': 'DEBUG', - 'propagate': True - } - }, -} +# LOGGING = { +# 'version': 1, +# 'disable_existing_loggers': False, +# 'handlers': { +# 'file': { +# 'level': 'DEBUG', +# 'class': 'logging.FileHandler', +# 'filename': 'debug.log', +# }, +# }, +# 'loggers': { +# 'django': { +# 'handlers': ['file'], +# 'level': 'DEBUG', +# 'propagate': True, +# }, +# 'django_auth_ldap': { +# 'handlers': ['file'], +# 'level': 'DEBUG', +# 'propagate': True +# } +# }, +# } # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { diff --git a/uncloud/uncloud/urls.py b/uncloud/uncloud/urls.py index a01ef66..60054c4 100644 --- a/uncloud/uncloud/urls.py +++ b/uncloud/uncloud/urls.py @@ -23,7 +23,6 @@ from opennebula import views as oneviews router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) -router.register(r'groups', views.GroupViewSet) router.register(r'opennebula', oneviews.VMViewSet, basename='opennebula') router.register(r'opennebula_raw', oneviews.RawVMViewSet) diff --git a/uncloud/uncloud_api/models.py b/uncloud/uncloud_api/models.py index 1540e69..50857fb 100644 --- a/uncloud/uncloud_api/models.py +++ b/uncloud/uncloud_api/models.py @@ -51,6 +51,7 @@ class Product(models.Model): default='pending' ) + # This is calculated by each product and saved in the DB recurring_price = models.FloatField() one_time_price = models.FloatField() @@ -67,6 +68,15 @@ class VMSnapshotProduct(Product): price_per_gb_ssd = 0.35 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_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, cls.sample_ssd, cls.sample_hdd, cls.sample_price()) - gb_ssd = models.FloatField() - gb_hdd = models.FloatField() + + + + diff --git a/uncloud/uncloud_api/views.py b/uncloud/uncloud_api/views.py index 68963ff..c8ffca7 100644 --- a/uncloud/uncloud_api/views.py +++ b/uncloud/uncloud_api/views.py @@ -7,17 +7,9 @@ from .serializers import UserSerializer, GroupSerializer from rest_framework.views import APIView from rest_framework.response import Response - -class CreditCardViewSet(viewsets.ModelViewSet): - - """ - 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] - +import inspect +import sys +import re class UserViewSet(viewsets.ModelViewSet): @@ -29,24 +21,6 @@ class UserViewSet(viewsets.ModelViewSet): 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 # GET /vm/snapshot => list @@ -57,9 +31,6 @@ class VMSnapshotView(generics.ListCreateAPIView): #lookup_field = 'uuid' permission_classes = [permissions.IsAuthenticated] -import inspect -import sys -import re # Next: create /order/ urls # Next: strip off "Product" at the end