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
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