Add dockerfile & makefile

This commit is contained in:
Yann Verry 2021-05-29 23:14:26 +02:00
parent 9ca2319662
commit 9af0739d80
Signed by: yann
GPG key ID: 19754E8692B8416C
5 changed files with 94 additions and 2 deletions

14
Dockerfile Normal file
View file

@ -0,0 +1,14 @@
#
# Dockerfile
#
FROM python:alpine
MAINTAINER Yann Verry <docker@verry.org>
WORKDIR .
RUN pip install --no-cache-dir pipenv && \
pipenv install --system --deploy
USER nobody
CMD python /routeros-restapi/main.py

7
Makefile Normal file
View file

@ -0,0 +1,7 @@
all: pull build
pull:
docker pull python:alpine
build:
docker build --network yann_default -t python-routeros .

68
Pipfile.lock generated Normal file
View file

@ -0,0 +1,68 @@
{
"_meta": {
"hash": {
"sha256": "d6bc38cdbe538e25214de6d4e7185b5b544a0b692423b40b8b66e181816e4d2f"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.9"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"certifi": {
"hashes": [
"sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c",
"sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"
],
"version": "==2020.12.5"
},
"chardet": {
"hashes": [
"sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa",
"sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==4.0.0"
},
"idna": {
"hashes": [
"sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
"sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.10"
},
"prometheus-client": {
"hashes": [
"sha256:030e4f9df5f53db2292eec37c6255957eb76168c6f974e4176c711cf91ed34aa",
"sha256:b6c5a9643e3545bcbfd9451766cbaa5d9c67e7303c7bc32c750b6fa70ecb107d"
],
"index": "pypi",
"version": "==0.10.1"
},
"requests": {
"hashes": [
"sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804",
"sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"
],
"index": "pypi",
"version": "==2.25.1"
},
"urllib3": {
"hashes": [
"sha256:2f4da4594db7e1e110a944bb1b551fdf4e6c136ad42e4234131391e21eb5b0df",
"sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
"version": "==1.26.4"
}
},
"develop": {}
}

4
README.md Normal file
View file

@ -0,0 +1,4 @@
# RouterOS Restful API
## Dev

View file

@ -1,11 +1,10 @@
import requests as req
import json
from requests.models import Response
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from prometheus_client import start_http_server, Gauge
import random, time, os
import time, os
def process_request(router_ip,router_username,router_password):
url = 'https://' + router_ip + '/rest/interface'