1.复制容器中关于汉化配置的文件到本地
docker cp c99ddcb:/opt/netbox/netbox/netbox/navigation/menu.py .
2.修改menu.py配置,修改为汉化之后的配置文件
具体内容如下
参考配置为:https://songxwn.com/netbox/
from django.utils.translation import gettext as _
from netbox.registry import registry
from . import *
Nav menus
ORGANIZATION_MENU = Menu(
label=('组织机构'),
icon_class='mdi mdi-domain',
groups=(
MenuGroup(
label=('机房'),
items=(
get_model_item('dcim', 'site', _('数据中心')),
get_model_item('dcim', 'region', _('地区')),
get_model_item('dcim', 'sitegroup', _('数据中心组')),
get_model_item('dcim', 'location', ('具体地点')),
),
),
MenuGroup(
label=('机架'),
items=(
get_model_item('dcim', 'rack', _('机柜')),
get_model_item('dcim', 'rackrole', ('机柜角色')),
get_model_item('dcim', 'rackreservation', ('预留')),
MenuItem(
link='dcim:rack_elevation_list',
link_text=('立面图'),
permissions=['dcim.view_rack']
),
),
),
MenuGroup(
label=('租凭'),
items=(
get_model_item('tenancy', 'tenant', _('租户')),
get_model_item('tenancy', 'tenantgroup', ('租户组')),
),
),
MenuGroup(
label=('联系方式'),
items=(
get_model_item('tenancy', 'contact', _('联系人')),
get_model_item('tenancy', 'contactgroup', _('联系人组')),
get_model_item('tenancy', 'contactrole', _('联系人角色')),
get_model_item('tenancy', 'contactassignment', _('联系方式分配'), actions=[]),
),
),
),
)
DEVICES_MENU = Menu(
label=('设备'),
icon_class='mdi mdi-server',
groups=(
MenuGroup(
label=('Devices'),
items=(
get_model_item('dcim', 'device', _('设备')),
get_model_item('dcim', 'module', _('模块组件')),
get_model_item('dcim', 'devicerole', _('设备角色')),
get_model_item('dcim', 'platform', _('平台')),
get_model_item('dcim', 'virtualchassis', _('虚拟机箱')),
get_model_item('dcim', 'virtualdevicecontext', ('Virtual Device Contexts')),
),
),
MenuGroup(
label=('类型'),
items=(
get_model_item('dcim', 'devicetype', _('设备型号')),
get_model_item('dcim', 'moduletype', _('模块类型')),
get_model_item('dcim', 'manufacturer', ('制造商')),
),
),
MenuGroup(
label=('设备组件'),
items=(
get_model_item('dcim', 'interface', _('接口')),
get_model_item('dcim', 'frontport', _('前端口')),
get_model_item('dcim', 'rearport', _('后端口')),
get_model_item('dcim', 'consoleport', _('Console 端口')),
get_model_item('dcim', 'consoleserverport', _('Console 服务器端口')),
get_model_item('dcim', 'powerport', _('电力接口')),
get_model_item('dcim', 'poweroutlet', _('电源插座PDU')),
get_model_item('dcim', 'modulebay', _('模块组件托架')),
get_model_item('dcim', 'devicebay', _('设备托架')),
get_model_item('dcim', 'inventoryitem', _('库存物品')),
get_model_item('dcim', 'inventoryitemrole', _('库存项目角色')),
),
),
),
)
CONNECTIONS_MENU = Menu(
label=('连接'),
icon_class='mdi mdi-connection',
groups=(
MenuGroup(
label=('Connections'),
items=(
get_model_item('dcim', 'cable', ('线缆'), actions=['import']),
get_model_item('wireless', 'wirelesslink', ('无线连接')),
MenuItem(
link='dcim:interface_connections_list',
link_text=('接口连接'),
permissions=['dcim.view_interface']
),
MenuItem(
link='dcim:console_connections_list',
link_text=('Console 连接'),
permissions=['dcim.view_consoleport']
),
MenuItem(
link='dcim:power_connections_list',
link_text=_('电源连接'),
permissions=['dcim.view_powerport']
),
),
),
),
)
WIRELESS_MENU = Menu(
label=('无线'),
icon_class='mdi mdi-wifi',
groups=(
MenuGroup(
label=('Wireless'),
items=(
get_model_item('wireless', 'wirelesslan', _('无线局域网')),
get_model_item('wireless', 'wirelesslangroup', _('无线局域网组')),
),
),
),
)
IPAM_MENU = Menu(
label=('IP地址管理'),
icon_class='mdi mdi-counter',
groups=(
MenuGroup(
label=('IP Addresses'),
items=(
get_model_item('ipam', 'ipaddress', _('IP 地址')),
get_model_item('ipam', 'iprange', ('IP 范围')),
),
),
MenuGroup(
label=('Prefixes'),
items=(
get_model_item('ipam', 'prefix', _('IP网段')),
get_model_item('ipam', 'role', ('网段和VLAN 角色')),
),
),
MenuGroup(
label=('ASNs'),
items=(
get_model_item('ipam', 'asnrange', _('ASN Ranges')),
get_model_item('ipam', 'asn', ('ASNs')),
),
),
MenuGroup(
label=('Aggregates'),
items=(
get_model_item('ipam', 'aggregate', _('Aggregates')),
get_model_item('ipam', 'rir', ('RIRs')),
),
),
MenuGroup(
label=('VRFs'),
items=(
get_model_item('ipam', 'vrf', _('VRFs')),
get_model_item('ipam', 'routetarget', ('Route Targets')),
),
),
MenuGroup(
label=('VLANs'),
items=(
get_model_item('ipam', 'vlan', _('VLANs')),
get_model_item('ipam', 'vlangroup', ('VLAN Groups')),
),
),
MenuGroup(
label=('Other'),
items=(
get_model_item('ipam', 'fhrpgroup', _('FHRP Groups')),
get_model_item('ipam', 'servicetemplate', _('Service Templates')),
get_model_item('ipam', 'service', _('Services')),
),
),
),
)
OVERLAY_MENU = Menu(
label=_('网络虚拟化Overlay'),
icon_class='mdi mdi-graph-outline',
groups=(
MenuGroup(
label='L2VPNs',
items=(
get_model_item('ipam', 'l2vpn', _('L2VPNs')),
get_model_item('ipam', 'l2vpntermination', _('Terminations')),
),
),
),
)
VIRTUALIZATION_MENU = Menu(
label=('裸金属虚拟化'),
icon_class='mdi mdi-monitor',
groups=(
MenuGroup(
label=('Virtual Machines'),
items=(
get_model_item('virtualization', 'virtualmachine', _('虚拟机')),
get_model_item('virtualization', 'vminterface', ('虚拟机接口')),
),
),
MenuGroup(
label=('Clusters'),
items=(
get_model_item('virtualization', 'cluster', _('虚拟化集群')),
get_model_item('virtualization', 'clustertype', _('虚拟化集群类型')),
get_model_item('virtualization', 'clustergroup', _('集群组')),
),
),
),
)
CIRCUITS_MENU = Menu(
label=('线路'),
icon_class='mdi mdi-transit-connection-variant',
groups=(
MenuGroup(
label=('Circuits'),
items=(
get_model_item('circuits', 'circuit', _('线路')),
get_model_item('circuits', 'circuittype', ('线路类型')),
),
),
MenuGroup(
label=('Providers'),
items=(
get_model_item('circuits', 'provider', _('供应商')),
get_model_item('circuits', 'provideraccount', _('供应商账号')),
get_model_item('circuits', 'providernetwork', _('供应商网络')),
),
),
),
)
POWER_MENU = Menu(
label=('电力'),
icon_class='mdi mdi-flash',
groups=(
MenuGroup(
label=('Power'),
items=(
get_model_item('dcim', 'powerfeed', _('电源线')),
get_model_item('dcim', 'powerpanel', _('电源插座')),
),
),
),
)
PROVISIONING_MENU = Menu(
label=('设备配置'),
icon_class='mdi mdi-file-document-multiple-outline',
groups=(
MenuGroup(
label=('Configurations'),
items=(
get_model_item('extras', 'configcontext', _('Config Contexts'), actions=['add']),
get_model_item('extras', 'configtemplate', _('Config Templates'), actions=['add']),
),
),
),
)
CUSTOMIZATION_MENU = Menu(
label=('自定义'),
icon_class='mdi mdi-toolbox-outline',
groups=(
MenuGroup(
label=('Customization'),
items=(
get_model_item('extras', 'customfield', _('自定义字段')),
get_model_item('extras', 'customlink', _('自定义链接')),
get_model_item('extras', 'exporttemplate', ('自定义验证')),
get_model_item('extras', 'savedfilter', ('已保存的筛选条件')),
get_model_item('extras', 'tag', 'Tags'),
get_model_item('extras', 'imageattachment', ('图片附件'), actions=()),
),
),
MenuGroup(
label=('Reports & Scripts'),
items=(
MenuItem(
link='extras:report_list',
link_text=('报告'),
permissions=['extras.view_report'],
buttons=get_model_buttons('extras', "reportmodule", actions=['add'])
),
MenuItem(
link='extras:script_list',
link_text=('脚本'),
permissions=['extras.view_script'],
buttons=get_model_buttons('extras', "scriptmodule", actions=['add'])
),
),
),
),
)
OPERATIONS_MENU = Menu(
label=('运营'),
icon_class='mdi mdi-cogs',
groups=(
MenuGroup(
label=('Integrations'),
items=(
get_model_item('core', 'datasource', ('Data Sources')),
get_model_item('extras', 'webhook', ('Webhooks')),
),
),
MenuGroup(
label=('Jobs'),
items=(
MenuItem(
link='core:job_list',
link_text=('Jobs'),
permissions=['core.view_job'],
),
),
),
MenuGroup(
label=_('Logging'),
items=(
get_model_item('extras', 'journalentry', _('日记列表'), actions=['import']),
get_model_item('extras', 'objectchange', _('操作日志'), actions=[]),
),
),
),
)
MENUS = [
ORGANIZATION_MENU,
DEVICES_MENU,
CONNECTIONS_MENU,
WIRELESS_MENU,
IPAM_MENU,
OVERLAY_MENU,
VIRTUALIZATION_MENU,
CIRCUITS_MENU,
POWER_MENU,
PROVISIONING_MENU,
CUSTOMIZATION_MENU,
OPERATIONS_MENU,
]
Add plugin menus
for menu in registry['plugins']['menus']:
MENUS.append(menu)
if registry['plugins']['menu_items']:
# Build the default plugins menu
groups = [
MenuGroup(label=label, items=items)
for label, items in registry['plugins']['menu_items'].items()
]
plugins_menu = Menu(
label=_("Plugins"),
icon_class="mdi mdi-puzzle",
groups=groups
)
MENUS.append(plugins_menu)
3.将修改好之后的文件传入docker容器中
docker cp menu.py c99ddc:/opt/netbox/netbox/netbox/navigation/
4.重启docker对应的netbox容器,刷新web页面即可
标签:netbox,dcim,get,items,汉化,item,model,label,docker From: https://www.cnblogs.com/nike-wang/p/17754627.html