The findResourceType and findPlatform functions are pretty straightforward. The interesting work happens in createTomcatConnectionProps and in manuallyAddTomcat. The key to it all though is on line 44. DiscoveryBoss provides methods for importing resources from the discovery queue as well as for manually adding resources. manuallyAddResources expects as arguments a resource type id, a parent resource id, and the plugin configuration (i.e., connection properties).
Determining the connection properties that you need to specify might not be entirely intuitive. I looked at the plugin descriptor as well as the TomcatDiscoveryComponent class from the tomcat plugin to determine the minimum, required connection properties that need to be included.
Here is how the script could be used from the CLI shell:
rhqadmin@localhost:7080$ login rhqadmin rhqadmin rhqadmin@localhost:7080$ exec -f manual_add.js rhqadmin@localhost:7080$ hostname = '127.0.0.1' rhqadmin@localhost:7080$ tomcatDir = '/home/jsanda/Development/tomcat6' rhqadmin@localhost:7080$ manuallyAddTomcat(hostname, tomcatDir) Resource: id: 12071 name: 127.0.0.1:8080 version: 184.108.40.206 resourceType: Tomcat Server rhqadmin@localhost:7080$
This effectively adds the Tomcat server to the inventory of managed resources. This same approach can be used with other resource types. The key is knowing what connection properties you need to specify so that the plugin (in which the resource type is defined) knows how to connect to and manage the resource.