[Freeipa-devel] dns.py question

John Dennis jdennis at redhat.com
Thu May 24 16:07:45 UTC 2012


In dns_is_enabled it computes the base_dn but never uses it.
Instead it uses self.base_dn, but as far as I can figure out there is no 
self.base_dn in the class hierarchy (if so could you point me at it). 
The access to self.base_dn is wrapped in a try/except block that doesn't 
handle any errors so if in fact there was no self.base_dn that error 
would be silently ignored.

So is self.base_dn a typo and we're supposed to be using the local 
base_dn that's computed but never used?

Code snipped attached so it won't be mangled by line wrapping.

-- 
John Dennis <jdennis at redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
-------------- next part --------------
class dns_is_enabled(Command):
    """
    Checks if any of the servers has the DNS service enabled.
    """
    NO_CLI = True
    has_output = output.standard_value

    base_dn = 'cn=masters,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=self.filter, base_dn=self.base_dn)
            if len(ent):
                dns_enabled = True
        except Exception, e:
            pass

        return dict(result=dns_enabled, value=u'')


More information about the Freeipa-devel mailing list