예제 #1
0
 def delete(self, request):
     reqData = parseJson(request.body)
     params = mandatoryParams(reqData, 'db_user', 'db_name', 'host')
     try:
         host = core.models.Host.objects.get(main_domain=params['host'])
     except core.models.Host.DoesNotExist:
         return makeError('Host does not exists: {host}', params)
     params['db_type'] = self.DB_TYPE
     res = core.hostjobs.DatabaseJobs(host.main_domain,
                                      request.user.username).remove(params)
     return JsonResponse({'completed': False, 'id': taskToId(res)})
예제 #2
0
 def post(self, request):
     reqData = parseJson(request.body)
     mandatoryParams(reqData, 'domain')
     # Filter for current user
     user = request.user
     try:
         domain = core.models.DomainModel.objects.get(
             domain_name=reqData['domain'], user=user)
     except core.models.DomainModel.DoesNotExist:
         return makeError('Invalid domain id: {domain}', reqData)
     res = core.hostjobs.DomainJobs(domain.host.main_domain,
                                    user.username).enableSsl(reqData)
     return JsonResponse({'completed': False, 'id': taskToId(res)})
예제 #3
0
 def getHostContainers(self, hosts):
     containers = {}
     if len(hosts) == 0:
         return containers
     try:
         r = getRedisConnection()
         hostKeys = ['dockerStatus:' + host for host in hosts]
         dockerStatuses = r.mget(hostKeys)
         for host in hosts:
             stat = dockerStatuses.pop(0)
             containers[host] = parseJson(stat) if stat else {}
     except:
         pass
     return containers
예제 #4
0
 def put(self, request):
     reqData = parseJson(request.body)
     mandatoryParams(reqData, 'domain', 'publicKey')
     # Filter for current user
     user = request.user
     reqData['user'] = user.username
     try:
         domain = core.models.DomainModel.objects.get(
             domain_name=reqData['domain'], user=user)
     except ObjectDoesNotExist:
         return makeError('Invalid domain id: {domain}', reqData)
     if not domain.host:
         return makeError('Domain [{domain}] has no host attached.',
                          reqData)
     res = core.hostjobs.DomainJobs(domain.host.main_domain,
                                    user.username).addPublicKey(reqData)
     return JsonResponse({'completed': False, 'id': taskToId(res)})
예제 #5
0
 def post(self, request):
     reqData = parseJson(request.body)
     reqData = mandatoryParams(reqData, 'domain')
     # Filter for current user
     user = request.user
     try:
         domain = core.models.DomainModel.objects.get(
             domain_name=reqData['domain'])
     except ObjectDoesNotExist:
         return makeError("Domain doesn't exist exists: {domain}", reqData)
     if not domain.host:
         return makeError('Domain [{domain}] has no host attached.',
                          reqData)
     reqData['host'] = domain.host.main_domain
     reqData['app_type'] = domain.app_type.to_dict(json=True)
     res = core.hostjobs.DomainJobs(domain.host.main_domain,
                                    user.username).create(reqData)
     return JsonResponse({'completed': False, 'id': taskToId(res)})
예제 #6
0
 def post(self, request):
     reqData = parseJson(request.body)
     reqData = mandatoryParams(reqData, 'domain', 'app_type', 'host')
     # Filter for current user
     user = request.user
     try:
         core.models.DomainModel.objects.get(domain_name=reqData['domain'])
         return makeError('Domain already exists: {domain}', reqData)
     except ObjectDoesNotExist:
         pass
     try:
         host = core.models.Host.objects.get(main_domain=reqData['host'])
     except ObjectDoesNotExist:
         return makeError('Host does not exists: {host}', reqData)
     try:
         app_type = core.models.ContainerRuntime.objects.get(
             id=reqData['app_type'])
     except ObjectDoesNotExist:
         return makeError('app_type does not exists: {host}', reqData)
     reqData['app_type'] = app_type.to_dict(json=True)
     res = core.hostjobs.DomainJobs(host.main_domain,
                                    user.username).create(reqData)
     return JsonResponse({'completed': False, 'id': taskToId(res)})