Commit 01de9191 by Bodor Máté

Use connection dict to connect to the interface

parent ab579640
Pipeline #751 failed with stages
in 18 seconds
...@@ -3,18 +3,17 @@ from image.serializers import DiskSerializer ...@@ -3,18 +3,17 @@ from image.serializers import DiskSerializer
# from django.shortcuts import render # from django.shortcuts import render
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 openstack
from interface_openstack.implementation.image.openstack_image_manager import ( from interface_openstack.implementation.image.openstack_image_manager import (
OpenstackImageManager, OpenstackImageManager,
) )
import openstack from django.conf import settings
conn = openstack.connect(cloud="openstack")
class DiskList(APIView): class DiskList(APIView):
def get(self, request, format=None): def get(self, request, format=None):
# OpenStack # OpenStack
interface = OpenstackImageManager(conn) interface = OpenstackImageManager(settings.CONNECTION)
return Response([disk.__dict__ for disk in interface.list()]) return Response([disk.__dict__ for disk in interface.list()])
# Create response # Create response
......
...@@ -4,14 +4,11 @@ from django.http import Http404 ...@@ -4,14 +4,11 @@ from django.http import Http404
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework import status from rest_framework import status
from interface_openstack.implementation.vm.instance import OSVirtualMachineManager
import openstack import openstack
import datetime import datetime
from interface_openstack.implementation.vm.instance import OSVirtualMachineManager
conn = openstack.connect(cloud="openstack") from django.conf import settings
class InstanceList(APIView): class InstanceList(APIView):
def get(self, request, format=None): def get(self, request, format=None):
...@@ -20,7 +17,7 @@ class InstanceList(APIView): ...@@ -20,7 +17,7 @@ class InstanceList(APIView):
def post(self, request, format=None): def post(self, request, format=None):
data = request.data data = request.data
interface = OSVirtualMachineManager(conn) interface = OSVirtualMachineManager(settings.CONNECTION)
imageId = "da51253f-867c-472d-8ce0-81e7b7126d60" imageId = "da51253f-867c-472d-8ce0-81e7b7126d60"
flavorId = "1" flavorId = "1"
networks = [{"uuid": "c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"}] networks = [{"uuid": "c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"}]
......
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