Brocade FabricOS 8.2 release notes said REST API is ready.

     820_releaseNotes.png

I introduce how REST API works using curl(1) command for some fundamental usage.

 

At the first, you need to verify REST API is enabled to run "mgmtapp --show" on your switches.

     RestAPI_show.png

      Above showed already enabled. If "Disabled", please run "mgmtapp --enable rest" to enable.

 

1. Login to switch

    curl(1) command has a option "--user <user:password>". We use this option for login user and password.

    And we specify

          http command: POST

          Content-Type: application/yang-data+xml

          url: http://<ip-addr>/rest/login ("https" is recommended.)

       RestAPI_Login.png

          Authorization-Header orange-circled is "session-key". This is used for next requests.

 

2. logout

     User/Password is not required but you need session-key received when login request.

     You can logout following curl command,

     curl -v -X POST -H "Content-Type: application/yang-data+xml" -H "Authorization: Custom_Basic YWRtaW46eHh4OjlhMmU3NTUyNmZhY2QxN2ZjNGQ0ZTViNjkyZDczMmUyMjgzMWI0Y2JjYzU0ZmZlM2YzNGJkODRkZTI0NmExM2Y=" "http://<ip-addr>/rest/logout"

 

3. logout (Using FOS command)

     You can force logout session by "mgmtapp --terminate <session>" on your switch.

3-1. Confirm current sessions by "apploginhistory --show" command.

     Rest_API_appLoginHistory_1session.png

3-2. Terminate session by "mgmtapp -terminare <session>" (rounded pink color)

     Rest_API_appLoginHistory_TerminateSession.png

          After the terminate session, this session was gone. (rounded sky blue color)

4. Reading switch information

     GET command with http://<ip-addr>/rest/running/fabric/fabric-switch

     Rest_API_fabricfabric-switch.png

          <fcid>16776193</fcid> is same as switchID by switchShow command 0xfffc01 (=16776193) bellow,

     Rest_API_switchShow_fabric-switch.png

 

5. Reading ports information

     GET command with http://<ip-addr>/rest/running/brocade-interface/fibrechannel.

      This is similar to  switchShow + portCfgShow.

     Information for all ports are read unless port number <slot#>/<port#> is specifed. 

     Rest_API_brocade-interface_fibrechannel.png 

          speed: 32Gb: 32000000000

                      16Gb: 16000000000

           8Gb:   8000000000

      operational-status: 2: Online/Testing

                3: Offline

                5: Faulty

      enabled-state:  2: Port is enabled

               6: Port is disabled

       

          The first entry was matched with following switchShow information.

  Rest_API_switchShow_brocade-interface_fibrechannel.png

 

6. Changing port speed setting

     PATCH command with http://<ip-addr>/rest/running/brocade-interface/fibrechannel.

6-1. Current setting

          Auto speed (32Gb)

     Rest_API_portSpeedOrg.png

6-2. Changing to 8Gb auto speed (Same as "portcfgspeed 5 0 -m8)

     Rest_API_portSpeed_Auto8Gb_err.png

          Errored. Setting was changed to fixed 8Gb speed settings bellow,

     Rest_API_portSpeed_Auto8Gb_err2.png

          According to API reference, auto-negotiate member is read-only.

     Rest_API_autoNegotiate_Manual.png

          You can see <auto-negotiate>1</auto-negotiate> when you run "portcfgspeed 5 0 -m 8".

     Rest_API_portCfgSpeed_max8Gb_brocade-interface_fibrechannel.png

7. Reading port error count.

          GET command with http://<ip-addr>/rest/running/brocade-interface/fibrechannel-statistics/......

     Rest_API_fibrechannel-statistics.png

          You can also reset counters via REST API, but port basis.


8.  Those are very summary introduction for Brocade FabricOS REST API.

     Now logging out session.

     Rest_API_logout.png