Skip to content

Commit 872ba89

Browse files
Merge pull request #5454 from netbox-community/develop-2.10
Stage v2.10 release
2 parents 230b503 + 1f2daaa commit 872ba89

File tree

461 files changed

+45674
-21436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

461 files changed

+45674
-21436
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
python-version: [3.6, 3.7]
8+
python-version: [3.6, 3.7, 3.8]
99
services:
1010
redis:
1111
image: redis

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ categories for discussions:
1515
* **Ideas** - Ideas for new functionality that isn't yet ready for a formal
1616
feature request
1717
* **Q&A** - Request help with installing or using NetBox
18-
* **Show and tell** - Share a plugin, script, or something else you've made
19-
using NetBox
2018

2119
### Mailing List
2220

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,69 @@
11
# Custom Fields
22

3-
Each object in NetBox is represented in the database as a discrete table, and each attribute of an object exists as a column within its table. For example, sites are stored in the `dcim_site` table, which has columns named `name`, `facility`, `physical_address`, and so on. As new attributes are added to objects throughout the development of NetBox, tables are expanded to include new rows.
3+
Each model in NetBox is represented in the database as a discrete table, and each attribute of a model exists as a column within its table. For example, sites are stored in the `dcim_site` table, which has columns named `name`, `facility`, `physical_address`, and so on. As new attributes are added to objects throughout the development of NetBox, tables are expanded to include new rows.
44

5-
However, some users might want to associate with objects attributes that are somewhat esoteric in nature, and that would not make sense to include in the core NetBox database schema. For instance, suppose your organization needs to associate each device with a ticket number pointing to the support ticket that was opened to have it installed. This is certainly a legitimate use for NetBox, but it's perhaps not a common enough need to warrant expanding the internal data schema. Instead, you can create a custom field to hold this data.
5+
However, some users might want to store additional object attributes that are somewhat esoteric in nature, and that would not make sense to include in the core NetBox database schema. For instance, suppose your organization needs to associate each device with a ticket number correlating it with an internal support system record. This is certainly a legitimate use for NetBox, but it's not a common enough need to warrant including a field for _every_ NetBox installation. Instead, you can create a custom field to hold this data.
66

7-
Custom fields must be created through the admin UI under Extras > Custom Fields. To create a new custom field, select the object(s) to which you want it to apply, and the type of field it will be. NetBox supports six field types:
7+
Within the database, custom fields are stored as JSON data directly alongside each object. This alleviates the need for complex queries when retrieving objects.
88

9-
* Free-form text (up to 255 characters)
10-
* Integer
11-
* Boolean (true/false)
12-
* Date
13-
* URL
14-
* Selection
9+
## Creating Custom Fields
1510

16-
Assign the field a name. This should be a simple database-friendly string, e.g. `tps_report`. You may optionally assign the field a human-friendly label (e.g. "TPS report") as well; the label will be displayed on forms. If a description is provided, it will appear beneath the field in a form.
11+
Custom fields must be created through the admin UI under Extras > Custom Fields. NetBox supports six types of custom field:
1712

18-
Marking the field as required will require the user to provide a value for the field when creating a new object or when saving an existing object. A default value for the field may also be provided. Use "true" or "false" for boolean fields. (The default value has no effect for selection fields.)
13+
* Text: Free-form text (up to 255 characters)
14+
* Integer: A whole number (positive or negative)
15+
* Boolean: True or false
16+
* Date: A date in ISO 8601 format (YYYY-MM-DD)
17+
* URL: This will be presented as a link in the web UI
18+
* Selection: A selection of one of several pre-defined custom choices
1919

20-
When creating a selection field, you should create at least two choices. These choices will be arranged first by weight, with lower weights appearing higher in the list, and then alphabetically.
20+
Each custom field must have a name; this should be a simple database-friendly string, e.g. `tps_report`. You may also assign a corresponding human-friendly label (e.g. "TPS report"); the label will be displayed on web forms. A weight is also required: Higher-weight fields will be ordered lower within a form. (The default weight is 100.) If a description is provided, it will appear beneath the field in a form.
2121

22-
## Using Custom Fields
22+
Marking a field as required will force the user to provide a value for the field when creating a new object or when saving an existing object. A default value for the field may also be provided. Use "true" or "false" for boolean fields, or the exact value of a choice for selection fields.
2323

