Infoblox Exchange Cybersecurity Roadshow 2020 – Join us!
North America | Europe | Middle East/Africa | Asia-Pacific

API & Integration

Reply
Highlighted

WAPI start_discovery function to begin Network Discovery?

JKuo
Techie
Posts: 6
1689     0

Hi,

 

I am trying to call the function 'start_dsicovery' under the 'grid' object, as per the documentation, it takes in an input field called 'objects', which should be an array of references as strings.

 

Below is my curl script for proto-typing:

 

 

curl -k -u admin:infoblox -H 'Content-Type:application/json' \
  -X POST 'https://192.168.1.59/wapi/v2.6/grid?_function=start_discovery' \
  -d \
  '{
    "objects":
      [
        "network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xLjAvMjQvMA:192.168.1.0/24/default",
        "network/ZG5zLm5ldHdvcmskMy4wLjAuMC84LzA:3.0.0.0/8/default"
      ]
  }'

 

 

However, I get this error message, even after a few different combinations of the call.

 

 

{ "Error": "AdmConProtoError: Invalid reference: ",
  "code": "Client.Ibap.Proto",
  "text": "Invalid reference: "
}

What is the correct way to invoke a network discovery via WAPI?

Re: WAPI start_discovery function to begin Network Discovery?

TTiscareno Community Manager
Community Manager
Posts: 360
1690     0

It looks like you are associating the function against the Grid object instead of the discoverytask object. If you refer to the Infoblox REST API Guide, you will find details for how to call vDiscovery tasks, including examples using CURL. I believe the same logic will apply for the network_discovery_control function for the discoverytask object as well.

 

https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf

 

curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://127.0.0.1/wapi/v2.7/vdiscoverytask/ZG5zLmNkaXNjb3ZlcnlfdGFzayRBV1MgdkRpc2NvdmVyeQ:AWS%20vDiscovery -d '{"_function=vdiscovery_control&action=START"}'

 

Regards,

Tony

Re: WAPI start_discovery function to begin Network Discovery?

JKuo
Techie
Posts: 6
1690     0

Thanks for the reply Tony, and maybe I am confused myself, but from reading the other threads as well as the WAPI guide, my understanding is this:

 

There are 3 kinds of discovery-related objects, and they control 3 different kinds of discovery operations in NIOS:

1) 'discovery' object: controls Network Insight discovery

2) 'vdiscoverytask' object: controls vDiscovery

3) '???' object: controls network discovery (basically nmap scan)

 

It is the last type of discovery that I am hoping to invoke via WAPI, and the closest thing I found in the documentation is to call the 'grid' object and call its function 'start_discovery'. I tried looking in the 'network' object, but couldn't find anything.

 

If you could point me in the direction to initiate a network-based discovery, that would be much appreciated.

 

-Josh

Re: WAPI start_discovery function to begin Network Discovery?

JKuo
Techie
Posts: 6
1690     0

Answering my own question, it would appear that this feature is not supported by WAPI, and the function I found 'start_discovery' is actually starting the Network Insight discovery.

 

But to add to how to make that type of discovery working (Network Insight member required), it should go like this:

 

1) Update the target network to make sure it has 'enable_discovery' and 'discovery_member' configured.

2) Call 'start_discovery' on the grid reference

 

Sample curl commands

#
# Update network
#
NET_REF="network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xLjAvMjQvMA:192.168.1.0/24/default"
curl -k -u admin:infoblox -H 'Content-Type:application/json' \
 -X PUT 'https://192.168.1.59/wapi/v2.6/'$NET_REF \
 -d \
 '{
    "discovery_member": "ns3.example.com",
    "enable_discovery": true
 }'

#
# Begin discovery
#
GRID_REF="GRID_REF="grid/b25lLmNsdXN0ZXIkMA:Infoblox"
curl -k -u admin:infoblox -H 'Content-Type:application/json' \
  -X POST 'https://192.168.1.59/wapi/v2.6/'$GRID_REF'?_function=start_discovery' \
  -d \
  '{
    "objects":
      [
        { "_ref": "network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xLjAvMjQvMA:192.168.1.0/24/default"}
      ]
  }'

Re: WAPI start_discovery function to begin Network Discovery?

noziwatele
Techie
Posts: 1
1690     0

Hi Jkuo,

 

This question of how to manage a basic discovery task (i.e. not Network Insight) came up for me too. I managed to get it to work via the WAPI v2.7 and 2.10.1, like this:

 

1) Get the 'discoverytask' object

 

curl -k -u admin:infoblox -X GET \
'https://<infoblox-ip>/wapi/v2.10.1/discoverytask?_return_fields=discovery_task_oid,member_name,networks'

This returns a list of two objects, the 'current' discovery task (Discover Now in the GUI) and the 'scheduled' discovery task. Each has a different '_ref' attribute.

 

 

2) Update the discovery object with the networks to discover

 

curl -k -u admin:infoblox -X PUT \
  https://<infoblox-ip>/wapi/v2.10.1/<<discovery_task_ref>> \
  -H 'Content-Type: application/json' \
  -d '{
	"networks":[
            "network/ZG5zLm5ldHdvcmskMTAuNDguMC4wLzIyLzA:10.8.4.0/22/default",
            "network/ZG5zLm5ldHdvcmskMTAuNDguNC4wLzIyLzA:10.8.8.0/22/default"
		]
}'

Substitute the 'discovery_task_ref' and the network refs for the relevant ones.

 

 

3) Start the discovery task

 

curl -k -u admin:infoblox -X PUT \
'https://<infoblox-ip>/wapi/v2.10.1/<<discovery_task_ref>>?_function=network_discovery_control' \
  -H 'Content-Type: application/json' \
  -d '{
	"action":"START"
}'

As per the 'discoverytask' documentation, valid values for 'action' are: “START”, “PAUSE”, “RESUME”, “END”.

 

This can be done with the Python infoblox-client module too, as follows:

 

# assumes the following:
# 'ib_conn' is an Infoblox connector object
# 'net_list' is a list of network refs to be discovered

net_disco = ib_conn.get_object('discoverytask', return_fields=['discovery_task_oid', 'member_name', 'networks']) # update the IPAM discovery task object with the list of networks # use net_disco[0] for the current discovery object (Discover Now) ib_conn.update_object(net_disco[0]['_ref'], {'networks': net_list}) # or net_disco[1] for the scheduled discovery object ib_conn.update_object(net_disco[1]['_ref'], {'networks': net_list}) # start the current discovery task ib_conn.call_func('network_discovery_control', net_disco[0]['_ref'], {'action': 'START'})
Showing results for 
Search instead for 
Do you mean 

Recommended for You