Handle stale cache

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-05-04 07:22:30 +01:00 committed by Pedro Algarvio
parent f871c09e7b
commit f6188fddfc

View file

@ -630,6 +630,11 @@ class VM:
self.ctx.error(str(exc))
self.ctx.exit(1)
instance_id_path.unlink()
except AttributeError:
# This machine no longer exists?!
instance_id_path.unlink()
self.ctx.info("It appears the cached image no longer exists...")
self.ctx.exit(1)
if not instance_id_path.exists():
filters = [
{"Name": "tag:vm-name", "Values": [self.name]},