THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

How do i update Network DHCP options using WAPI?

Adviser
Posts: 9
2433     0

I'm am writing a script to resize a subnet and need to update the Routers option and an extensible attribute.

The resize works fine as well as the attribute update, however i am stuck on updating the Routers field.

I use postman to test then write in python and I can't find a solution for this using either.

 

Since we are updating an existing network, i'm assuming this is going to be a PUT request.  I am also assuming, like the Perl API, that the options have to be added as a whole, not as individual options.

 Anyone have any insight on this?

 I have tried a few different things and am coming up empty with a 400 Bad Request error.   Postman with the same data gives me "AdmConProtoError: Input is not an object"

        '''
        # 6. Change dhcp options
        -> GET https://lab-gm/wapi/v2.10.5/network?network=10.64.35.0/26&_return_as_object=1\
        &_return_fields%2B=options
        Update "routers"
        {
            "name": "routers",
            "num": 3,
            "use_option": true,
            "value": "10.64.35.62",
            "vendor_class": "DHCP"
         }
         '''
        # TODO - Not currently working
        iotvlanopts = iotvlanoutput[0]['options']
        # print(iotvlanopts)
        for options in iotvlanopts:
            for key, value in options.items():
                if value == 'routers':
                    print("Updating default gateway")
                    options.update({"value": "10.64.39.62"})
                if key == 'use_option':
                    options.update({"use_option": "True"})
        print(iotvlanopts)
        # newopts = json.dumps(iotvlanopts)
        newopts = iotvlanopts
        print(newopts)
        optsupdate = api_put(baseurl + '/' + iotvlanref, newopts, ibapauth_cookie, debug)
        if optsupdate.status_code != requests.codes.ok:
            error_msg = 'Error {} updating default gateway: {}'
            print(error_msg.format(optsupdate.status_code, optsupdate.reason))
        else:
            success_msg = 'Default Gateway updated {}'
            print(success_msg.format(optsupdate.reason))

Re: How do i update Network DHCP options using WAPI?

New Member
Posts: 1
2434     0

Did you ever get this working? 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

NIOS 8.6.3 – What’s New in DDI