mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Properly handle RequestExpired
when getting the VMs state
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
b15106b835
commit
a6e68eeb76
1 changed files with 14 additions and 8 deletions
22
tools/vm.py
22
tools/vm.py
|
@ -555,15 +555,21 @@ class VM:
|
|||
{"Name": "tag:instance-client-id", "Values": [REPO_CHECKOUT_ID]},
|
||||
]
|
||||
log.info(f"Checking existing instance of {self.name}({self.config.ami})...")
|
||||
instances = list(
|
||||
self.ec2.instances.filter(
|
||||
Filters=filters,
|
||||
try:
|
||||
instances = list(
|
||||
self.ec2.instances.filter(
|
||||
Filters=filters,
|
||||
)
|
||||
)
|
||||
)
|
||||
for _instance in instances:
|
||||
if _instance.state["Name"] == "running":
|
||||
instance = _instance
|
||||
break
|
||||
for _instance in instances:
|
||||
if _instance.state["Name"] == "running":
|
||||
instance = _instance
|
||||
break
|
||||
except ClientError as exc:
|
||||
if "RequestExpired" not in str(exc):
|
||||
raise
|
||||
self.ctx.error(str(exc))
|
||||
self.ctx.exit(1)
|
||||
if instance:
|
||||
self.instance = instance
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue