Discovery in the Generic plugin
This topic describes how the Generic plugin supports discovery in any subtype of generic.Container
, generic.NestedContainer
, or generic.AbstractDeployed
.
To implement custom discovery tasks, you provide shell scripts that interact with the discovery mechanism, via the standard out, with specially formatted output representing the inspected property or discovered configuration item.
To extend the Generic plugin for custom discovery tasks, you must set attributes in synthetic.xml
as follows:
- The
inspectable
attribute must be set totrue
on the container - You must define one or more properties with the
inspectionProperty
attribute set totrue
This is a sample extension for Tomcat:
<!-- Sample of extending Generic Mode plugin -->
<type type="sample.TomcatServer" extends="generic.Container" inspectable="true">
...
<property name="inspectScript" default="inspect/inspect-server" hidden="true"/>
<property name="example" inspectionProperty="true"/>
</type>
<type type="sample.VirtualHost" extends="sample.NestedContainer">
<property name="server" kind="ci" as-containment="true" referenced-type="sample.TomcatServer"/>
...
<property name="inspectScript" default="inspect/inspect-virtualhost" hidden="true"/>
</type>
<type type="sample.DataSource" extends="generic.ProcessedTemplate" deployable-type="sample.DataSourceSpec"
container-type="sample.Server">
<generate-deployable type="sample.DataSourceSpec" extends="generic.Resource"/>
<property name="inspectScript" default="inspect/inspect-ds" hidden="true"/>
...
</type>
Encoding
The discovery mechanism uses URL encoding as described in RFC3986 to interpret the value of an inspected property. It is the responsibility of the plugin extender to perform said encoding in the inspect shell scripts.
Sample of encoding in a BASH shell script:
function encode()
{
local myresult=$(printf "%b" "$1" | perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg')
echo "$myresult"
}
myString='This is a string spanning many lines and with funky characters like !@#$%^&*() and \|'"'"'";:<>,.[]{}'
myEncodedString = $(encode "$myString")
echo $myEncodedString
Property inspection
The discovery mechanism identifies an inspected property when output with the following format is sent to the standard out.
INSPECTED:propertyName=value
The output must be prefixed with INSPECTED:
followed by the name of the inspected property, an =
sign and then the encoded value of
the property.
Sample:
echo INSPECTED:stringField=A,value,with,commas
echo INSPECTED:intField=1999
echo INSPECTED:boolField=true