move uncloud a layer up

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-02-23 14:07:37 +01:00
parent 1d1ae6fb3e
commit 94633d6cc8
70 changed files with 99 additions and 50 deletions

View file

@ -1,42 +0,0 @@
## How to place a order with penguin pay
### Requirements
* An ungleich account - can be registered for free on
https://account.ungleich.ch
* httpie installed (provides the http command)
## Get a membership
## Registering a payment method
To be able to pay for the membership, you will need to register a
credit card or apply for payment on bill (TO BE IMPLEMENTED).
### Register credit card
```
http POST https://api.ungleich.ch/membership \
username=nico password=yourpassword \
cc_number=.. \
cc_
```
### Request payment via bill
## Create the membership
```
http POST https://api.ungleich.ch/membership username=nico password=yourpassword
```
## List available products

View file

@ -49,3 +49,52 @@ password=...
* Django rest framework * Django rest framework
** viewset: .list and .create ** viewset: .list and .create
** view: .get .post ** 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
* An ungleich account - can be registered for free on
https://account.ungleich.ch
* httpie installed (provides the http command)
## Get a membership
## Registering a payment method
To be able to pay for the membership, you will need to register a
credit card or apply for payment on bill (TO BE IMPLEMENTED).
### Register credit card
```
http POST https://api.ungleich.ch/membership \
username=nico password=yourpassword \
cc_number=.. \
cc_
```
### Request payment via bill
## Create the membership
```
http POST https://api.ungleich.ch/membership username=nico password=yourpassword
```
## List available products

View file

@ -1 +0,0 @@
*

View file

@ -1,6 +0,0 @@
* TODO register CC
* TODO list products
* ahmed
** schemas
*** field: is_valid? - used by schemas
*** definition of a "schema"

View file

@ -15,7 +15,7 @@ class VM(models.Model):
def cores(self): def cores(self):
return int(self.data['TEMPLATE']['VCPU']) return int(self.data['TEMPLATE']['VCPU'])
@property @propertyx
def ram_in_gb(self): def ram_in_gb(self):
return (int(self.data['TEMPLATE']['MEMORY'])/1024.) return (int(self.data['TEMPLATE']['MEMORY'])/1024.)

View file

@ -12,3 +12,5 @@ class VMDetail(generics.RetrieveAPIView):
lookup_field = 'vmid' lookup_field = 'vmid'
queryset = VM.objects.all() queryset = VM.objects.all()
serializer_class = VMSerializer serializer_class = VMSerializer
class VMViewSet(

View file

View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class UncloudVmConfig(AppConfig):
name = 'uncloud_vm'

View file

@ -0,0 +1,12 @@
from django.db import models
class VM(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
cores = models.IntegerField()
ram = models.FloatField()
class VMDisk(models.Model):

View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View file

@ -0,0 +1,24 @@
from django.shortcuts import render
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404
from myapps.serializers import UserSerializer
from rest_framework import viewsets
from rest_framework.response import Response
from opennebula.models import VM as OpenNebulaVM
class VMViewSet(viewsets.ViewSet):
def list(self, request):
queryset = User.objects.all()
serializer = UserSerializer(queryset, many=True)
return Response(serializer.data)
def retrieve(self, request, pk=None):
queryset = User.objects.all()
user = get_object_or_404(queryset, pk=pk)
serializer = UserSerializer(user)
return Response(serializer.data)
permission_classes = [permissions.IsAuthenticated]