24-
When a single object is edited, the form will include any custom fields which have been defined for the object type. These fields are included in the "Custom Fields" panel. On the backend, each custom field value is saved separately from the core object as an independent database call, so it's best to avoid adding too many custom fields per object.
24+
The filter logic controls how values are matched when filtering objects by the custom field. Loose filtering (the default) matches on a partial value, whereas exact matching requires a complete match of the given string to a field's value. For example, exact filtering with the string "red" will only match the exact value "red", whereas loose filtering will match on the values "red", "red-orange", or "bored". Setting the filter logic to "disabled" disables filtering by the field entirely.
2525

26-
When editing multiple objects, custom field values are saved in bulk. There is no significant difference in overhead when saving a custom field value for 100 objects versus one object. However, the bulk operation must be performed separately for each custom field.
26+
A custom field must be assigned to one or object types, or models, in NetBox. Once created, custom fields will automatically appear as part of these models in the web UI and REST API. Note that not all models support custom fields.
27+
28+
### Custom Field Validation
29+
30+
NetBox supports limited custom validation for custom field values. Following are the types of validation enforced for each field type:
31+
32+
* Text: Regular expression (optional)
33+
* Integer: Minimum and/or maximum value (optional)
34+
* Selection: Must exactly match one of the prescribed choices
35+
36+
### Custom Selection Fields
37+
38+
Each custom selection field must have at least two choices. These are specified as a comma-separated list. Choices appear in forms in the order they are listed. Note that choice values are saved exactly as they appear, so it's best to avoid superfluous punctuation or symbols where possible.
39+
40+
If a default value is specified for a selection field, it must exactly match one of the provided choices.
41+
42+
## Custom Fields and the REST API
43+
44+
When retrieving an object via the REST API, all of its custom data will be included within the `custom_fields` attribute. For example, below is the partial output of a site with two custom fields defined:
45+
46+
```json
47+
{
48+
"id": 123,
49+
"url": "http://localhost:8000/api/dcim/sites/123/",
50+
"name": "Raleigh 42",
51+
...
52+
"custom_fields": {
53+
"deployed": "2018-06-19",
54+
"site_code": "US-NC-RAL42"
55+
},
56+
...
57+
```
58+
59+
To set or change these values, simply include nested JSON data. For example:
60+
61+
```json
62+
{
63+
"name": "New Site",
64+
"slug": "new-site",
65+
"custom_fields": {
66+
"deployed": "2019-03-24"
67+
}
68+
}
69+
```

docs/additional-features/graphs.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/administration/netbox-shell.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ To delete an object, simply call `delete()` on its instance. This will return a
185185
>>> vlan
186186
<VLAN: 123 (BetterName)>
187187
>>> vlan.delete()
188-
(1, {'extras.CustomFieldValue': 0, 'ipam.VLAN': 1})
188+
(1, {'ipam.VLAN': 1})
189189
```
190190

191191
To delete multiple objects at once, call `delete()` on a filtered queryset. It's a good idea to always sanity-check the count of selected objects _before_ deleting them.
@@ -194,9 +194,9 @@ To delete multiple objects at once, call `delete()` on a filtered queryset. It's
194194
>>> Device.objects.filter(name__icontains='test').count()
195195
27
196196
>>> Device.objects.filter(name__icontains='test').delete()
197-
(35, {'extras.CustomFieldValue': 0, 'dcim.DeviceBay': 0, 'secrets.Secret': 0,
198-
'dcim.InterfaceConnection': 4, 'extras.ImageAttachment': 0, 'dcim.Device': 27,
199-
'dcim.Interface': 4, 'dcim.ConsolePort': 0, 'dcim.PowerPort': 0})
197+
(35, {'dcim.DeviceBay': 0, 'secrets.Secret': 0, 'dcim.InterfaceConnection': 4,
198+
'extras.ImageAttachment': 0, 'dcim.Device': 27, 'dcim.Interface': 4,
199+
'dcim.ConsolePort': 0, 'dcim.PowerPort': 0})
200200
```
201201

202202
!!! warning

docs/core-functionality/ipam.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
---
1616

