From 3945794704d3dcf7fed84a8322e61c1ba0ee6a2d Mon Sep 17 00:00:00 2001 From: Andrei Lukovenko Date: Sun, 17 Jul 2016 15:24:22 +0200 Subject: [PATCH] Bug: repeatable invocation with state=present leads to (#3052) [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "'Domain' object has no attribute 'id'"} How to reproduce: - name: create domain digital_ocean_domain: state=present name=DOMAIN_NAME ip=DROPLET_IP - name: create domain digital_ocean_domain: state=present name=DOMAIN_NAME ip=DROPLET_IP Problem: DigitalOcean API changed API (https://developers.digitalocean.com/documentation/v2/#list-all-domain-records) --- cloud/digital_ocean/digital_ocean_domain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud/digital_ocean/digital_ocean_domain.py b/cloud/digital_ocean/digital_ocean_domain.py index cf05a7f91c1..565fec030f0 100644 --- a/cloud/digital_ocean/digital_ocean_domain.py +++ b/cloud/digital_ocean/digital_ocean_domain.py @@ -128,7 +128,7 @@ class Domain(JsonfyMixIn): self.manager.destroy_domain(self.name) def records(self): - json = self.manager.all_domain_records(self.id) + json = self.manager.all_domain_records(self.name) return map(DomainRecord, json) @classmethod @@ -194,12 +194,12 @@ def core(module): records = domain.records() at_record = None for record in records: - if record.name == "@" and record.record_type == 'A': + if record.name == "@" and record.type == 'A': at_record = record if not at_record.data == getkeyordie("ip"): record.update(data=getkeyordie("ip"), record_type='A') - module.exit_json(changed=True, domain=Domain.find(id=record.domain_id).to_json()) + module.exit_json(changed=True, domain=Domain.find(id=record.id).to_json()) module.exit_json(changed=False, domain=domain.to_json())