Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker version API enhancement #26

Closed
svoropaev opened this issue Jan 10, 2022 · 4 comments
Closed

Docker version API enhancement #26

svoropaev opened this issue Jan 10, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@svoropaev
Copy link

svoropaev commented Jan 10, 2022

Hi!

API needs the credential and there is no way to create a user/password at the moment of Docker image deployment.
Now we need to create username/password via WEB interface and use the API then. It makes automatic deployment almost impossible. It would be fine to have a default username/password for local Docker image or it would be fine to be able to configure it in docker-compose.yml.
The same is for ip address range for authorised API users. Would be fine to have it enabled by default for 0.0.0.0/0 or to hve an ability to configure it in docker-compose.yml during the deployment.

Also Swagger ReST links (click "try it out") have a "topolograph" http://topolograph.com/api/ in the URL instead of localhost/127.0.0.1/or any other hostname which is used to reach the page.

@Vadims06 Vadims06 added the enhancement New feature or request label Jan 11, 2022
@Vadims06 Vadims06 self-assigned this Jan 11, 2022
@Vadims06
Copy link
Owner

Hi @svoropaev, new variables has been implemented

        TOPOLOGRAPH_WEB_API_USERNAME_EMAIL: 'ospf@topolograph.com'
        TOPOLOGRAPH_WEB_API_PASSWORD: 'ospf'
        TOPOLOGRAPH_WEB_API_AUTHORISED_NETWORKS: '127.0.0.1/32,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'
        SWAGGER_HOST: 'localhost:8088'

After booting docker-compose up - it's possible to create default credentials using variables from yaml file via single POST request

import requests
res = requests.post('http://localhost:8088/create-default-credentials')
res.json()
{'errors': '', 'status': 'ok'}

...right after this you can use them in other requests:

res = requests.get('http://localhost:8088/api/graph/', auth=('ospf@topolograph.com', 'ospf'))
res.json()
[{'graph_time': '14Jan2022_12h10m30s_13_hosts_demo', 'hosts': {'count': 13}, 'networks': {'backuped': 18, 'count': 40, 'notbackuped': 22, 'url_link': 'http://localhost:8088/api/network/14Jan2022_12h10m30s_13_hosts_demo'}, 'timestamp': '2022-01-14T12:10:30.815000'}]

Full docker-compose.override.yml looks like this:

version: '3'
services:

  flask:
    environment:
        NAPALM_USERNAME: cisco
        NAPALM_PASSWORD: cisco
        NAPALM_PORT: 22
        DNS: ''
        NETBOX_URL: '' # http://localhost:8000
        NETBOX_RO_TOKEN : ''
        TOPOLOGRAPH_WEB_API_USERNAME_EMAIL: 'ospf@topolograph.com'
        TOPOLOGRAPH_WEB_API_PASSWORD: 'ospf'
        TOPOLOGRAPH_WEB_API_AUTHORISED_NETWORKS: '127.0.0.1/32,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'
        SWAGGER_HOST: 'localhost:8088'

SWAGGER_HOST allows to send "try now" requests from swagger dashboard
image

@Vadims06
Copy link
Owner

Off topic, have you tried to integrate Topolograph with OSPF Watcher to get historical topology changes dashboard?

@Vadims06
Copy link
Owner

Tagged v2.25.1

@svoropaev
Copy link
Author

Off topic, have you tried to integrate Topolograph with OSPF Watcher to get historical topology changes dashboard?
Hi Vadim. No I did not use this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants