Document toolboxDocument toolbox

Objects Usage

As described, each statement results in a value. The object type affects the results of various operations. For example, dividing an integer by another integer always results in an integer, whereas dividing a floating-point number by an integer will result in a floating-point number.
Some statements operate on the current object, including <PolicyRuleLogic>, <SetFilter>, <Expr> with a field attribute, <Expr> with in-group, not-in-group, and defined operators, and all the Config Check elements. In the case of the <PolicyRuleLogic>, the "current object" is the device against which the policy rule is evaluated.
Object fields and methods are described in the API documentation, which may be found in the user interface in Tools  > Network > API Documentation. The current object at the time of policy rule evaluation will always be an InfraDevice. In the API documentation, go to the API List link, scroll down to the Device section, and click Infrastructure Devices. On the page that results, click the InfraDevice link under Model.
It is possible to change the current object for a statement, by setting the 'object' attribute to the name of a variable containing the new current object. This will apply only to that element. For example, this checks if the parent_device of the current device is a Nexus 7k:

<PolicyRuleLogic editor='raw-xml'>
   <Assign variable='parent'><Expr method='parent_device'/></Assign>
   <If>
     <Expr op='=='>
      <Expr object='parent' field='DeviceModel'/>
      <Expr value='N7Kc7010'/>
     </Expr>
     <Then><PolicyRulePass/></Then>
     <Else><PolicyRuleFail/></Else>
   </If>
</PolicyRuleLogic>

You can also chain the names into the field attribute without declaring the variable first, using a period as the separator:

<PolicyRuleLogic editor='raw-xml'>
   <If>
     <Expr op='=='>
      <Expr field='parent_device.DeviceModel'/>
      <Expr value='N7Kc7010'/>
     </Expr>
     <Then><PolicyRulePass/></Then>
     <Else><PolicyRuleFail/></Else>
   </If>
</PolicyRuleLogic>

In this case, each component in the change can be either a method call that takes no arguments or a field.