Merge pull request #40471 from tonybaloney/libcloud_dns_kwargs

Update to libcloud_dns module to allow custom kwargs for DNS drivers
This commit is contained in:
Mike Place 2017-04-04 10:12:44 -06:00 committed by GitHub
commit d254b96498
3 changed files with 49 additions and 13 deletions

View File

@ -10,13 +10,15 @@ Connection module for Apache Libcloud DNS management
.. code-block:: yaml
libcloud_dns:
profile1:
driver: godaddy
key: 2orgk34kgk34g
profile2:
driver: route53
key: blah
secret: blah
profile_test1:
driver: cloudflare
key: 12345
secret: mysecret
profile_test2:
driver: godaddy
key: 12345
secret: mysecret
shopper_id: 12345
:depends: apache-libcloud
'''
@ -68,12 +70,14 @@ def __init__(opts):
def _get_driver(profile):
config = __salt__['config.option']('libcloud_dns')[profile]
cls = get_driver(config['driver'])
key = config.get('key')
secret = config.get('secret', None)
secure = config.get('secure', True)
host = config.get('host', None)
port = config.get('port', None)
return cls(key, secret, secure, host, port)
args = config
del args['driver']
args['key'] = config.get('key')
args['secret'] = config.get('secret', None)
args['secure'] = config.get('secure', True)
args['host'] = config.get('host', None)
args['port'] = config.get('port', None)
return cls(**args)
def list_record_types(profile):

View File

@ -92,3 +92,14 @@ mysql.user: 'salt'
mysql.pass: 'salt'
mysql.db: 'salt'
mysql.port: 3306
libcloud_dns:
profile_test1:
driver: cloudflare
key: 12345
secret: mysecret
profile_test2:
driver: godaddy
key: 12345
secret: mysecret
shopper_id: 12345

View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import tests.integration as integration
class LibcloudDNSTest(integration.ModuleCase):
'''
Validate the libcloud_dns module
'''
def test_list_record_types(self):
'''
libcloud_dns.list_record_types
'''
# Simple profile (no special kwargs)
self.assertTrue('SPF' in self.run_function('libcloud_dns.list_record_types', ['profile_test1']))
# Complex profile (special kwargs)
accepted_record_types = self.run_function('libcloud_dns.list_record_types', ['profile_test2'])
self.assertTrue(isinstance(accepted_record_types, list) and 'SRV' in accepted_record_types)