简介

Netbox 的QR插件,用于给各种实体生成二维码标签,用于贴在实体上。二维码为实体的netbox网址。

最新版本不需要增加中文字体,由浏览器渲染字体。

Netbox系列文章:https://songxwn.com/categories/NetBox/

适用于版本 Netbox 4.5.3 、netbox_qrcode 0.0.20

适用于对应源码安装教程:https://songxwn.com/netbox4-CN/

官方文档:https://github.com/netbox-community/netbox-qrcode/blob/master/README.md

PS:由于此插件大更新后配置方式变化,所以也更新一波。

安装

1
2
3
4
source /opt/netbox/venv/bin/activate
# 进入netbox虚拟python环境
pip install netbox-qrcode
# 安装相关包

开启和配置

1
2
3
4
cd /opt/netbox/netbox/netbox
# 进入目录
sudo -u netbox vim configuration.py
# 以netbox 用户打开文件

配置示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
PLUGINS = ['netbox_qrcode']
# 插件开启列表
PLUGINS_CONFIG = {
'netbox_qrcode': {
##################################
# General Plugin
'title': 'By Songxwn.com',

##################################
# Text content
'with_text': True,
'text_location': 'right',
'text_align_horizontal': 'left',
'text_align_vertical': 'middle',

# Text source (Option A)
'text_fields': ['name', 'serial'],
'custom_text': 'By Songxwn.com',

# Text source (Option B)
'text_template': 'By Songxwn.com',

##################################
# Font
'font': 'TahomaBold',
'font_size': '3mm',
'font_weight': 'normal',
'font_color': 'black',

##################################
# QR-Code
'with_qr': True,

# QR-Code alternative source
'url_template': None,

# QR-Code Image File
'qr_version': 1,
'qr_error_correction': 0,
'qr_box_size': 4,
'qr_border': 0,

##################################
# Label Layout

# Label dimensions
'label_qr_width': '12mm',
'label_qr_height': '12mm',

# Label edge
'label_edge_top': '0mm',
'label_edge_left': '1.5mm',
'label_edge_right': '1.5mm',
'label_edge_bottom': '0mm',

# Label QR code positioning
'label_width': '56mm',
'label_height': '32mm',
'label_qr_text_distance': '1mm',

##################################
# Module-dependent configuration

'rack': {
'label_qr_width': '24mm',
'label_qr_height': '24mm',
'label_width': '84mm',
'label_height': '32mm',
'label_qr_text_distance': '2mm',
'font': 'TahomaBold',
'font_size': '4mm',
'font_weight': 'normal',
'font_color': 'black',
'text_template': '机柜名称: {{ obj.name }}<br>所属站点: {{ obj.site }}<br>所属租户: {{ obj.tenant }}',
},


'device': {
'text_template': '设备名称: {{ obj.name }}<br>所属站点: {{ obj.site }}<br>所属租户: {{ obj.tenant }}<br>序列号: {{ obj.serial }}<br>型号: {{ obj.device_type }}',
},

'cable': {
'text_fields': [
'_termination_a_device',
'termination_a',
'_termination_b_device',
'termination_b',
'a_terminations.device',
'a_terminations',
'b_terminations.device',
'b_terminations'
]
},

'powerfeed': {
'text_fields': ['name']
},

'powerpanel': {
'text_fields': ['name']
},

'logo': 'https://songxwn.com/images/favicon.png'
}
}
# 插件自定配置

重启Netbox

1
2
systemctl restart netbox netbox-rq.service
# 最后保存文件重启进行即可生效。

图片示例

机柜

设备

中文社区微信群

可发送微信号到邮箱➡️ [email protected]