转换代码修改

This commit is contained in:
tzwang 2022-10-27 02:57:24 -07:00
parent 5321eb916c
commit 4c7a07b5b4
1 changed files with 14 additions and 26 deletions

View File

@ -37,38 +37,18 @@ func (slurmStruct SlurmStruct) ListNodes(ctx context.Context, req *pbslurm.ListN
func (slurmStruct SlurmStruct) GetAllJobs(ctx context.Context, req *pbslurm.JobInfoMsgReq) (*pbslurm.JobInfoMsgResp, error) {
job_info_msg := slurm.Get_all_jobs()
var resp = pbslurm.JobInfoMsgResp{}
var jobInfoList = getJobList(job_info_msg)
jobInfoMsg := pbslurm.JobInfoMsg{}
jobInfoMsg.RecordCount = job_info_msg.Record_count
jobInfoMsg.LastUpdate = job_info_msg.Last_update
jobInfoMsg.JobList = jobInfoList
resp.JobInfoMsg = append(resp.JobInfoMsg, &jobInfoMsg)
return &resp, nil
return getJobInfoMsgResp(job_info_msg), nil
}
func (slurmStruct SlurmStruct) GetJob(ctx context.Context, req *pbslurm.JobInfoMsgReq) (*pbslurm.JobInfoMsgResp, error) {
job_info_msg := slurm.Get_job(req.JobId)
var resp = pbslurm.JobInfoMsgResp{}
var jobInfoList = getJobList(job_info_msg)
jobInfoMsg := pbslurm.JobInfoMsg{}
jobInfoMsg.RecordCount = job_info_msg.Record_count
jobInfoMsg.LastUpdate = job_info_msg.Last_update
jobInfoMsg.JobList = jobInfoList
resp.JobInfoMsg = append(resp.JobInfoMsg, &jobInfoMsg)
return &resp, nil
return getJobInfoMsgResp(job_info_msg), nil
}
func getJobList(job_info_msg slurm.Job_info_msg) []*pbslurm.JobInfo {
func getJobInfoMsgResp(job_info_msg slurm.Job_info_msg) *pbslurm.JobInfoMsgResp {
var resp = pbslurm.JobInfoMsgResp{}
var jobInfoList = []*pbslurm.JobInfo{}
for _, e := range job_info_msg.Job_list {
jobInfo := pbslurm.JobInfo{}
jobInfo.ArrayJobId = e.Array_job_id
@ -146,5 +126,13 @@ func getJobList(job_info_msg slurm.Job_info_msg) []*pbslurm.JobInfo {
jobInfo.Wait4Switch = e.Wait4switch
jobInfoList = append(jobInfoList, &jobInfo)
}
return jobInfoList
jobInfoMsg := pbslurm.JobInfoMsg{}
jobInfoMsg.RecordCount = job_info_msg.Record_count
jobInfoMsg.LastUpdate = job_info_msg.Last_update
jobInfoMsg.JobList = jobInfoList
resp.JobInfoMsg = append(resp.JobInfoMsg, &jobInfoMsg)
return &resp
}