Ignore FileNotFoundError when ejecting virtual media image

As these files are in /tmp the can be garbage collected
causing a FileNotFoundError. As it is trying to remove
the file anyway there is no reason to propogate this
error as the end result is the same.

Change-Id: If44be26e3fba70b89aec6ba88743d740276e7560
This commit is contained in:
Michele Costa 2023-02-21 11:50:03 +00:00
parent 7115db2f3a
commit 4357bf2347
1 changed files with 8 additions and 4 deletions

View File

@ -335,8 +335,12 @@ class StaticDriver(base.DriverBase):
local_file = device_info.pop('_local_file', None)
if local_file:
os.unlink(local_file)
try:
os.unlink(local_file)
self._logger.debug(
'Removed local file %(file)s for %(identity)s' % {
'identity': identity, 'file': local_file})
self._logger.debug(
'Removed local file %(file)s for %(identity)s' % {
'identity': identity, 'file': local_file})
except FileNotFoundError:
# Ignore error as we are trying to remove the file anyway
pass