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 26 of 3
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
}
# 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] } {
puts "Getting config for $context"
set out [issue_command "changeto $context\nshow conn count"]
if { [regexp {<xml_show_result>(.*)</xml_show_result>} $out -
running_config]} {
running_config]} {
set fp [open "${context}.cfg" w+]
puts $fp $running_config
close $fp
}
}
}
II. XML Script Example (resource usage)
#!/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