entity.change.additions[0].name

2,562 views
Skip to first unread message

joethu...@gmail.com

unread,
Jun 22, 2016, 1:04:07 PM6/22/16
to cloud-dns-discuss
Using python 2.7 , gcloud 0.16:

Using the api examples listed:

from gloud import dns
client = dns.Client.from_service_account_json('/etc/opt/hider/dnste-testtestxx.json','dnste-1337')
zone = client.zone('base-test')
record_set = zone.resource_record_set("willows.test.com", "A", 3600, "11.11.11.11")
changes = zone.changes()
changes.add_record_set(record_set)
changes.create()

Getting:

BadRequest: 400 Invalid value for 'entity.change.additions[0].name': 'willows.test.com' (POST https://www.googleapis.com....

Tried CNAME, A, still no luck.


Looking at the source, the first input in the record_set is the name.

Seems to be nothing available as to what or why I'm getting this error.

Thanks, Joe

Alex Dupuy

unread,
Jun 22, 2016, 1:58:59 PM6/22/16
to cloud-dns-discuss, joethu...@gmail.com

record_set = zone.resource_record_set("willows.test.com", "A", 3600, "11.11.11.11")

BadRequest: 400 Invalid value for 'entity.change.additions[0].name': 'willows.test.com' (POST https://www.googleapis.com....

Tried CNAME, A, still no luck.


Looking at the source, the first input in the record_set is the name.

Seems to be nothing available as to what or why I'm getting this error.


Not 100% sure, but suspect that the problem is that the zone is for the test.com domain, and you are now trying to create willows.test.com.test.com (name willows.test.com in test.com zone).

You might have better luck with:

record_set = zone.resource_record_set("willows", "A", 3600, "11.11.11.11")

joethu...@gmail.com

unread,
Jun 22, 2016, 2:37:50 PM6/22/16
to cloud-dns-discuss, joethu...@gmail.com
Per this page:
https://googlecloudplatform.github.io/gcloud-python/stable/dns-usage.html


>>> import time
>>> from gcloud import dns
>>> client = dns.Client(project='PROJECT_ID')
>>> zone = client.zone('acme-co', 'example.com')
>>> TWO_HOURS = 2 * 60 * 60 # seconds
>>> record_set = zone.resource_record_set(
... 'www.example.com', 'CNAME', TWO_HOURS, 'www1.example.com')
>>> changes = zone.changes()
>>> changes.add_record_set(record_set)
>>> changes.create() # API request
>>> while changes.status != 'done':
... print('Waiting for changes to complete')
... time.sleep(60) # or whatever interval is appropriate
... changes.reload() # API request

joethu...@gmail.com

unread,
Jun 22, 2016, 2:54:08 PM6/22/16
to cloud-dns-discuss, joethu...@gmail.com
Well to any running into the same issue, the docs seem to be wrong.

record_set = zone.resource_record_set('www.example.com', 'CNAME', 3600, 'www1.example.com')

Needs to be in this form:

CNAME:

record_set = zone.resource_record_set('www.example.com.', 'CNAME', 3600, ['www1.example.com.',])

Or for A records:

record_set = zone.resource_record_set('www.example.com.', 'A', 3600, ['11.111.11.111',])

Resource records need to be in a List form, DNS records seem to need the trailing dot.. can someone chime in on this? Is that correct form?

It's the only way I seem to be able to get records into the zone files.


Thanks, Joe

Alex Dupuy

unread,
Jun 22, 2016, 3:29:44 PM6/22/16
to cloud-dns-discuss, joethu...@gmail.com
Thanks, Joe, for tracking this down. I submitted a documentation issue at https://github.com/GoogleCloudPlatform/gcloud-python/issues/1886, hopefully the GCP docs folks can fix this up.

Reply all
Reply to author
Forward
0 new messages