Remove tmp bitstream file always

On fpga program, we will download a bitstream file from glance
to a tmp local file. And no matter driver.program is success
or failed, the tmp local file should be removed

Change-Id: Ic7be96f3f6da9cf366224401bc330485e67fedf1
Signed-off-by: guolei <guolei_yewu@cmss.chinamobile.com>
This commit is contained in:
guolei 2020-10-25 10:17:51 +08:00
parent 27dba65ba6
commit 2b50fd9595
1 changed files with 7 additions and 4 deletions

View File

@ -67,10 +67,13 @@ class AgentManager(periodic_task.PeriodicTasks):
self.image_api.download(context,
bitstream_uuid,
dest_path=download_path.name)
driver = self.fpga_driver.create(driver_name)
ret = driver.program(controlpath_id, download_path.name)
LOG.info('Driver program() API returned %s', ret)
os.remove(download_path.name)
try:
driver = self.fpga_driver.create(driver_name)
ret = driver.program(controlpath_id, download_path.name)
LOG.info('Driver program() API returned %s', ret)
finally:
LOG.debug('Remove tmp bitstream file: %s', download_path.name)
os.remove(download_path.name)
return ret
@periodic_task.periodic_task(run_immediately=True)