Hazenet
Enthusiast
Enthusiast

Find all SNMP:SnmpDevice and Policy

Jump to solution

Hi

I am trying to automate SNMP creation/deletion and Policies, in vRealize Orchestrator, for a large amount of SNMP devices.

But I can't figure out how to get all SNMP:SnmpDevice already in the vRealize Orchestrator inventory.

Likewise, how would I get a array of all existing Policies in the vRealize Orchestrator

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Instead of

  Server.findAllForType("SNMP:SnmpDevice");

could you try with

  Server.findAllForType("SNMP:SnmpDevice", "");

?

The only difference is that it passes an empty string instead of null/undefined value to the second parameter (which is a plug-in specific query string; for SNMP plug-in there you can pass some string value and the method will filter SNMP devices and return only those whose address contains this query as a sub-string).

View solution in original post

0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Try the generic find method:

var all = Server.findAllForType("SNMP:SnmpDevice");

for each (var device in all) {

  System.log(device);

}

Similar code will work for policies, just replace "SNMP:SnmpDevice" with "Policy" .

0 Kudos
Hazenet
Enthusiast
Enthusiast

Hi Ilian

I knew about the Server.findAllForType, but it does not work for "SNMP.SnmpDevice". And vRO fails to produce a output for "Policy"

var arrayOfPolicy = Server.findAllForType("Policy");

System.log(arrayOfPolicy.length);

var arrayOfSnmpDevices = Server.findAllForType("SNMP:SnmpDevice");

System.log(arrayOfSnmpDevices.length);

I get the following output:

[2017-05-02 10:19:59.195] [I] 3

[2017-05-02 10:19:59.202] [E] Server error : ch.dunes.model.sdk.SDKFinderException: Unable to execute 'fetchAll' for type : SnmpDevice : 'java.lang.NullPointerException'

[2017-05-02 10:19:59.214] [E] Workflow execution stack:

***

item: 'Get all SNMP Devices/item1', state: 'failed', business state: 'null', exception: 'Server error : ch.dunes.model.sdk.SDKFinderException: Unable to execute 'fetchAll' for type : SnmpDevice : 'java.lang.NullPointerException''

workflow: 'Get all SNMP Devices' (a4d88610-3caa-4353-b64e-d13204d3b7c8)

|  'attribute': name=arrayOfPolicy type=Array/Policy value=__NULL__

|  'attribute': name=arrayOfSnmpDevices type=Array/SNMP:SnmpDevice value=__NULL__

|  'no inputs'

|  'no outputs'

*** End of execution stack.

On top of that, my Attribute "arrayOfPolicy" (with type Array/Policy) in the General tab, is not set.

So the system, finds the the Policies, but does not produce a output.

I am running vRealize Orchestrator 7.1.0.4262825

0 Kudos
Hazenet
Enthusiast
Enthusiast

Sorry, was to quick here.

  1. var arrayOfPolicy = Server.findAllForType("Policy"); 
  2. System.log(arrayOfPolicy.length);

Works, and produces a output, if run alone, and not in a failing Scriptable Task element.

But the Server.findAllForType("SNMP:SnmpDevice") still fails.

0 Kudos
iiliev
VMware Employee
VMware Employee

Instead of

  Server.findAllForType("SNMP:SnmpDevice");

could you try with

  Server.findAllForType("SNMP:SnmpDevice", "");

?

The only difference is that it passes an empty string instead of null/undefined value to the second parameter (which is a plug-in specific query string; for SNMP plug-in there you can pass some string value and the method will filter SNMP devices and return only those whose address contains this query as a sub-string).

0 Kudos
Hazenet
Enthusiast
Enthusiast

Thank you very much, Ilian.

This works.

0 Kudos