Compare commits
225 commits
Author | SHA1 | Date | |
---|---|---|---|
4242832396 | |||
13b84b4da1 | |||
837860e31a | |||
c1a7f661a3 | |||
|
7d268ea0e8 | ||
|
9d496c6854 | ||
|
6ef23eae4d | ||
12ceea413c | |||
7a968deee9 | |||
d55cbd62fc | |||
59ce76fc29 | |||
|
c3d3e6857a | ||
|
56627c1aa9 | ||
|
8dde35dd31 | ||
|
de88ca85b9 | ||
|
514627aa72 | ||
|
4b54a0a3db | ||
|
e44fd2fe78 | ||
|
1429fedb9d | ||
|
818c835711 | ||
|
40af19e801 | ||
|
1d69f4e2f0 | ||
|
a7104b6b94 | ||
|
ee41fb4fc2 | ||
|
e04d0c6d59 | ||
|
c9a57de843 | ||
|
f512e7a0a9 | ||
|
116334be2f | ||
|
ba4cdb217b | ||
|
7ab7bbb9e1 | ||
|
b6a3acd6b4 | ||
|
bb05e12f6e | ||
|
fa51ca31ca | ||
|
0fdb56e01d | ||
|
19a158ec82 | ||
|
08360bafbb | ||
|
e0d734d0ca | ||
|
dc224e209b | ||
|
7259c7602d | ||
|
8cba98ec43 | ||
|
ab96965767 | ||
|
221ac16e87 | ||
|
9204ae2187 | ||
|
528ecc09b0 | ||
|
117b39350e | ||
|
4cf054278f | ||
|
b82dc80fe3 | ||
|
49b269efa6 | ||
|
cedb6818a3 | ||
|
a9af96bba2 | ||
|
282f914665 | ||
|
ca2a69b66f | ||
|
778814b0a1 | ||
|
e0685e7167 | ||
|
ba0be73d3c | ||
|
bf65da0c58 | ||
|
5b0df6ca05 | ||
|
2d8ec831e6 | ||
|
fde6211f5b | ||
|
e96a50379b | ||
|
633b6d3851 | ||
|
04c1f83e74 | ||
|
9b06584fed | ||
|
f7cdd92fa3 | ||
|
53769db3e4 | ||
|
bce02a5e7c | ||
|
368d793704 | ||
|
776f951e3b | ||
|
84f1f00ffe | ||
|
8c12fa8e86 | ||
|
5d0f0bf2fa | ||
|
4bd4b6bb94 | ||
|
d286fde999 | ||
|
dfe937d54e | ||
|
042a6fcf35 | ||
|
f4d7796094 | ||
|
0b9087fa41 | ||
|
79a08359ae | ||
|
29d2f23986 | ||
|
838ffd8e41 | ||
|
ea66becd3d | ||
|
0cff7d3477 | ||
|
be770a947a | ||
|
6181800cb3 | ||
|
2f23844dfd | ||
|
5f0aae6c01 | ||
|
6717b43cc9 | ||
|
05bfc69f26 | ||
|
d06931852f | ||
|
46354865d3 | ||
|
3dbeb5b9de | ||
|
dfb6b234ba | ||
|
9e797c376e | ||
|
cf2cc54da4 | ||
|
2a4f24f00a | ||
|
a7b965a8b5 | ||
|
ddf2e4d1cc | ||
|
7bf955d601 | ||
|
dd4d935fb2 | ||
|
ce83364ff9 | ||
|
75f14fa895 | ||
|
bb08813700 | ||
|
ad951b9288 | ||
|
b53dfa9b59 | ||
|
3b8917aaf3 | ||
|
18773a2dff | ||
|
84a9aca141 | ||
|
a7c6ae68e2 | ||
|
0f210e16f2 | ||
|
e789619b34 | ||
|
af9df9ab4b | ||
|
b092079820 | ||
|
021c5db7d3 | ||
|
1fc0aee929 | ||
|
7cfcd685f3 | ||
|
d1ee380ffb | ||
|
305d4d41ec | ||
|
34c1619ce8 | ||
|
fcb038f4b6 | ||
|
5d9602402b | ||
|
71c603620b | ||
|
2f09cf8d42 | ||
|
58775c0950 | ||
|
8a46af19b8 | ||
|
bdc450ef6a | ||
|
794f9787f0 | ||
|
86527af1c0 | ||
|
b738f4bfef | ||
|
aaea0a2477 | ||
|
9eafcbf215 | ||
|
95d7f98389 | ||
|
576eb07dd7 | ||
|
337e272eea | ||
|
a1af028df6 | ||
|
58c18fc2da | ||
|
3639662961 | ||
|
1d98d3c8e9 | ||
|
dc582b5de6 | ||
|
51efa8edba | ||
|
c4eb8f34ac | ||
|
7147670255 | ||
|
9e934af835 | ||
|
2a1196b52d | ||
|
77a84b365f | ||
|
0f2cb531ae | ||
|
00653628c6 | ||
|
7999244096 | ||
|
137728be1f | ||
|
0fe17c9687 | ||
|
28955612be | ||
|
fc930b9ef4 | ||
|
e20e6a7dee | ||
|
e95a66d93a | ||
|
feab0f1a58 | ||
|
0a903596dc | ||
|
3aea4fbc3b | ||
|
54526d3d0b | ||
|
a866e20548 | ||
|
f8c0732c2b | ||
|
a59690469b | ||
|
da5e8ad2e7 | ||
|
df18f6ea00 | ||
|
4f0db3478f | ||
|
d1a0ec2324 | ||
|
e6472c623d | ||
|
1685ecab16 | ||
|
18e3480574 | ||
|
839d9a908c | ||
|
875ad5c92e | ||
|
ebee42bb48 | ||
|
70146b8614 | ||
|
f936aeb717 | ||
|
9611400b22 | ||
|
53cb29a6d4 | ||
|
70e5d407f5 | ||
|
67a564855b | ||
|
0894e645a8 | ||
|
95d2ae420e | ||
|
275e1850c6 | ||
|
9aedb46530 | ||
|
a60c0cd70c | ||
|
bd5037996b | ||
|
665531cb87 | ||
|
21ddf3f312 | ||
|
f654187074 | ||
|
a896d118d7 | ||
|
a71d992a51 | ||
|
c6a1e48956 | ||
|
b331bcb934 | ||
|
feec16c4fe | ||
|
d227f35964 | ||
|
b94f246196 | ||
|
754a284fd1 | ||
|
683e6cacb1 | ||
|
41f0b04d00 | ||
|
9dedbea47a | ||
|
28fc87c9e2 | ||
|
29d2bff805 | ||
|
bd5b45fc6d | ||
|
26413fe0e8 | ||
|
f06da32fc3 | ||
|
996c10d95b | ||
|
ace8f69eab | ||
|
312f472e9c | ||
|
a42cf2eb48 | ||
|
dc4f90d490 | ||
|
5590f39131 | ||
|
bb7c8c8f94 | ||
|
a5bc16d3b1 | ||
|
bab2d26ad0 | ||
|
bdc2cbeb8f | ||
|
2280169cd9 | ||
|
b36d61e610 | ||
|
3aa851413e | ||
|
405cce3995 | ||
|
86a8d73873 | ||
|
957e5f4fb9 | ||
|
5f66d31ef0 | ||
|
46af158d49 | ||
|
60f6e16cf7 | ||
|
357ddc07f2 | ||
|
6c3466cb55 | ||
|
6497261708 | ||
|
c458e88b57 | ||
|
8ef94272a1 |
68 changed files with 18673 additions and 1476 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use nix
|
25
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
25
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Configuration file**
|
||||
Paste here your netbox agent configuration file
|
||||
|
||||
**Environment:**
|
||||
- OS: [e.g. Ubuntu 18.04]
|
||||
- Netbox agent version [e.g. master, v0.6.0]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -179,3 +179,8 @@ dmypy.json
|
|||
.pyre/
|
||||
|
||||
# End of https://www.gitignore.io/api/emacs,python
|
||||
|
||||
netbox-docker
|
||||
/.vscode
|
||||
.direnv
|
||||
.pre-commit-config.yaml
|
||||
|
|
19
.travis.yml
19
.travis.yml
|
@ -2,20 +2,23 @@ sudo: false
|
|||
dist: xenial
|
||||
language: python
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- python: 3.5
|
||||
env: TOXENV=py35
|
||||
env: TOXENV=pytest
|
||||
- python: 3.6
|
||||
env: TOXENV=py36
|
||||
env: TOXENV=pytest
|
||||
- python: 3.7
|
||||
env: TOXENV=py37
|
||||
env: TOXENV=pytest
|
||||
- python: pypy3
|
||||
env: TOXENV=pypy3
|
||||
env: TOXENV=pytest
|
||||
- python: 3.5
|
||||
env: TOXENV=pep8
|
||||
env: TOXENV=flake8
|
||||
- python: 3.7
|
||||
env: TOXENV=pep8
|
||||
env: TOXENV=flake8
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
@ -23,7 +26,7 @@ cache:
|
|||
|
||||
install:
|
||||
- pip install tox
|
||||
- if [[ $TOXENV == py* ]]; then pip install coveralls; fi
|
||||
- if [[ $TOXENV == pytest ]]; then pip install coveralls; fi
|
||||
|
||||
script:
|
||||
- tox
|
||||
|
@ -32,4 +35,4 @@ notifications:
|
|||
email: false
|
||||
|
||||
after_success:
|
||||
- if [[ $TOXENV == py* ]]; then coveralls; fi
|
||||
- if [[ $TOXENV == pytest ]]; then coveralls; fi
|
||||
|
|
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
@ -0,0 +1 @@
|
|||
include requirements.txt
|
183
README.md
183
README.md
|
@ -1,5 +1,4 @@
|
|||
# Netbox agent
|
||||
|
||||
# Netbox agent [![Build Status](https://travis-ci.com/Solvik/netbox-agent.svg?branch=master)](https://travis-ci.com/Solvik/netbox-agent)
|
||||
|
||||
This project aims to create hardware automatically into [Netbox](https://github.com/netbox-community/netbox) based on standard tools (dmidecode, lldpd, parsing /sys/, etc).
|
||||
|
||||
|
@ -7,21 +6,22 @@ The goal is to generate an existing infrastructure on Netbox and have the abilit
|
|||
|
||||
# Features
|
||||
|
||||
* Create servers, chassis and blade through standard tools (`dmidecode`)
|
||||
* Create virtual machines, servers, chassis and blade through standard tools (`dmidecode`)
|
||||
* Create physical, bonding and vlan network interfaces with IPs (IPv4 & IPv6)
|
||||
* Create IPMI interface if found
|
||||
* Create or get existing VLAN and associate it to interfaces
|
||||
* Generic ability to guess datacenters and rack location through drivers (`cmd` and `file` and custom ones)
|
||||
* Update existing `Device` and `Interface`
|
||||
* Handle blade moving (new slot, new chassis)
|
||||
* Handle blade GPU expansions
|
||||
* Automatic cabling (server's interface to switch's interface) using lldp
|
||||
* Local inventory using `Inventory Item` for CPU, RAM, RAID cards, physical disks (behind raid cards)
|
||||
* Local inventory using `Inventory Item` for CPU, GPU, RAM, RAID cards, physical disks (behind raid cards)
|
||||
* PSUs creation and power consumption reporting (based on vendor's tools)
|
||||
|
||||
# Requirements
|
||||
|
||||
- Netbox >= 2.6
|
||||
- Python >= 3.4
|
||||
- Netbox >= 3.7
|
||||
- Python >= 3.7
|
||||
- [pynetbox](https://github.com/digitalocean/pynetbox/)
|
||||
- [python3-netaddr](https://github.com/drkjam/netaddr)
|
||||
- [python3-netifaces](https://github.com/al45tair/netifaces)
|
||||
|
@ -33,35 +33,112 @@ The goal is to generate an existing infrastructure on Netbox and have the abilit
|
|||
- lldpd
|
||||
- lshw
|
||||
|
||||
# Known limitations
|
||||
## Inventory requirement
|
||||
- hpassacli
|
||||
- storcli
|
||||
- omreport
|
||||
|
||||
* The project is only compatible with Linux.
|
||||
Since it uses `ethtool` and parses `/sys/` directory, it's not compatible with *BSD distributions.
|
||||
* Netbox `>=2.6.0,<=2.6.2` has a caching problem ; if the cache lifetime is too high, the script can get stale data after modification.
|
||||
We advise to set `CACHE_TIME` to `0`.
|
||||
# Installation
|
||||
|
||||
```
|
||||
# pip3 install netbox-agent
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
The agent can be run from a shell and get its configuration from either the configuration file or environment variables.
|
||||
|
||||
Configuration values are overridden based on the following precedence: command line arguments (might include config file) > environment variables > default config file > defaults.
|
||||
|
||||
```
|
||||
# netbox_agent -c /etc/netbox_agent.yaml --register
|
||||
INFO:root:Creating chassis blade (serial: QTFCQ574502EF)
|
||||
INFO:root:Creating blade (serial: QTFCQ574502D2) myserver on chassis QTFCQ574502EF
|
||||
INFO:root:Setting device (QTFCQ574502D2) new slot on Slot 9 (Chassis QTFCQ574502EF)..
|
||||
INFO:root:Interface a8:1e:84:f2:9e:6a not found, creating..
|
||||
INFO:root:Creating NIC enp1s0f1 (a8:1e:84:f2:9e:6a) on myserver
|
||||
INFO:root:Interface 02:42:7a:89:cf:a4 not found, creating..
|
||||
INFO:root:Creating NIC br-07ea1e4a2f0e (02:42:7a:89:cf:a4) on myserver
|
||||
INFO:root:Create new IP 172.19.0.1/16 on br-07ea1e4a2f0e
|
||||
INFO:root:Interface a8:1e:84:f2:9e:69 not found, creating..
|
||||
INFO:root:Creating NIC enp1s0f0 (a8:1e:84:f2:9e:69) on myserver
|
||||
INFO:root:Create new IP 42.42.42.42/24 on enp1s0f0
|
||||
INFO:root:Create new IP fe80::aa1e:84ff:fef2:9e69/64 on enp1s0f0
|
||||
INFO:root:Interface a8:1e:84:cd:9d:d6 not found, creating..
|
||||
INFO:root:Creating NIC IPMI (a8:1e:84:cd:9d:d6) on myserver
|
||||
INFO:root:Create new IP 10.191.122.10/24 on IPMI
|
||||
```
|
||||
|
||||
If you need, you can update only specific informations like:
|
||||
* Network
|
||||
* Inventory
|
||||
* Location
|
||||
* PSUs
|
||||
|
||||
```
|
||||
# ip a add 42.42.42.43/24 dev enp1s0f1
|
||||
# netbox_agent -c /etc/netbox_agent.yaml --update-network
|
||||
INFO:root:Create new IP 42.42.42.43/24 on enp1s0f1
|
||||
# netbox_agent --update-inventory
|
||||
INFO:root:Creating Disk Samsung SSD 850 S2RBNX0K101698D
|
||||
```
|
||||
|
||||
# Configuration
|
||||
|
||||
```
|
||||
# Netbox configuration
|
||||
netbox:
|
||||
url: 'http://netbox.internal.company.com'
|
||||
token: supersecrettoken
|
||||
# uncomment to disable ssl verification
|
||||
# ssl_verify: false
|
||||
# uncomment to use the system's CA certificates
|
||||
# ssl_ca_certs_file: /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
# Network configuration
|
||||
network:
|
||||
# Regex to ignore interfaces
|
||||
ignore_interfaces: "(dummy.*|docker.*)"
|
||||
# Regex to ignore IP addresses
|
||||
ignore_ips: (127\.0\.0\..*)
|
||||
# enable auto-cabling
|
||||
# enable auto-cabling by parsing LLDP answers
|
||||
lldp: true
|
||||
|
||||
#
|
||||
# You can use these to change the Netbox roles.
|
||||
# These are the defaults.
|
||||
#
|
||||
#device:
|
||||
# chassis_role: "Server Chassis"
|
||||
# blade_role: "Blade"
|
||||
# server_role: "Server"
|
||||
# tags: server, blade, ,just a comma,delimited,list
|
||||
# custom_fields: field1=value1,field2=value2#
|
||||
#
|
||||
# Can use this to set the tenant
|
||||
#
|
||||
#tenant:
|
||||
# driver: "file:/tmp/tenant"
|
||||
# regex: "(.*)"
|
||||
|
||||
## Enable virtual machine support
|
||||
# virtual:
|
||||
# # not mandatory, can be guessed
|
||||
# enabled: True
|
||||
# # see https://netbox.company.com/virtualization/clusters/
|
||||
# cluster_name: my_vm_cluster
|
||||
|
||||
# Enable datacenter location feature in Netbox
|
||||
datacenter_location:
|
||||
driver: "cmd:cat /etc/qualification | tr [a-z] [A-Z]"
|
||||
regex: "DATACENTER: (?P<datacenter>[A-Za-z0-9]+)"
|
||||
driver: "cmd:cat /etc/qualification | tr [A-Z] [a-z]"
|
||||
regex: "datacenter: (?P<datacenter>[A-Za-z0-9]+)"
|
||||
# driver: 'cmd:lldpctl'
|
||||
# regex: 'SysName: .*\.([A-Za-z0-9]+)'
|
||||
#
|
||||
# driver: "file:/tmp/datacenter"
|
||||
# regex: "(.*)"
|
||||
|
||||
# Enable rack location feature in Netbox
|
||||
rack_location:
|
||||
# driver: 'cmd:lldpctl'
|
||||
# match SysName: sw-dist-a1.dc42
|
||||
|
@ -70,6 +147,7 @@ rack_location:
|
|||
# driver: "file:/tmp/datacenter"
|
||||
# regex: "(.*)"
|
||||
|
||||
# Enable local inventory reporting
|
||||
inventory: true
|
||||
```
|
||||
|
||||
|
@ -84,6 +162,36 @@ The `get_blade_slot` method return the name of the `Device Bay`.
|
|||
|
||||
Certain vendors don't report the blade slot in `dmidecode`, so we can use the `slot_location` regex feature of the configuration file.
|
||||
|
||||
Some blade servers can be equipped with additional hardware using expansion blades, next to the processing blade, such as GPU expansion, or drives bay expansion. By default, the hardware from the expnasion is associated with the blade server itself, but it's possible to register the expansion as its own device using the `--expansion-as-device` command line parameter, or by setting `expansion_as_device` to `true` in the configuration file.
|
||||
|
||||
## Drives attributes processing
|
||||
|
||||
It is possible to process drives extended attributes such as the drive's physical or logical identifier, logical drive RAID type, size, consistency and so on.
|
||||
|
||||
Those attributes as set as `custom_fields` in Netbox, and need to be registered properly before being able to specify them during the inventory phase.
|
||||
|
||||
As the custom fields have to be created prior being able to register the disks extended attributes, this feature is only activated using the `--process-virtual-drives` command line parameter, or by setting `process_virtual_drives` to `true` in the configuration file.
|
||||
|
||||
The custom fields to create as `DCIM > inventory item` `Text` are described below.
|
||||
|
||||
```
|
||||
NAME LABEL DESCRIPTION
|
||||
mount_point Mount point Device mount point(s)
|
||||
pd_identifier Physical disk identifier Physical disk identifier in the RAID controller
|
||||
vd_array Virtual drive array Virtual drive array the disk is member of
|
||||
vd_consistency Virtual drive consistency Virtual disk array consistency
|
||||
vd_device Virtual driv |