2021-02-27 13:25:47 +01:00
# NetBox Device Type Library
## About this Library
2019-09-25 20:49:47 +02:00
2022-08-18 15:23:52 +02:00
This library is intended to be used for populating device types in [NetBox ](https://github.com/netbox-community/netbox ).
It contains a set of device type definitions expressed in YAML and arranged by manufacturer. Each file represents a
discrete physical device type (e.g. make and model). These definitions can be loaded into NetBox instead of creating
new device type definitions manually.
2019-09-25 20:49:47 +02:00
2021-03-31 02:45:33 +02:00
If you would like to contribute to this library, please read through our [contributing guide ](CONTRIBUTING.md ) before
2019-12-19 18:20:22 +01:00
submitting content.
2019-12-11 20:05:11 +01:00
2023-03-03 16:04:50 +01:00
**Note: As of March 2023 Netbox-Device-Type-Library-Import has been brought into the NetBox Community Organization. We will work to get this fully supported soon.**
2021-03-31 02:45:33 +02:00
If you would like to automate the import of these devicetype template files, there is a **community based** python script
2023-03-03 16:04:50 +01:00
that will check for duplicates, allow you to selectively import vendors, etc. available here [netbox-community/Device-Type-Library-Import ](https://github.com/netbox-community/Device-Type-Library-Import ). **Note** : This is not related to NetBox in any official way and you will not get support for it here.
2021-02-27 15:32:48 +01:00
2021-02-27 13:25:47 +01:00
## Device Type Definitions
2019-09-25 20:49:47 +02:00
2023-01-11 21:37:55 +01:00
Each definition **must** include at minimum the following fields:
2019-09-25 20:49:47 +02:00
2021-02-27 13:25:47 +01:00
- `manufacturer` : The name of the manufacturer which produces this device type.
2023-01-11 21:37:55 +01:00
- Type: String
2021-02-27 13:25:47 +01:00
- `model` : The model number of the device type. This must be unique per manufacturer.
2023-01-11 21:37:55 +01:00
- Type: String
2021-02-27 13:25:47 +01:00
- `slug` : A URL-friendly representation of the model number. Like the model number, this must be unique per
2019-12-19 18:20:22 +01:00
manufacturer.
2023-01-11 21:37:55 +01:00
- Type: String
- Pattern: `"^[-a-zA-Z0-9_]+$"` . Must match the following characters: `-` , `_` , Uppercase or Lowercase `a` to `z` , Numbers `0` to `9` .
>:test_tube: **Valid Example** :
>```
>manufacturer: Dell
>model: PowerEdge R6515
>slug: dell-poweredge-r6515
>```
The following fields may **optionally** be declared:
- `part_number` : An alternative representation of the model number (e.g. a SKU). (**Default: None**)
- Type: String
> :test_tube: **Example**: `part_number: D109-C3`
- `u_height` : The height of the device type in rack units. Increments of 0.5U are supported. (**Default: 1**)
- Type: number (minimum of `0` , multiple of `0.5` )
> :test_tube: **Example**: `u_height: 12.5`
- `is_full_depth` : A boolean which indicates whether the device type consumes both the front and rear rack faces. (**Default: true**)
- Type: Boolean
> :test_tube: **Example**: `is_full_depth: false`
- `airflow` : A decleration of the airflow pattern for the device. (**Default: None**)
- Type: String
- Options:
- `front-to-rear`
- `rear-to-front`
- `left-to-right`
- `right-to-left`
- `side-to-rear`
- `passive`
> :test_tube: **Example**: `airflow: side-to-rear`
- `subdevice_role` : Indicates that this is a `parent` or `child` device. (**Default: None**)
- Type: String
- Options:
- `parent`
- `child`
> :test_tube: **Example**: `subdevice_role: parent`
- `comments` : A string field which allows for comments to be added to the device. (**Default: None**)
- Type: String
> :test_tube: **Example**: `comments: This is a comment that will appear on all NetBox devices of this type`
2023-01-19 17:40:40 +01:00
- `weight` : An array with a **single** item that allow for a value and unit of measurement to be defined. (**Default: None**)
- Type: Array
- Value: Number - must be multiple of 0.01
- Unit: String
- Options:
- kg
- g
- lb
- oz
>:test_tube: **Example** :
>```
>weight:
> - value: 12.21
> unit: lb
>```
2019-09-25 20:49:47 +02:00
2019-12-19 19:41:22 +01:00
For further detail on these attributes and those listed below, please reference the
2023-01-11 21:37:55 +01:00
[schema definitions ](schema/ ) and the [Component Definitions ](#component-definitions ) below.
2019-12-19 19:41:22 +01:00
2021-02-27 13:25:47 +01:00
### Component Definitions
2019-09-25 20:49:47 +02:00
2019-12-19 18:20:22 +01:00
Valid component types are listed below. Each type of component must declare a list of the individual component templates
to be added.
2019-09-25 20:49:47 +02:00
2023-01-11 21:37:55 +01:00
- [`console-ports` ](#console-ports "Availible in NetBox 2 and later" )
- [`console-server-ports` ](#console-server-ports "Availible in NetBox 2.2 and later" )
- [`power-ports` ](#power-ports "Availible in NetBox 1.7 and later" )
- [`power-outlets` ](#power-outlets "Availible in NetBox 2 and later" )
- [`interfaces` ](#interfaces "Availible in all versions of NetBox" )
- [`front-ports` ](#front-ports "Availible in NetBox 2.5 and later" )
- [`rear-ports` ](#rear-ports "Availible in NetBox 2.5 and later" )
- [`module-bays` ](#module-bays "Availible in NetBox 3.2 and later" )
- [`device-bays` ](#device-bays "Availible in all versions of NetBox" )
- [`inventory-items` ](#inventory-items "Availible in NetBox 3.2 and later" )
2019-09-25 20:49:47 +02:00
The available fields for each type of component are listed below.
2021-02-27 13:25:47 +01:00
#### Console Ports
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Port type slug (Array)
2021-02-27 13:25:47 +01:00
#### Console Server Ports
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Port type slug (Array)
2021-02-27 13:25:47 +01:00
#### Power Ports
2019-09-25 20:49:47 +02:00
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Port type slug (Array)
2021-02-27 13:25:47 +01:00
- `maximum_draw` : The port's maximum power draw, in watts (optional)
- `allocated_draw` : The port's allocated power draw, in watts (optional)
2019-09-25 20:49:47 +02:00
2021-02-27 13:25:47 +01:00
#### Power Outlets
2019-09-25 20:49:47 +02:00
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Port type slug (Array)
2021-02-27 13:25:47 +01:00
- `power_port` : The name of the power port on the device which powers this outlet (optional)
- `feed_leg` : The phase (leg) of power to which this outlet is mapped; A, B, or C (optional)
2019-09-25 20:49:47 +02:00
2021-02-27 13:25:47 +01:00
#### Interfaces
2019-09-25 20:49:47 +02:00
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Interface type slug (Array)
2021-02-27 13:25:47 +01:00
- `mgmt_only` : A boolean which indicates whether this interface is used for management purposes only (default: false)
2019-09-25 20:49:47 +02:00
2021-02-27 13:25:47 +01:00
#### Front Ports
2019-09-25 20:49:47 +02:00
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Port type slug (Array)
2021-02-27 13:25:47 +01:00
- `rear_port` : The name of the rear port on this device to which the front port maps
- `rear_port_position` : The corresponding position on the mapped rear port (default: 1)
2019-09-25 20:49:47 +02:00
2021-02-27 13:25:47 +01:00
#### Rear Ports
2019-09-25 20:49:47 +02:00
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2023-01-11 21:37:55 +01:00
- `type` : Port type slug (Array)
2021-02-27 13:25:47 +01:00
- `positions` : The number of front ports that can map to this rear port (default: 1)
2019-09-25 20:49:47 +02:00
2021-12-30 19:51:30 +01:00
#### Module Bays
- `name` : Name
- `label` : Label
- `position` : The module bay's position within the parent device
2021-02-27 13:25:47 +01:00
#### Device Bays
2019-09-25 20:49:47 +02:00
2021-12-30 19:41:40 +01:00
- `name` : Name
- `label` : Label
2019-09-25 20:49:47 +02:00
2021-12-30 19:51:30 +01:00
#### Inventory Items
- `name` : Name
- `label` : Label
- `manufacturer` : The name of the manufacturer which produces this item
- `part_id` : The part ID assigned by the manufacturer
2021-02-27 13:25:47 +01:00
## Data Validation / Commit Quality Checks
2019-09-25 20:49:47 +02:00
2021-02-27 13:25:47 +01:00
There are two ways this repo focuses on keeping quality device-type definitions:
2019-12-11 20:05:11 +01:00
2023-01-11 21:37:55 +01:00
- **Pre-Commit Checks** - Optional, but **highly recommended** , for helping to identify simple issues before committing. (trailing-whitespace, end-of-file-fixer, check-yaml, yamlfmt, yamllint)
- Installation
- Virtual Environment Route
- It is recommended to create a virtual env for your repo (`python3 -m venv venv`)
- Install the required pip packages (`pip install -r requirements.txt`)
- Continue to the "Install `pre-commit` Hooks"
- `pre-commit` Only Route
- [Install pre-commit ](https://pre-commit.com/#install ) (`pip install pre-commit`)
- Install `pre-commit` Hooks
- To install the pre-commit script: `pre-commit install`
- Usage & Useful `pre-commit` Commands
- After staging your files with `git` , to run the pre-commit script on changed files: `pre-commit run`
- To run the pre-commit script on all files: `pre-commit run --all`
- To uninstall the pre-commit script: `pre-commit uninstall`
2021-02-27 13:25:47 +01:00
- Learn more about [pre-commit ](https://pre-commit.com/ )
2023-01-11 21:37:55 +01:00
- **GitHub Actions** - Automatically run before a PR can be merged. Repeats yamllint & validates against NetBox Device-Type Schema.