This example script sets the selected Cisco port to administration down.
1. expect.with
2. {
3. if( vendor.equals("9") )
4. {
5. shortDesc = target.portShortDescr
6. portIdentifier = shortDesc.substring(2,shortDesc.length()-2)
7. sendln "configure terminal"
8. expect( configPrompt, {} )
9. sendln "interface " + portIdentifier
10. expect( configIfPrompt, {} )
11. sendln "shutdown"
12. expect( configIfPrompt, {} )
13. }
14. else
15. {
16. println "NO VALID METHOD FOR THIS DEVICE"
17. throw new Exception("no valid method for this device")
18. }
19. }
Overview of the set port to administration down script structure:
- Line 3. finds the seventh character of the sysOID to identify the device vendor.
- Line 5. sets shortDescr to the short description of the selected interface.
- Line 6. extracts from shortDescr the port identifier by removing the square brackets and spaces that enclose the port identifier (this is the default format of interface names in Entuity).
- Line 7. sets the terminal to configure mode.
- Line 9. sets context to the selected interface (changing the prompt to the interface prompt).
- Line 11. sends the shutdown command to the port. Entuity will report the port Admin Status as down within five minutes of you taking it down.
- Line 14. to Line 18. return an error message when the device is not a Cisco device. This script concentrates on Cisco but you could extended it to use with devices from
other vendors.
Comments
0 comments
Please sign in to leave a comment.