Is there a way to omit all the unused config from a 'show conf'

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
Coming from a mostly Procurve background, the one thing we are finding more difficult is the CLI output from EXOS.  Is there any way to omit the features we aren't using, so there are not show many pages of output when doing a 'show conf' ?
  
Photo of Bruce Garlock

Bruce Garlock

  • 674 Points 500 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Patrick Voss

Patrick Voss, Alum

  • 11,594 Points 10k badge 2x thumb
Are you referring to the modules that may come up empty?
Photo of Bruce Garlock

Bruce Garlock

  • 674 Points 500 badge 2x thumb
Yes.
Photo of Patrick Voss

Patrick Voss, Alum

  • 11,594 Points 10k badge 2x thumb
Unfortunately you can't omit unused modules. If you are looking for specific configuration you can either specify the module you would like to look at after "show configuration" or you can use the "| i" filter. For example, "show config | i vlan". This will display any lines in the output that have that specific string in it.
(Edited)
Photo of Patrick Voss

Patrick Voss, Alum

  • 11,594 Points 10k badge 2x thumb
As a workaround you can use the command below to remove any line with a # in it:

show config | e "#"

This should minimize the amount of output you receive.
Photo of Bruce Garlock

Bruce Garlock

  • 674 Points 500 badge 2x thumb
That's very helpful - thanks!  I live in BASH all day, so anytime I can pipe, I'm happy :-)
Photo of Drew C.

Drew C., Community Manager

  • 40,104 Points 20k badge 2x thumb
Hi Bruce,
EXOS 15.7+ natively supports Python Scripting, if you're into that.  It wouldn't be very difficult to write up a script that excludes modules that don't give output - we may already have one written that I can share.  It might also be a good addition to EXOS' native CLI, but that won't happen overnight :)
Photo of Drew C.

Drew C., Community Manager

  • 40,104 Points 20k badge 2x thumb
Bruce, here's a Python script (for EXOS 15.7+) that will do exactly what you're looking for.  It was adapted from another script.  It's possible that there's a better way, but this works!
You can copy it to your switch as a .py file with TFTP, or just paste the script in through vi on the CLI.
class Clean_Config(object):
    def process_config(self):
        self.cfg_modules = []
        print "\nProcessing Configuration...\n\n"
        config = exsh.clicmd('show config', capture=True)
        config = config.splitlines(True)
        print "\n->show configuration\n"
        moduleName = ''
        moduleStr = ''
        configExist = False
        for line in config:
            if '#' not in line and line != '\n':
                moduleStr += line
                configExist = True
            elif configExist is True and '#' in line:
                self.cfg_modules.append(moduleName)
                moduleStr = line
                moduleName = ''
                configExist = False
            elif '#' in line:
                moduleStr += line
                configExist = False
                if '# Module ' in line:
                    moduleName = line.replace('# Module ','')
                    moduleName = moduleName.replace(' configuration.\n','')
                    moduleName = moduleName.lower()
            elif configExist is True and line == '\n':
                moduleStr += line
            else:
                moduleStr = ''

def main():
    cfg = Clean_Config()
    cfg.process_config()
    for module in cfg.cfg_modules:
        cmd = 'show config %s' % module
        print exsh.clicmd(cmd, capture=True)

main()


And here's how it looks when executed:
X460_TestSwitch.12 # run script clean_config.py
Processing Configuration...
->show configuration

#
# Module devmgr configuration.
#
configure snmp sysName "X460_TestSwitch"
configure snmp sysContact "support@extremenetworks.com, +1 888 257 3000"
configure sys-recovery-level switch reset

#
# Module vlan configuration.
#
configure vlan default delete ports all
configure vr VR-Default delete ports 1-34
configure vr VR-Default add ports 1-34
configure vlan default delete ports 1-34
create vlan "lp"
configure vlan lp tag 1001
enable loopback-mode vlan lp
create vlan "v1"
configure vlan v1 tag 10
create vlan "v3"
configure vlan v3 tag 30
create vlan "x460g2"
configure vlan x460g2 tag 1500
configure vlan v1 add ports 3 tagged 
configure vlan v3 add ports 2 tagged 
configure vlan x460g2 add ports 4 tagged 
configure vlan v1 ipaddress 10.0.0.1 255.255.255.0
enable ipforwarding vlan v1
configure vlan lp ipaddress 192.168.1.1 255.255.255.0
enable ipforwarding vlan lp
configure vlan v3 ipaddress 30.0.0.2 255.255.255.0
enable ipforwarding vlan v3
configure vlan x460g2 ipaddress 172.16.11.1 255.255.255.0
enable ipforwarding vlan x460g2

#
# Module netTools configuration.
#
configure dns-client add name-server 10.1.1.1 vr VR-Default
configure dns-client add name-server 10.1.1.2 vr VR-Default
configure dns-client add domain-suffix extremenetworks.com
enable dhcp vlan Mgmt

#
# Module ospf configuration.
#
configure ospf routerid 192.168.1.1
enable ospf
create ospf area 0.0.0.2
configure ospf add vlan lp area 0.0.0.0
configure ospf add vlan v1 area 0.0.0.2 link-type point-to-point
configure ospf add vlan v3 area 0.0.0.2 link-type point-to-point
configure ospf add vlan x460g2 area 0.0.0.2 link-type point-to-point

#
# Module thttpd configuration.
#
configure ssl certificate hash-algorithm sha512

Let me know what you think!

-Drew
(Edited)
Photo of Bruce Garlock

Bruce Garlock

  • 674 Points 500 badge 2x thumb
This is even better, Drew - thank you!  Another reason why I tell everyone that 'vi' is better than emacs! I had no idea I could use Python.  I'm still a newbie to Extreme, and this is a very nice selling point.  Thanks again.
Photo of Drew C.

Drew C., Community Manager

  • 40,072 Points 20k badge 2x thumb
You're welcome!
If you want to explore the capabilities of Python in EXOS, there's a lot of good information in the "Scripting" category here on The Hub.
If you want more, you can check out the Python Scripting Guide and documentation on The EXOS Python API, which you may find helpful.

Since you're new to Extreme - you'll likely want to see what you can find in our KB, GTAC Knowledge.  New articles are loaded there every day.

Come back and see us... we're a helpful bunch of Extremists!
(Edited)