mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
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:
commit
d254b96498
@ -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):
|
||||
|
@ -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
|
21
tests/integration/modules/test_libcloud_dns.py
Normal file
21
tests/integration/modules/test_libcloud_dns.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user