コード例 #1
0
    def get_queryset(self):
        service = CalipsoAvailableImagesServices()

        username = self.kwargs.get('username')
        if username == self.request.user.username:
            return service.get_sum_containers_quota(username=username)
        else:
            raise PermissionDenied
コード例 #2
0
 def get(self, *args, **kwargs):
     service = CalipsoAvailableImagesServices()
     username = self.kwargs.get('username')
     if username == self.request.user.username:
         quota = service.get_sum_containers_quota(username=username)
         serializer_class = CalipsoUserQuotaSerializer(quota)
         return Response(serializer_class.data)
     else:
         raise PermissionDenied
コード例 #3
0
 def put(self, request, *args, **kwargs):
     service = CalipsoAvailableImagesServices()
     public_name = self.kwargs.get('public_name')
     service.modify_image(public_name=public_name,
                          image=request.data.get('image'),
                          port_hook=request.data.get('port_hook'),
                          logs_er=request.data.get('logs_er'),
                          protocol=request.data.get('protocol'),
                          cpu=request.data.get('cpu'),
                          memory=request.data.get('memory'),
                          hdd=request.data.get('hdd'))
     return Response(status=status.HTTP_200_OK)
コード例 #4
0
from rest_framework.permissions import IsAuthenticated

from apprest.serializers.container import CalipsoContainerSerializer
from apprest.services.container import CalipsoContainersServices
from apprest.services.guacamole import CalipsoGuacamoleServices
from apprest.services.image import CalipsoAvailableImagesServices
from apprest.services.session import CalipsoSessionsServices

from apprest.utils.request import JSONResponse, ErrorFormatting

from django.conf import settings

container_service = CalipsoContainersServices()
guacamole_service = CalipsoGuacamoleServices()
session_service = CalipsoSessionsServices()
image_service = CalipsoAvailableImagesServices()

logger = logging.getLogger(__name__)
errorFormatting = ErrorFormatting()


@api_view(['GET'])
@permission_classes((IsAuthenticated, ))
@authentication_classes((
    SessionAuthentication,
    BasicAuthentication,
))
def rm_container(request, username, container_name):
    if username != request.user.username:
        return JSONResponse("username mismatch",
                            status=status.HTTP_403_FORBIDDEN)
コード例 #5
0
 def delete(self, *args, **kwargs):
     service = CalipsoAvailableImagesServices()
     service.delete_image(self.kwargs.get('public_name'))
     return Response(status=status.HTTP_204_NO_CONTENT)
コード例 #6
0
 def get(self, *args, **kwargs):
     service = CalipsoAvailableImagesServices()
     public_name = self.kwargs.get('public_name')
     image = service.get_available_image(public_name=public_name)
     serializer_class = CalipsoImageSerializer(image)
     return Response(serializer_class.data)
コード例 #7
0
 def get(self, *args, **kwargs):
     service = CalipsoAvailableImagesServices()
     images = service.get_all_images()
     serializer_class = CalipsoImageSerializer(images, many=True)
     return Response(serializer_class.data)
コード例 #8
0
    def get_queryset(self):
        service = CalipsoAvailableImagesServices()

        return service.get_all_images()
コード例 #9
0
    def get_queryset(self):
        service = CalipsoAvailableImagesServices()
        public_name = self.kwargs.get('public_name')

        return service.get_available_image(public_name=public_name)