def post(self, request, *args, **kwargs):
     task_id = int(self.kwargs['task_id'])
     config_stages = request.data.get('config_stages', None)
     if config_stages is not None:
         for stage in config_stages:
             temp_serializer = self.get_serializer(data=stage)
             temp_serializer.is_valid()
             temp_serializer._saving_instances = False
             instance = CITaskConfigService.task_stage(stage.get('id'))
             instance = temp_serializer.recursive_save(
                 temp_serializer.validated_data, instance)
             instance.save()
             for step in stage.get('steps', []):
                 temp_serializer = ci_step_serializer.CITaskStepSerializer(
                     data=step)
                 temp_serializer.is_valid()
                 temp_serializer._saving_instances = False
                 instance = CITaskConfigService.task_step(step.get('id'))
                 instance = temp_serializer.recursive_save(
                     temp_serializer.validated_data, instance)
                 instance.save()
         parameter_groups = CITaskParameterService.task_parameter_list(
             task_id)
         for group in parameter_groups:
             CITaskParameterService.save_step_settings(str(group.id))
     return Response(config_stages, status=status.HTTP_201_CREATED)
Exemple #2
0
 def update(self, request, *args, **kwargs):
     result = {"code": 1, "message": "更新成功"}
     try:
         CITaskParameterService.update_task_parameter(request.data)
     except Exception as ex:
         result["code"] = 0
         result["message"] = "参数更新失败"
     return response.Response(request,status=status.HTTP_202_ACCEPTED)
def create(request, task_id):
    '''create a new parameter group after press enter'''
    result = True
    try:
        CITaskParameterService.create_task_parameter(request, task_id)
    except Exception as ex:
        result = str(ex)
        SimpleLogger.exception(ex)
    return HttpResponse(result)
 def post(self, request, *args, **kwargs):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     self.perform_create(serializer)
     CITaskParameterService.save_step_settings(serializer.instance.id)
     headers = self.get_success_headers(serializer.data)
     return Response(serializer.data,
                     status=status.HTTP_201_CREATED,
                     headers=headers)
def copy(request):
    '''save parameter value for exiting parameter group'''
    result = True
    try:
        CITaskParameterService.copy_task_parameter(request)
    except Exception as ex:
        result = str(ex)
        SimpleLogger.exception(ex)
    return HttpResponse(result)
 def delete(self, request, *args, **kwargs):
     stage_id = self.kwargs['stage_id']
     CITaskConfigService.delete_steps(stage_id)
     stage = CITaskConfigService.task_stage(stage_id)
     parameter_groups = CITaskParameterService.task_parameter_list(
         stage.task_id)
     for group in parameter_groups:
         CITaskParameterService.save_step_settings(str(group.id))
     return self.destroy(request, *args, **kwargs)
 def task_parameter_confirm_dialog(self, request):
     parameter_group_id = request.GET.get('group_id')
     task_parameter_group = CITaskParameterService.task_parameter(
         parameter_group_id)
     pre_task_parameter_group = CITaskParameterService.init_parameter_group(
         request)
     task_parameter_diff = VM_TaskParameterGroupDiff(
         task_parameter_group, pre_task_parameter_group)
     pagefileds = {
         "task_parameter_group": task_parameter_group,
         "task_parameter_diff": task_parameter_diff
     }
     return self.get_webpart(pagefileds, CITaskPath.task_parameter_confirm)
 def post(self, request, *args, **kwargs):
     stage_id = self.kwargs.get('stage_id', None)
     stage = CITaskConfigService.task_stage(stage_id)
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     self.perform_create(serializer)
     headers = self.get_success_headers(serializer.data)
     parameter_groups = CITaskParameterService.task_parameter_list(
         stage.task_id)
     for group in parameter_groups:
         CITaskParameterService.save_step_settings(str(group.id))
     return Response(serializer.data,
                     status=status.HTTP_201_CREATED,
                     headers=headers)
 def copy_ci_task(validate_data,user):
     task_id=int(validate_data.get('CopyTaskID'))
     ci_task=CITask.objects.get(int(task_id))
     ci_task.TaskName=validate_data.get('TaskName')
     ci_task.Project=validate_data.get('Project')
     ci_task.BuildVersion=0
     ci_task.id=None
     ci_task.Creator=user.id
     ci_task.save()
     new_config=CITaskConfigService.copy_config(ci_task.TaskConfig,ci_task.id,ci_task.TaskName)
     ci_task.TaskConfig=new_config
     ci_task.save()
     CITaskParameterService.copy_parameter_group_form_task(task_id,ci_task.id)
     CITaskService.log_create_activity(user, ci_task)
     return ci_task
