Coder Social home page Coder Social logo

grpcreader's Introduction

Running javascript plugins for devmand

Install dependencies into node_modules:

npm install

then run the Ubiquiti plugin:

node plugin-ubnt-ifc-config-reader.js

or linux plugin:

node plugin-linux-ifc-reader.js

Either of those will start a gRPC server on 0.0.0.0:50051 .

Note that the plugins only talk with devmand, there is no direct connection to the managed device.

Devmand

Configuration

Devmand needs to be configured as well, example configuration is stored in devmand's doc/config-sample folder.

plugin.json

{
  "grpcPlugins":[
    {"id":"nodejsapp", "endpoint":"localhost:50051"}
  ]
}

This file contains list of remote plugins - their endpoints and identifiers. Devmand will fail to start if any of those endpoints is not available.

dev_conf.yaml

Plugin.json needs to be referenced from dev_conf.yaml as shown.

pluginConfig: /root/plugin.json
...

For linux example use following contents:

devices:
 - id: linux
   ip: 172.8.0.85
   readonly: false
   platform: StructuredUbntCli
   yangConfig: /root/localhost.json
   type: Device
   poll:
     seconds: 10
   channels:
     cliChannel:
       port: 22
       username: root
       password: root
       flavour: default
       stateCommand: echo 1
pluginConfig: /root/plugin.json

Tweaks

All tweaks are available here: `https://github.com/tomasol/magma/commits/grpc-plugins-tweaks

Quick start guide for running the demo with linux plugin

  • Start devmand container e.g. using docker/scripts/start_devmand_img.sh found in devmand repo
  • Build devmand with the tweaks so that datastore is stored in device_state.json.
  • Copy dev_conf.yaml (the linux version mentioned above), localhost.json, plugin.json from devmand's doc/config-sample to /root/ of devmand container.
  • Start plugin-linux-ifc-reader.js. The endpoint must be accessible from the container, e.g. using ssh -R 50051:127.0.0.1:50051 root@container_ip.
  • Start devmand. NodeJS should start logging registration request immediately.
  • First pass of device polling should be done after a couple of seconds and the device_state.json should contain:
$ docker exec 85 cat /cache/devmand/build/device_state.json
{
  "openconfig-interfaces:interfaces": {
    "interface": [
      {
        "subinterfaces": {
          "subinterface": [
            {
              "config": {
                "index": 0
              },
              "index": "0"
            }
          ]
        },
        "state": {
          "name": "lo"
        },
        "config": {
          "name": "lo",
          "enabled": true,
          "mtu": 65535
        },
        "name": "lo"
      },
      {
        "subinterfaces": {
          "subinterface": [
            {
              "config": {
                "index": 0
              },
              "index": "0"
            }
          ]
        },
        "state": {
          "name": "eth0"
        },
        "config": {
          "name": "eth0",
          "mtu": 1500,
          "enabled": true
        },
        "name": "eth0"
      }
    ]
  },
  "openconfig-network-instance:network-instances": {
    "network-instance": [
      {
        "vlans": {
          "vlan": [
            {
              "state": {
                "vlan-id": 1,
                "status": "ACTIVE"
              },
              "config": {
                "status": "ACTIVE",
                "vlan-id": 1
              },
              "vlan-id": "1"
            }
          ]
        },
        "config": {
          "type": "openconfig-network-instance-types:DEFAULT_INSTANCE",
          "name": "default"
        },
        "name": "default"
      }
    ]
  },
  "fbc-symphony-device:system": {
    "status": "UP"
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.