mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Handle errors when checking the state of a VM
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
0522ed759c
commit
077f2f350e
1 changed files with 10 additions and 4 deletions
14
tools/vm.py
14
tools/vm.py
|
@ -395,10 +395,16 @@ class VM:
|
|||
if instance_id_path.exists():
|
||||
instance_id = instance_id_path.read_text().strip()
|
||||
_instance = self.ec2.Instance(instance_id)
|
||||
|
||||
if _instance.state["Name"] == "running":
|
||||
instance = _instance
|
||||
else:
|
||||
try:
|
||||
if _instance.state["Name"] == "running":
|
||||
instance = _instance
|
||||
except ClientError as exc:
|
||||
if "InvalidInstanceID.NotFound" not in str(exc):
|
||||
# This machine no longer exists?!
|
||||
self.ctx.error(str(exc))
|
||||
self.ctx.exit(1)
|
||||
instance_id_path.unlink()
|
||||
if not instance_id_path.exists():
|
||||
filters = [
|
||||
{"Name": "tag:vm-name", "Values": [self.name]},
|
||||
{"Name": "tag:instance-client-id", "Values": [REPO_CHECKOUT_ID]},
|
||||
|
|
Loading…
Add table
Reference in a new issue