Chinaunix首页 | 论坛 | 博客
  • 博客访问: 473559
  • 博文数量: 67
  • 博客积分: 2952
  • 博客等级: 少校
  • 技术积分: 679
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-24 10:50
文章分类

全部博文(67)

文章存档

2011年(9)

2010年(36)

2009年(8)

2008年(5)

2007年(5)

2006年(4)

我的朋友

分类: LINUX

2010-09-03 16:00:34

Cisco的UCS系统提供了丰富的XML API,可以很方便的通过程序来配置系统和查询状态。这里我采用最简单的shell命令来调用API。主要是用curl和命令。我们采用aaaLogin来举例。
aaaLogin是用来登录UCS的函数,他的正确返回会有cookie等信息。
 

curl -H "Content-Type: text/xml" -N -s -d ''


  • -H is the header to pass
  • -N disables buffering
  • -s is silent mode, still displays the output from UCS just does not display curl output
  • -d the HTTP Post data

当发送数据给UCS Manager API的时候,URL路径必须是/nuova 上面执行的结果是:

<aaaLogin cookie="" response="yes" outCookie="1283499983/cd347549-26c1-4988-86b5-aadbdbdacbdd" outRefreshPeriod="600" outPriv="admin,read-only" outDomains="" outChannel="noencssl" outEvtChannel="noencssl"> </aaaLogin>

他表示你已经登陆进去了,得到的cookie是1283499983/cd347549-26c1-4988-86b5-aadbdbdacbdd

如果想单独的得到cookie,不显示其他信息,可以用xml来处理得到的XML

# curl -H "Content-Type: text/xml" -N -s -d '' http://10.224.106.14/nuova | xml sel -t -m //aaaLogin -v @outCookie


  • sel means select data or query XML
  • -t specifies the template to use, no template means use the default template
  • -m indicates the XPATH expression to match
  • -v prints out the value of the item specified, in this case the outCookie attribute

这样就直接得到了cookie.

1283499983/cd347549-26c1-4988-86b5-aadbdbdacbdd


其他函数可以采用相同的方法来访问。
阅读(971) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~