Creating a discovery profile through REST

Document ID : KB000044175
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction:

This KB article shows how to create a discovery profile through REST and kick it off

 

Question:  

Can I create and start a discovery profile through REST?

 

Environment:  

2.x

 

Answer:  

Yes you can.  In the example below, we create a discovery profile called Paris

 

Create a discovery profile 

A discovery profile needs an Tenant ID, IP domain ID, and SNMP Profile ID. Let’s find those first. 

1. Issue an HTTP GET to http://<dahost>:8581/rest/tenants. This will fetch the list of tenants from the DA. Make a note of the Default Tenant’s ID. We’ll call this “daTenantId” 

2. Issue a HTTP GET to http://<dahost>:8581/rest/ipdomains for a list of IP domains. (To scope the list by tenant, see the reference guide.) 

3. From the list, make a note of the IP Domain ID of the Default Domain. We’ll call this “daIpDomainId”. 

4. Find the parisSnmpProfileItemId from above. This is PC’s SNMP Profile Item ID. We need to translate it to the DA’s representation of the same thing. 

5. Run the following MySQL command on the PC’s host: 

mysql -D netqosportal -e 'select * from item_identifiers where ItemID=<parisSnmpProfileId> and SourceId=<daDataSourceId>' 

6. Make a note of the LocalID (call it “daParisSnmpProfileId”). You’ll refer to it later. 

7. Issue a HTTP POST to http://<dahost>:8581/rest/tenant/<daTenantId>/discoveryprofiles with the following content: 

(Must scope by tenant – POST’s to http://<dahost>:8581/rest/discoveryprofiles will not work!) 

Body (successful result): 

<DiscoveryProfile version="1.0.0"> 

<Item version="1.0.0"> 

<Name>Paris</Name> 

</Item> 

<!-- IPRangesList can be omitted if empty --> 

<IPRangesList> 

<IPRanges>10.XXX.XXX.XXX-255</IPRanges> 

</IPRangesList> 

<!-- IPListList can be omitted if empty --> 

<IPListList> 

<IPList>10.XXX.XXX.XX</IPList> 

<IPList>10.XXX.XX.XX</IPList> 

</IPListList> 

<!-- HostNamesList can be omitted if empty --> 

<HostNamesList> 

<HostNames>PAR-SW3</HostNames> 

<HostNames>PAR-Ctrx</HostNames> 

</HostNamesList> 

<!-- If omitted, use all SNMP Profiles in Tenant --> 

<SNMPProfileIDList> 

<!-- These ID’s are DA Item ID’s for the profiles --> 

<SNMPProfileID>{daParisSnmpProfileId}</SNMPProfileID> 

</SNMPProfileIDList> 

<!-- ActivationStatus is required (true/false) --> 

<ActivationStatus>true</ActivationStatus> 

<!-- IcmpDiscoveryEnabled is optional --> 

<IcmpDiscoveryEnabled>true</IcmpDiscoveryEnabled> 

<IPDomainMember version="1.0.0"> 

<!-- DA's IP Domain ID --> 

<IPDomainID>{daIpDomainId}</IPDomainID> 

</IPDomainMember> 

</DiscoveryProfile> 

 

Running the discovery profile 

1. Issue a HTTP PUT to http://<dahost>8581/rest/tenant/<daTenantId>/discoveryprofiles/<daDiscoveryProfileId> with the following content: 

Body: 

<DiscoveryProfile version="1.0.0"> 

<RunStatus>START</RunStatus> 

</DiscoveryProfile>