Skip to content

Latest commit

 

History

History
167 lines (124 loc) · 6.12 KB

README.md

File metadata and controls

167 lines (124 loc) · 6.12 KB

device-discovery

Orb device discovery backend

Usage

usage: device-discovery [-h] [-V] [-s HOST] [-p PORT] -t DIODE_TARGET -k DIODE_API_KEY

Orb Device Discovery Backend

options:
  -h, --help            show this help message and exit
  -V, --version         Display Device Discovery, NAPALM and Diode SDK versions
  -s HOST, --host HOST  Server host
  -p PORT, --port PORT  Server port
  -t DIODE_TARGET, --diode-target DIODE_TARGET
                        Diode target
  -k DIODE_API_KEY, --diode-api-key DIODE_API_KEY
                        Diode API key. Environment variables can be used by wrapping them in ${} (e.g.
                        ${MY_API_KEY})
  -a DIODE_APP_NAME_PREFIX, --diode-app-name-prefix DIODE_APP_NAME_PREFIX
                        Diode producer_app_name prefix

Policy RFC

policies:
  discovery_1:
    config:
      schedule: "* * * * *" #Cron expression
      defaults:
        site: New York NY
    scope:
      - hostname: 192.168.0.32
        username: ${USER}
        password: admin
      - driver: eos
        hostname: 127.0.0.1
        username: admin
        password: ${ARISTA_PASSWORD}
        optional_args:
          enable_password: ${ARISTA_PASSWORD}
  discover_once: # will run only once
    scope:
      - hostname: 192.168.0.34
        username: ${USER}
        password: ${PASSWORD}

Run device-discovery

device-discovery can be run by installing it with pip

git clone https://github.com/netboxlabs/orb-discovery.git
cd orb-discovery/
pip install --no-cache-dir ./device-discovery/
device-discovery -t 'grpc://192.168.0.10:8080/diode' -k '${DIODE_API_KEY}'

Docker Image

device-discovery can be build and run using docker:

cd device-discovery
docker build --no-cache -t device-discovery:develop -f docker/Dockerfile .
docker run  -e DIODE_API_KEY={YOUR_API_KEY} -p 8072:8072 device-discovery:develop \
 device-discovery -t 'grpc://192.168.0.10:8080/diode' -k '${DIODE_API_KEY}'

Routes (v1)

Get runtime and capabilities information

GET /api/v1/status (gets discovery runtime data)
Parameters

None

Responses
http code content-type response
200 application/json; charset=utf-8 {"version": "0.1.0","up_time_seconds": 3678 }
Example cURL
 curl -X GET -H "Content-Type: application/json" http://localhost:8072/api/v1/status
GET /api/v1/capabilities (gets device-discovery capabilities)
Parameters

None

Responses
http code content-type response
200 application/json; charset=utf-8 {"supported_drivers":["ios","eos","junos","nxos","cumulus"]}
Example cURL
 curl -X GET -H "Content-Type: application/json" http://localhost:8072/api/v1/capabilities

Policies Management

POST /api/v1/policies (Creates a new policy)
Parameters
name type data type description
None required YAML object yaml format specified in Policy RFC
Responses
http code content-type response
201 application/json; charset=UTF-8 {"detail":"policy 'policy_name' was started"}
400 application/json; charset=UTF-8 { "detail": "invalid Content-Type. Only 'application/x-yaml' is supported" }
400 application/json; charset=UTF-8 Any other policy error
403 application/json; charset=UTF-8 { "detail": "config field is required" }
409 application/json; charset=UTF-8 { "detail": "policy 'policy_name' already exists" }
Example cURL
 curl -X POST -H "Content-Type: application/x-yaml" --data-binary @policy.yaml http://localhost:8072/api/v1/policies
DELETE /api/v1/policies/{policy_name} (delete a existing policy)
Parameters
name type data type description
policy_name required string The unique policy name
Responses
http code content-type response
200 application/json; charset=UTF-8 { "detail": "policy 'policy_name' was deleted" }
400 application/json; charset=UTF-8 Any other policy deletion error
404 application/json; charset=UTF-8 { "detail": "policy 'policy_name' not found" }
Example cURL
 curl -X DELETE http://localhost:8072/api/v1/policies/policy_name