cs_instance: fix error when state destroyed but querying user_data (#37175)

(cherry picked from commit 190d3fbbed)
This commit is contained in:
René Moser 2018-03-08 11:40:31 +01:00 committed by GitHub
parent bfceaf696c
commit 193687851b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -460,7 +460,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
return instance['userdata']
user_data = ""
if self.get_user_data() is not None:
if self.get_user_data() is not None and instance.get('id'):
res = self.query_api('getVirtualMachineUserData', virtualmachineid=instance['id'])
user_data = res['virtualmachineuserdata'].get('userdata', "")
return user_data