dnaeon / pyinfoblox

Infoblox WAPI module for Python
16 stars 11 forks source link

unable to access 'special case' objects #16

Open gr33dypr0d87 opened 4 years ago

gr33dypr0d87 commented 4 years ago

I am unable to access child objects that don't fall under record:*. This would include anything under discovery, or, grid. Under the class 'InfobloxWAPI' the definition getattr() originally only looks for 'record' and replaces '_' with ':' to complete the corrected URI. I have added additional if statements below to catch the remaining parent objects. Please see the modified getattr() definition below:

def getattr(self, attr): """ Dynamically create a new Infoblox object class, e.g. 'network'

    """
    # Special case for 'record' objects.
    #
    # The Infoblox 'record' objects are in the following form:
    #
    #     'record:<objtype>'
    #
    # For example A records in Infoblox are 'record:a' objects.
    #
    # In order to use an Infoblox 'record' object replace the
    # colon character with underscore in your call, e.g. 'record_a'
    if 'record' in attr:
        attr = attr.replace('_', ':', 1)
    if 'discovery' in attr:
        attr = attr.replace('_',':',1)
    if 'dtc' in attr:
        attr = attr.replace('_', ':', 1)
    if 'grid' in attr:
        attr = attr.replace('_', ':', 1)
    return InfobloxWAPIObject(
        objtype=attr,
        wapi=self.wapi,
        session=self.session
    )
dnaeon commented 4 years ago

Please consider submitting a PR. Thanks!

nixnerd2038 commented 3 years ago

Fixed. https://github.com/dnaeon/pyinfoblox/pull/17