Provide API to check if IPA DNS is enabled on some server

Fixes: https://fedorahosted.org/freeipa/ticket/600
This commit is contained in:
Simo Sorce 2011-01-17 12:28:24 -05:00
parent a44607ecba
commit 835436df15
2 changed files with 30 additions and 0 deletions

View File

@ -467,6 +467,11 @@ option: Str('version?', exclude='webui', flags=['no_option', 'no_output'])
output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
output: Entry('result', <type 'dict'>, Gettext('A dictionary representing an LDAP entry', domain='ipa', localedir=None))
output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
command: dns_is_enabled
args: 0,0,3
output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
output: Output('result', <type 'bool'>, 'True means the operation was successful')
output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
command: dns_resolve
args: 1,0,3
arg: Str('hostname', label=Gettext('Hostname', domain='ipa', localedir=None))

View File

@ -616,3 +616,28 @@ class dns_resolve(Command):
return dict(result=True, value=query)
api.register(dns_resolve)
class dns_is_enabled(Command):
"""
Checks if any of the servers has the DNS service enabled.
"""
INTERNAL = True
has_output = output.standard_value
base_dn = 'cn=master,cn=ipa,cn=etc,%s' % api.env.basedn
filter = '(&(objectClass=ipaConfigObject)(cn=DNS))'
def execute(self, *args, **options):
ldap = self.api.Backend.ldap2
dns_enabled = False
try:
ent = ldap.find_entries(filter=filter, base_dn=base_dn)
if len(e):
dns_enabled = True
except Exception, e:
pass
return dict(result=dns_enabled, value=u'')
api.register(dns_is_enabled)