Commit 261dd9e0 by Gazdag Péter

add image view

parent eeb4dcd3
from django.urls import include, path
from rest_framework.urlpatterns import format_suffix_patterns
from image import views
urlpatterns = [
path('image/', include('image.urls')),
]
\ No newline at end of file
path('', views.DiskList.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
\ No newline at end of file
from image.models import Disk
from image.serializers import DiskSerializer
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from implementation.image.OpenstackImageManager import OpenstackImageManager
import openstack
conn = openstack.connect(cloud='openstack')
class DiskList(APIView):
def get(self, request, format=None):
#OpenStack
interface = OpenstackImageManager(conn)
return Response([disk.toJSON() for disk in interface.list()])
#Create response
disks = Disk.object.all()
serializer = DiskSerializer(disks, many=True)
return Response(serializer.data)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment