Cisco CSR1000VでREST API

今回はCiscoのCSR1000VでREST APIを試してみました。

ダウンロードは こちらから。

インストールは こちらから。

CSR1000V設定

Configuring Support for Management Using the REST API
設定

Router(config)#interface virtualportGroup 0
Router(config-if)#ip unnumbered gigabitEthernet 1
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#virtual-service csr_mgt
Router(config-virt-serv)#vnic gateway virtualPortGroup 0
Router(config-virt-serv-vnic)#guest ip address 172.19.60.31
Router(config-virt-serv-vnic)#exit
Router(config-virt-serv)#activate 
% Virtual service csr_mgmt install has not completed, please activate the VM after install is completed

HTTPSの設定

Router(config)#ip http secure-server 
Router(config)#transport-map type persistent webui http-webui
Router(config-tmap)#secure-server 
Router(config-tmap)#exit
Router(config)#transport type persistent webui input http-webui

設定確認

Router#show virtual-service list
Virtual Service List:


Name                    Status             Package Name
------------------------------------------------------------------------------
csr_mgmt                Activated          csrmgmt.1_3_1.20140213_121708.ova

Router#show virtual-service detail 
Virtual service csr_mgmt detail
  State                 : Activated
  Package information
    Name                : csrmgmt.1_3_1.20140213_121708.ova
    Path                : bootflash:/csrmgmt.1_3_1.20140213_121708.ova
    Application
      Name              : csr_mgmt
      Installed version : 1.3.1
      Description       : CSR-MGMT
    Signing
      Key type          : Cisco development key
      Method            : SHA-1
    Licensing
      Name              : Not Available
      Version           : Not Available

  Detailed guest status
    
----------------------------------------------------------------------
Process               Status            Uptime           # of restarts
----------------------------------------------------------------------
nginx                  UP         0Y 0W 0D  0:17: 3        0
climgr                 UP         0Y 0W 0D  0:17: 3        0
restful_api            UP         0Y 0W 0D  0:17: 3        0   ←UPしています
fcgicpa                Down      
pnscag                 Down      
pnscdme                Down      
----------------------------------------------------------------------
Feature         Status                 Configuration
----------------------------------------------------------------------
Restful API   Enabled, UP             port: 443
                                      auto-save-timer: 8 seconds
                                      socket: unix:/usr/local/nginx/csrapi-fcgi.sock;

APIを叩く

REST API Management Reference Guide

guest ipで指定した172.19.60.31から叩いてみます。

[root@localhost ~]# curl -v -k -X POST https://172.19.60.30/api/v1/auth/token-services -H "Accept:application/json" -u "cisco:cisco"

結果

[root@localhost ~]# curl -v -k -X POST https://172.19.60.30/api/v1/auth/token-services -H "Accept:application/json" -u "cisco:cisco"
* About to connect() to 172.19.60.30 port 443 (#0)
*   Trying 172.19.60.30... connected
* Connected to 172.19.60.30 (172.19.60.30) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* warning: ignoring value of ssl.verifyhost
* skipping SSL peer certificate verification
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
*       subject: CN=IOS-Self-Signed-Certificate-3165186186
*       start date:  5月 21 08:59:34 2014 GMT
*       expire date:  1月 01 00:00:00 2020 GMT
*       common name: IOS-Self-Signed-Certificate-3165186186
*       issuer: CN=IOS-Self-Signed-Certificate-3165186186
* Server auth using Basic with user 'cisco'
> POST /api/v1/auth/token-services HTTP/1.1
> Authorization: Basic Y2lzY286Y2lzY28=
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 172.19.60.30
> Accept:application/json
>
< HTTP/1.1 404 Not Found
< Date: Wed, 25 Jun 2014 08:44:33 GMT
< Server: cisco-IOS
< Connection: close
< Accept-Ranges: none
<
404 Not Found
* Closing connection #0

”404 Not Found” 見事失敗しました。参考にする記事もあまりなく。
”-kオプション”つけてるのが原因かな。
これ以上どうすることもできず。

いつかリベンジします。
(ノ´▽`)ノ{+++THANK YOU+++}ヽ(´▽`ヽ)

広告を非表示にする