- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Netmri interface description script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 02:27 AM
Hello,
I'm looking to have a script in Netmri that will performs some actions on all the interfaces from my switches that contains a certain value "TEST" in the interface description:
If interface description contains "TEST" do : conf t; shutdown;
Do you have some examples? What's the best langage (CCS, Perl, Python) ?
Thank you for your replies.
Re: Netmri interface description script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 11:52 AM
The choice of scripting language almost doesn't matter -- use what's easiest for you. For Perl or Python, you'll need to use the netmri_easy library to perform device association, login, etc.
The issue in most scripts is the pattern matching -- what will produce the output you want to capture to let you conditionally perform an operation. For your case, I suggest sending this via CLI:
show interface description | include up.*TEST
That will find interfaces with that description but will ignore ones that are already admin down.
If the output is empty, there's nothing to do. Otherwise, loop on each matching statement (or implicitly in a CCS Trigger), and issue the shutdown command.
To prevent going in and out of config mode more than once, use a boolean ($config_changed) that you set the first time. If it's false, then "config term"... and set it to true.
When there are no more matches, if $config_changed is true, then send a CLI "end" and optionally "write mem".
If you want to be extra careful in testing, use the DEBUG: attribute on CLI commands so that they don't actually change the config but you can check the logic flow.
The sample scripts that are available in each language show this technique.
Re: Netmri interface description script
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:12 AM - edited 04-25-2024 10:43 PM
Thanks for sharing this inforamtion.