Forum Discussion

JessieBryan's avatar
3 months ago
Solved

Looking for Socket Interface Wan Role and Precedence

Hello devs!

I am trying to fetch interface data for our application. In doing so, I realized that I cannot locate the interface wan role # and the precedence # from CATO API.

I did some digging and found 'naturalOrder' - is this the WAN precedence?

Also, directly from the Socket Web GUI (proxy) - I could see `wan_outlet_id` which looks like it could be the wan role, however this is not exposed in InterfaceSnapshot.

ps: Do varioius Socket/vSocket platforms have different values/limits for WAN Role and Precedence? I currently see 3 WAN Roles, and 3 Precedences in our deployments.

 

 

  • peter's avatar
    peter
    3 months ago

    Hey JessieBryan I think you're right, I've hunted high and low and I can't find a field in the public API which maps to role. This has also been identified as a gap by some of our field engineers working with customers on automation projects, so it is known, but if you were to submit an RFE for this that would also help grease the wheels.

6 Replies

  • Hi JessieBryan ,

    I believe what you are looking for has been added to the API, and can be found here under interfaceinfo in the accountsnapshot query.

    https://api.catonetworks.com/documentation/#definition-InterfaceInfo

    query accountSnapshot ( $siteIDs:[ID!] $accountID:ID ) {
        accountSnapshot ( accountID:$accountID  ) {
            id 
            sites ( siteIDs:$siteIDs  )  {
                id
                infoSiteSnapshot: info {
                    name 
                    type 
                    description 
                    countryCode 
                    region 
                    countryName 
                    countryStateName 
                    cityName 
                    isHA 
                    connType 
                    creationTime 
                    interfaces  {
                        id
                        name
                        upstreamBandwidth
                        downstreamBandwidth
                        upstreamBandwidthMbpsPrecision
                        downstreamBandwidthMbpsPrecision
                        destType
                        wanRole
                    }

            }

            timestamp 
        }    
    }

    Response snippit:
    {
      "infoInterfaceSnapshot": {
        "id": "1",
       "name": "WAN",
       "upstreamBandwidth": 500,
       "downstreamBandwidth": 500,
       "upstreamBandwidthMbpsPrecision": 500,
       "downstreamBandwidthMbpsPrecision": 500,
       "destType": "CATO",
       "wanRole": "wan_1"
      }
    }

  • Ah yes great, thanks peter  - I do have some trouble understanding what I'm looking at in CMA vs. API. In this example, the CMA says Port "LTE" uses WAN Role "WAN2", but the data gathered over API shows the interface / info / id is just "LTE". How does CMA map "LTE" to "WAN2" for the role?

    Here's my sample data:

    {
        "interfaces": [
            {
                "connected": 0,
                "id": "1",
                "info": {
                    "destType": "CATO",
                    "id": "1",
                    "name": "WAN 01"
                },
                "name": "WAN 01",
                "naturalOrder": 1
            },
            {
                "connected": 1,
                "id": "2",
                "info": {
                    "destType": "CATO",
                    "id": "2",
                    "name": "WAN 02"
                },
                "name": "WAN 02",
                "naturalOrder": 3
            },
            {
                "connected": 0,
                "id": "LTE",
                "info": {
                    "destType": "CATO",
                    "id": "LTE",
                    "name": "LTE 01"
                },
                "name": "LTE 01",
                "naturalOrder": 3
            }
        ]
    }

     

    • JessieBryan's avatar
      JessieBryan
      Meteor

      I just realized the API data I provided has transforms that are not CATO native. 

      Here is the non-transformed example data:

      {
          "interfaces": [
              {
                  "connected": true,
                  "id": "1",
                  "info": {
                      "destType": "CATO",
                      "id": "1",
                      "name": "WAN 01"
                  },
                  "name": "WAN 01",
                  "naturalOrder": 1
              },
              {
                  "connected": true,
                  "id": "2",
                  "info": {
                      "destType": "CATO",
                      "id": "2",
                      "name": "WAN 02"
                  },
                  "name": "WAN 02",
                  "naturalOrder": 3
              },
              {
                  "connected": false,
                  "id": "LTE",
                  "info": {
                      "destType": "CATO",
                      "id": "LTE",
                      "name": "LTE 01"
                  },
                  "name": "LTE 01",
                  "naturalOrder": 3
              }
          ]
      }

       

      • peter's avatar
        peter
        Icon for Cato Employee rankCato Employee

        Hey JessieBryan I think you're right, I've hunted high and low and I can't find a field in the public API which maps to role. This has also been identified as a gap by some of our field engineers working with customers on automation projects, so it is known, but if you were to submit an RFE for this that would also help grease the wheels.

  • peter's avatar
    peter
    Icon for Cato Employee rankCato Employee

    Hi Jessie,

    Yes, naturalOrder is the cunningly-disguised precedence. I have code like this in some of my own scripts to convert it back to the human-readable precedence:

    			for interface in self.snapshot["devices"][0]["interfaces"]:
    				if interface["name"] == if_name:
    					no = interface["naturalOrder"]
    					if no == 1:
    						return "Active"
    					elif no == 2:
    						return "Passive"
    					elif no == 3:
    						return "Last Resort"
    					elif no == 0:
    						return "0"
    					else:
    						print(f'FATAL: {self.ID}:{self.name}:{if_name} get_role unknown naturalOrder {no}')
    						sys.exit(1)		

    The role is also cunningly disguised as interface / info / id: