Skip to content

Commit ab79483

Browse files
authored
Merge pull request #8 from alsigna/nb-3.4.3
netbox 3.4 support
2 parents 3d61bdb + b5c6f79 commit ab79483

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2398
-1735
lines changed

Dockerfile

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
FROM netboxcommunity/netbox:latest-ldap
1+
FROM netboxcommunity/netbox:v3.4.3-2.4.0
22

33
COPY requirements.txt /requirements.txt
44
RUN /opt/netbox/venv/bin/python -m pip install -r /requirements.txt
55

66
RUN mkdir /opt/netbox/netbox/media/software-images/
7-
RUN chown -R unit:unit /opt/netbox/netbox/media/software-images
7+
RUN chown -R unit:root /opt/netbox/netbox/media/software-images
88

9-
# RUN mkdir /var/lib/unit/.ssh
10-
# RUN chown -R unit:unit /var/lib/unit/.ssh
11-
12-
# RUN echo $'\n\
13-
# Host * \n\
14-
# KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1\n\
15-
# Ciphers +aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc\n\
16-
# ' > /var/lib/unit/.ssh/config
17-
# RUN chown -R unit:unit /var/lib/unit/.ssh
18-
19-
20-
RUN echo $'\n\
9+
RUN echo '\n\
2110
RQ_QUEUES["software_manager"]=RQ_PARAMS\n\
2211
' >> /opt/netbox/netbox/netbox/settings.py
2312

README.md

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# Software Manager - NetBox plugin
22

