- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How do i update Network DHCP options using WAPI?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2021 08:31 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 07:43 AM
Did you ever get this working?