class SchemaRpcHandler(mano_dts.AbstractRpcHandler):
"""RPC handler to generate the schema for the packages.
"""
- def __init__(self, log, dts, loop, proxy):
+ def __init__(self, log, dts, loop, project, proxy):
"""
Args:
proxy: Any impl of .proxy.AbstractPackageManagerProxy
"""
- super().__init__(log, dts, loop)
+ super().__init__(log, dts, loop, project)
self.proxy = proxy
@property
3. Return a tracking ID for the client to monitor the entire status
"""
- def __init__(self, log, dts, loop, proxy, publisher):
+ def __init__(self, log, dts, loop, proxy, tasklet):
"""
Args:
proxy: Any impl of .proxy.AbstractPackageManagerProxy
- publisher: Instance of DownloadStatusPublisher
+ publisher: Instance of tasklet to find the DownloadStatusPublisher
+ for a specific project
"""
super().__init__(log, dts, loop)
self.proxy = proxy
- self.publisher = publisher
+ self.tasklet = tasklet
@property
def xpath(self):
return "/rw-pkg-mgmt:package-file-add"
+ def get_publisher(self, msg):
+ try:
+ proj = self.tasklet.projects[msg.project_name]
+ except Exception as e:
+ err = "Project or project name not found {}: {}". \
+ format(msg.as_dict(), e)
+ self.log.error (err)
+ raise Exception (err)
+
+ return proj.job_handler
+
@asyncio.coroutine
def callback(self, ks_path, msg):
+ publisher = self.get_publisher(msg)
+
if not msg.external_url:
# For now we will only support External URL download
raise Exception ("No download URL provided")
proxy=self.proxy,
log=self.log)
- download_id = yield from self.publisher.register_downloader(url_downloader)
+ download_id = yield from publisher.register_downloader(url_downloader)
rpc_op = RPC_PACKAGE_ADD_ENDPOINT.from_dict({"task_id": download_id})
return rpc_op
class PackageCopyOperationsRpcHandler(mano_dts.AbstractRpcHandler):
- def __init__(self, log, dts, loop, proxy, publisher):
+ def __init__(self, log, dts, loop, project, proxy, publisher):
"""
Args:
proxy: Any impl of .proxy.AbstractPackageManagerProxy
publisher: CopyStatusPublisher object
"""
- super().__init__(log, dts, loop)
+ super().__init__(log, dts, loop, project)
self.proxy = proxy
self.publisher = publisher