infobloxopen / infoblox-client

Infoblox NIOS Python WAPI Client
Apache License 2.0
142 stars 104 forks source link

Exceptions when trying to call restart function with correct parameters. #370

Open itsthekraken opened 1 year ago

itsthekraken commented 1 year ago

When trying to call the object_manager.InfobloxObjectManager(conn).restart_all_services(member=member) function i got the error that i was missing an option:

_infoblox_client.exceptions.InfobloxFuncException: Error occurred during function's 'restartservices' call: ref grid/b25lLmNsdXN0ZXIkMA:ANETTA: b'{ "Error": "AdmConDataError: None (IBDataError: IB.Data:\'member_order\' required)", \n "code": "Client.Ibap.Data", \n "text": "\'memberorder\' required"\n}' [code 400]

I found that the function in the object_manager only provide 2 options to the call but needed 2 more,

Original:

def restart_all_services(self, member):
    if not member._ref:
        member.fetch(only_ref=True)
    self.connector.call_func('restartservices', member._ref,
                                {'restart_option': 'RESTART_IF_NEEDED',
                                'service_option': 'ALL'})

Improved:

def restart_all_services(self, member):
    if not member._ref:
        member.fetch(only_ref=True)
    self.connector.call_func('restartservices', member._ref,
                                {'restart_option': 'RESTART_IF_NEEDED',
                                'service_option': 'ALL',
                                'member_order': 'SEQUENTIALLY',
                                'sequential_delay': 10})

For the sequential_delay i chose a arbitrary integer as i do not know if this is seconds for sure. We can also choose Simultaneously as a member order. I propose to give the function a payload variable to let the user decide what is best. and please put the options in a doc string to clarify what is needed.