1 个不稳定版本
0.0.1-pre-alpha.1 | 2024年7月16日 |
---|
#362 in 网络编程
101 每月下载次数
110KB
1.5K SLoC
███╗ ██╗ █████╗ ███████╗ █████╗ ██████╗ █████╗
████╗ ██║██╔══██╗╚══███╔╝██╔══██╗██╔══██╗██╔══██╗
██╔██╗ ██║███████║ ███╔╝ ███████║██████╔╝███████║
██║╚██╗██║██╔══██║ ███╔╝ ██╔══██║██╔══██╗██╔══██║
██║ ╚████║██║ ██║███████╗██║ ██║██║ ██║██║ ██║
╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
纳扎拉是一个实验性的Rust程序,它使用NetBox的API自动化收集NetBox的系统信息。它允许自动在NetBox中创建新的机器或填充现有机器的信息字段。
纳扎拉处于开发的早期阶段。请注意,以下列出的信息可能会发生变化。
安装
要使用纳扎拉,您需要安装Rust编程语言和 cargo
。如果您还没有安装它们,可以按照 官方Rust文档 中的说明进行操作。
请注意,此程序仅在Linux系统上运行。
安装完毕后,您可以克隆此存储库,并通过运行以下命令构建程序
git clone https://github.com/The-Nazara-Project/Nazara.git
cd Nazara
cargo build --release
这将创建一个位于 target/release
目录的可执行文件。
用法(进行中)
要使用纳扎拉,您需要配置NetBox API的URL并向程序提供API令牌。
配置(进行中)
纳扎拉支持两种提供配置参数的方式:命令行参数和配置文件。
纳扎拉需要您提供两个参数
API_URL
:您的NetBox API的URLAPI_TOKEN
:NetBox API的认证令牌
通过命令行配置
以下是一个使用命令行传递这些参数的示例
./target/release/Nazara --api-url <API_URL> --api-token <API_TOKEN>
通过 nbs-config.toml
文件配置。
或者,您可以将配置参数提供在名为 nazara-config.toml
的配置文件中,该文件位于可执行文件所在的同一目录中。以下是配置文件应如何看起来
[netbox]
netbox_api_token = "$API_TOKEN"
netbox_uri = "$API_URI"
除了NetBox系统参数外,通过.nazara-config.toml
进行配置还可以让您添加某些自定义字段到系统信息中,这些字段无法自动选择。一个很好的例子就是系统位置
条目。要指定它,只需在配置文件中的[system]
块下添加参数即可。
[netbox]
netbox_api_token = "$API_TOKEN"
netbox_uri = "$NETBOX_URI"
[system]
system_location = "$SYSTEM_LOCATION"
示例文件可能看起来像这样
# Template nazara-config.toml file for v0.1.0
# Configuration parameters for the NetBox connection
[netbox]
netbox_api_token = "{NETBOX_TOKEN}"
netbox_uri = "{NETBOX_URI}"
# Mandatory information about the system
[system]
name = "{SYSTEM_NAME}" # Name of the machine or VM. **Required** when device is a VM
site_id = 0 # The id of the site this device is located at. (Stored in NetBox)
# site_name = "" # Name of the site this device is located at. (May take longer to search for) (Mutually exclusive with ID!)
description = ""
comments = "Automatically registered by Nazara."
device_type = 0 # ID of the type of the Device Type in NetBox
device_role = 0 # ID of the device role in NetBox
# Name of the network interface to set. (e.g eth0, etc)
# If not set, the first active interface will be selected.
primary_network_interface = "eth0"
face = "" # Direction this device may face in (e.g front or rear)
status = "active" # status of the device. default: active
airflow = "front-to-rear" # Direction of airflow
# Optional data of your device.
# This section may be empty
[[system.optional]]
# tenant_group = 0 # ID of the department this device belongs to
# tenant_group_name = "" # Name of the department this device belongs to (mutually exclusive with ID!)
# tenant = 0 # ID of the team or individual this device belongs to
# tenant_name = "" # Name of the individual or team this device belongs to (mutually exclusive with ID!)
# location = 0 # ID of the location of the device
# rack = 0 # ID of the rack the device is mounted in if any
# position = 0 # Position of the device within the rack if any
platform = "x86_64"
# Custom parameters about the system, which fall under the "custom_fields" section.
# Basically anything can go here, these are example values Nazara collects.
[system.custom_fields]
# cpu_count = 1 # overriden by collector
# config_template = 0
## ...
请注意,本节仍在进行中,所有信息均可能发生变化。
贡献
如果您想为Nazara做出贡献,请自由地查看贡献指南以了解我们的工作流程,并查看问题部分以了解任何开放问题。
许可证
Nazara根据GPL-v3.0条款发布。
依赖项
~7-20MB
~302K SLoC