33
[NetBox](https://github.com/netbox-community/netbox) plugin to manage software for your Cisco devices in following aspects:
4-
- software repository (download does not work after Gunicorn was changed to nginx-unit, trying to manage with it)
4+
5+
- software repository
56
- assign target (golden) image on created Device Types
6-
- get software version compliance report for every device in Excel format
77
- scheduled upload golden image on devices
88
- scheduled reload devices with golden image
99

1010
## Important notes
1111

12-
1. Compatible with NetBox 2.9 and higher versions only.
12+
1. Developed on NetBox 3.4.3 and compatible (probably) with other versions, but not tested.
1313
2. Plugin works with standalone IOS/IOS-XE boxes only. No Stacks/VSS/StackWiseVirtual at present.
1414
3. Plugin operates with software version only, and does not consider feature set (lanlite vs lanbase, K9 vs NPE).
1515
4. Test in your local sandbox, do not jump to production network.
1616
5. Use this plugin on production network at one's own risk with take responsibility for any potential outages due to reload of devices.
17+
6. Don't hesitate to contact me for any bugs/feature requests.
1718

1819
## Software Repository
1920

@@ -23,17 +24,21 @@
2324

2425
### Add/Edit software page
2526

26-
<img src="static/add_software.png" width="50%">
27+
<img src="static/software_add.png" width="50%">
2728

2829
Select *.bin file, specify expected MD5 (from cisco site) and verbose version. Plugin calculates MD5 when file uploading and result should matches with entered MD5, otherwise MD5 will be redded.
2930

31+
### Software image details
32+
33+
<img src="static/software_details.png" width="50%">
34+
3035
## Golden Images
3136

3237
### Main page
3338

3439
<img src="static/golden_images.png" width="75%">
3540

36-
Assigned Image/Version for all created DeviceTypes with upgrade progress for particular DeviceType. "Export" button provides detailed Excel report.
41+
Assigned Image/Version for all created DeviceTypes with upgrade progress for particular DeviceType.
3742

3843
## Upgrade Devices
3944

@@ -50,8 +55,10 @@ provides information about Target/Current versions (green = match, yellow = upgr
5055
<img src="static/scheduled_task_add.png" width="75%">
5156

5257
- Select job type:
53-
- upload (transfer golden image to the box)
54-
- upgrade (reload with golden image w/o transfer)
58+
59+
- upload (transfer golden image to the box)
60+
- upgrade (reload with golden image w/o transfer)
61+
5562
- select time to start or set "Start Now". Time is based on NetBox TimeZone, not your browser/hostPC.
5663
- select MW duration. All tasks will be skipped after this time (countdown starts from scheduled time, not from time of creation tasks)
5764

@@ -91,19 +98,19 @@ docker build -t netbox-plugin .
9198
> Dockerfile:
9299
>
93100
> ```dockerfile
94-
> FROM netboxcommunity/netbox:latest-ldap
101+
> FROM netboxcommunity/netbox:v3.4.3-2.4.0
95102
>
96-
> # install scrapli[paramiko], rq-scheduler, xlsxwriter
103+
> # install scrapli[paramiko], scrapli[textfsm]
97104
> COPY requirements.txt /requirements.txt
98105
> RUN /opt/netbox/venv/bin/python -m pip install -r /requirements.txt
99106
>
100-
> # make folder for image location. Shold be in django media folder
101-
> # folder name (software-images in example) is used as FTP username and should be copied to NetBox configuration.py file. Remember this name.
107+
> # make folder for image location. Should be in django media folder
108+
> # folder name (software-images in example).
102109
> RUN mkdir /opt/netbox/netbox/media/software-images/
103110
> RUN chown -R unit:unit /opt/netbox/netbox/media/software-images
104111
>
105-
> # Add additional queue (software_manager in example). This name should be copied to NetBox configuration.py. Remember this name.
106-
> RUN echo $'\n\
112+
> # Add additional queue (software_manager in example). This name should be copied to NetBox configuration.py.
113+
> RUN echo '\n\
107114
> RQ_QUEUES["software_manager"]=RQ_PARAMS\n\
108115
> ' >> /opt/netbox/netbox/netbox/settings.py
109116
>
@@ -117,23 +124,26 @@ docker build -t netbox-plugin .
117124
> #--Pip
118125
> RUN /opt/netbox/venv/bin/python -m pip install /source/SoftwareManager/
119126
120-
## 2. Create FTP docker image based on [docker-alpine-ftp-server](https://github.com/delfer/docker-alpine-ftp-server)
127+
## 2. Create FTP or HTTP docker image
121128
122-
>Why FTP? Originally scp was used to transfer files, but based on experience, FTP is much faster.
129+
for FTP [docker-alpine-ftp-server](https://github.com/delfer/docker-alpine-ftp-server) is used. For HTTP nginx base image is used.
123130
124-
>HTTP was added in 0.0.3, But FTP_USERNAME in configuration still required as it used as folder name for IOS upload
131+
>Originally scp was used to transfer files, but based on experience, FTP/HTTP is much faster.
125132
126133
```shell
127134
cd ftp
128135
docker build -t ftp_for_netbox .
129136
cd ../../
130137
```
138+
131139
or
140+
132141
```shell
133142
cd http
134143
docker build -t http_for_netbox .
135144
cd ../../
136145
```
146+
137147
## 3. Change docker-compose.yml
138148

139149
```dockerfile
@@ -147,7 +157,7 @@ cd ../../
147157
# Replace nginx-unit config
148158
- ./netbox-software-manager/nginx-unit.json:/etc/unit/nginx-unit.json:z,ro
149159
# Mount folder with IOS images. NetBox will upload/delete images.
150-
# Format: /opt/netbox/netbox/media/{{ FTP_SERVER_USRNAME}}
160+
# Format: /opt/netbox/netbox/media/{{ IMAGE_FOLDER }}
151161
- ./netbox-software-manager/software-images:/opt/netbox/netbox/media/software-images:z
152162
# Mount script for rq
153163
- ./netbox-software-manager/rq.sh:/etc/netbox/rq.sh:z,ro
@@ -184,7 +194,7 @@ cd ../../
184194
# Your external (host) IP address, not contaner's IP
185195
- ADDRESS=192.168.0.1
186196

187-
# simple http server
197+
# OR HTTP server
188198
http:
189199
image: http_for_netbox
190200
ports:
@@ -199,36 +209,36 @@ cd ../../
199209

200210
```python
201211
PLUGINS = [
202-
'software_manager',
212+
"software_manager",
203213
]
204214

205215
PLUGINS_CONFIG = {
206-
'software_manager': {
216+
"software_manager": {
207217
# Device credentials
208-
'DEVICE_USERNAME': 'cisco',
209-
'DEVICE_PASSWORD': 'cisco',
210-
# FTP credentials
211-
'FTP_USERNAME': 'software-images',
212-
'FTP_PASSWORD': 'ftp_password',
213-
'FTP_SERVER': '192.168.0.1',
214-
# HTTP server name with patch to images
215-
"HTTP_SERVER": "http://192.168.0./",
216-
# Default transport method, can be also changed while scheduling task, [tfp|http]
217-
"DEFAULT_TRANSFER_METHOD": "ftp",
218-
218+
"DEVICE_USERNAME": "cisco",
219+
"DEVICE_PASSWORD": "cisco",
220+
# FTP credentials (can be skipped if HTTP is used)
221+
"FTP_USERNAME": "ftp-user",
222+
"FTP_PASSWORD": "ftp_password",
223+
"FTP_SERVER": "192.168.0.1",
224+
# HTTP server name with patch to images (can be skipped if FTP is used)
225+
"HTTP_SERVER": "http://10.8.0.1:8001/",
226+
# Default transport method, [tfp|http]
227+
"DEFAULT_TRANSFER_METHOD": "http",
219228
# Log file
220-
'UPGRADE_LOG_FILE': '/var/log/upgrade.log',
221-
# Queue name. Check step 1. Should be the same
222-
'UPGRADE_QUEUE': 'software_manager',
229+
"UPGRADE_LOG_FILE": "/var/log/upgrade.log",
230+
# Queue name. Check step 1 (dockerfile). Should be the same
231+
"UPGRADE_QUEUE": "software_manager",
232+
# Custom field name which is used for store current SW version
233+
"CF_NAME_SW_VERSION": "sw_version",
234+
# folder name for image storing. located in netbox media.
235+
"IMAGE_FOLDER": "software-images",
223236
# Threshold for non-ACK check
224-
'UPGRADE_THRESHOLD': 2,
237+
"UPGRADE_THRESHOLD": 2,
225238
# Number of tries to connect to device before declare that we lost it.
226-
'UPGRADE_MAX_ATTEMPTS_AFTER_RELOAD': 10,
239+
"UPGRADE_MAX_ATTEMPTS_AFTER_RELOAD": 10,
227240
# Hold timer between tries
228-
'UPGRADE_SECONDS_BETWEEN_ATTEMPTS': 60,
229-
230-
# Custom field name which is used for store current SW version
231-
'CF_NAME_SW_VERSION': 'sw_version',
241+
"UPGRADE_SECONDS_BETWEEN_ATTEMPTS": 60,
232242
}
233243
}
234244
```
@@ -248,6 +258,7 @@ PLUGINS_CONFIG = {
248258
## nginx-unit.json
249259

250260
Original NetBox config is used with max_body_size:
261+
251262
```json
252263
"settings": {
253264
"http": {
@@ -257,6 +268,7 @@ Original NetBox config is used with max_body_size:
257268
```
258269

259270
## rq.sh script
271+
260272
```shell
261273
#!/bin/bash
262274

@@ -267,12 +279,7 @@ Original NetBox config is used with max_body_size:
267279
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker software_manager &
268280
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker software_manager &
269281

270-
# start scheduler
271-
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqscheduler &
272-
273282
# start default netbox worker
274-
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker check_releases default
283+
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker high default low
275284
exec "$@"
276-
277285
```
278-

http/default.conf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
server {
2-
listen 80;
3-
server_name localhost;
2+
listen 80;
3+
autoindex on;
44

55
location / {
6-
root /usr/share/nginx/html;
7-
autoindex on;
6+
root /usr/share/nginx/html;
87
}
98
}

http/dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
FROM nginx
22

33
ADD default.conf /etc/nginx/conf.d/
4-
5-
# VOLUME ["/usr/share/nginx/html"]

nginx-unit.json

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
11
{
2-
"listeners": {
3-
"*:8080": {
4-
"pass": "routes"
5-
}
2+
"listeners": {
3+
"0.0.0.0:8080": {
4+
"pass": "routes"
65
},
7-
8-
"routes": [
9-
{
10-
"match": {
11-
"uri": "/static/*"
12-
},
13-
"action": {
14-
"share": "/opt/netbox/netbox"
15-
}
6+
"[::]:8080": {
7+
"pass": "routes"
8+
}
9+
},
10+
11+
"routes": [
12+
{
13+
"match": {
14+
"uri": "/static/*"
1615
},
17-
18-
{
19-
"action": {
20-
"pass": "applications/netbox"
21-
}
22-
}
23-
],
24-
25-
"applications": {
26-
"netbox": {
27-
"type": "python 3",
28-
"path": "/opt/netbox/netbox/",
29-
"module": "netbox.wsgi",
30-
"home": "/opt/netbox/venv",
31-
"processes": {
32-
"max": 4,
33-
"spare": 1,
34-
"idle_timeout": 120
35-
}
16+
"action": {
17+
"share": "/opt/netbox/netbox${uri}"
3618
}
3719
},
38-
39-
"access_log": "/dev/stdout",
40-
41-
"settings": {
42-
"http": {
43-
"max_body_size": 1073741824
20+
21+
{
22+
"action": {
23+
"pass": "applications/netbox"
4424
}
4525
}
26+
],
27+
28+
"applications": {
29+
"netbox": {
30+
"type": "python 3",
31+
"path": "/opt/netbox/netbox/",
32+
"module": "netbox.wsgi",
33+
"home": "/opt/netbox/venv",
34+
"processes": {
35+
"max": 4,
36+
"spare": 1,
37+
"idle_timeout": 120
38+
}
39+
}
40+
},
41+
42+
"access_log": "/dev/stdout",
43+
44+
"settings": {
45+
"http": {
46+
"max_body_size": 1073741824
47+
}
4648
}
47-
49+
}

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
scrapli[paramiko]
2-
rq-scheduler
3-
xlsxwriter
2+
scrapli[textfsm]

rq.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker software_manager &
66
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker software_manager &
77

8-
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqscheduler &
9-
10-
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker check_releases default
8+
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker high default low
119
exec "$@"

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55

66
setup(
77
name="netbox-plugin-software-manager",
8-
version="0.0.3",
8+
version="0.0.4",
99
description="Software Manager for Cisco IOS/IOS-XE devices",
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",
1212
author="Alexander Ignatov",
1313
license="MIT",
1414
install_requires=[
1515
"scrapli[paramiko]",
16-
"rq-scheduler",
17-
"xlsxwriter",
16+
"scrapli[textfsm]",
1817
],
1918
packages=find_packages(),
2019
include_package_data=True,

0 commit comments

Comments
 (0)