1 # Copyright 2016 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from lcm.pub.utils.jobutil import JobUtil
17 from lcm.pub.utils.values import remove_none_key
18 from lcm.jobs.api_model import JobQueryResp, JobDescriptor, JobHistory
19 from lcm.jobs.serializers import JobQueryRespSerializer
22 logger = logging.getLogger(__name__)
25 class GetJobInfoService(object):
26 def __init__(self, job_id, response_id=0):
28 self.response_id = response_id if response_id else 0
31 logger.debug("[getjob]job_id=%s, response_id=%s", self.job_id, self.response_id)
32 jobs = JobUtil.query_job_status(self.job_id, self.response_id)
34 job_query_resp = JobQueryResp(self.job_id)
35 job_query_resp_serializer = JobQueryRespSerializer(job_query_resp)
36 return remove_none_key(job_query_resp_serializer.data)
37 job_query_resp = JobQueryResp(
56 job_query_resp_serializer = JobQueryRespSerializer(job_query_resp)
57 return remove_none_key(job_query_resp_serializer.data)