I'm developing a plugin that has a collection script that makes api calls to our equipment and needs to pass a username and password in the call. Sounds like a job for a Named Credential but I'm just a little unclear about how to do this with all the options available.
From what I read, It sounds like I want to define a Credential Type and Set - as in the example in chapter 14 of the plugin guide - and add that to my XML. I presume this named credential will then get set up in EM under the Security, Named Credentials section when I deploy the plugin. My install instructions would then direct the user to fill in the proper values and then the plugin would use those in the collection script.
Is that about right?
What I don't understand is how I reference the values of the Named Credential, in the plugin. Right now, I'm using the OSLineToken Fetchlet to call my collection script. I'm just not clear on how to pass the username password values of the Named Credential to the script.
Thanks for any insight,
Bump. Anyone have any insight on this? I've created a Monitoring Credential set and I can set the values in EM. I just don't know how to reference them in my script. I've looked at the host sample and there is an example of using Credentials for a Jobtype but that's not what I'm using and I can't make the leap to just a metric collection script.
Basically in the "CredentialSetColumn" use the SET_COLUMN attribute to set the credential handle and you can directly refer to it in your query.
For example, If you define the following credential set with credential handles "sampleUser" or "samplePassword" or "sampleRole", you can directly use the "sampleUser", "samplePassword" and "sampleRole" from the above CredentialSet in your Query
<CredentialSet NAME="SampleCredsMon" CREDENTIAL_TYPE="SampleCredsType" USAGE="MONITORING">
<Label NLSID="hs_hostsamplecreds_credset">Monitoring Sample Credentials</Label>
<CredentialSetColumn TYPE_COLUMN="SampleCredUser" SET_COLUMN="sampleUser">
<Label NLSID="hs_hostsamplecreds_uname">Monitoring User Id</Label>
<CredentialSetColumn TYPE_COLUMN="SampleCredPassword" SET_COLUMN="samplePassword">
<Label NLSID="hs_hostsamplecreds_pwd">Monitoring Password</Label>
<CredentialSetColumn TYPE_COLUMN="SampleCredRole" SET_COLUMN="sampleRole">
<Label NLSID="hs_hostsamplecreds_role">Monitoring Role</Label>
Thanks for the reply. I wasn't quite sure what you meant by "refer to it in your query" but I just tried using the value like any other instance variable and it worked!
So in my QueryDescriptor where I used to define a Property element and set it to the value of an instance variable, I now just set it to the SET_COLUM value as you stated. I then pass this to my data collection script like normal.
<Property NAME="MY_PASSWORD" SCOPE="INSTANCE" OPTIONAL="FALSE">sampleUser</Property>
<Property NAME="script">myscript.pl %MY_PASSWORD%</Property>
Thanks again for the help,