I am trying to set the DS record in the gandi api as describded in the gandi api support doc
It states to 'import xmlrpclib' but I immediately get an error 'module not found' (full text reproduced below).
I found this page where they use 'from xmlrpc import client', but in my context, the gandi API is none responsive.
python3 session:
>>> import xmlrpclib
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
import xmlrpclib
ImportError: No module named 'xmlrpclib'
>>> from xmlrpc import client
>>> api = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
Traceback (most recent call last):
File "<pyshell#71>", line 1, in <module>
api = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
NameError: name 'xmlrpclib' is not defined
>>> api = xmlclient.ServerProxy('https://rpc.gandi.net/xmlrpc/')
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
api = xmlclient.ServerProxy('https://rpc.gandi.net/xmlrpc/')
NameError: name 'xmlclient' is not defined
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = '<my_api_key_here>'
>>> version = api.version.info(apikey)
>>> print(version)
{'api_version': '3.3.29'}
>>> domain.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
Traceback (most recent call last):
File "<pyshell#77>", line 1, in <module>
domain.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
NameError: name 'domain' is not defined
>>> client.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
client.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
AttributeError: 'module' object has no attribute 'dnssec'
How do I update the DS record via gandi API?
Update: The following code was provided to me and errors with an invalid key error. The key I am using is known good in PhP
my_in_file = open('/home/ex-mailer-domains/'+domain+'/dsset-'+domain+'.', 'rt')
dstext = my_in_file.read()
dslist = dstext.split()[3:7]
print(dslist[3])
api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
apikey = 'MyKeyThatWorksInPHPjustFineForOtherScripts'
api.domain.dnssec.create(apikey, 'domain2.com', {'algorithm': 8, 'flags': 256, 'public_key': dslist[3]})
xmlrpc.client.Fault: <Fault 510150: 'Error on object : OBJECT_ACCOUNT (CAUSE_NORIGHT) [Invalid API key]'>
UPDATE: The key works for this sample code
But using it with other calls, I still get the error:
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = 'MyKeyThatWorksInPHPjustFineForOtherScripts'
>>> version = api.version.info(apikey)
>>> print(version)
{'api_version': '3.3.29'}
>>> domain.dnssec.create('xxxxx', 'domain2.com', 1, 256, '97BF8186C193EBF12A794A75FEF4B331A29C1A26')
I am not sure if you did give out your real API key, but I urge you to change it ASAP. In any case, in Python, top level variables/names do not come from thin air - they're introduced either by
import
or the assignment statement (x = 123
), (or some other statements likedef
,class
usually).You never assigned anything into
domain
variable, then it couldn't possibly work; the same goes forxmlrpclib
; since theimport
statement failed, the name is not defined.Thus how about: