[Freeipa-devel] dns.py question

Martin Kosek mkosek at redhat.com
Fri May 25 06:41:14 UTC 2012


On Thu, 2012-05-24 at 12:07 -0400, John Dennis wrote:
> 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.
> 

Hello John,

base_dn is defined in dns_is_enabled command class along with filter:

class dns_is_enabled(Command):
...
    base_dn = 'cn=masters,cn=ipa,cn=etc,%s' % api.env.basedn
    filter = '(&(objectClass=ipaConfigObject)(cn=DNS))'
...

    def execute(self, *args, **options):
...
        try:
            ent = ldap.find_entries(filter=self.filter,
base_dn=self.base_dn)
            if len(ent):
                dns_enabled = True
        except Exception, e:
            pass

So self.base_dn and self.filter return correct value. Otherwise the
function would never return True as in my case:

>>> from ipalib import api
>>> api.bootstrap(context='cli_installer')
>>> api.finalize()
>>> api.Backend.xmlclient.connect()
ipa: INFO: trying https://vm-143.idm.lab.bos.redhat.com/ipa/xml
>>> api.Command['dns_is_enabled']()
ipa: INFO: Forwarding 'dns_is_enabled' to server
'http://vm-143.idm.lab.bos.redhat.com/ipa/xml'
{'result': True, 'value': u'', 'summary': None}

HTH,
Martin




More information about the Freeipa-devel mailing list