X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwimagemgr%2Frift%2Fimagemgr%2Fclient.py;h=42185ae27e74cdecc05bf16174e564546c8efc63;hb=a3bb91f092d378448cb870eccd45d43865de143c;hp=10df45b928eee5ca439c2d49d0d43e1346874f1b;hpb=255ff03a528a3090ce7f46f0a63b65da3e6f9bcf;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwimagemgr/rift/imagemgr/client.py b/rwlaunchpad/plugins/rwimagemgr/rift/imagemgr/client.py index 10df45b9..42185ae2 100644 --- a/rwlaunchpad/plugins/rwimagemgr/rift/imagemgr/client.py +++ b/rwlaunchpad/plugins/rwimagemgr/rift/imagemgr/client.py @@ -48,7 +48,7 @@ class UploadJobClient(object): self._loop = loop self._dts = dts - def create_job(self, image_name, image_checksum, cloud_account_names=None): + def create_job(self, image_name, image_checksum, project, cloud_account_names=None): """ Create an image upload_job and return an UploadJob instance Arguments: @@ -62,6 +62,7 @@ class UploadJobClient(object): """ create_job_msg = RwImageMgmtYang.CreateUploadJob.from_dict({ "onboarded_image": { + "project_name": project.name, "image_name": image_name, "image_checksum": image_checksum, } @@ -81,9 +82,9 @@ class UploadJobClient(object): job_id = rpc_result.job_id - return UploadJob(self._log, self._loop, self._dts, job_id) + return UploadJob(self._log, self._loop, self._dts, job_id, project) - def create_job_threadsafe(self, image_name, image_checksum, cloud_account_names=None): + def create_job_threadsafe(self, image_name, image_checksum, project, cloud_account_names=None): """ A thread-safe, syncronous wrapper for create_job """ future = concurrent.futures.Future() @@ -96,7 +97,7 @@ class UploadJobClient(object): def add_task(): task = self._loop.create_task( - self.create_job(image_name, image_checksum, cloud_account_names) + self.create_job(image_name, image_checksum, project, cloud_account_names) ) task.add_done_callback(on_done) @@ -106,11 +107,12 @@ class UploadJobClient(object): class UploadJob(object): """ A handle for a image upload job """ - def __init__(self, log, loop, dts, job_id): + def __init__(self, log, loop, dts, job_id, project): self._log = log self._loop = loop self._dts = dts self._job_id = job_id + self._project = project @asyncio.coroutine def wait_until_complete(self): @@ -122,12 +124,11 @@ class UploadJob(object): UploadJobCancelled: The upload job was cancelled """ self._log.debug("waiting for upload job %s to complete", self._job_id) + xpath = self._project.add_project("D,/rw-image-mgmt:upload-jobs/" + + "rw-image-mgmt:job[rw-image-mgmt:id='{}']". + format(self._job_id)) while True: - query_iter = yield from self._dts.query_read( - "D,/rw-image-mgmt:upload-jobs/rw-image-mgmt:job[rw-image-mgmt:id='{}']".format( - self._job_id - ) - ) + query_iter = yield from self._dts.query_read(xpath) job_status_msg = None for fut_resp in query_iter: job_status_msg = (yield from fut_resp).result