Skip to content
Snippets Groups Projects
Erik Reid's avatar
Erik Reid authored
Merge branch 'develop' of gitlab.geant.net:live-projects/dashboardv3/inventory-provider into develop
f84bc4aa
History
  1. [Inventory Provider]
    1. [Overview]
    2. [Configuration]
    3. [Running this module]
    4. [Protocol specification]

Inventory Provider

Overview

This module implements a Flask-based webservice which provides some access to GÉANT network router inventory information.

The webservice is communicates with clients over HTTP. Responses to valid requests are returned as JSON messages. The server will therefore return an error unless application/json is in the Accept request header field.

HTTP communication and JSON grammar details are beyond the scope of this document. Please refer to RFC 2616 and www.json.org for more details.

Configuration

Several configuration files must be provided when launching the web service.

The runtime-accessible filename of the first configuration file must be stored in the environment variable SETTINGS_FILENAME.

The configuration file is python and defines a single variable. The following is an example:

INVENTORY_PROVIDER_CONFIG_FILENAME = "/somepath/config.json"
  • INVENTORY_PROVIDER_CONFIG_FILENAME: run-time accessible filename of a json file containing the server configuration parameters. This file must be formatted according to the following json schema:

    {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
            "alarms-db": {
                "type": "object",
                "properties": {
                    "hostname": {"type": "string"},
                    "dbname": {"type": "string"},
                    "username": {"type": "string"},
                    "password": {"type": "string"}
                },
                "required": ["hostname", "dbname", "username", "password"],
                "additionalProperties": False
            },
            "oid_list.conf": {"type": "string"},
            "routers_community.conf": {"type": "string"},
            "ssh": {
                "type": "object",
                "properties": {
                    "private-key": {"type": "string"},
                    "known-hosts": {"type": "string"}
                },
                "required": ["private-key", "known-hosts"],
                "additionalProperties": False
            },
            "redis": {
                "type": "object",
                "properties": {
                    "hostname": {"type": "string"},
                    "port": {"type": "integer"}
                },
                "required": ["hostname", "port"],
                "additionalProperties": False
            }
        },
        "required": [
            "alarms-db",
            "oid_list.conf",
            "routers_community.conf",
            "ssh",
            "redis"],
        "additionalProperties": False
    }

Running this module

This module has been tested in the following execution environments:

  • As an embedded Flask application. For example, the application could be launched as follows:
$ export FLASK_APP=app.py
$ export SETTINGS_FILENAME=settings.cfg
$ flask run
  • As an Apache/mod_wsgi service.
    • Details of Apache and mod_wsgi configuration are beyond the scope of this document.

protocol specification

The following resources can be requested from the webservice.

resources

Any non-empty responses are JSON formatted messages.

  • /data/version

    The response will be an object containing the module and protocol versions of the running server and will be formatted as follows:

    {
          "$schema": "http://json-schema.org/draft-07/schema#",
          "type": "object",
          "properties": {
              "api": {
                  "type": "string",
                  "pattern": r'\d+\.\d+'
              },
              "module": {
                  "type": "string",
                  "pattern": r'\d+\.\d+'
              }
          },
          "required": ["api", "module"],
          "additionalProperties": False
      }
  • /data/routers

    The response will be a list of router hostnames for which information is available and will be formatted as follows:

    {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "array",
        "items": {"type": "string"}
    }
  • /data/interfaces/hostname

    The response will be a list of information about the interfaces present on the requested host and will be formatted as follows:

    {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "description": {"type": "string"}
            },
            "required": ["name", "description"],
            "additionalProperties": False
        }
    }
  • /data/snmp/hostname

    The response will be a list of information about the interfaces discovered through snmp queries on the requested host and will be formatted as follows:

    {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "index": {"type": "string"},
                "name": {"type": "string"}
            },
            "required": ["index", "name"],
            "additionalProperties": False
        }
    }
  • /data/bgp/hostname

    The response will be a list of information about the bgp peerings configured for the requested host and will be formatted as follows:

    {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "description": {"type": "string"},
                "as": {
                    "type": "object",
                    "properties": {
                        "peer": {
                            "type": "string",
                            "pattern": r'^\d+$'
                        },
                        "local": {
                            "type": "string",
                            "pattern": r'^\d+$'
                        },
                    },
                    "required": ["peer", "local"],
                    "additionalProperties": False
                },
            },
            "required": ["description", "as"],
            "additionalProperties": False
        }
    }
  • /jobs/update

    This resource updates the inventory network data for juniper devices.