Beispiel #1
0
 def put(self, request, *args, **kwargs):
     """
     Handles ember requests with user's cluster creation parameters.
     Check the parameters with HadoopCluster object from create_cluster
     script.
     """
     self.resource_name = 'clusterchoice'
     self.serializer_class = ClusterchoicesSerializer
     serializer = self.serializer_class(data=request.DATA)
     if serializer.is_valid():
         user_token = Token.objects.get(key=request.auth)
         user = UserInfo.objects.get(user_id=user_token.user.user_id)
         if serializer.data['hadoop_status']:
             try:
                 cluster_action = hadoop_cluster_action_async.delay(serializer.data['id'],
                                                                    serializer.data['hadoop_status'])
                 task_id = cluster_action.id
                 return Response({"id":1, "task_id": task_id}, status=status.HTTP_202_ACCEPTED)
             except Exception, e:
                 return Response({"status": str(e.args[0])})
         # Update existing cluster
         if serializer.data['cluster_edit']:
             cluster = ClusterInfo.objects.get(id=serializer.data['cluster_edit'])
             cluster_delta = serializer.data['cluster_size']-cluster.cluster_size
             try:
                 cluster_action = scale_cluster_async.delay(user.okeanos_token, serializer.data['cluster_edit'], cluster_delta)
                 task_id = cluster_action.id
                 return Response({"id":1, "task_id": task_id}, status=status.HTTP_202_ACCEPTED)
             except Exception, e:
                 return Response({"status": str(e.args[0])})
Beispiel #2
0
    def put(self, request, *args, **kwargs):
        """
        Handles ember requests with user's cluster creation parameters.
        Check the parameters with HadoopCluster object from create_cluster
        script.
        """
        self.resource_name = 'clusterchoice'
        self.serializer_class = ClusterchoicesSerializer
        serializer = self.serializer_class(data=request.DATA)
        if serializer.is_valid():
            user_token = Token.objects.get(key=request.auth)
            user = UserInfo.objects.get(user_id=user_token.user.user_id)
            if serializer.data['hadoop_status']:
                try:
                    cluster_action = hadoop_cluster_action_async.delay(serializer.data['id'],
                                                                       serializer.data['hadoop_status'])
                    task_id = cluster_action.id
                    return Response({"id":1, "task_id": task_id}, status=status.HTTP_202_ACCEPTED)
                except Exception, e:
                    return Response({"status": str(e.args[0])})

            # Dictionary of YarnCluster arguments
            choices = dict()
            choices = serializer.data.copy()
            choices.update({'token': user.okeanos_token})
            try:
                YarnCluster(choices).check_user_resources()
            except ClientError, e:
                return Response({"id": 1, "message": e.message})
Beispiel #3
0
    def put(self, request, *args, **kwargs):
        """
        Handles ember requests with user's cluster creation parameters.
        Check the parameters with HadoopCluster object from create_cluster
        script.
        """
        self.resource_name = 'clusterchoice'
        self.serializer_class = ClusterchoicesSerializer
        serializer = self.serializer_class(data=request.DATA)
        if serializer.is_valid():
            user_token = Token.objects.get(key=request.auth)
            user = UserInfo.objects.get(user_id=user_token.user.user_id)
            if serializer.data['hadoop_status']:
                try:
                    cluster_action = hadoop_cluster_action_async.delay(
                        serializer.data['id'],
                        serializer.data['hadoop_status'])
                    task_id = cluster_action.id
                    return Response({
                        "id": 1,
                        "task_id": task_id
                    },
                                    status=status.HTTP_202_ACCEPTED)
                except Exception, e:
                    return Response({"status": str(e.args[0])})

            # Dictionary of YarnCluster arguments
            choices = dict()
            choices = serializer.data.copy()
            choices.update({'token': user.okeanos_token})
            try:
                YarnCluster(choices).check_user_resources()
            except ClientError, e:
                return Response({"id": 1, "message": e.message})