For this exercise, we will choose the second option (which allows us to get started much faster), and run the in the script editor. This script populates our Org Chart model with interesting data.
This function uses the topology service to create or update an object instance. To do that, it requires a typeName and a collection of propertyValues. The typeName is used to create a potential instance of an object of that type. The TopologyService is used to create the instance. The propertyValues are a map of (name, value) pairs. The script iterates over the properties, inspects each one and tries to set that property on the object using the appropriate API.
What happens at the end is critical. Using the topSvc.mergeData() call, we send a potential instance of an object with several properties set. The TopologyService decides whether we need to create an object or simply update the definition for an existing one.
This creates a new Employee object. When using this function, you must include all the identity properties at least. You can include additional properties if you want.
With this function we almost have everything we need to create models using scripts. In order to enable iterative development, we need a way to delete old object instances. In this way, we can create a re-entrant Groovy script that cleans up obsolete objects.
Note that we use the createOrUpdateObject call to return the original object. Then we make a TopologyService call to delete it.
At the end of the script, there is a bit of code which allows you to connect the employees to Host systems. This code simply finds some Host instances and manually attaches them to the employees. This code was included so that we can verify whether the alarm propagation works properly.
...where topologyObject is the object that the user has chosen as interesting. This is pretty much what is done in the Services Operations Console. It is all done using Dashboards and Groovy.
The last step is to build dashboards to visualize the data. The provided in the appendix creates a nice organization.