Reply

WAPI (Web API) Sample Code for NIOS

[ Edited ]
Employee
Employee
Posts: 21
5803     0

Sample code showing how to use the WAPI (Web API) for NIOS in various languages. These samples include Java, Python and Javascript. 

9/17 - these examples have recently been reviewed and are still current.  If you have specific questions please let us know.

It's nice when...

Not applicable
Posts: 3
5803     0

A multimillion dollar setup has old outdated API docs and examples. Where's 1.7.1?

Re: WAPI (Web API) Sample Code for NIOS

Guru
Posts: 26
5803     0

I'm using python 3 and am attempting to use the WAPI to do a couple of things that appear to be beyond its capabilities.

 

1) Set a vendor-option-space for a subnet:

 

ISC dhcpd.conf:

subnet 10.102.220.0 netmask 255.255.255.0 {
  option routers 10.102.220.1;
  option subnet-mask 255.255.255.0;
  option domain-name-servers 10.70.0.160,10.71.0.151;
  option broadcast-address 10.102.220.255;
  default-lease-time 864000;
  max-lease-time 864000;
  boot-unknown-clients true;
  vendor-option-space CAPWAP;
  option CAPWAP.controller 10.7.51.20, 10.7.51.24, 10.7.51.28

2) via WAPI, using the same config abive, set boot-unknown-clients to true

 

3) via WAPI, set the allow/deny known/unclient client flags for a subnet or a range

 

4) Using the WAPi, retrieve all of the various settings for an object and not just check to see if it exists or not.

 

5) By some automated means, preferably WAPI, import one or more ISC dhcpd.leases file into a grid

 

Anybody done this before?

 

Thanks!

Re: WAPI (Web API) Sample Code for NIOS (JAVA)

New Member
Posts: 1
5803     0

Hi,

 

I am trying to use the JAVA libraries to create a host with the following data:

- next available ip

- configure for dhcp enabled

 

I forked my own method and tried to convert it to add a host, but I keep getting error:

"Error": "AdmConProtoError: List value expected for field: ipv4addrs",   "code": "Client.Ibap.Proto",   "text": "List value expected for field: ipv4addrs"

 

This is the class I built:

    /**

     * Perform some operations with Hosts with JSON.

     * 

     * @param port

     */

    public static void hostJSON(WapiPort port) {

        IWapiDAO<JSONObject, JSONObject> network = new WapiDAO<JSONObject, JSONObject>(

                port, "record:host", JSONObject.class, JSONObject.class); //$NON-NLS-1$

        try {

            JSONObject object = new JSONObject();

            object.put("ipv4addrs", ""); //$NON-NLS-1$ //$NON-NLS-2$

            object.put("ipv4addr","func:nextavailableip:10.1.0.0/16"); //$NON-NLS-1$ //$NON-NLS-2$

            object.put("configure_for_dhcp","true"); //$NON-NLS-1$ //$NON-NLS-2$

            object.put("mac","aa:bb:cc:41:22:31"); //$NON-NLS-1$ //$NON-NLS-2$

            object.put("name","naorproj-tal3.weizmann.ac.il"); //$NON-NLS-1$ //$NON-NLS-2$

 

            String ref = network.create(object);

 

 

        } catch (JSONException e) {

            logger.error("An exception occurred when creating JSON", e); //$NON-NLS-1$

            throw new RuntimeException(e);

        }

    }

 

Can someone please put me in the right direction? or at least head me to a guid how to use these libraries?

 

Thanks!

 

Naor.

Re: WAPI (Web API) Sample Code for NIOS

[ Edited ]
New Member
Posts: 1
5803     0

For the javascript sample, I don't see any configuration to put Infoblox IP address or URL, username, password etc.

Can anyone help to get that information from Javascript script, please?

 

Thanks,

Re: WAPI (Web API) Sample Code for NIOS

Guru
Posts: 26
5803     0

Where's python 3?

Showing results for 
Search instead for 
Did you mean: 

Recommended for You