Network Computing is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Managing Switches with REST and Thrift APIs: Page 2 of 4

SnapRoute is a newly formed company focused on providing an easily automated and functional routing platform. It was built by a group of engineers who had worked on Apple's network. Here we will dive into how an API programmable routing stack works.

As it uses a RESTful API, the commands sent to the switch are done using either POST, GET,OPTIONS, PATCH, or DELETE.

SnapRoute refers to ports on a switch as fpPortX, where X is the number of the front panel (fp) ports. If the port can be broken out (for example, 10 Gx4 for 40 G or 25 Gx4 for 100 G), then there will be a delineator fpPortXsY, where the port number is X and the breakout is referred to as Y. So fpPort1s1 would be the front panel port 1, which is the breakout link 1.

The following diagram shows the general software layout of a switch running SnapRoute's FlexSwitch. We have not included the operating system or any other programs or drivers necessary for the device to operate:

 

In order to send the output of commands to SnapRoute's FlexSwitch, use a Python module that formats JSON for better readability. If you don't use something to parse the data, the data will be somewhat readable but hard to understand. For example, if you want to see all the interfaces on the box, send this command:

curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://localhost:8080/public/v1/config/Ports'

Without a parser, you will see something similar to the following output, which is very hard to decipher:

{"ObjectId":"6ec727d1-c2c8-44dc-77fd-d9b1fd6dce4c","Object":{"IntfRef":"fpPort1","IfIndex":145,"Name":"fpPort1","OperState":"DOWN","NumUpEvents":0,"LastUpEventTime":"","NumDownEvents":0}}

If we run the command again, using the Python-based json.tool parser, we get:

curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://localhost:8080/public/v1/config/Ports' | python -m json.tool

 

{

 "CurrentMarker": 0,

 "MoreExist": false,

 "NextMarker": 0,

 "ObjCount": 160,

 "Objects": [

 {

 "Object": {

 "AdminState": "DOWN",

 "Autoneg": "OFF",

 "BreakOutMode": "1x100",

 "Description": "",

 "Duplex": "Full Duplex",

 "EnableFEC": false,

 "IfIndex": 145,

 "IntfRef": "fpPort1",

 "LoopbackMode": "",

 "MacAddr": "00:90:fb:55:e5:11",

 "MediaType": "Media Type",

 "Mtu": 9412,

 "PRBSPolynomial": "",

 "PRBSRxEnable": false,

 "PRBSTxEnable": false,

 "PhyIntfType": "KR4",

 "Speed": 100000

 },

 "ObjectId": "6ec727d1-c2c8-44dc-77fd-d9b1fd6dce4c"

 },

 {

 "Object": {

 "AdminState": "DOWN",

 "Autoneg": "OFF",

 "BreakOutMode": "1x100",

 "Description": "",

 "Duplex": "Full Duplex",

 "EnableFEC": false,

 "IfIndex": 140,

 "IntfRef": "fpPort2",

 "LoopbackMode": "",

 "MacAddr": "00:90:fb:55:e5:11",

 "MediaType": "Media Type",

 "Mtu": 9412,

 "PRBSPolynomial": "",

 "PRBSRxEnable": false,

 "PRBSTxEnable": false,

 "PhyIntfType": "KR4",

 "Speed": 100000

 },

 "ObjectId": "8029f48f-5b1b-492f-73b7-dc879e386508"

 },

The preceding information is much clearer.

Taking it further, to get information about a specific port, say fpPort1, send:

curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"IntfRef":"fpPort1"}' 'http://localhost:8080/public/v1/config/Port' | python -m json.tool

 

{

 "Object": {

 "AdminState": "DOWN",

 "Autoneg": "OFF",

 "BreakOutMode": "1x100",

 ... duplicate content omitted (see above output)

 "Speed": 100000

 },

 "ObjectId": "6ec727d1-c2c8-44dc-77fd-d9b1fd6dce4c"

}

Some of the pieces of information you receive are as follows:

  • The port speed is 100 Gbps
  • The port breakout mode is 1x100 Gbps (that is, it is not broken out)

In the preceding code, note that we are including the filter:

{"IntfRef":"fpPort1"}

This says we are referring to the interface with the name fpPort1 or front panel port 1.

To enable fpPort1, send:

curl -X PATCH --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"IntfRef":"fpPort1","AdminState":"UP"}' 'http://localhost:8080/public/v1/config/Port' | python -m json.tool

 

{

 "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type,

 Accept",

 "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PATCH, DELETE",

 "Access-Control-Allow-Origin": "*",

 "Access-Control-Max_age": "86400",

 "ObjectId": "6ec727d1-c2c8-44dc-77fd-d9b1fd6dce4c",

 "Result": "Success"

}

Refer to the following code:

{"IntfRef":"fpPort1","AdminState":"UP"}

This is the main piece of information; we are asking the system to turn front panel port 1 up.

This tells us that the call was successful:

"Result": "Success"

Now we can query the port again and see that it is now "AdminState": "UP":

curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"IntfRef":"fpPort1"}' 'http://localhost:8080/public/v1/config/Port' | python -m json.tool

 

{

 "Object": {

 "AdminState": "UP",

 "Autoneg": "OFF",

 "BreakOutMode": "1x100",

 "Description": "",

 "Duplex": "Full Duplex",

 "EnableFEC": false,

 "IfIndex": 145,

 "IntfRef": "fpPort1",

 "LoopbackMode": "",

 "MacAddr": "00:90:fb:55:e5:11",

 "MediaType": "Media Type",

 "Mtu": 9412,

 "PRBSPolynomial": "",

 "PRBSRxEnable": false,

 "PRBSTxEnable": false,

 "PhyIntfType": "KR4",

 "Speed": 100000

 },

 "ObjectId": "6ec727d1-c2c8-44dc-77fd-d9b1fd6dce4c"

}

NEXT Page: More configurations