Skip to content

Commit

Permalink
aws: skip terminated vm when stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Apr 24, 2024
1 parent 01ed4bb commit 5cb331e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kvirt/providers/aws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ def stop(self, name, soft=False):
except:
return {'result': 'failure', 'reason': f"VM {name} not found"}
instanceid = vm['InstanceId']
conn.stop_instances(InstanceIds=[instanceid])
state = vm['State']['Name']
if state != 'terminated':
conn.stop_instances(InstanceIds=[instanceid])
return {'result': 'success'}

def create_snapshot(self, name, base):
Expand Down

0 comments on commit 5cb331e

Please sign in to comment.