1717
{!docs/models/ipam/vrf.md!}
18+
{!docs/models/ipam/routetarget.md!}

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ NetBox is built on the [Django](https://djangoproject.com/) Python framework and
5555

5656
## Supported Python Versions
5757

58-
NetBox supports Python 3.6 and 3.7 environments currently. (Support for Python 3.5 was removed in NetBox v2.8.)
58+
NetBox supports Python 3.6, 3.7, and 3.8 environments currently. (Support for Python 3.5 was removed in NetBox v2.8.)
5959

6060
## Getting Started
6161

docs/installation/1-postgresql.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,27 @@ This section entails the installation and configuration of a local PostgreSQL da
55
!!! warning
66
NetBox requires PostgreSQL 9.6 or higher. Please note that MySQL and other relational databases are **not** currently supported.
77

8-
The installation instructions provided here have been tested to work on Ubuntu 18.04 and CentOS 7.5. The particular commands needed to install dependencies on other distributions may vary significantly. Unfortunately, this is outside the control of the NetBox maintainers. Please consult your distribution's documentation for assistance with any errors.
9-
108
## Installation
119

1210
#### Ubuntu
1311

14-
If a recent enough version of PostgreSQL is not available through your distribution's package manager, you'll need to install it from an official [PostgreSQL repository](https://wiki.postgresql.org/wiki/Apt).
12+
Install the PostgreSQL server and client development libraries using `apt`.
1513

1614
```no-highlight
17-
# apt-get update
18-
# apt-get install -y postgresql libpq-dev
15+
sudo apt update
16+
sudo apt install -y postgresql libpq-dev
1917
```
2018

2119
#### CentOS
2220

23-
CentOS 7 does not ship with a recent enough version of PostgreSQL, so it will need to be installed from an external repository. The instructions below show the installation of PostgreSQL 9.6, however you may opt to install a more recent version.
21+
PostgreSQL 9.6 and later are available natively on CentOS 8.2. If using an earlier CentOS release, you may need to [install it from an RPM](https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/).
2422

2523
```no-highlight
26-
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
27-
# yum install -y postgresql96 postgresql96-server postgresql96-devel
28-
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
24+
sudo yum install -y postgresql-server libpq-devel
25+
sudo postgresql-setup --initdb
2926
```
3027

31-
CentOS users should modify the PostgreSQL configuration to accept password-based authentication by replacing `ident` with `md5` for all host entries within `/var/lib/pgsql/9.6/data/pg_hba.conf`. For example:
28+
CentOS configures ident host-based authentication for PostgreSQL by default. Because NetBox will need to authenticate using a username and password, modify `/var/lib/pgsql/data/pg_hba.conf` to support MD5 authentication by changing `ident` to `md5` for the lines below:
3229

3330
```no-highlight
3431
host all all 127.0.0.1/32 md5
@@ -38,8 +35,8 @@ host all all ::1/128 md5
3835
Then, start the service and enable it to run at boot:
3936

4037
```no-highlight
41-
# systemctl start postgresql-9.6
42-
# systemctl enable postgresql-9.6
38+
sudo systemctl start postgresql
39+
sudo systemctl enable postgresql
4340
```
4441

4542
## Database Creation
@@ -50,8 +47,8 @@ At a minimum, we need to create a database for NetBox and assign it a username a
5047
**Do not use the password from the example.** Choose a strong, random password to ensure secure database authentication for your NetBox installation.
5148

5249
```no-highlight
53-
# sudo -u postgres psql
54-
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
50+
$ sudo -u postgres psql
51+
psql (12.5 (Ubuntu 12.5-0ubuntu0.20.04.1))
5552
Type "help" for help.
5653
5754
postgres=# CREATE DATABASE netbox;
@@ -68,13 +65,16 @@ postgres=# \q
6865
You can verify that authentication works issuing the following command and providing the configured password. (Replace `localhost` with your database server if using a remote database.)
6966

7067
```no-highlight
71-
# psql --username netbox --password --host localhost netbox
68+
$ psql --username netbox --password --host localhost netbox
7269
Password for user netbox:
73-
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
70+
psql (12.5 (Ubuntu 12.5-0ubuntu0.20.04.1))
7471
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
7572
Type "help" for help.
7673
74+
netbox=> \conninfo
75+
You are connected to database "netbox" as user "netbox" on host "localhost" (address "127.0.0.1") at port "5432".
76+
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
7777
netbox=> \q
7878
```
7979

80-
If successful, you will enter a `netbox` prompt. Type `\q` to exit.
80+
If successful, you will enter a `netbox` prompt. Type `\conninfo` to confirm your connection, or type `\q` to exit.

docs/installation/2-redis.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
### Ubuntu
1111

1212
```no-highlight
13-
# apt-get install -y redis-server
13+
sudo apt install -y redis-server
1414
```
1515

1616
### CentOS
1717

1818
```no-highlight
19-
# yum install -y epel-release
20-
# yum install -y redis
21-
# systemctl start redis
22-
# systemctl enable redis
19+
sudo yum install -y redis
20+
sudo systemctl start redis
21+
sudo systemctl enable redis
2322
```
2423

2524
You may wish to modify the Redis configuration at `/etc/redis.conf` or `/etc/redis/redis.conf`, however in most cases the default configuration is sufficient.

0 commit comments

Comments
 (0)