This discussion is archived
3 Replies Latest reply: Aug 2, 2013 3:20 PM by tmhudg RSS

Need some help with using a named Credential with a custom plugin

tmhudg Newbie
Currently Being Moderated

Hello,

 

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,

 

Tom

  • 1. Re: Need some help with using a named Credential with a custom plugin
    tmhudg Newbie
    Currently Being Moderated

    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.

     

    Thanks,

     

    Tom

  • 2. Re: Need some help with using a named Credential with a custom plugin
    user764924 Newbie
    Currently Being Moderated

    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">

      <Display>

      <Label NLSID="hs_hostsamplecreds_credset">Monitoring Sample Credentials</Label>

      </Display>

      <CredentialSetColumn TYPE_COLUMN="SampleCredUser" SET_COLUMN="sampleUser">

      <Display>

      <Label NLSID="hs_hostsamplecreds_uname">Monitoring User Id</Label>

      </Display>

      </CredentialSetColumn>

      <CredentialSetColumn TYPE_COLUMN="SampleCredPassword" SET_COLUMN="samplePassword">

      <Display>

      <Label NLSID="hs_hostsamplecreds_pwd">Monitoring Password</Label>

      </Display>

      </CredentialSetColumn>

      <CredentialSetColumn TYPE_COLUMN="SampleCredRole" SET_COLUMN="sampleRole">

      <Display>

      <Label NLSID="hs_hostsamplecreds_role">Monitoring Role</Label>

      </Display>

      </CredentialSetColumn>

      </CredentialSet>

  • 3. Re: Need some help with using a named Credential with a custom plugin
    tmhudg Newbie
    Currently Being Moderated

    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.

     

    <QueryDescriptor FETCHLET_ID="OSLineToken">

      <Property NAME="MY_PASSWORD" SCOPE="INSTANCE" OPTIONAL="FALSE">sampleUser</Property>

    ...

      <Property NAME="script">myscript.pl %MY_PASSWORD%</Property>

    </QueryDescriptor>

     

    Thanks again for the help,

     

    Tom

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points