Fwd: How to get SystemInfo from a Plugin
John Mazzitelli
mazz at redhat.com
Tue Jan 26 14:23:07 UTC 2010
> For templating, it looks like all the information we want is hanging
> off the SystmInfo interface.
> We can get the system info object off the resource context. I am not
> sure the correct way to get the resource context. I see that it is
> available fairly early in the creation of the resource object on the
> agent side, but I'm unclear about where to get it later, specifically
> when trying to write configuration files.
I actually think you don't need the resource context for what you want
to do. The resource context is really just for the plugin component's
use - you'll see we create a context in
InventoryManager.activateResource and just pass it to the plugin itself.
But we do store it in the ResourceContainer - so if you have a
ResourceContainer instance, just call
org.rhq.core.pc.inventory.ResourceContainer.getResourceContext()
But you don't need that if all you want is a SystemInfo.
The SystemInfo object is the API into the native system stuff - it
essentially is the API we give to plugin developers so they can access
things via SIGAR.
There is a SystemInfoFactory object that is used to initialize SIGAR and
get a SystemInfo instance - for use by the plugin container.
If you need a SystemInfo object within the plugin container code (e.g.
not within a plugin, but inside the actual plugin container managers),
you can directly create a SystemInfo from the factory:
org.rhq.core.system.SystemInfoFactory.createSystemInfo()
(note: that actually doesn't "create" one - in that code, it actually
just returns a cached instance, so it only creates it once the first
time its called)
Hope that helps,
John Mazz
More information about the rhq-devel
mailing list