Repository: AnalogJ/lexicon

Issue:
Gandi Records not picking up TTL
I'm trying to renew Lets Encrypt Certs using dehydrated, using lexicon to handle DNS modifications on a Gandi domain.  New challenge TXT records are being created with a TTL of 3 hours.  I have tried setting --ttl manually but they're always created with the default 3 hour TTL:

`lexicon gandi create platformservices.io TXT --name="testsubdomain.platformservices.io" --content="TEST" --ttl="120"`

Looks to me like the create_record method is missing the ttl property:

https://github.com/AnalogJ/lexicon/blob/master/lexicon/providers/gandi.py#L93


Discussion:
Hey @michaeltravisuk 

Good catch. I'm traveling right now so I'm only going to have time to create a quick PR. If the existing unit tests pass I'll kick off a new release, but if not I'll need to debug it when I get back. 


Thanks for looking at it so quickly.  The fix makes the TTL parameter work.  I also tested without using the TTL parameter and it no longer works.  I have modified our copy of the dehydrated example script to pass a TTL value so it works for me, however I just wanted to bring it to your attention:

`Namespace(action='create', auth_token=None, content='TEST', domain='platformservices.io', identifier=None, name='testsubdomain.platformservices.io', priority=None, provider_name='gandi', ttl=None, type='TXT')
Traceback (most recent call last):
  File "/bin/lexicon", line 11, in <module>
    load_entry_point('dns-lexicon==1.1.19', 'console_scripts', 'lexicon')()
  File "/usr/lib/python2.7/site-packages/lexicon/__main__.py", line 52, in main
    client.execute()
  File "/usr/lib/python2.7/site-packages/lexicon/client.py", line 28, in execute
    return self.provider.create_record(self.options.get('type'), self.options.get('name'), self.options.get('content'))
  File "/usr/lib/python2.7/site-packages/lexicon/providers/gandi.py", line 97, in create_record
    'ttl': self.options.get('ttl',self.default_ttl)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1581, in __request
    allow_none=self.__allow_none)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1086, in dumps
    data = m.dumps(params)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 633, in dumps
    dump(v, write)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 655, in __dump
    f(self, value, write)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 736, in dump_struct
    dump(v, write)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 655, in __dump
    f(self, value, write)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 659, in dump_nil
    raise TypeError, "cannot marshal None unless allow_none is enabled"
TypeError: cannot marshal None unless allow_none is enabled`

Resolving patch:
diff --git a/lexicon/providers/gandi.py b/lexicon/providers/gandi.py
--- a/lexicon/providers/gandi.py
+++ b/lexicon/providers/gandi.py
@@ -94,7 +94,7 @@ def create_record(self, type, name, content):
                                             {'type': type.upper(),
                                              'name': name,
                                              'value': content,
-                                             'ttl': self.options.get('ttl',self.default_ttl)
+                                             'ttl': self.options.get('ttl') or self.default_ttl
                                             })
             self.api.domain.zone.version.set(self.apikey, self.zone_id, version)
             ret = True


Test patch: