Reply

Run a command through compliance xml

[ Edited ]
Authority
Posts: 27
3371     0

Hello,

    I was wondering if there is a way to run a command on a device, put it into a variable, then run a compliancy check against the variable. Some things I want to check on a device, such as snmp user, is not displayed in a config and wanted to see if it was possible to check this using compliancy xml.

 

Thank you,

Jerry

Re: Python - External Script to Run the "Ad Hoc Command Batch" on NetMRI

Adviser
Posts: 353
3372     0
Yes, you can put it in a list or in a device custom field and have the rule check it from there.

Re: Python - External Script to Run the "Ad Hoc Command Batch" on NetMRI

Adviser
Posts: 353
3372     0

To be clear, you can't run a command within the policy engine. You would run a separate job that sets the value in the custom field or list, and have a policy rule that checks that.

Re: Python - External Script to Run the "Ad Hoc Command Batch" on NetMRI

CalB
Techie
Posts: 2
3372     0

Would you be able to supply an example of an xml rule checking a custom field?

Re: Python - External Script to Run the "Ad Hoc Command Batch" on NetMRI

Adviser
Posts: 353
3372     0

Sure. This rule will check whether a device custom field "asset_tag_no" is populated or not.

 

<PolicyRuleLogic editor="raw-xml" xmlns='http://www.infoblox.com/NetworkAutomation/1.0/ScriptXml'>
  <If>
    <Expr op='and'>
      <Expr op='eq'>
        <Expr value=''/>
        <Expr field=’meta.asset_tag_no'/>
      </Expr>
    </Expr>
    <Then>
      <PolicyRuleFail>Asset tag number is empty.</PolicyRuleFail>
    </Then>
    <Else>
      <PolicyRulePass/>
    </Else>
  </If>
</PolicyRuleLogic>

John

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You