- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
RAW XML Policy - multiple interface checks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2021 12:17 PM
We currently have a rule that checks to see if a shutdown script is set for ports that use MAB. The script checks for GigabitEthernet interfaces. Due to some recent changes we also need to have it check TenGigabitEthernet interfaces as well. I tried to tweak a few things but with no luck.
Below is the current xml:
<PolicyRuleLogic editor="raw-xml" xmlns='http://www.infoblox.com/NetworkAutomation/1.0/ScriptXml'>
<Assign variable='device-config'>
<Expr method='running_config_text'/>
</Assign>
<Assign variable='intface'>
<Expr value=''/>
</Assign>
<ConfigBlockCheck block-start='^interface' boundary-method='indent'>
<Expr op='matches'>
<Expr variable='_block'/>
<Expr value='GigabitEthernet(.*)'/>
</Expr>
<Assign variable='intface'>
<Expr variable='_match_1'/>
</Assign>
<If>
<ConfigFileCheck op='contains-all'>mab</ConfigFileCheck>
<Then>
<Assign variable='event-line'>
<Expr op='concat'>
<Expr value=' event syslog pattern "%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet'/>
<Expr variable='intface'/>
<Expr value=', changed state to down"'/>
</Expr>
</Assign>
<If>
<Expr op='matches'>
<Expr variable='device-config'/>
<Expr variable='event-line'/>
</Expr>
<Then>
<Assign variable='event-config'>
<Expr op='concat'>
<Expr value=' action 1.3 cli command "interface GigabitEthernet'/>
<Expr variable='intface'/>
<Expr value='"'/>
</Expr>
</Assign>
<If>
<Expr op='matches'>
<Expr variable='device-config'/>
<Expr variable='event-config'/>
</Expr>
<Then>
</Then>
<Else>
<Return>
<PolicyRuleFail>
<Expr op='concat'>
<Expr value='Shutdown script not set correctly for port GigabitEthernet'/>
<Expr variable='intface'/>
</Expr>
</PolicyRuleFail>
</Return>
</Else>
</If>
</Then>
<Else>
<Return>
<PolicyRuleFail>
<Expr op='concat'>
<Expr value='Shutdown script not set correctly for port GigabitEthernet'/>
<Expr variable='intface'/>
</Expr>
</PolicyRuleFail>
</Return>
</Else>
</If>
</Then>
</If>
</ConfigBlockCheck>
<PolicyRulePass>Shutdown scripts are configured correctly.</PolicyRulePass>
</PolicyRuleLogic>
Re: RAW XML Policy - multiple interface checks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2021 07:57 AM
Try the following
Change this <Expr value='GigabitEthernet(.*)'/> to <Expr value='GigabitEthernet(.*)|TenGigabitEthernet(.*)'/>
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com