Skip to content
Snippets Groups Projects
To learn more about this project, read the wiki.
README.md 39.89 KiB

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"
ENABLE_TESTING_ROUTES = True
  • INVENTORY_PROVIDER_CONFIG_FILENAME: [REQUIRED] 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#",
    
        "definitions": {
            "database_credentials": {
                "type": "object",
                "properties": {
                    "hostname": {"type": "string"},
                    "dbname": {"type": "string"},
                    "username": {"type": "string"},
                    "password": {"type": "string"}
                },
                "required": ["hostname", "dbname", "username", "password"],
                "additionalProperties": False
    
            }
        },
    
        "type": "object",
        "properties": {
            "alarms-db": {"$ref": "#/definitions/database_credentials"},
            "ops-db": {"$ref": "#/definitions/database_credentials"},
            "oid_list.conf": {"type": "string"},
            "ssh": {
                "type": "object",
                "properties": {
                    "username": {"type": "string"},
                    "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
            },
            "junosspace": {
                "api": {"type": "string"},
                "username": {"type": "string"},
                "password": {"type": "string"}
            },
            "infinera-dna": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {"type": "string"},
                        "address": {"type": "string"}
                    },
                    "required": ["name", "address"],
                    "additionalProperties": False
                }
            },
            "coriant-tnms": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {"type": "string"},
                        "address": {"type": "string"}
                    },
                    "required": ["name", "address"],
                    "additionalProperties": False
                }
            }
        },
        "required": [
            "alarms-db",
            "ops-db",
            "oid_list.conf",
            "ssh",
            "redis",
            "junosspace",
            "infinera-dna",
            "coriant-tnms"],
        "additionalProperties": False
    }
  • ENABLE_TESTING_ROUTES: [OPTIONAL (default value: False)] Flat (can be any value that evaluates to True) to enable routes to special utilities used for testing. This must never be enabled in a production environment.

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.
  • As a gunicorn wsgi service.

    • Details of gunicorn configuration are beyond the scope of this document.

Protocol Specification

The following resources can be requested from the webservice.

resources