Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

How do i update Network DHCP options using WAPI?

Adviser
Posts: 9
1582     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
1583     0

Did you ever get this working? 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Demo: Infoblox IPAM plug-in integration with OpenStack Newton