예제 #1
0
    def post(self):
        try:
            post_param = urlparse.parse_qs(self.request.body, True)
            print post_param
            UserName = post_param['UserName'][0]
            ClusterName = post_param['ClusterName'][0]
            JenkinsURL = JENKINSURL
            if (ClusterName == "PublicCluster"):
                JenkinsURL = JENKINSURL
            else:
                ret_info = {"errcode": 1, "ret": "ERROR : cluster not exist"}
                self.write(json.dumps(ret_info))
                return
            JobName = post_param['JobName'][0]
            SpecifyNode = int(post_param['SpecifyNode'][0])
            JobParameter = json.loads(post_param['JobParameter'][0])

            for item in JobParameter:
                if (type(JobParameter[item]) == list
                        or type(JobParameter[item]) == dict):
                    JobParameter[item] = json.dumps(JobParameter[item])
            #print JobParameter
            url = gearmanjobclient.addtask(UserName, JenkinsURL, JobName,
                                           SpecifyNode, JobParameter)
            ret_info = {"errcode": 0, "ret": url}
            self.write(json.dumps(ret_info))
        except KeyError:
            try:
                jsonobj = json.loads(self.request.body)
                UserName = jsonobj['UserName']
                ClusterName = jsonobj['ClusterName']
                JenkinsURL = JENKINSURL
                if (ClusterName == "PublicCluster"):
                    JenkinsURL = JENKINSURL
                else:
                    ret_info = {
                        "errcode": 1,
                        "ret": "ERROR : cluster not exist"
                    }
                    self.write(json.dumps(ret_info))
                    return
                JobName = jsonobj['JobName']
                SpecifyNode = int(jsonobj['SpecifyNode'])
                JobParameter = jsonobj['JobParameter']

                for item in JobParameter:
                    if (type(JobParameter[item]) == list
                            or type(JobParameter[item]) == dict):
                        JobParameter[item] = json.dumps(JobParameter[item])
                #print JobParameter
                url = gearmanjobclient.addtask(UserName, JenkinsURL, JobName,
                                               SpecifyNode, JobParameter)
                ret_info = {"errcode": 0, "ret": url}
                self.write(json.dumps(ret_info))
            except Exception as e:
                print(e)
                ret_info = {"errcode": 1, "ret": "ERROR : internal error"}
                self.write(json.dumps(ret_info))
예제 #2
0
    def post(self):
        try:
            post_param=urlparse.parse_qs(self.request.body,True)
            print post_param
            UserName=post_param['UserName'][0]
            ClusterName=post_param['ClusterName'][0]
            JenkinsURL = JENKINSURL
            if (ClusterName == "PublicCluster"):
                JenkinsURL = JENKINSURL
            else:
                ret_info = {"errcode":1, "ret":"ERROR : cluster not exist"}
                self.write(json.dumps(ret_info))
                return
            JobName=post_param['JobName'][0]
            SpecifyNode=int(post_param['SpecifyNode'][0])
            JobParameter=json.loads(post_param['JobParameter'][0])

            for item in JobParameter:
                if(type(JobParameter[item]) == list or type(JobParameter[item]) == dict):
                    JobParameter[item] = json.dumps(JobParameter[item])
            #print JobParameter
            url = gearmanjobclient.addtask(UserName, JenkinsURL, JobName, SpecifyNode, JobParameter)
            ret_info = {"errcode":0,"ret":url}
            self.write(json.dumps(ret_info))
        except KeyError:
            try:
                jsonobj = json.loads(self.request.body)
                UserName = jsonobj['UserName']
                ClusterName = jsonobj['ClusterName']
                JenkinsURL = JENKINSURL
                if (ClusterName == "PublicCluster"):
                    JenkinsURL = JENKINSURL
                else:
                    ret_info = {"errcode":1, "ret":"ERROR : cluster not exist"}
                    self.write(json.dumps(ret_info))
                    return
                JobName = jsonobj['JobName']
                SpecifyNode = int(jsonobj['SpecifyNode'])
                JobParameter = jsonobj['JobParameter']

                for item in JobParameter:
                    if(type(JobParameter[item]) == list or type(JobParameter[item]) == dict):
                        JobParameter[item] = json.dumps(JobParameter[item])
                #print JobParameter
                url = gearmanjobclient.addtask(UserName, JenkinsURL, JobName, SpecifyNode, JobParameter)
                ret_info = {"errcode":0,"ret":url}
                self.write(json.dumps(ret_info))
            except Exception as e:
                print(e)
                ret_info = {"errcode":1,"ret":"ERROR : internal error"}
                self.write(json.dumps(ret_info))
예제 #3
0
    def post(self):
        try:
            jsonobj = json.loads(self.request.body)
            UserName = jsonobj['UserName']
            JenkinsURL = jsonobj['JenkinsURL']
            JobName = jsonobj['JobName']
            SpecifyNode = int(jsonobj['SpecifyNode'])
            JobParameter = jsonobj['JobParameter']

            for item in JobParameter:
                if(type(JobParameter[item]) == list or type(JobParameter[item]) == dict):
                    JobParameter[item] = json.dumps(JobParameter[item])
            #print JobParameter
            url = gearmanjobclient.addtask(UserName, JenkinsURL, JobName, SpecifyNode, JobParameter)
            ret_info = {"ret":url}
            self.write(json.dumps(ret_info))
        except Exception as e:
            print(e)
            ret_info = {"ret":"ERROR : internal error"}
            self.write(json.dumps(ret_info))
예제 #4
0
    def post(self):
        try:
            jsonobj = json.loads(self.request.body)
            UserName = jsonobj['UserName']
            JenkinsURL = jsonobj['JenkinsURL']
            JobName = jsonobj['JobName']
            SpecifyNode = int(jsonobj['SpecifyNode'])
            JobParameter = jsonobj['JobParameter']

            for item in JobParameter:
                if (type(JobParameter[item]) == list
                        or type(JobParameter[item]) == dict):
                    JobParameter[item] = json.dumps(JobParameter[item])
            #print JobParameter
            url = gearmanjobclient.addtask(UserName, JenkinsURL, JobName,
                                           SpecifyNode, JobParameter)
            ret_info = {"ret": url}
            self.write(json.dumps(ret_info))
        except Exception as e:
            print(e)
            ret_info = {"ret": "ERROR : internal error"}
            self.write(json.dumps(ret_info))