Exemple #10
0
 def start_ci_task(request, task_id, parameter_group_id, project_version):
     ci_task = CITask.objects.get(int(task_id))
     queuetask = TaskQueue()
     queuetask.EnqueueTime = DateTimeHelper.get_local_now()
     queuetask.TaskType = ci_task.TaskType
     queuetask.Command = TaskQueueCommandTypeEnum.TaskQueueCommandType_Start
     queuetask.Priority = 2
     queuetask.Status = TaskQueueStatusEnum.QueueTaskStatus_New
     queuetask.TaskID = int(task_id)
     queuetask.TaskUUID = uuid.uuid1()
     if parameter_group_id:
         queuetask.BuildParameterID = parameter_group_id
     else:
         queuetask.BuildParameterID = CITaskParameterService.default_parameter_group(
             int(task_id))
     queuetask.save()
     ci_task.BuildVersion = ci_task.BuildVersion + 1
     if str(project_version) == '0':
         project_version = VersionService.get_latest_version(
             ci_task.Project)
         if project_version:
             project_version = project_version.id
         else:
             project_version = 0
     ci_task.LastHistory = CITaskService.save_ci_taskhistory(
         request, queuetask, ci_task, project_version)
     ci_task.save(update_fields=['BuildVersion', 'LastHistory'])
     message = "任务ID为:" + str(task_id) + "的执行指令已经下发,请耐心等待。"
     user_id = 0
     if request.user.id:
         user_id = request.user.id
     CITaskService.log_build_activity(user_id, ci_task)
     CITaskService.send_task_enqueue_message()
     return [queuetask.id, message, queuetask.TaskUUID]
 def build_parameter(self):
     result = "--"
     if self.ci_task_history.BuildParameterID:
         parameter_group = CITaskParameterService.task_parameter(
             self.ci_task_history.BuildParameterID)
         if parameter_group:
             result = parameter_group.group_name
     return result
 def get_ci_task_parameter_list(self, task_id):
     ci_task = CITask.objects.get(int(task_id))
     task_parameter_groups = CITaskParameterService.task_parameter_list(
         int(task_id))
     vm_groups = list()
     for group in task_parameter_groups:
         temp = VM_TaskParameterGroup(group)
         vm_groups.append(temp)
     pagefileds = {"ci_task_parameter_groups": vm_groups, "task": ci_task}
     return self.get_webpart(pagefileds, CITaskPath.task_parameter_list)
Exemple #13
0
 def get_ParameterGroups(self, obj):
     parameter_groups = CITaskParameterService.task_parameter_list(obj.id)
     result = list()
     for item in parameter_groups:
         temp = dict()
         temp['id'] = str(item.id)
         temp['title'] = item.group_name
         temp['default'] = item.is_default
         result.append(temp)
     return result
 def get_ci_task_parameter_edit(self, parameter_group_id):
     task_parameter_group = CITaskParameterService.task_parameter(
         parameter_group_id)
     vm_task_parameter_group = VM_TaskParameterGroup(task_parameter_group)
     task_plugin_list = self.parameter_group_plugin_webpart(
         task_parameter_group.task_id, task_parameter_group)
     pagefileds = {
         "task_parameter_group": vm_task_parameter_group,
         "task_plugin_list": task_plugin_list
     }
     return self.get_webpart(pagefileds, CITaskPath.task_parameter_edit)
def build_with_parameter_page(request,task_id,task_property):
    ''' index page'''
    try:
        page_worker=CIDeployPageWorker(request)
        if CITaskParameterService.has_parameters(task_id):
            return page_worker.build_with_parameter_fullpage(request,task_id,task_property)
        else:
            CITaskService.start_ci_task(request,task_id,0,0)
    except Exception as ex:
        SimpleLogger.exception(ex)
    return redirect('/ci/dashboard',request)
Exemple #16
0
 def get_ParameterGroups(self, obj):
     parameter_groups = CITaskParameterService.task_parameter_list(obj.id)
     result = list()
     for item in parameter_groups:
         temp = dict()
         temp['id'] = str(item.id)
         temp['title'] = item.group_name
         temp['default'] = item.is_default
         temp['parameters'] = list()
         i = 1
         if item.parameters is not None:
             for parameter in item.parameters:
                 temp_dict = dict()
                 temp_dict['id'] = i
                 temp_dict['key'] = parameter.key
                 temp_dict['value'] = parameter.value
                 temp_dict['description'] = parameter.description
                 temp['parameters'].append(temp_dict)
                 i = i + 1
         result.append(temp)
     return result
 def post(self, request, *args, **kwargs):
     group_id = self.kwargs['id']
     parameter_group = CITaskParameterService.copy_task_parameter(group_id)
     group_serializer = ci_serializer.TaskParameterGroupSerializer(
         instance=parameter_group)
     return Response(group_serializer.data)
 def get_object(self):
     group_id = self.kwargs['id']
     return CITaskParameterService.task_parameter(group_id)
Exemple #19
0
 def has_parameters(self):
     return CITaskParameterService.has_parameters(self.ci_task.id)
 def task_parameter_dropdown_list(self, task_id):
     task_parameter_groups = CITaskParameterService.task_parameter_list(
         int(task_id))
     pagefileds = {"ci_task_parameter_groups": task_parameter_groups}
     return self.get_webpart(
         pagefileds, CICommonControllPath.task_parameter_dropdownlist)
 def get_queryset(self):
     task_id = self.kwargs['task_id']
     return CITaskParameterService.task_parameter_list(task_id)
 def get_task_parameter_menu(self, task_id):
     task_parameter_group = CITaskParameterService.task_parameter_list(
         int(task_id))
     pagefileds = {"parameter_groups": task_parameter_group}
     return self.get_webpart(pagefileds, CITaskPath.task_parameter_menu)
 def patch(self, request, *args, **kwargs):
     result = self.partial_update(request, *args, **kwargs)
     group = self.get_object()
     if group.is_default:
         CITaskParameterService.set_parameter_group_default(group, True)
     return result