STORDIS / orca_nw_lib

gNMI python package for SONiC switch discovery and management.
Apache License 2.0
2 stars 3 forks source link

Interface autoneg configuration. #56

Closed kamalkrbh closed 3 months ago

kamalkrbh commented 4 months ago

Autonegotiation (autoneg) can be configured at following path -/restconf/data/openconfig-interfaces:interfaces Payload -

{
    "openconfig-interfaces:interfaces": {
        "interface": [
            {
                "name": "Ethernet0",
                "openconfig-if-ethernet:ethernet": {
                    "config": {
                        "auto-negotiate": true,
                        "openconfig-if-ethernet-ext2:advertised-speed": "10000,1000"
                    }
                }
            }
        ]
    }
}

advertised-speed here is one or more speeds from valid_speeds properties of interface.

For updating the database with the changes done with payload above a subsequent Subscription Notification is received by ORCA (respective gNMI path is already subscribed in orca_nw_lib) a sample notification (for the command - sonic(config-if-Ethernet0)# speed auto 1000,10000)is as follows :

update {
  timestamp: 1717768606808136677
  prefix {
    elem {
      name: "openconfig-interfaces:interfaces"
    }
    elem {
      name: "interface"
      key {
        key: "name"
        value: "Ethernet0"
      }
    }
    elem {
      name: "openconfig-if-ethernet:ethernet"
    }
    elem {
      name: "config"
    }
  }
  update {
    path {
      elem {
        name: "advertised-speed"
      }
    }
    val {
      string_val: "1000,10000"
    }
  }
  update {
    path {
      elem {
        name: "auto-negotiate"
      }
    }
    val {
      bool_val: true
    }
  }
}

As soon as the notification is received, the parameters from the notification JSON needs to be retrieved and interface in the Neo4j Database needs to be updated, refer gnmi_sub.py

UI need to provide provision for enabling, disabling autoneg also for selecting adv_speeds (can be more than one.)

Testcase in orca_backend for testing autoneg configuration.