Cisco Cisco MGX Service Resource Module Enhanced [SRM-E] 백서
Technical Overview
© 2011 Cisco Systems, Inc. All rights reserved. This document is Cisco Public Information.
Page 30 of 3
III. XML Script Example (SSL Certificate expiration)
#!/usr/bin/tclsh
# Global login credentials
set user "username"
set pass "password"
# Global mgmt IP address of Admin context
set mgmt_ip "xx.xx.xx.xx"
#
# this procedure will execute a curl command to send the XML
# command to ACE. If the command fails to execute properly,
# the script will exit with and error.
# If the command executes with no problem, then the output
# of the XML command is returned
proc issue_command { cmd } {
global user pass mgmt_ip
if { [catch {set output [exec -- curl -s\
http://${user}:${pass}@${mgmt_ip}/bin/xml_agent\
-d "xml_cmd=<request_raw>${cmd}</request_raw>"] } error] }
{
{
puts "Problem with exec: $error"
exit 0
}
return $output
}
set current_date [clock seconds]
# Get a list of contexts from Admin context
set contexts [split [issue_command "show context | inc Name"] \n]
foreach line $contexts {
if { [regexp {Name: (.*) ,} $line - context] } {
# output example
# Ace-Mod3/Paul# sho crypto files | inc CERT
# test-cert.pem 787 PEM Yes CERT
set crypto_out [issue_command\