Skip to content

Commit e4f7cbf

Browse files
author
Sven Diebold
committedJan 15, 2019
Netman in a container
So it can be run quickly to test. Docker compose to pop up a fake switch with it to test out as well. JIRA-Reference: TD-398
1 parent ac2fdae commit e4f7cbf

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed
 

‎Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:2.7-alpine
2+
3+
RUN apk update && apk add --no-cache python-dev gcc git g++ make libffi-dev openssl-dev libxml2 libxml2-dev libxslt libxslt-dev
4+
5+
RUN mkdir -p /usr/src/app
6+
WORKDIR /usr/src/app
7+
8+
COPY requirements.txt /usr/src/app/
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
COPY . /usr/src/app
12+
13+
RUN PBR_VERSION=0.0.0 pip install .
14+
15+
EXPOSE 5000
16+
ENTRYPOINT [ "python" ]
17+
18+
CMD [ "netman/main.py" ]

‎README.md

+26
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,32 @@ curl -X POST http://127.0.0.1:5000/switches/hostname_or_ip/vlans -d '{"number":
7474
-H "Netman-Proxy-Server: http://192.168.1.1"
7575
```
7676

77+
Docker usage
78+
============
79+
80+
From your computer, start a Netman container and a fake-switch container in order to mock a switch Netman will configure.
81+
```shell
82+
$ docker-compose up -d
83+
```
84+
85+
Create a Vlan
86+
```bash
87+
curl -X POST http://localhost:32771/switches/netman_tsr1.yul1.example.net_1/vlans -d '{"number": 1000, "name": "myvlan"}'
88+
-H "Content-Type: application/json"
89+
-H "Netman-model: cisco"
90+
-H "Netman-username: root"
91+
-H "Netman-password: root"
92+
```
93+
94+
Get information of an existing Vlan
95+
```bash
96+
curl -X GET http://localhost:32771/switches/netman_tsr1.yul1.example.net_1/vlans/1000
97+
-H "Content-Type: application/json"
98+
-H "Netman-model: cisco"
99+
-H "Netman-username: root"
100+
-H "Netman-password: root"
101+
```
102+
77103
Contributing
78104
============
79105

‎docker-compose.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
version: '2'
3+
4+
services:
5+
tsr1.yul1.example.net:
6+
image: "internap/fake-switches:latest"
7+
environment:
8+
- SWITCH_MODEL=cisco_2960_48TT_L
9+
ports:
10+
- "32769:22"
11+
12+
netman:
13+
image: "internap/netman:latest"
14+
ports:
15+
- "32771:5000"

‎netman/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def load_app(session_inactivity_timeout=None):
5858

5959
if __name__ == '__main__':
6060
parser = argparse.ArgumentParser(description='Netman Server')
61-
parser.add_argument('--host', nargs='?', default="127.0.0.1")
61+
parser.add_argument('--host', nargs='?', default="0.0.0.0")
6262
parser.add_argument('--port', type=int, nargs='?', default=5000)
6363
parser.add_argument('--session-inactivity-timeout', type=int, nargs='?')
6464

0 commit comments

Comments
 (0)
Please sign in to comment.