Ejemplo n.º 1
0
 def delete_container(self, request, pk=None):
     user_info = request.user
     container_vul = self.get_object()
     task_id = tasks.delete_container_task(
         container_vul=container_vul,
         user_info=user_info,
         request_ip=get_request_ip(request))
     return JsonResponse(R.ok(task_id))
Ejemplo n.º 2
0
 def stop_container(self, request, pk=None):
     """
     停止容器运行
     :param request:
     :param pk:
     :return:
     """
     user_info = request.user
     container_vul = self.get_object()
     expire = request.GET.get('expire', "")
     task_id = tasks.stop_container_task(container_vul=container_vul,
                                         user_info=user_info,
                                         request_ip=get_request_ip(request))
     setting_config = get_setting_config()
     del_container = setting_config['del_container']
     if expire != "" and expire == "true":
         if not del_container or del_container == 0 or del_container == '0':
             pass
         else:
             tasks.delete_container_task(container_vul=container_vul,
                                         user_info=user_info,
                                         request_ip=get_request_ip(request))
     return JsonResponse(R.ok(task_id))
Ejemplo n.º 3
0
 def delete_container(self, request, pk=None):
     """
     删除容器
     :param request:
     :param pk:
     :return:
     """
     if not pk:
         return JsonResponse(R.build(msg="id不能为空"))
     container_vul = ContainerVul.objects.filter(
         Q(docker_container_id__isnull=False),
         ~Q(docker_container_id=''),
         container_id=pk).first()
     if not container_vul:
         return JsonResponse(R.build(msg="环境不存在"))
     user_info = request.user
     # container_vul = self.get_object()
     task_id = tasks.delete_container_task(
         container_vul=container_vul,
         user_info=user_info,
         request_ip=get_request_ip(request))
     return JsonResponse(R.ok(task_id))