OiaSam
OiaSam

Reputation: 560

How to add custom MIBs in Opendaylight SNMP Plug in?

I am writing a python application which is supposed to use Opendaylight SNMP Plugin REST API (http://IPAddress:8181/restconf/operations/snmp:snmp-get) to get some info from a network device running an snmp agent.

I am simulating the setup as follows:

Environment

what has been done

To get information such as Total RAM (OID: .1.3.6.1.4.1.2021.4.5.0) I need to add UCD-SNMP-MIB.mib to opendaylight so it understands the object type and ID.

I have checked out this page but I can't seem to make it work. The tutorial in the page seems outdated and it explains how to create a native opendaylight project whereas my objective is to use the northbound APIs.

Question: How do we add a custom MIB files to opendaylight directories so an application can use the REST API to manage an snmp agent over the network?

Upvotes: 0

Views: 497

Answers (1)

donaldh
donaldh

Reputation: 833

The odl-snmp-plugin does not have any functionality to work directly with MIB files.

The generic RPCs such as snmp-get will only take OID values and return a JSON document of OID/value pairs.

POST :host/restconf/operations/snmp:snmp-get
Authentication: :basic-auth
Content-Type: application/json
{
   "input": {
      "ip-address": ":addr",
      "oid" : "1.3.6.1.2.1.2.2.1",
      "get-type" : "GET-BULK",
      "community" : ":community"
   }
}

{
  "output": {
    "results": [
      {
        "oid": "1.3.6.1.2.1.2.2.1.1.1",
        "value": "1"
      },
      {
        "oid": "1.3.6.1.2.1.2.2.1.1.2",
        "value": "2"
      },
      ...
    ]
  }
}

The module specific RPCs such as get-interfaces relies on two prerequisites:

  1. A YANG file has been generated from the required MIB
  2. A .oid file which contains mappings from MIB name to OID, for the yang-oid-plugin.

With these prerequisites, you can then write a Maven POM file that will generate Java code that includes OID annotations. This is intended to let you use the Java binding-aware APIs to fetch Java objects that are populated with SNMP data.

The OpenDaylight snmp project is a complete example for how to do this.

See here for an example YANG file generated from IF-MIB: https://github.com/opendaylight/snmp/blob/master/mibs-model/src/main/yang/IF-MIB.yang

See here for an example .oid file, also generated from IF-MIB: https://github.com/opendaylight/snmp/blob/master/mibs-model/src/main/oid/IF-MIB.oid

Further steps are required to implement a solution that exposes this over either NETCONF or RESTCONF. A simple way is to add and hard-code RPCs as the odl-snmp-plugin has done. A more sophisticated solution would require a concept of mounted devices, just like the odl-netconf-connector does, where you extend topology to store a device's SNMP credentials then write a connector that mounts the SNMP-backed YANG modules under the topology node for the device.

Upvotes: 0

Related Questions