2017-05-11 02:05:58 +00:00
|
|
|
from rest_framework import generics
|
2017-05-11 03:51:30 +00:00
|
|
|
|
|
|
|
from .serializers import VirtualMachineTemplateSerializer, \
|
|
|
|
VirtualMachineSerializer
|
|
|
|
from .models import VirtualMachineTemplate, VirtualMachine, OpenNebulaManager
|
2017-05-09 14:33:56 +00:00
|
|
|
|
2017-05-11 02:05:58 +00:00
|
|
|
class TemplateCreateView(generics.ListCreateAPIView):
|
|
|
|
"""This class defines the create behavior of our rest api."""
|
|
|
|
queryset = VirtualMachineTemplate.objects.all()
|
|
|
|
serializer_class = VirtualMachineTemplateSerializer
|
|
|
|
|
|
|
|
def perform_create(self, serializer):
|
|
|
|
"""Save the post data when creating a new template."""
|
|
|
|
serializer.save()
|
|
|
|
|
|
|
|
class TemplateDetailsView(generics.RetrieveUpdateDestroyAPIView):
|
|
|
|
"""This class handles the http GET, PUT and DELETE requests."""
|
|
|
|
|
|
|
|
queryset = VirtualMachineTemplate.objects.all()
|
|
|
|
serializer_class = VirtualMachineTemplateSerializer
|
2017-05-11 03:51:30 +00:00
|
|
|
|
|
|
|
class VmCreateView(generics.ListCreateAPIView):
|
|
|
|
"""This class defines the create behavior of our rest api."""
|
|
|
|
queryset = VirtualMachine.objects.all()
|
|
|
|
serializer_class = VirtualMachineSerializer
|
|
|
|
|
|
|
|
def perform_create(self, serializer):
|
|
|
|
"""Save the post data when creating a new template."""
|
|
|
|
serializer.save()
|
|
|
|
|
|
|
|
class VmDetailsView(generics.RetrieveUpdateDestroyAPIView):
|
|
|
|
"""This class handles the http GET, PUT and DELETE requests."""
|
|
|
|
|
|
|
|
queryset = VirtualMachine.objects.all()
|
|
|
|
serializer_class = VirtualMachineSerializer
|