Compare commits

...

498 Commits

Author SHA1 Message Date
Jeremy Stretch
b15ecf7649 Merge pull request #8123 from netbox-community/develop
Release v3.1.2
2021-12-20 16:04:41 -05:00
jeremystretch
df4f80e773 Release v3.1.2 2021-12-20 15:48:28 -05:00
jeremystretch
b8b485af4d Changelog & PEP8 cleanup for #7999 2021-12-20 14:17:52 -05:00
Jeremy Stretch
892d6b55ec Merge pull request #8000 from joni1993/more-channels
feat: add 6GHz & 60Ghz channels
2021-12-20 14:16:12 -05:00
Jeremy Stretch
4a3bc8d365 Merge pull request #8111 from bonktree/opaque-icon
templates: add an opaque icon for mobile home screens
2021-12-20 13:58:25 -05:00
jeremystretch
e12da72615 Fixes #8101: Preserve return URL when using "create and add another" button 2021-12-20 13:41:22 -05:00
jeremystretch
f95e510060 Fixes #8102: Raise validation error when attempting to assign an IP address to multiple objects 2021-12-20 13:09:28 -05:00
Daniel Sheppard
82932ae7a5 Fixes #8102 - Add validation around assigned objects 2021-12-20 11:07:44 -06:00
jeremystretch
14fc37a8b8 Closes #7661: Remove forced styling of custom banners 2021-12-19 15:33:48 -05:00
Arseny Maslennikov
7b23856cc8 templates: add an opaque icon for mobile home screens
The netbox_touch-icon-180.png icon was produced by rendering
netbox_icon.svg into a 160x160 square, centered in a 180x180 PNG filled
by the background colour of #212529.

In other words, it is a screenshot of the following HTML element:
```html
  <div style="width: 180px;height: 180px;background-color: #212529;">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320" style="padding: 10px;">
    <g fill="#9cc8f8" stroke="#9cc8f8">
      <circle cx="37" cy="284" r="23"></circle>
      <circle cx="101" cy="37" r="23"></circle>
      <circle cx="101" cy="220" r="23"></circle>
      <circle cx="284" cy="220" r="23"></circle>
      <rect x="93" y="37" width="16" height="180"></rect>
      <rect x="101" y="212" width="180" height="16"></rect>
      <rect x="93" y="212" width="16" height="90" transform="rotate(45 101 220)"></rect>
    </g>
    <g fill="#1685fc" stroke="#1685fc">
      <circle cx="284" cy="37" r="23"></circle>
      <circle cx="37" cy="101" r="23"></circle>
      <circle cx="220" cy="101" r="23"></circle>
      <circle cx="220" cy="284" r="23"></circle>
      <rect x="37" y="93" width="180" height="16"></rect>
      <rect x="212" y="101" width="16" height="180"></rect>
      <rect x="212" y="93" width="16" height="90" transform="rotate(225 220 101)"></rect>
    </g>
  </svg>
  </div>
```
2021-12-19 01:32:15 +03:00
jeremystretch
85f9690377 Closes #8083: Removed "related devices" panel from device view 2021-12-18 14:30:28 -05:00
jeremystretch
4723500c5f Fixes #8092: Rack elevations should not include device asset tags 2021-12-18 14:26:32 -05:00
jeremystretch
2db82a73a5 #8096: Include only first assigned IP in FHRPGroup string representation 2021-12-18 14:19:57 -05:00
jeremystretch
b00eeb86ea Fixes #8096: Fix DataError during change logging of objects with very long string representations 2021-12-18 14:16:37 -05:00
jeremystretch
628e186846 Closes #8108: Improve breadcrumb links for device/VM components 2021-12-18 14:02:01 -05:00
jeremystretch
cf4a55bc2f Closes #8107: Correct template name 2021-12-18 13:52:39 -05:00
Christian Jonak
cab07c7c4b fix: non 20Mhz-wide channel centers 2021-12-16 19:28:39 +01:00
jeremystretch
7735a539e9 Fixes #8088: Improve legibility of text in labels with light-colored backgrounds 2021-12-16 12:44:18 -05:00
Christian Jonak
68eb6fc3c1 fix: use center freq instead of beginning of freq range for 6Ghz 2021-12-16 18:14:56 +01:00
jeremystretch
fd785fc9a5 Move speed select dropdown menu to widget template 2021-12-16 08:41:43 -05:00
jeremystretch
8d06908353 Bulk component add view should use tabs 2021-12-15 16:57:30 -05:00
jeremystretch
806706ca1d Refresh development documentation 2021-12-15 16:31:06 -05:00
jeremystretch
044e203eab Standardize button colors 2021-12-15 12:16:50 -05:00
jeremystretch
fcc7207b67 Restore actions column under VM interfaces table 2021-12-15 12:11:20 -05:00
jeremystretch
8dbd3f332b Closes #8081: Allow creating services directly from navigation menu 2021-12-15 11:55:27 -05:00
jeremystretch
f43ec7c05d Add "add IP range" button to prefix IP ranges view 2021-12-15 11:03:38 -05:00
jeremystretch
ff9dde54e3 Ensure consistent placement of table paginator 2021-12-15 10:34:20 -05:00
jeremystretch
3699f16848 Show per-page selector only when results are present 2021-12-15 09:46:59 -05:00
jeremystretch
fee2ac2ebd Changelog for #8057 2021-12-15 09:36:52 -05:00
Jeremy Stretch
57d3bfcfc9 Merge pull request #8073 from netbox-community/8057-htmx-tables
Closes #8057: Dynamic object tables using HTMX
2021-12-15 09:16:41 -05:00
jeremystretch
b92e34556f Fixes #8077: Fix exception when attaching image to location, circuit, or power panel 2021-12-15 08:45:17 -05:00
jeremystretch
b6ff55309e Fixes #8078: Add missing wireless models to lsmodels() in nbshell 2021-12-15 08:38:19 -05:00
jeremystretch
305d88ebda Fixes #8079: Fix validation of LLDP neighbors when connected device has an asset tag 2021-12-15 08:36:03 -05:00
jeremystretch
cdc73d4f56 Closes #8080: Link to NAT IPs for device/VM primary IPs 2021-12-15 08:35:01 -05:00
jeremystretch
0e50c964d5 Remove obsolete pagination TS/CSS 2021-12-14 21:00:48 -05:00
jeremystretch
863fb9aa47 Sync HTMX and non-HTMX paginator styles 2021-12-14 20:53:24 -05:00
jeremystretch
298fb00a3e Remove obsolete "quick find" TS 2021-12-14 20:04:49 -05:00
jeremystretch
d1e8c06d36 Fixes #8074: Ordering VMs by name should reference naturalized value 2021-12-14 17:03:03 -05:00
jeremystretch
8ed79d5973 Remove obsolete templates 2021-12-14 16:44:03 -05:00
jeremystretch
85b10b59e4 Introduce child prefixes view for aggregates 2021-12-14 16:38:25 -05:00
jeremystretch
9a53c22833 Serve HTMX JS locally 2021-12-14 15:55:40 -05:00
jeremystretch
c981b5cba0 Add prep_table_data() method to ObjectChildrenView 2021-12-14 15:42:28 -05:00
jeremystretch
4ffa823ab8 Enable HTMX for all ObjectChildrenViews 2021-12-14 15:31:42 -05:00
Jeremy Stretch
001c7e4b18 Merge pull request #8070 from netbox-community/8069-generic-children-view
Closes #8069: Generic children view
2021-12-14 14:30:41 -05:00
jeremystretch
402136dc8f Merge branch '8069-generic-children-view' into 8057-htmx-tables 2021-12-14 14:21:08 -05:00
jeremystretch
59ee30f056 Update cluster VM/device views to use ObjectChildrenView 2021-12-14 14:08:44 -05:00
jeremystretch
c795068a78 Update VLAN member interface views to use ObjectChildrenView 2021-12-14 14:03:44 -05:00
jeremystretch
5ce080779b Update IPRange IP addresses view to use ObjectChildrenView 2021-12-14 13:55:09 -05:00
jeremystretch
8d3b296eed Update device/VM component views to use ObjectChildrenView 2021-12-14 13:47:40 -05:00
jeremystretch
cfdb985d00 Update prefix children views to use ObjectChildrenView 2021-12-14 13:33:53 -05:00
jeremystretch
af6f0db284 Introduce ObjectChildrenView 2021-12-14 13:33:36 -05:00
jeremystretch
491eac184e Enable HTMX for connections lists 2021-12-14 11:53:16 -05:00
jeremystretch
414d33eb26 Refactor HTMX table template 2021-12-14 11:41:39 -05:00
jeremystretch
6dd6094088 Push HTMX URL to browser location 2021-12-14 08:25:17 -05:00
jeremystretch
5c34a75032 Enable HTMX for quick table search 2021-12-13 20:15:03 -05:00
jeremystretch
91f33d3289 #8057: Enable dynamic tables for object list views 2021-12-13 16:51:59 -05:00
jeremystretch
c50dc1eb35 Standardize usage of table template 2021-12-13 15:36:51 -05:00
jeremystretch
dc1331e736 Fixes #7674: Fix inadvertent application of device type context to virtual machines 2021-12-13 13:42:59 -05:00
jeremystretch
afc866eee4 #7665: Refactored add_requested_prefixes(); removed button icons 2021-12-13 12:15:43 -05:00
jeremystretch
b6d93b7c5b Changelog for #7665 2021-12-13 12:10:03 -05:00
Jeremy Stretch
5d6158dd64 Merge pull request #7826 from WillIrvine/develop
Add filter for optionally including assigned prefixes
2021-12-13 12:04:38 -05:00
jeremystretch
e9549ab0bd PRVB 2021-12-13 09:16:55 -05:00
Jeremy Stretch
779249ff81 Merge pull request #8053 from netbox-community/develop
Release v3.1.1
2021-12-13 09:08:33 -05:00
jeremystretch
66d206a710 Release v3.1.1 2021-12-13 08:51:55 -05:00
jeremystretch
bfc1cab6df Fixes #8051: Contact group parent assignment should not be required under REST API 2021-12-13 08:22:48 -05:00
jeremystretch
5b0c79629e Closes #8047: Display sorting indicator in table column headers 2021-12-10 21:03:24 -05:00
jeremystretch
7922d3909a Fixes #8042: Fix filtering cables list by site slug or rack name 2021-12-10 16:41:03 -05:00
jeremystretch
ee6e2e0af1 Fixes #7690: Fix custom field integer support for MultiValueNumberFilter 2021-12-10 16:34:38 -05:00
jeremystretch
326a6be91c #7519: Update REST API tests 2021-12-10 15:45:22 -05:00
jeremystretch
58095e1916 Fixes #8038: Placeholder filter should display zero integer values 2021-12-10 15:38:51 -05:00
jeremystretch
3dae077b4d Fixes #8035: Redirect back to parent prefix after creating IP address(es) where applicable 2021-12-10 15:34:12 -05:00
jeremystretch
7c14c0812b Fixes #7519: Return a 409 status for unfulfillable available prefix/IP requests 2021-12-10 15:11:45 -05:00
Jeremy Stretch
3a05eda63a Merge pull request #8039 from netbox-community/5869-available-prefixes
Fixes #5869: Fix permissions evaluation under available prefix/IP REST API endpoints
2021-12-10 14:22:29 -05:00
jeremystretch
d850b3ac7e Fix available prefix creation test 2021-12-10 13:58:11 -05:00
jeremystretch
08de6c32c9 Changelog for #5869 2021-12-10 13:26:56 -05:00
jeremystretch
91fe158c26 Restore endpoint schema documentation 2021-12-10 13:23:49 -05:00
jeremystretch
661b3c4bfb Fix queryset restrictions 2021-12-10 12:52:48 -05:00
jeremystretch
35eabc0353 Move available IPs endpoints to separate views 2021-12-10 12:37:55 -05:00
jeremystretch
ef5bbdb1e2 Move available prefixes endpoint to its own view 2021-12-10 11:40:57 -05:00
jeremystretch
88fae2171d Closes #7691: Remove field_order from filterset forms 2021-12-10 08:57:19 -05:00
jeremystretch
de698154cd Fixes #8030: Validate custom field names 2021-12-09 15:19:19 -05:00
jeremystretch
1df05715c2 Fixes #8033: Fix display of zero values for custom integer fields in tables 2021-12-09 14:56:12 -05:00
jeremystretch
e5524da40e Fixes #8009: Validate IP addresses for uniqueness when creating an FHRP group 2021-12-09 13:46:19 -05:00
jeremystretch
50d393e0f9 Clean up user preferences view 2021-12-08 16:36:06 -05:00
jeremystretch
cd08836f3e Refresh user profile view; add recent activity 2021-12-08 16:32:31 -05:00
jeremystretch
45ac1cfd54 Fixes #8019: Exclude metrics endpoint when LOGIN_REQUIRED is true 2021-12-08 15:47:41 -05:00
jeremystretch
dda11ec69e Fixes #8003: Fix cable tracing across bridged interfaces with no cable 2021-12-08 11:35:50 -05:00
jeremystretch
7be6206d9d Fixes #8010: Allow filtering devices by multiple serial numbers 2021-12-08 11:08:19 -05:00
jeremystretch
4d896573b1 Fixes #8005: Fix contact email display 2021-12-08 11:04:03 -05:00
jeremystretch
988383648c Fixes #8001: Correct verbose name for wireless LAN group model 2021-12-08 10:45:27 -05:00
Daniel Sheppard
d59847537d Fix #7990 - Fix title display on contact view 2021-12-07 10:58:44 -06:00
jeremystretch
36859d89c8 Fixes #7996: Show WWN field in interface creation form 2021-12-07 10:59:08 -05:00
Christian Jonak-Möchel
cc50e22928 feat: add 6GHz & 60Ghz channels 2021-12-07 15:14:17 +01:00
William Irvine
13414dcd25 pep8 compliance... 2021-12-07 10:13:54 +13:00
jeremystretch
ba8b593351 PRVB 2021-12-06 16:13:48 -05:00
William Irvine
aebfccfd4b Merge branch 'develop' into develop 2021-12-07 10:06:35 +13:00
Jeremy Stretch
5a59f2352c Merge pull request #7986 from netbox-community/develop
Release v3.1.0
2021-12-06 16:00:19 -05:00
jeremystretch
5164b78da1 Release v3.1.0 2021-12-06 15:01:36 -05:00
jeremystretch
5561b46a59 Finalize release notes 2021-12-06 14:58:49 -05:00
jeremystretch
26b2431cbf Bump django-taggit to 2.0.0 2021-12-06 14:38:13 -05:00
jeremystretch
029605f926 Clean up site view 2021-12-06 13:43:02 -05:00
jeremystretch
0cd173f9df Update django-taggit to 2.0 2021-12-06 13:25:09 -05:00
jeremystretch
414810bdf5 Update required dependencies 2021-12-06 13:15:17 -05:00
jeremystretch
f94c1e91ea Merge branch 'develop' into feature 2021-12-06 12:10:31 -05:00
Jeremy Stretch
b7129e1456 Merge pull request #7984 from netbox-community/develop
Release v3.0.12
2021-12-06 12:07:04 -05:00
jeremystretch
dc6decd404 Release v3.0.12 2021-12-06 11:54:50 -05:00
jeremystretch
40c6b172f7 Fixes #7981: Fix Markdown sanitization regex 2021-12-06 11:33:00 -05:00
thatmattlove
7cb9cedfe1 Fixes #7823: Properly handle return_url when Save & Continue button is present 2021-12-03 16:20:05 -07:00
jeremystretch
b43980d660 Fixes #7960: Prevent creation of regions/site groups/locations with duplicate names (see #7354) 2021-12-03 15:09:56 -05:00
jeremystretch
09b612546b Omit actions column from non-paginated child object tables 2021-12-03 11:07:16 -05:00
jeremystretch
a99d14c13f Closes #7924: Include child groups on contact group view 2021-12-03 11:00:00 -05:00
jeremystretch
68f322a03b Closes #7925: Linkify contact phone and email attributes 2021-12-03 10:51:24 -05:00
jeremystretch
97f0414ff3 Changelog for #7751, #7885, #7892 2021-12-03 09:51:05 -05:00
Jeremy Stretch
d5f308d9c9 Merge pull request #7928 from kkthxbye-code/fix-7751
Fix #7751: LDAP: Only get API user from ldap when FIND_GROUP_PERMS is on
2021-12-03 09:48:58 -05:00
Jonathan Senecal
1377eda0ba Add support for L22-30P power port type (#7915)
* Add support for L22-30P power port type

Fixes #7892

* Add support for L22-30R power outlet type
2021-12-03 09:43:42 -05:00
Jeremy Stretch
70259b0d04 Merge pull request #7970 from rhyser9/7885_linkify_vlan_name
Fixes #7885: Linkify VLAN name in VLAN tables
2021-12-03 09:41:28 -05:00
Rhys Barrie
f1466d6da3 netbox-community/netbox#7885: Linkify VLAN name in VLAN tables 2021-12-02 12:27:30 -05:00
Will Irvine
ca07a88674 fix spelling... 2021-12-02 10:47:19 +13:00
jeremystretch
83010e278c Add changelog for #7932, #7941 2021-12-01 09:18:31 -05:00
Will Irvine
dcfd332cbf Moved filtering logic to utils, adjusted show buttons 2021-12-01 19:24:44 +13:00
thatmattlove
dc3040550d Merge branch 'fast-filter' into develop 2021-11-30 10:10:38 -07:00
Daniel Sheppard
3b25db919a Update changelog for #7940 2021-11-30 09:43:14 -06:00
Daniel Sheppard
09f038f997 Merge pull request #7941 from bluikko/patch-9
Add multistandard ITA power outlet type
2021-11-30 09:37:53 -06:00
bluikko
bbdd3804c7 Add multistandard ITA power outlet type 2021-11-26 10:06:52 +07:00
kkthxbye
a0b9ac7bcc UI: Improve performance of the quick filter 2021-11-25 12:14:07 +01:00
kkthxbye
8bb0cba949 Fix #7751 - LDAP: Only get API user from ldap when FIND_GROUP_PERMS is enabled 2021-11-25 08:09:50 +01:00
jeremystretch
870aa3a265 Merge branch 'develop' into feature 2021-11-24 14:00:37 -05:00
jeremystretch
86ada33577 PRVB 2021-11-24 13:58:57 -05:00
Jeremy Stretch
869808b3f9 Merge pull request #7922 from netbox-community/develop
Release v3.0.11
2021-11-24 13:51:17 -05:00
jeremystretch
57ccbf44b8 Release v3.0.11 2021-11-24 13:25:57 -05:00
jeremystretch
416caa8f50 Hide code blocks when not needed 2021-11-24 13:17:59 -05:00
jeremystretch
1e42fecf66 Changelog for #7657 2021-11-24 09:15:30 -05:00
Jeremy Stretch
c9b00891ed Merge pull request #7861 from netbox-community/7657-threadsafe-changelog
Fixes #7657: Make request/webhook caching thread-safe
2021-11-24 09:06:48 -05:00
Jeremy Stretch
497eacbea3 Merge pull request #7898 from ypid/fix/7897
CEE 7/5 exists as power port and power outlet. It is only a power port.
2021-11-22 13:45:08 -05:00
jeremystretch
f90c591c78 Fixes #7890: Correct typo 2021-11-22 13:36:51 -05:00
Robin Schneider
175498940e Fixes #7897: CEE 7/5 is only a power outlet, no power port
Ref:

* https://en.wikipedia.org/wiki/CEE_7_standard_AC_plugs_and_sockets#CEE_7/5_socket_and_CEE_7/6_plug_(French;_Type_E)
* https://blog.packetsar.com/wp-content/uploads/Power_and_Cooling_Cheat_Sheet.pdf
2021-11-21 23:41:36 +01:00
Robin Schneider
eded00cbb3 chore: Always use "CEE 7" (with the space) consistently 2021-11-21 22:23:29 +01:00
jeremystretch
b7c9ca720a Closes #7886: Introduce a base FilterForm class 2021-11-19 15:12:45 -05:00
jeremystretch
7072f207c0 Call out all models with cable_peer name changes 2021-11-19 11:42:34 -05:00
jeremystretch
5f59f458f4 Fixes #7880: Include assigned IP addresses in FHRP group object representation 2021-11-19 11:34:59 -05:00
jeremystretch
b6fe613329 Fix redirection after creating FHRP group assignment 2021-11-19 10:42:13 -05:00
jeremystretch
cd128e557c Closes #7884: Add FHRP groups column to interface tables 2021-11-19 10:27:56 -05:00
Jeremy Stretch
30a5c70260 Merge pull request #7878 from netbox-community/7877-bootstrapmixin-cleanup
Closes #7877: BootstrapMixin cleanup
2021-11-18 17:05:29 -05:00
jeremystretch
beca978af5 Clean up imports 2021-11-18 16:48:29 -05:00
jeremystretch
98a830a6a0 Apply BootstrapMixin to ComponentForm 2021-11-18 16:32:22 -05:00
jeremystretch
ed2231e34b Apply BootstrapMixin to CustomFieldModelFilterForm 2021-11-18 16:27:06 -05:00
jeremystretch
55049bb303 Apply BootstrapMixin to BulkEditForm 2021-11-18 16:23:26 -05:00
jeremystretch
c210c6937b Apply BootstrapMixin to CustomFieldModelForm 2021-11-18 16:19:25 -05:00
jeremystretch
d2767f39f0 Closes #7850: Add note about where to assign FHRP groups 2021-11-18 15:12:12 -05:00
jeremystretch
1c9d39d3e6 Fix REST API version reporting for beta releases 2021-11-18 11:19:00 -05:00
jeremystretch
f16c6d81cf Merge branch 'develop' into feature 2021-11-18 11:06:54 -05:00
jeremystretch
e8d6281007 Changelog for #7399 2021-11-18 10:02:23 -05:00
Jeremy Stretch
8299845615 Merge pull request #7676 from kkthxbye-code/develop
Fix #7399: LDAP excessive CPU usage when AUTH_LDAP_FIND_GROUP_PERMS is enabled
2021-11-18 09:58:34 -05:00
jeremystretch
9ae5865c2d Fixes #7865: REST API should support null values for console port speeds 2021-11-18 09:34:41 -05:00
jeremystretch
c2d0cfdfc0 Fixes #7864: power_port can be null when creating power outlets 2021-11-18 09:27:45 -05:00
Jeremy Stretch
5dd252731e Merge pull request #7863 from etcet/sudo-ln-s
Fixes #7862: Docs: Link housekeeping cron using sudo
2021-11-18 09:16:55 -05:00
Chris James
7b9436d2b9 Docs: Run ln with sudo 2021-11-17 20:33:42 -06:00
jeremystretch
6a369ac985 Closes #7531: Add Markdown support for strikethrough formatting 2021-11-17 16:50:23 -05:00
jeremystretch
23d90823a3 Fixes #7720: Fix initialization of custom script MultiObjectVar field with multiple values 2021-11-17 16:22:47 -05:00
jeremystretch
4bfb6b476c Fixes #7859: Fix styling of form widgets under cable connection views 2021-11-17 15:53:26 -05:00
jeremystretch
0d60099588 Move request object and webhook queue to TLS 2021-11-17 15:12:19 -05:00
jeremystretch
9a45547cda Closes #5143: Include a device's asset tag in its display value 2021-11-17 13:06:57 -05:00
jeremystretch
a000ded350 Remove "primary for" references to Device on IPAddress 2021-11-17 12:50:46 -05:00
jeremystretch
424ac29131 Closes #7812: Enable change logging for image attachments 2021-11-17 11:52:50 -05:00
jeremystretch
b7b5a5788f Fixes #7589: Correct 128GFC interface type identifier 2021-11-17 11:18:41 -05:00
jeremystretch
9de179cba8 Closes #7858: Standardize the representation of content types across import & export functions 2021-11-17 11:02:22 -05:00
jeremystretch
94069e76c9 Fixes #7857: Fix ordering IP addresses by assignment status 2021-11-17 08:51:17 -05:00
jeremystretch
df9d67b873 Fixes #7851: Add missing cluster name filter for virtual machines 2021-11-17 08:48:09 -05:00
jeremystretch
6f7fbf7686 Fixes #7849: Fix exception when creating an FHRPGroup with an invalid IP address 2021-11-16 16:50:20 -05:00
jeremystretch
f32e694499 Fixes #7739: Fix exception when tracing cable across circuit with no far end termination 2021-11-15 12:41:57 -05:00
jeremystretch
e5900a3fe3 Correct changelog for #7729 2021-11-15 09:04:18 -05:00
jeremystretch
6e151b044d Changelog for #7229, #7424, #7542 2021-11-15 08:56:03 -05:00
Jeremy Stretch
516bea6a0a Merge pull request #7829 from rhyser9/7542_prefix_vlan_group_column
Fix #7542: Add VLAN Group column to IP Prefix table
2021-11-15 08:54:30 -05:00
Jeremy Stretch
496cabcc53 Merge pull request #7828 from rhyser9/7229_bug_add_vlans_link
Fix #7229: Fix context of VLAN table in VLAN Group view
2021-11-15 08:52:36 -05:00
Jeremy Stretch
d051db5083 Merge pull request #7827 from rhyser9/7424_virtualchassis_id_filter
Fix #7424: Add virtual_chassis_id filter for device components
2021-11-15 08:43:45 -05:00
Rhys Barrie
660fc23e15 netbox-community/netbox#7542: Add VLAN Group column to IP Prefix table 2021-11-13 23:29:26 -05:00
Rhys Barrie
a5a480133f netbox-community/netbox#7229: Fix context of VLAN table in VLAN Group view 2021-11-13 23:08:46 -05:00
Rhys Barrie
68b544c676 netbox-community/netbox#7424: add filterset test for virtual_chassis_id 2021-11-13 22:16:18 -05:00
Rhys Barrie
a8c958ece2 netbox-community/netbox#7424: fix test failure from adding virtual chassis filter field 2021-11-13 22:01:15 -05:00
Rhys Barrie
f77f7ca0ec netbox-community/netbox#7424:make device component device field filter from selected virtual chassis 2021-11-13 21:35:13 -05:00
Rhys Barrie
6b21c8453f netbox-community/netbox#7424: Add virtual_chassis field to device component filter form 2021-11-13 21:33:52 -05:00
Rhys Barrie
fa8a8abc98 netbox-community/netbox#7424: Add virtual_chassis and virtual_chassis_id filter to device components 2021-11-13 21:30:38 -05:00
Will Irvine
80048bfa2b Make the same changes for aggregate views as these use the same adjusted functions 2021-11-13 16:42:38 +13:00
Will Irvine
641a9bc6c5 pep8 compliance 2021-11-13 15:26:07 +13:00
Will Irvine
0edf9b17f6 Closes #7665 add new boolen for filtering assigned prefixes, adjust current filter for avaliabile prefixes to only return avaliable 2021-11-13 13:27:49 +13:00
Jeremy Stretch
98cc36c458 Merge pull request #7824 from netbox-community/2101-q-filters
Closes #2101: Ensure all relevant models have a general purpose search filter
2021-11-12 15:48:19 -05:00
jeremystretch
f3beabba69 Changelog for #2101 2021-11-12 15:33:49 -05:00
jeremystretch
467fa5a847 Add q filters for Token and ObjectPermission filter sets 2021-11-12 15:30:16 -05:00
jeremystretch
50f283cf28 Add q filter for extras models 2021-11-12 15:26:58 -05:00
jeremystretch
f49d7008a0 Add q filters for connection lists 2021-11-12 15:05:33 -05:00
jeremystretch
1fed564c47 Clean up script & report lists 2021-11-12 14:44:14 -05:00
jeremystretch
bb99c3e6f9 Changelog for #7803, #7810 2021-11-12 13:46:06 -05:00
Jeremy Stretch
8820cac792 Merge pull request #7820 from kkthxbye-code/script-reload
Fix #7803: Clear sys.modules cache when reloading scripts
2021-11-12 13:44:42 -05:00
Jeremy Stretch
ada911c20b Merge pull request #7816 from byts-tech/FR7810
Fixes: #7810 Add IEEE 802.15.1 Interface Type
2021-11-12 13:40:41 -05:00
jeremystretch
17e01644f5 Fixes #7813: Fix handling of errors during export template rendering 2021-11-12 13:32:52 -05:00
kkthxbye
9458521f3e Merge branch 'netbox-community:develop' into script-reload 2021-11-12 17:07:11 +01:00
Flo
8aa73c5900 Add IEEE 802.15.1 Interface Type 2021-11-12 16:05:42 +01:00
jeremystretch
500f213c6b Fix erroneous merge resolution 2021-11-12 09:29:55 -05:00
jeremystretch
cede27b5fe Merge branch 'develop' into feature 2021-11-12 09:09:15 -05:00
jeremystretch
c0ca1eaf90 PRVB 2021-11-12 08:54:08 -05:00
Jeremy Stretch
b29a5511df Merge pull request #7815 from netbox-community/develop
Release v3.0.10
2021-11-12 08:50:43 -05:00
jeremystretch
49e77841e0 Release v3.0.10 2021-11-12 08:36:33 -05:00
jeremystretch
daf6c8e327 Fixes #7814: Fix restriction of user & group objects in GraphQL API queries 2021-11-12 08:23:58 -05:00
jeremystretch
9f8068e8d1 Fixes #7808: Fix reference values for content type under custom field import form 2021-11-11 16:21:27 -05:00
jeremystretch
0b705553a5 Fixes #7809: Add missing export template support for various models 2021-11-11 16:16:54 -05:00
jeremystretch
a799094227 Fixes #7788: Improve XSS mitigation in Markdown renderer 2021-11-11 15:38:34 -05:00
jeremystretch
d529c1b5b3 Housekeeping: Use RestrictedQuerySet for default manager on base models 2021-11-11 15:04:22 -05:00
jeremystretch
834f68e6e4 Fixes #7761: Extend cable tracing across bridged interfaces 2021-11-11 14:45:10 -05:00
jeremystretch
83b2102705 Closes #7769: Enable assignment of IP addresses to an existing FHRP group 2021-11-11 14:05:35 -05:00
jeremystretch
2f064cdfd1 Changelog for #7767 2021-11-11 12:30:28 -05:00
Jeremy Stretch
6c28182dd3 Merge pull request #7767 from CironAkono/FR6925
Fixes: #6925 Interfaces Table - bring back the visual aids from v2.9
2021-11-11 12:29:01 -05:00
jeremystretch
3cb8c5db28 Fixes #7654: Fix assignment of members to virtual chassis with initial position of zero 2021-11-11 12:10:47 -05:00
CironAkono
251abdb4dd Apply suggestions from code review
Co-authored-by: Jeremy Stretch <jstretch@ns1.com>
2021-11-11 16:36:13 +00:00
jeremystretch
726e4df54b Changelog for #7791 2021-11-11 11:31:51 -05:00
Jeremy Stretch
bd32a6ac8e Merge pull request #7804 from kkthxbye-code/fix-7791
Fix #7791 - Allow devicebay table to be sorted by status
2021-11-11 10:46:15 -05:00
jeremystretch
27d7400c36 Fixes #7802: Differentiate ID and VID columns in VLANs table 2021-11-11 10:23:38 -05:00
kkthxbye-code
53e52aeaa8 Fix sorting devicebay table by status 2021-11-11 14:05:39 +01:00
kkthxbye-code
ae6ed97a80 Clear sys.modules cache when reloading scripts 2021-11-11 11:53:31 +01:00
jeremystretch
34f24de3e4 Fixes #7757: Fix 404 when assigning multiple contacts/FHRP groups in succession 2021-11-09 17:08:28 -05:00
jeremystretch
f93d6813a9 Merge branch 'develop' into feature 2021-11-09 16:52:36 -05:00
jeremystretch
3ad773beb3 Fixes #7741: Fix 404 when attaching multiple images in succession 2021-11-09 16:46:58 -05:00
jeremystretch
be91235858 Changelog for #7740 2021-11-09 16:08:11 -05:00
Jeremy Stretch
95fc0bbc94 Merge pull request #7774 from byts-tech/FR7740
Fixes: #7740 Add Mini-DIN 8 Console-Port-Type
2021-11-09 16:06:58 -05:00
jeremystretch
9dad7e4daf Fixes #7701: Fix conflation of assigned IP status & role in interface tables 2021-11-09 16:04:16 -05:00
jeremystretch
d08ed9fe5f Fixes #7780: Preserve mutli-line values during CSV file import 2021-11-09 15:24:21 -05:00
jeremystretch
82210cc116 Changelog for #7783 2021-11-09 15:15:34 -05:00
Jeremy Stretch
94d3e76517 Merge pull request #7785 from jasonyates/develop
Fixes #7783 - Site location visual changes
2021-11-09 15:12:47 -05:00
Jason Yates
3f72492a59 Fixed #7783 - Site location visual changes
Updating site location list to visually match the /dcim/locations list where child locations are "indtended" with mdi-circle-small.

Also removes the padding-left attribute on each row as it is no longer functional.
2021-11-09 15:18:46 +00:00
Jeremy Stretch
c0653da736 Merge pull request #7778 from netbox-community/7775-dynamic-config
7775 dynamic config
2021-11-08 15:54:25 -05:00
jeremystretch
f3d8f1b1fb Changelog for #7775 2021-11-08 15:38:55 -05:00
jeremystretch
d2391b9c63 Move GRAPHQL_ENABLED to dynamic configuration 2021-11-08 15:31:09 -05:00
jeremystretch
f8e44c09eb Move CUSTOM_VALIDATORS to dynamic configuration 2021-11-08 15:22:29 -05:00
jeremystretch
2a00519b93 Move CHANGELOG_RETENTION to dyanmic configuration 2021-11-08 15:07:58 -05:00
jeremystretch
3292a2aecc Closes #7619: Permit custom validation rules to be defined as plain data or dotted path to class 2021-11-08 14:52:56 -05:00
Flo
b7aa44837f Add Mini-DIN 8 Console-Port-Type 2021-11-08 17:50:13 +01:00
jeremystretch
17fd6e692e Fixes #7768: Validate IP address status when creating a new FHRP group 2021-11-08 08:40:24 -05:00
jeremystretch
2ce8ef5704 Fixes #7771: Group assignment should be optional when creating contacts via REST API 2021-11-08 08:34:10 -05:00
jeremystretch
7b7afd3e7b Changelog for #7765 2021-11-08 08:24:14 -05:00
Nico Domino
9c2514fce4 feat: add outer_width to RackTable (#7766)
* feat: add outer_width to RackTable

* fix: add outer_units to column display

* feat: add outer_depth to available columns
2021-11-08 08:15:26 -05:00
jeremystretch
e04402ed57 Allow bypassing the pre-commit script with NOVALIDATE=1 2021-11-05 13:40:38 -04:00
jeremystretch
3eda8d8482 Closes #7760: Add vid filter field to VLANs list 2021-11-05 13:31:36 -04:00
jeremystretch
79f2f03fb2 Issues policy tweaks 2021-11-05 13:26:18 -04:00
jeremystretch
f7d0db9cd2 Fixes #7756: Fix AttributeError exception when editing an IP address assigned to a FHRPGroup 2021-11-05 13:16:43 -04:00
jeremystretch
fab1d3651b Add new models to developer docs 2021-11-05 13:10:27 -04:00
jeremystretch
e5d7578663 Fixes #7750: Fix cable trace image link 2021-11-05 11:10:17 -04:00
jeremystretch
cf80c1a506 Release v3.1-beta1 2021-11-05 09:03:27 -04:00
jeremystretch
4649ab2d85 Merge branch 'develop' into feature 2021-11-05 08:49:25 -04:00
jeremystretch
773fd47ca6 Fixes #7752: Fix minimum version check under Python v3.10 2021-11-05 08:45:57 -04:00
jeremystretch
2fd526b359 Fix up contact template 2021-11-05 08:33:16 -04:00
kkthxbye-code
830cf4b31f Fix #7399 - LDAP using excessive CPU when AUTH_LDAP_FIND_GROUP_PERMS is enabled 2021-11-05 10:28:30 +01:00
jeremystretch
2826f27153 Split interface edit forms into subsections 2021-11-04 16:36:49 -04:00
jeremystretch
83ac869693 Fix ASNs column in SiteTable 2021-11-04 16:29:43 -04:00
jeremystretch
bc92f9221a Tweak site ASN filters & tests 2021-11-04 16:22:55 -04:00
jeremystretch
c2f85a2877 #6732: Show sites table under ASN view 2021-11-04 16:16:59 -04:00
jeremystretch
0bbd186635 Rearrange site view layout 2021-11-04 15:58:52 -04:00
jeremystretch
806dcd74ec Split circuits models into submodules 2021-11-04 15:58:17 -04:00
jeremystretch
93772e7265 Move remote authentication config parameters to a separate page 2021-11-04 15:41:46 -04:00
jeremystretch
9094f07290 Fix config revision form help texts 2021-11-04 15:35:17 -04:00
jeremystretch
0aae155c80 Refresh installation docs 2021-11-04 15:18:58 -04:00
jeremystretch
54233aba1b Remove extraneous slug field from contact import form 2021-11-04 14:23:24 -04:00
jeremystretch
bd3d2c60d9 FHRP groups cleanup 2021-11-04 14:19:10 -04:00
jeremystretch
2e75a111ed Fix return URLs for contact assignment edit/delete 2021-11-04 14:09:12 -04:00
jeremystretch
e4b0359b8e Include action buttons on contact assignments table 2021-11-04 14:01:07 -04:00
jeremystretch
803e0bfe72 #1344: Show object type & name when assigning a contact 2021-11-04 13:44:02 -04:00
jeremystretch
a5024a65a0 Add warning for Python 3.7 2021-11-04 13:32:52 -04:00
jeremystretch
734a00237a Clean up FHRP group filterset tests 2021-11-04 13:23:02 -04:00
jeremystretch
06f1d15283 Introduce create_test_virtualmachine() 2021-11-04 13:22:21 -04:00
jeremystretch
ff3edc9889 Add NestedContactAssignmentSerializer; add contact assignment API tests 2021-11-04 11:55:00 -04:00
jeremystretch
8f1acb700d Fix ID list creation in API tests 2021-11-04 11:31:39 -04:00
jeremystretch
519884d167 Invert default priority ordering for FHRPGroupAssignment 2021-11-04 11:17:10 -04:00
jeremystretch
3f0a98acbd Add nested FHRPGroupAssignment serializer; add missing API tests 2021-11-04 11:15:34 -04:00
jeremystretch
c023e5f518 Fix up FHRPGroupAssignmentTable 2021-11-04 10:05:47 -04:00
jeremystretch
67c73768c1 Add count_fhrp_groups to interface serializers 2021-11-04 09:58:33 -04:00
jeremystretch
bbb98083eb Clean up filtersets 2021-11-03 16:58:31 -04:00
jeremystretch
8bb9f4b8a2 #1344: Add missing object field to ContactAssignmentSerializer 2021-11-03 16:27:43 -04:00
jeremystretch
96cde7d4af Add wireless_lans to InterfaceSerializer; extend tests 2021-11-03 15:55:16 -04:00
jeremystretch
ea39c8a4c1 Optimize interface REST API endpoints 2021-11-03 15:38:17 -04:00
jeremystretch
7a55832a22 #6732: Add asns relationship to SiteSerializer and extend tests 2021-11-03 15:24:15 -04:00
jeremystretch
7a97d5d4eb Changelog for #6732; misc fixes 2021-11-03 14:40:14 -04:00
Jeremy Stretch
8305f6d1f5 Merge pull request #7662 from netbox-community/6732-asn-model
Closes: #6732 - Add new ASN model
2021-11-03 14:15:24 -04:00
jeremystretch
dcececf9c0 Improve documentation and testing for conditions 2021-11-03 14:02:43 -04:00
jeremystretch
839afe5ac0 Improve webhook tests 2021-11-03 14:01:59 -04:00
Daniel Sheppard
c72f25c693 #6732 - Add documentation 2021-11-03 12:22:44 -05:00
Daniel Sheppard
5fc373f5cc Merge feature -> develop 2021-11-03 12:05:11 -05:00
Daniel Sheppard
cf9eaf2eff Fix dcim/views.py merge error 2021-11-03 11:36:54 -05:00
jeremystretch
04d145d6d8 Add summary page to release notes 2021-11-03 11:47:11 -04:00
Daniel Sheppard
76d73abd81 Update ip.py 2021-11-03 10:04:26 -05:00
Daniel Sheppard
0ec0185d84 Fix Migration 2021-11-03 09:51:03 -05:00
jeremystretch
7b1335825b Closes #7687: Update CentOS installation docs 2021-11-03 10:47:17 -04:00
jeremystretch
2c2e37e9f0 Merge branch 'develop' into feature 2021-11-03 10:29:02 -04:00
Daniel Sheppard
25957bfae3 Fix migration issues 2021-11-03 08:56:04 -05:00
jeremystretch
11e2200acf PRVB 2021-11-03 09:51:28 -04:00
Jeremy Stretch
f5356b84f6 Merge pull request #7730 from netbox-community/develop
Release v3.0.9
2021-11-03 09:47:37 -04:00
Daniel Sheppard
db2d71ed9e Merge branch 'feature' into 6732-asn-model 2021-11-03 08:37:11 -05:00
jeremystretch
1bf100ba15 Release v3.0.9 2021-11-03 09:32:57 -04:00
jeremystretch
7614f423e5 #7612: Use escape() rather than strip_tags() 2021-11-03 08:56:30 -04:00
jeremystretch
318c8b85e9 Fixes #7721: Retain pagination preference when MAX_PAGE_SIZE is zero 2021-11-03 08:25:50 -04:00
jeremystretch
7085fe77da Changelog for #6529 2021-11-03 08:11:38 -04:00
Jeremy Stretch
2e20d7f02b Merge pull request #7677 from netbox-community/6529-command-line-run-scripts
#6529 - Add CLI to run scripts
2021-11-03 08:10:36 -04:00
Steven
831065b5a1 #7717 Missing tags column definition in IP range table (#7724) 2021-11-03 08:05:34 -04:00
Daniel Sheppard
b97167e841 Fix PEP8 error 2021-11-02 21:40:40 -05:00
Daniel Sheppard
19bacc9e23 #6529 - Adjusted the arguments. Fixed documentation 2021-11-02 21:37:11 -05:00
jeremystretch
61b61b1bc0 Fixes #7664: Preserve initial form data when bulk edit validation fails 2021-11-02 17:07:30 -04:00
Daniel Sheppard
7c3318df92 #6529 - Adjusted the arguments. Added documentation 2021-11-02 15:56:42 -05:00
jeremystretch
d0b85586b9 Changelog & cleanup for #6930 2021-11-02 16:24:28 -04:00
Rhys Barrie
cef0d168a5 Closes #6930: Add 'ID' column to object tables (#7673)
* netbox-community/netbox#6930: Add ID column to devices, device types, and components

* netbox-community/netbox#6930: Add ID column to sites, racks, and tenants

* netbox-community/netbox#6930: Add ID column to power, providers, TODO circuits

* netbox-community/netbox#6930: Add ID column to virtualization tables

* netbox-community/netbox#6930: Add ID column to IPAM tables

* netbox-community/netbox#6930: Add ID column to 'extras' tables

* netbox-community/netbox#6930: Move ID column to BaseTable class

* netbox-community/netbox#6930: Don't linkify ID in device component template tables

* netbox-community/netbox#6930: Don't show ID column in interface/console/power connections tables

* netbox-community/netbox#6930: Don't show ID column in device component template tables

* netbox-community/netbox#6930: Add ID column to ObjectJournal, DeviceImport, and Circuit tables

* Exclude ID column from selected tables

* netbox-community/netbox#6930:revert default columns on ObjectChangeTable, not configurable

* netbox-community/netbox#6930: Add object ID to tagged objects table in tag detail view

Co-authored-by: Jeremy Stretch <jstretch@ns1.com>
2021-11-02 16:21:34 -04:00
jeremystretch
3a192223a3 Changelog & cleanup for #7668, #7717 2021-11-02 15:58:14 -04:00
Jeremy Stretch
288a1d23e5 Merge pull request #7693 from rhyser9/7668_location_detail_elevation
Closes #7668: Add 'View Elevations' button to location detail page
2021-11-02 15:53:09 -04:00
Jeremy Stretch
7c05db8e2f Merge pull request #7718 from cybarox/7717-fix-tags-missing-from-ip-ranges-table-fields
Closes #7717 Missing tags column in IP range table
2021-11-02 15:49:35 -04:00
Jeremy Stretch
18080a969e Merge pull request #7714 from netbox-community/6235-fhrp
Closes #6235: FHRP group modeling
2021-11-02 15:43:40 -04:00
jeremystretch
412430e1c3 Docs & changelog for #6235 2021-11-02 15:26:45 -04:00
jeremystretch
131e433880 Rename FHRPGroupAssignment object to interface 2021-11-02 15:10:02 -04:00
Daniel Sheppard
b7c0e8b71f #6529 - Streamline code and resolve some issues 2021-11-02 13:12:12 -05:00
jeremystretch
264652f2c3 REST API optimizations 2021-11-02 14:08:36 -04:00
jeremystretch
2cb53a0f7e Clean up FHRP group templates, forms 2021-11-02 13:32:41 -04:00
Daniel Sheppard
7625a2dd3c #6732 - Swap ASN M2M to Site model and update some templates/filters 2021-11-02 12:26:06 -05:00
jeremystretch
93da5a39be Make assignment priority a required field 2021-11-02 13:22:00 -04:00
jeremystretch
aeb4996ac2 Allow users to create new FHRP group directly from the interface view 2021-11-02 13:06:58 -04:00
Daniel Sheppard
330c498fe4 Merge feature 2021-11-02 11:16:01 -05:00
Daniel Sheppard
5d0a7cb307 #6732 - Remove migration 2021-11-02 11:10:50 -05:00
Daniel Sheppard
8c27ff3859 #6732 - Add ASN back to filtersets 2021-11-02 11:07:19 -05:00
jeremystretch
736d6cb675 Merge branch 'feature' into 6235-fhrp 2021-11-02 12:05:34 -04:00
Jeremy Stretch
200aca470b Merge pull request #7709 from netbox-community/7649-social-auth
Closes #7649: Add support for SSO
2021-11-02 12:04:58 -04:00
jeremystretch
b2dc6c5d3d Changelog & initial docs for #7649 2021-11-02 11:49:10 -04:00
cybarox
a5ec0ee277 Closes #7717 Missing tags column in IP range table 2021-11-02 15:14:08 +01:00
jeremystretch
f48d7aedce Enable filtering FHRP groups by related IP addresses 2021-11-02 09:56:52 -04:00
jeremystretch
bb4f3e1789 Initial work on #6235 2021-11-01 16:56:30 -04:00
jeremystretch
e0230ed104 Remove errant URL path 2021-11-01 13:32:02 -04:00
jeremystretch
704fdf9ccd Optimize wireless migrations 2021-11-01 11:23:58 -04:00
Rhys Barrie
d528614cbf netbox-community/netbox#7668: Relocate elevations button to location details table 2021-11-01 11:17:15 -04:00
bluikko
b5e8157700 Fix #7685: Doc image links (#7698)
* Fix image link in custom-script.md

* Fix image link in cable.md

* Fix image link in power.md
2021-11-01 09:13:18 -04:00
jeremystretch
339776c139 Initial work on SSO support (WIP) 2021-10-29 17:06:14 -04:00
Daniel Sheppard
87e07e731d #6732 - Removed ASN field hiding 2021-10-29 14:56:58 -05:00
Daniel Sheppard
3991115ae5 #6732 - Fix imports and other small items 2021-10-29 14:54:55 -05:00
Daniel Sheppard
a30e7bf34f #6732 - Add ASN field back to bulk edit 2021-10-29 14:28:13 -05:00
Daniel Sheppard
43b983054a #6732 - Corrected model field definitions 2021-10-29 14:26:19 -05:00
Daniel Sheppard
d3364ef4d1 #6732 - Restore resolve_field to the filterset 2021-10-29 14:15:37 -05:00
Rhys Barrie
24d6941cc4 netbox-community/netbox#7668: Add 'View Elevations' button to location detail page 2021-10-29 14:07:02 -04:00
jeremystretch
4099dd3a05 Closes #6615: Add filter lookups for custom fields 2021-10-29 11:23:56 -04:00
Jeremy Stretch
f420435b82 Merge pull request #7678 from netbox-community/6615-custom-field-filters
Closes #6615: Enable filter lookups for custom fields
2021-10-29 11:21:45 -04:00
jeremystretch
696fe7bc0d Add tests for custom field lookups 2021-10-29 09:45:48 -04:00
Daniel Sheppard
7c147db324 #6732 - Fix test exception in Site form 2021-10-28 16:08:32 -05:00
jeremystretch
32205045ba Use multi-value filters for custom fields 2021-10-28 16:40:51 -04:00
jeremystretch
1ce9192369 Move MACAddressField to utilities 2021-10-28 16:26:31 -04:00
Daniel Sheppard
0a62f75a40 #6529 - Add CLI to run scripts 2021-10-28 15:14:42 -05:00
jeremystretch
2e0f15b35f Automatically add additional lookup filters for custom fields 2021-10-28 16:09:36 -04:00
jeremystretch
7c60089692 Ditch CustomFieldFilter 2021-10-28 15:36:12 -04:00
Daniel Sheppard
0a8788eb97 #6732 - Fix Site form and ASN form 2021-10-28 13:57:36 -05:00
Daniel Sheppard
9565addcd4 #6732 - Fix test failure when sending data 2021-10-28 13:12:55 -05:00
jeremystretch
6377d475fc Refactor generation of additional lookup filters 2021-10-28 14:00:07 -04:00
Daniel Sheppard
fff124ebb1 #6732 - Update migration file 2021-10-28 12:06:41 -05:00
Daniel Sheppard
033db83068 Merge branch 'feature' of https://github.com/netbox-community/netbox into 6732-asn-model 2021-10-28 11:55:20 -05:00
Daniel Sheppard
de5c9ef4b2 #6732 - Add graphql support for new ASN model and fix ASN overflow on longs 2021-10-28 11:49:59 -05:00
Daniel Sheppard
3c261b05d9 #6732 - Fix ASN tests 2021-10-28 11:49:21 -05:00
Daniel Sheppard
ada81e31c9 #6732 - Fix CSV import form 2021-10-28 11:48:50 -05:00
Daniel Sheppard
0f68ecda78 #6732 - Fix hiding of ASN field in Site creation form 2021-10-28 11:47:54 -05:00
Daniel Sheppard
1902e112f6 #6732 - Fix tests for utilities 2021-10-28 11:46:55 -05:00
Daniel Sheppard
96565c31d9 #6732 - ASN should be unique 2021-10-28 10:04:12 -05:00
jeremystretch
aa9e68e121 Tweak preformatted block styling 2021-10-28 10:46:00 -04:00
jeremystretch
15e011ae52 Closes #7452: Add JSON custom field type 2021-10-28 10:29:14 -04:00
jeremystretch
a173083e5b Closes #7606: Model transmit power for interfaces 2021-10-28 09:31:45 -04:00
jeremystretch
33c0c8cf6a Extend dynamic config tests 2021-10-28 09:06:07 -04:00
Daniel Sheppard
9b5f45aee1 #6732 - Serializers 2021-10-27 23:07:04 -05:00
Daniel Sheppard
93de6c9f88 #6732 - Tests 2021-10-27 23:06:37 -05:00
Daniel Sheppard
0ad440fea5 #6732 - GraphQL support 2021-10-27 23:06:09 -05:00
Daniel Sheppard
8235b339ee #6732 - Revert some changes to legacy ASN field on site model
* Re-instates ASN field on Site model
* Re-instates ASN field on Site view
* Re-instates ASN field on edit form and API, except for where forms instances are new (add site) or instance does not have any existing AS data
* Does not re-instate asn field on SiteBulkEditForm
* Does not re-instate ASN field on SiteTable
* Does not re-instate filter for filterset, but does allow filtering by query (q=34342)
* Does not include tests for ASN field on Site model due to planned deprecation
2021-10-27 22:25:31 -05:00
Daniel Sheppard
3185cd0b1f #6732 - Correct incorrect field definition in field order 2021-10-27 21:31:59 -05:00
Jeremy Stretch
3a85edba3d Merge pull request #7648 from netbox-community/5883-dyanmic-config
Closes #5883: Enable dynamic configuration of some settings
2021-10-27 16:48:59 -04:00
jeremystretch
a573a35349 Use a key prefix for cache values when running tests 2021-10-27 16:33:59 -04:00
jeremystretch
d67d3f8d6d Add initial tests for dynamic config 2021-10-27 15:58:54 -04:00
jeremystretch
1e317f82f5 Move config parameter value population to ConfigRevisionForm init 2021-10-27 15:55:51 -04:00
jeremystretch
acdebea7f1 Improve visibility of modified values 2021-10-27 15:44:42 -04:00
thatmattlove
a090955918 Fixes #7599: Improve color mode handling 2021-10-27 11:34:21 -07:00
jeremystretch
70f71e0f57 Extend admin UI to allow restoring previous config revisions 2021-10-27 14:05:49 -04:00
jeremystretch
dfdeac4968 Fixes #7647: Require interface assignment when designating IP address as primary for device/VM during CSV import 2021-10-27 10:20:17 -04:00
jeremystretch
e84f2e3ad2 Fixes #7601: Correct devices count for locations within global search results 2021-10-27 10:10:14 -04:00
jeremystretch
98ca4f5b5a Fixes #7643: Fix circuit assignment when creating multiple terminations simultaneously 2021-10-27 10:02:36 -04:00
jeremystretch
87779b7b88 Fixes #7644: Prevent inadvertent deletion of prior change records when deleting objects (#7333 revisited) 2021-10-27 09:44:15 -04:00
jeremystretch
b56cae24c5 Fixes #7628: Fix load_yaml method for custom scripts 2021-10-27 09:04:18 -04:00
jeremystretch
d48a68317d Fixes #7612: Strip HTML from custom field descriptions 2021-10-27 08:41:28 -04:00
jeremystretch
77bd26d17f Work around unapplied migrations when bootstrapping config 2021-10-26 17:28:39 -04:00
jeremystretch
4cdc2601f5 Add descriptions to all config parameters 2021-10-26 16:54:12 -04:00
jeremystretch
ff5c274048 Ensure bootstrapping of config on start 2021-10-26 16:45:53 -04:00
jeremystretch
561e06e7f0 Indicate when dynamic parameters are defined statically 2021-10-26 15:50:33 -04:00
jeremystretch
626a446c3d Docs & changelog for #5883 2021-10-26 15:40:34 -04:00
jeremystretch
26d2da7b98 Initialize Config with empty dict 2021-10-26 14:18:18 -04:00
jeremystretch
66ed39b4b7 Clean up boolean fields 2021-10-26 14:08:03 -04:00
jeremystretch
fbf91dda7d Optimize config queries 2021-10-26 13:41:56 -04:00
jeremystretch
41ff1d0fc9 Add NAPALM config parameters 2021-10-26 11:53:46 -04:00
jeremystretch
64d8512fc3 Add PAGINATE_COUNT, MAX_PAGE_SIZE 2021-10-26 11:43:06 -04:00
jeremystretch
94804fecd8 Add MAINTENANCE_MODE, MAPS_URL 2021-10-26 10:57:33 -04:00
jeremystretch
559dc2f865 Add ALLOWED_URL_SCHEMES 2021-10-26 10:24:33 -04:00
jeremystretch
7c0f32e8ee Introduce ConfigItem; add rack elevation parameters 2021-10-26 10:04:56 -04:00
jeremystretch
82243732a1 Initial work on #5883 2021-10-25 16:10:50 -04:00
jeremystretch
61d2158f76 #6346: Add 'bridge' interface type 2021-10-25 11:11:58 -04:00
jeremystretch
68081fb9a2 Cleanup & API changelog for #3979 2021-10-25 11:07:15 -04:00
Jeremy Stretch
8276933dbb Merge pull request #7630 from netbox-community/6238-conditional-webhooks
Closes #6238: Implement conditional webhooks
2021-10-25 10:42:17 -04:00
jeremystretch
0d84338e28 Add regex condition op 2021-10-25 10:14:18 -04:00
jeremystretch
2423e0872f Documentation & changelog for #6238 2021-10-25 09:52:08 -04:00
jeremystretch
35c967e6f7 Implement condition negation 2021-10-25 09:09:51 -04:00
jeremystretch
b92de63245 Improve validation 2021-10-25 09:01:05 -04:00
Daniel Sheppard
8b529abfe1 Initial work on #6732 2021-10-24 23:47:31 -05:00
Daniel Sheppard
a01068949c Initial work on #6732 2021-10-24 23:42:47 -05:00
Miguel Teixeira
b07e88869a Fix interfaces row colors on device interfaces table 2021-10-24 03:31:29 +01:00
Miguel Teixeira
94bd27bcf5 Fix interface icons on the device interfaces table 2021-10-24 03:24:54 +01:00
jeremystretch
78ecc8673c Add conditions for webhooks 2021-10-22 17:15:08 -04:00
jeremystretch
7e26d92190 Introduce conditions & condition sets 2021-10-22 16:27:08 -04:00
Jeremy Stretch
dbe2f8a6f1 Merge pull request #7622 from netbox-community/6346-interface-bridge
Closes #6346: Bridge group support
2021-10-22 09:37:28 -04:00
jeremystretch
e96f5447f4 Changelog for #6346 2021-10-21 17:03:21 -04:00
jeremystretch
5193fa6483 Add tests for #6346 2021-10-21 16:57:01 -04:00
jeremystretch
e1e2c76ae1 Add bridge field to Interface, VMInterface models 2021-10-21 16:30:18 -04:00
jeremystretch
a3e7cab935 Split tenancy models into separate modules 2021-10-21 15:33:58 -04:00
jeremystretch
c06b3374ce #6497: Add missing tag fields to filter forms 2021-10-21 15:29:52 -04:00
jeremystretch
6f66138a18 Changelog for #3979 2021-10-21 15:15:01 -04:00
Jeremy Stretch
334c97035e Merge pull request #7611 from netbox-community/3979-wireless
Closes #3979: Wireless network modeling
2021-10-21 15:09:08 -04:00
jeremystretch
1c6a84659c #3979 cleanup 2021-10-21 14:20:47 -04:00
jeremystretch
3a3ed8bf64 Merge branch 'feature' into 3979-wireless 2021-10-21 13:19:52 -04:00
Jeremy Stretch
001ab1d067 Merge pull request #7610 from netbox-community/6497-organizational-model-tags
Closes #6297: Extend tag support to organizational models
2021-10-21 11:49:18 -04:00
jeremystretch
4932e4f8c6 Changelog for #6497 2021-10-21 11:28:25 -04:00
jeremystretch
6f05f17c62 Standardize & simplify tags panel inclusion 2021-10-21 11:23:31 -04:00
jeremystretch
cfb3897047 Add tags to organizational & nested group models 2021-10-21 10:51:02 -04:00
jeremystretch
8c058dcd45 Closes #7530: Move device type component lists to separate views 2021-10-20 15:04:40 -04:00
jeremystretch
7b70129974 Refactor device component views 2021-10-20 14:24:02 -04:00
jeremystretch
6a4becfb46 Add tests for wireless 2021-10-20 13:34:39 -04:00
jeremystretch
4a7159389e Add wireless documentation 2021-10-20 11:22:56 -04:00
jeremystretch
a66501250e Add wireless authentication attributes 2021-10-20 10:58:15 -04:00
jeremystretch
efb41b7433 Merge branch 'develop' into feature 2021-10-20 10:10:10 -04:00
jeremystretch
090df05193 PRVB 2021-10-20 09:59:33 -04:00
Jeremy Stretch
2c161c01c1 Merge pull request #7590 from netbox-community/develop
Release v3.0.8
2021-10-20 09:49:15 -04:00
jeremystretch
fc5a23cc88 Release v3.0.8 2021-10-20 09:31:12 -04:00
jeremystretch
73f2f9fc63 Closes #7551: Add UI field to filter interfaces by kind 2021-10-19 15:57:02 -04:00
jeremystretch
eb4b4a6c8d Closes #7561: Add a utilization column to the IP ranges table 2021-10-19 15:51:39 -04:00
jeremystretch
39430e01de Fixes #7550: Fix rendering of UTF8-encoded data in change records 2021-10-19 15:41:19 -04:00
jeremystretch
96015aa590 Fixes #7582: Fix rendering of CustomLink context data table 2021-10-19 15:31:07 -04:00
jeremystretch
c1720505f3 Fixes #7584: Fix alignment of object identifier under object view 2021-10-19 15:22:22 -04:00
Jeremy Stretch
5c338a90a1 Merge pull request #7566 from PieterL75/patch-1
Fix #7556 : NewVersion showing url
2021-10-19 15:20:58 -04:00
jeremystretch
f04dc55030 Reorganize panel inclusion templates 2021-10-19 14:21:31 -04:00
jeremystretch
38bc5de3e8 Changelog for #1344 2021-10-19 14:08:27 -04:00
jeremystretch
7c56b21095 Closes #7354: Relax uniqueness constraints on region, site group, and location names 2021-10-19 13:46:35 -04:00
jeremystretch
8d0ed99bcd Clean up UniqueTogetherValidator workarounds 2021-10-19 13:32:43 -04:00
jeremystretch
8375995680 Closes #1943: Relax uniqueness constraint on cluster names 2021-10-19 13:06:41 -04:00
jeremystretch
0afd3e6189 Closes #6715: Add tenant assignment for cables 2021-10-19 12:33:17 -04:00
PieterL75
79cee12b1e Updated release notes with #7556 2021-10-19 16:23:05 +02:00
Jeremy Stretch
ba7361bdc7 Merge pull request #7575 from netbox-community/1344-contacts
Closes #1344: Contact objects
2021-10-19 08:46:13 -04:00
jeremystretch
554b44b9f2 Fix string repr for ContactAssignment 2021-10-18 16:47:49 -04:00
jeremystretch
b44a5ea609 Prevent duplicate contact assignments 2021-10-18 16:33:31 -04:00
jeremystretch
487d67768b Cleanup and documentation for #1344 2021-10-18 16:20:31 -04:00
jeremystretch
f485a47b48 Tweak uniqueness constraints 2021-10-18 15:41:29 -04:00
jeremystretch
faf1e6a43d Add contact/role assignment tables 2021-10-18 15:30:28 -04:00
jeremystretch
f193f0d3f9 Add contact assignments to models 2021-10-18 15:09:57 -04:00
jeremystretch
2e78568d4d Initial work on contacts 2021-10-18 13:59:05 -04:00
PieterL75
aa5c42683a Fix #7556 : NewVersion showing url 2021-10-18 16:12:23 +02:00
jeremystretch
0c72c20d2a Add WirelessLANs column to interfaces table 2021-10-18 10:05:43 -04:00
thatmattlove
9c6938e7ae Minor Style Improvement: Fix interface table dropdowns being hidden when opened 2021-10-15 17:45:47 -07:00
thatmattlove
811c21ec7e Minor Style Improvement: Add vertical spacing to Device Type component navigation & fix inconsistent component active color 2021-10-15 17:21:36 -07:00
thatmattlove
84c14aadc7 Fixes #7300: Fix incorrect Device LLDP interface row coloring & improve related JS 2021-10-15 17:07:54 -07:00
thatmattlove
f1f0d9cd0d Fixes #7495: Fix sidenav overlapping elements 2021-10-15 15:02:50 -07:00
jeremystretch
717fd760df #3979: UI cleanup 2021-10-15 12:24:07 -04:00
jeremystretch
075f4907ef Store channel frequency & width as independent values 2021-10-15 11:39:53 -04:00
jeremystretch
b7317bfe29 Remove choices from rf_channel_width 2021-10-15 10:06:49 -04:00
jeremystretch
01d3c062f2 Move wireless field choices to wireless app 2021-10-15 10:00:03 -04:00
jeremystretch
6af5a884cd Merge branch 'feature' into 3979-wireless 2021-10-14 16:32:24 -04:00
Jeremy Stretch
6015c47587 Merge pull request #7547 from netbox-community/3839-device-airflow
Closes #3839: Add airflow fields to Device and DeviceType
2021-10-14 16:29:43 -04:00
jeremystretch
33ea8763d5 3839: Add airflow field to Device 2021-10-14 16:15:08 -04:00
jeremystretch
2c2c2e9060 3839: Add airflow field to DeviceType 2021-10-14 15:45:36 -04:00
jeremystretch
64dad7dbd2 Optimize migrations 2021-10-14 15:11:03 -04:00
jeremystretch
176bd2396b Closes #6711: Add longtext custom field type with Markdown support 2021-10-14 14:48:00 -04:00
jeremystretch
e16942dea5 Fixes #7529: Restore horizontal scrolling for tables in narrow viewports 2021-10-14 13:44:54 -04:00
Jeremy Stretch
12efcec3b0 Merge pull request #7546 from miaow2/7545-webhook-events-status
Fixes #7545: Incorrect display of Events status on webhook page
2021-10-14 13:43:00 -04:00
miaow2
a7b6c40596 Fixing display of webhook types 2021-10-14 20:35:21 +03:00
jeremystretch
b95773938d Fixes #7534: Avoid exception when utilizing "create and add another" twice in succession 2021-10-14 12:24:29 -04:00
jeremystretch
6898ae7106 Fixes #7544: Fix multi-value filtering of custom field objects 2021-10-14 11:36:13 -04:00
jeremystretch
909b83c537 Include interface RF attributes on wireless link view 2021-10-14 10:06:46 -04:00
jeremystretch
fb9da87abb Add devices to WirelessLinkForm 2021-10-14 10:02:05 -04:00
jeremystretch
bdf359470e Include WirelessLAN attached interfaces 2021-10-14 09:48:12 -04:00
jeremystretch
4c475c1b33 Extend wireless channel choices 2021-10-13 20:56:14 -04:00
jeremystretch
438b4b4758 Add rf_role to Interface 2021-10-13 20:16:36 -04:00
jeremystretch
01f791a44e Add WirelessLANGroup model 2021-10-13 16:40:12 -04:00
jeremystretch
43f2d4a331 Add SVG trace support for WirelessLinks 2021-10-13 15:00:35 -04:00
jeremystretch
95ed07a95e Add status field to WirelessLink 2021-10-13 14:31:30 -04:00
jeremystretch
ec0560a2c5 Fix trace_paths command for wireless links 2021-10-13 14:16:10 -04:00
jeremystretch
ac2cd552b9 Rename cable_peer fields to link_peer 2021-10-13 14:04:53 -04:00
jeremystretch
1c73bd5079 Resolve test errors 2021-10-13 13:39:14 -04:00
jeremystretch
138af27bf7 Record wireless links as part of cable path 2021-10-13 13:28:14 -04:00
jeremystretch
445e16f668 Reference WirelessLink on both attached Interfaces 2021-10-13 11:54:52 -04:00
jeremystretch
90e9f34494 Add WirelessLink model 2021-10-13 09:46:17 -04:00
jeremystretch
5271680483 Rename SSID model to WirelessLAN 2021-10-12 17:06:31 -04:00
jeremystretch
38f6d22d2d Enable attachment of wireless interfaces to SSIDs 2021-10-12 13:48:06 -04:00
jeremystretch
8b80b0c3df Introduce the wireless app and SSID model 2021-10-12 12:48:36 -04:00
jeremystretch
8e1535f7ec Add RF channel fields to Interface 2021-10-12 10:46:41 -04:00
jeremystretch
3e7922e41e Merge branch 'develop' into feature 2021-10-11 14:43:20 -04:00
jeremystretch
1a4f8c5422 PRVB 2021-10-11 14:42:29 -04:00
jeremystretch
5a6190e321 Closes #6874: Add tenant assignment for locations 2021-10-07 15:46:21 -04:00
jeremystretch
18c3bb673f Closes #1337: Add WWN field to interfaces 2021-10-07 15:09:42 -04:00
jeremystretch
6463fd902c Merge branch 'develop' into feature 2021-10-07 14:20:42 -04:00
jeremystretch
ca59cd1eb8 Merge branch 'develop' into feature 2021-10-06 14:04:53 -04:00
jeremystretch
9c8432cf13 Merge branch 'develop' into feature 2021-10-04 14:19:16 -04:00
jeremystretch
86aed4e073 Closes #7318: Raise minimum required PostgreSQL version from 9.6 to 10 2021-09-29 12:14:15 -04:00
481 changed files with 16558 additions and 5159 deletions

View File

@@ -13,11 +13,8 @@ body:
- type: input
attributes:
label: NetBox version
description: >
What version of NetBox are you currently running? (If you don't have access to the most
recent NetBox release, consider testing on our [demo instance](https://demo.netbox.dev/)
before opening a bug report to see if your issue has already been addressed.)
placeholder: v3.0.7
description: What version of NetBox are you currently running?
placeholder: v3.1.2
validations:
required: true
- type: dropdown

View File

@@ -14,7 +14,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.0.7
placeholder: v3.1.2
validations:
required: true
- type: dropdown

View File

@@ -76,14 +76,10 @@ free to add a comment with any additional justification for the feature.
(However, note that comments with no substance other than a "+1" will be
deleted. Please use GitHub's reactions feature to indicate your support.)
* Due to a large backlog of feature requests, we are not currently accepting
any proposals which substantially extend NetBox's functionality beyond its
current feature set. This includes the introduction of any new views or models
which have not already been proposed in an existing feature request.
* Before filing a new feature request, consider raising your idea on the
mailing list first. Feedback you receive there will help validate and shape the
proposed feature before filing a formal issue.
* Before filing a new feature request, consider raising your idea in a
[GitHub discussion](https://github.com/netbox-community/netbox/discussions)
first. Feedback you receive there will help validate and shape the proposed
feature before filing a formal issue.
* Good feature requests are very narrowly defined. Be sure to thoroughly
describe the functionality and data model(s) being proposed. The more effort

View File

@@ -1,6 +1,6 @@
# The Python web framework on which NetBox is built
# https://github.com/django/django
Django
Django<4.0
# Django middleware which permits cross-domain API requests
# https://github.com/OttoYiu/django-cors-headers
@@ -102,6 +102,14 @@ PyYAML
# https://github.com/andymccurdy/redis-py
redis
# Social authentication framework
# https://github.com/python-social-auth/social-core
social-auth-core[all]
# Django app for social-auth-core
# https://github.com/python-social-auth/social-app-django
social-auth-app-django
# SVG image rendering (used for rack elevations)
# https://github.com/mozman/svgwrite
svgwrite

View File

@@ -29,7 +29,7 @@ GET /api/dcim/devices/1/napalm/?method=get_environment
## Authentication
By default, the [`NAPALM_USERNAME`](../configuration/optional-settings.md#napalm_username) and [`NAPALM_PASSWORD`](../configuration/optional-settings.md#napalm_password) configuration parameters are used for NAPALM authentication. They can be overridden for an individual API call by specifying the `X-NAPALM-Username` and `X-NAPALM-Password` headers.
By default, the [`NAPALM_USERNAME`](../configuration/dynamic-settings.md#napalm_username) and [`NAPALM_PASSWORD`](../configuration/dynamic-settings.md#napalm_password) configuration parameters are used for NAPALM authentication. They can be overridden for an individual API call by specifying the `X-NAPALM-Username` and `X-NAPALM-Password` headers.
```
$ curl "http://localhost/api/dcim/devices/1/napalm/?method=get_environment" \

View File

@@ -0,0 +1,37 @@
# Authentication
## Local Authentication
Local user accounts and groups can be created in NetBox under the "Authentication and Authorization" section of the administrative user interface. This interface is available only to users with the "staff" permission enabled.
At a minimum, each user account must have a username and password set. User accounts may also denote a first name, last name, and email address. [Permissions](./permissions.md) may also be assigned to users and/or groups within the admin UI.
## Remote Authentication
NetBox may be configured to provide user authenticate via a remote backend in addition to local authentication. This is done by setting the `REMOTE_AUTH_BACKEND` configuration parameter to a suitable backend class. NetBox provides several options for remote authentication.
### LDAP Authentication
```python
REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend'
```
NetBox includes an authentication backend which supports LDAP. See the [LDAP installation docs](../installation/6-ldap.md) for more detail about this backend.
### HTTP Header Authentication
```python
REMOTE_AUTH_BACKEND = 'netbox.authentication.RemoteUserBackend'
```
Another option for remote authentication in NetBox is to enable HTTP header-based user assignment. The front end HTTP server (e.g. nginx or Apache) performs client authentication as a process external to NetBox, and passes information about the authenticated user via HTTP headers. By default, the user is assigned via the `REMOTE_USER` header, but this can be customized via the `REMOTE_AUTH_HEADER` configuration parameter.
### Single Sign-On (SSO)
```python
REMOTE_AUTH_BACKEND = 'social_core.backends.google.GoogleOAuth2'
```
NetBox supports single sign-on authentication via the [python-social-auth](https://github.com/python-social-auth) library. To enable SSO, specify the path to the desired authentication backend within the `social_core` Python package. Please see the complete list of [supported authentication backends](https://github.com/python-social-auth/social-core/tree/master/social_core/backends) for the available options.
Most remote authentication backends require some additional configuration through settings prefixed with `SOCIAL_AUTH_`. These will be automatically imported from NetBox's `configuration.py` file. Additionally, the [authentication pipeline](https://python-social-auth.readthedocs.io/en/latest/pipeline.html) can be customized via the `SOCIAL_AUTH_PIPELINE` parameter.

View File

@@ -8,7 +8,7 @@ NetBox includes a `housekeeping` management command that should be run nightly.
This command can be invoked directly, or by using the shell script provided at `/opt/netbox/contrib/netbox-housekeeping.sh`. This script can be linked from your cron scheduler's daily jobs directory (e.g. `/etc/cron.daily`) or referenced directly within the cron configuration file.
```shell
ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
```
!!! note

View File

@@ -1,6 +1,6 @@
# Permissions
NetBox v2.9 introduced a new object-based permissions framework, which replace's Django's built-in permissions model. Object-based permissions enable an administrator to grant users or groups the ability to perform an action on arbitrary subsets of objects in NetBox, rather than all objects of a certain type. For example, it is possible to grant a user permission to view only sites within a particular region, or to modify only VLANs with a numeric ID within a certain range.
NetBox v2.9 introduced a new object-based permissions framework, which replaces Django's built-in permissions model. Object-based permissions enable an administrator to grant users or groups the ability to perform an action on arbitrary subsets of objects in NetBox, rather than all objects of a certain type. For example, it is possible to grant a user permission to view only sites within a particular region, or to modify only VLANs with a numeric ID within a certain range.
{!models/users/objectpermission.md!}

View File

@@ -0,0 +1,180 @@
# Dynamic Configuration Settings
These configuration parameters are primarily controlled via NetBox's admin interface (under Admin > Extras > Configuration Revisions). These setting may also be overridden in `configuration.py`; this will prevent them from being modified via the UI.
---
## ALLOWED_URL_SCHEMES
Default: `('file', 'ftp', 'ftps', 'http', 'https', 'irc', 'mailto', 'sftp', 'ssh', 'tel', 'telnet', 'tftp', 'vnc', 'xmpp')`
A list of permitted URL schemes referenced when rendering links within NetBox. Note that only the schemes specified in this list will be accepted: If adding your own, be sure to replicate all of the default values as well (excluding those schemes which are not desirable).
---
## BANNER_TOP
## BANNER_BOTTOM
Setting these variables will display custom content in a banner at the top and/or bottom of the page, respectively. HTML is allowed. To replicate the content of the top banner in the bottom banner, set:
```python
BANNER_TOP = 'Your banner text'
BANNER_BOTTOM = BANNER_TOP
```
---
## BANNER_LOGIN
This defines custom content to be displayed on the login page above the login form. HTML is allowed.
---
## CHANGELOG_RETENTION
Default: 90
The number of days to retain logged changes (object creations, updates, and deletions). Set this to `0` to retain
changes in the database indefinitely.
!!! warning
If enabling indefinite changelog retention, it is recommended to periodically delete old entries. Otherwise, the database may eventually exceed capacity.
---
## CUSTOM_VALIDATORS
This is a mapping of models to [custom validators](../customization/custom-validation.md) that have been defined locally to enforce custom validation logic. An example is provided below:
```python
CUSTOM_VALIDATORS = {
"dcim.site": [
{
"name": {
"min_length": 5,
"max_length": 30
}
},
"my_plugin.validators.Validator1"
],
"dim.device": [
"my_plugin.validators.Validator1"
]
}
```
---
## ENFORCE_GLOBAL_UNIQUE
Default: False
By default, NetBox will permit users to create duplicate prefixes and IP addresses in the global table (that is, those which are not assigned to any VRF). This behavior can be disabled by setting `ENFORCE_GLOBAL_UNIQUE` to True.
---
## GRAPHQL_ENABLED
Default: True
Setting this to False will disable the GraphQL API.
---
## MAINTENANCE_MODE
Default: False
Setting this to True will display a "maintenance mode" banner at the top of every page. Additionally, NetBox will no longer update a user's "last active" time upon login. This is to allow new logins when the database is in a read-only state. Recording of login times will resume when maintenance mode is disabled.
---
## MAPS_URL
Default: `https://maps.google.com/?q=` (Google Maps)
This specifies the URL to use when presenting a map of a physical location by street address or GPS coordinates. The URL must accept either a free-form street address or a comma-separated pair of numeric coordinates appended to it.
---
## MAX_PAGE_SIZE
Default: 1000
A web user or API consumer can request an arbitrary number of objects by appending the "limit" parameter to the URL (e.g. `?limit=1000`). This parameter defines the maximum acceptable limit. Setting this to `0` or `None` will allow a client to retrieve _all_ matching objects at once with no limit by specifying `?limit=0`.
---
## NAPALM_USERNAME
## NAPALM_PASSWORD
NetBox will use these credentials when authenticating to remote devices via the supported [NAPALM integration](../additional-features/napalm.md), if installed. Both parameters are optional.
!!! note
If SSH public key authentication has been set up on the remote device(s) for the system account under which NetBox runs, these parameters are not needed.
---
## NAPALM_ARGS
A dictionary of optional arguments to pass to NAPALM when instantiating a network driver. See the NAPALM documentation for a [complete list of optional arguments](https://napalm.readthedocs.io/en/latest/support/#optional-arguments). An example:
```python
NAPALM_ARGS = {
'api_key': '472071a93b60a1bd1fafb401d9f8ef41',
'port': 2222,
}
```
Some platforms (e.g. Cisco IOS) require an argument named `secret` to be passed in addition to the normal password. If desired, you can use the configured `NAPALM_PASSWORD` as the value for this argument:
```python
NAPALM_USERNAME = 'username'
NAPALM_PASSWORD = 'MySecretPassword'
NAPALM_ARGS = {
'secret': NAPALM_PASSWORD,
# Include any additional args here
}
```
---
## NAPALM_TIMEOUT
Default: 30 seconds
The amount of time (in seconds) to wait for NAPALM to connect to a device.
---
## PAGINATE_COUNT
Default: 50
The default maximum number of objects to display per page within each list of objects.
---
## PREFER_IPV4
Default: False
When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to prefer IPv4 instead.
---
## RACK_ELEVATION_DEFAULT_UNIT_HEIGHT
Default: 22
Default height (in pixels) of a unit within a rack elevation. For best results, this should be approximately one tenth of `RACK_ELEVATION_DEFAULT_UNIT_WIDTH`.
---
## RACK_ELEVATION_DEFAULT_UNIT_WIDTH
Default: 220
Default width (in pixels) of a unit within a rack elevation.

View File

@@ -1,18 +1,22 @@
# NetBox Configuration
NetBox's local configuration is stored in `$INSTALL_ROOT/netbox/netbox/configuration.py`. An example configuration is provided as `configuration.example.py`. You may copy or rename the example configuration and make changes as appropriate. NetBox will not run without a configuration file.
NetBox's local configuration is stored in `$INSTALL_ROOT/netbox/netbox/configuration.py`. An example configuration is provided as `configuration.example.py`. You may copy or rename the example configuration and make changes as appropriate. NetBox will not run without a configuration file. While NetBox has many configuration settings, only a few of them must be defined at the time of installation: these are defined under "required settings" below.
While NetBox has many configuration settings, only a few of them must be defined at the time of installation.
Some configuration parameters may alternatively be defined either in `configuration.py` or within the administrative section of the user interface. Settings which are "hard-coded" in the configuration file take precedence over those defined via the UI.
## Configuration Parameters
* [Required settings](required-settings.md)
* [Optional settings](optional-settings.md)
* [Dynamic settings](dynamic-settings.md)
* [Remote authentication settings](remote-authentication.md)
## Changing the Configuration
Configuration settings may be changed at any time. However, the WSGI service (e.g. Gunicorn) must be restarted before the changes will take effect:
The configuration file may be modified at any time. However, the WSGI service (e.g. Gunicorn) must be restarted before the changes will take effect:
```no-highlight
$ sudo systemctl restart netbox
```
Configuration parameters which are set via the admin UI (those listed under "dynamic settings") take effect immediately.

View File

@@ -13,33 +13,6 @@ ADMINS = [
---
## ALLOWED_URL_SCHEMES
Default: `('file', 'ftp', 'ftps', 'http', 'https', 'irc', 'mailto', 'sftp', 'ssh', 'tel', 'telnet', 'tftp', 'vnc', 'xmpp')`
A list of permitted URL schemes referenced when rendering links within NetBox. Note that only the schemes specified in this list will be accepted: If adding your own, be sure to replicate all of the default values as well (excluding those schemes which are not desirable).
---
## BANNER_TOP
## BANNER_BOTTOM
Setting these variables will display custom content in a banner at the top and/or bottom of the page, respectively. HTML is allowed. To replicate the content of the top banner in the bottom banner, set:
```python
BANNER_TOP = 'Your banner text'
BANNER_BOTTOM = BANNER_TOP
```
---
## BANNER_LOGIN
This defines custom content to be displayed on the login page above the login form. HTML is allowed.
---
## BASE_PATH
Default: None
@@ -52,18 +25,6 @@ BASE_PATH = 'netbox/'
---
## CHANGELOG_RETENTION
Default: 90
The number of days to retain logged changes (object creations, updates, and deletions). Set this to `0` to retain
changes in the database indefinitely.
!!! warning
If enabling indefinite changelog retention, it is recommended to periodically delete old entries. Otherwise, the database may eventually exceed capacity.
---
## CORS_ORIGIN_ALLOW_ALL
Default: False
@@ -88,22 +49,6 @@ CORS_ORIGIN_WHITELIST = [
---
## CUSTOM_VALIDATORS
This is a mapping of models to [custom validators](../customization/custom-validation.md) that have been defined locally to enforce custom validation logic. An example is provided below:
```python
CUSTOM_VALIDATORS = {
'dcim.site': (
Validator1,
Validator2,
Validator3
)
}
```
---
## DEBUG
Default: False
@@ -168,14 +113,6 @@ Email is sent from NetBox only for critical events or if configured for [logging
---
## ENFORCE_GLOBAL_UNIQUE
Default: False
By default, NetBox will permit users to create duplicate prefixes and IP addresses in the global table (that is, those which are not assigned to any VRF). This behavior can be disabled by setting `ENFORCE_GLOBAL_UNIQUE` to True.
---
## EXEMPT_VIEW_PERMISSIONS
Default: Empty list
@@ -203,14 +140,6 @@ EXEMPT_VIEW_PERMISSIONS = ['*']
---
## GRAPHQL_ENABLED
Default: True
Setting this to False will disable the GraphQL API.
---
## HTTP_PROXIES
Default: None
@@ -299,30 +228,6 @@ The lifetime (in seconds) of the authentication cookie issued to a NetBox user u
---
## MAINTENANCE_MODE
Default: False
Setting this to True will display a "maintenance mode" banner at the top of every page. Additionally, NetBox will no longer update a user's "last active" time upon login. This is to allow new logins when the database is in a read-only state. Recording of login times will resume when maintenance mode is disabled.
---
## MAPS_URL
Default: `https://maps.google.com/?q=` (Google Maps)
This specifies the URL to use when presenting a map of a physical location by street address or GPS coordinates. The URL must accept either a free-form street address or a comma-separated pair of numeric coordinates appended to it.
---
## MAX_PAGE_SIZE
Default: 1000
A web user or API consumer can request an arbitrary number of objects by appending the "limit" parameter to the URL (e.g. `?limit=1000`). This parameter defines the maximum acceptable limit. Setting this to `0` or `None` will allow a client to retrieve _all_ matching objects at once with no limit by specifying `?limit=0`.
---
## MEDIA_ROOT
Default: $INSTALL_ROOT/netbox/media/
@@ -339,57 +244,6 @@ Toggle the availability Prometheus-compatible metrics at `/metrics`. See the [Pr
---
## NAPALM_USERNAME
## NAPALM_PASSWORD
NetBox will use these credentials when authenticating to remote devices via the supported [NAPALM integration](../additional-features/napalm.md), if installed. Both parameters are optional.
!!! note
If SSH public key authentication has been set up on the remote device(s) for the system account under which NetBox runs, these parameters are not needed.
---
## NAPALM_ARGS
A dictionary of optional arguments to pass to NAPALM when instantiating a network driver. See the NAPALM documentation for a [complete list of optional arguments](https://napalm.readthedocs.io/en/latest/support/#optional-arguments). An example:
```python
NAPALM_ARGS = {
'api_key': '472071a93b60a1bd1fafb401d9f8ef41',
'port': 2222,
}
```
Some platforms (e.g. Cisco IOS) require an argument named `secret` to be passed in addition to the normal password. If desired, you can use the configured `NAPALM_PASSWORD` as the value for this argument:
```python
NAPALM_USERNAME = 'username'
NAPALM_PASSWORD = 'MySecretPassword'
NAPALM_ARGS = {
'secret': NAPALM_PASSWORD,
# Include any additional args here
}
```
---
## NAPALM_TIMEOUT
Default: 30 seconds
The amount of time (in seconds) to wait for NAPALM to connect to a device.
---
## PAGINATE_COUNT
Default: 50
The default maximum number of objects to display per page within each list of objects.
---
## PLUGINS
Default: Empty
@@ -423,137 +277,6 @@ Note that a plugin must be listed in `PLUGINS` for its configuration to take eff
---
## PREFER_IPV4
Default: False
When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to prefer IPv4 instead.
---
## RACK_ELEVATION_DEFAULT_UNIT_HEIGHT
Default: 22
Default height (in pixels) of a unit within a rack elevation. For best results, this should be approximately one tenth of `RACK_ELEVATION_DEFAULT_UNIT_WIDTH`.
---
## RACK_ELEVATION_DEFAULT_UNIT_WIDTH
Default: 220
Default width (in pixels) of a unit within a rack elevation.
---
## REMOTE_AUTH_AUTO_CREATE_USER
Default: `False`
If true, NetBox will automatically create local accounts for users authenticated via a remote service. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_BACKEND
Default: `'netbox.authentication.RemoteUserBackend'`
This is the Python path to the custom [Django authentication backend](https://docs.djangoproject.com/en/stable/topics/auth/customizing/) to use for external user authentication. NetBox provides two built-in backends (listed below), though custom authentication backends may also be provided by other packages or plugins.
* `netbox.authentication.RemoteUserBackend`
* `netbox.authentication.LDAPBackend`
---
## REMOTE_AUTH_DEFAULT_GROUPS
Default: `[]` (Empty list)
The list of groups to assign a new user account when created using remote authentication. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_DEFAULT_PERMISSIONS
Default: `{}` (Empty dictionary)
A mapping of permissions to assign a new user account when created using remote authentication. Each key in the dictionary should be set to a dictionary of the attributes to be applied to the permission, or `None` to allow all objects. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_ENABLED
Default: `False`
NetBox can be configured to support remote user authentication by inferring user authentication from an HTTP header set by the HTTP reverse proxy (e.g. nginx or Apache). Set this to `True` to enable this functionality. (Local authentication will still take effect as a fallback.)
---
## REMOTE_AUTH_GROUP_SYNC_ENABLED
Default: `False`
NetBox can be configured to sync remote user groups by inferring user authentication from an HTTP header set by the HTTP reverse proxy (e.g. nginx or Apache). Set this to `True` to enable this functionality. (Local authentication will still take effect as a fallback.) (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_HEADER
Default: `'HTTP_REMOTE_USER'`
When remote user authentication is in use, this is the name of the HTTP header which informs NetBox of the currently authenticated user. For example, to use the request header `X-Remote-User` it needs to be set to `HTTP_X_REMOTE_USER`. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_GROUP_HEADER
Default: `'HTTP_REMOTE_USER_GROUP'`
When remote user authentication is in use, this is the name of the HTTP header which informs NetBox of the currently authenticated user. For example, to use the request header `X-Remote-User-Groups` it needs to be set to `HTTP_X_REMOTE_USER_GROUPS`. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_SUPERUSER_GROUPS
Default: `[]` (Empty list)
The list of groups that promote an remote User to Superuser on Login. If group isn't present on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_SUPERUSERS
Default: `[]` (Empty list)
The list of users that get promoted to Superuser on Login. If user isn't present in list on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_STAFF_GROUPS
Default: `[]` (Empty list)
The list of groups that promote an remote User to Staff on Login. If group isn't present on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_STAFF_USERS
Default: `[]` (Empty list)
The list of users that get promoted to Staff on Login. If user isn't present in list on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_GROUP_SEPARATOR
Default: `|` (Pipe)
The Seperator upon which `REMOTE_AUTH_GROUP_HEADER` gets split into individual Groups. This needs to be coordinated with your authentication Proxy. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## RELEASE_CHECK_URL
Default: None (disabled)

View File

@@ -0,0 +1,110 @@
# Remote Authentication Settings
The configuration parameters listed here control remote authentication for NetBox. Note that `REMOTE_AUTH_ENABLED` must be true in order for these settings to take effect.
---
## REMOTE_AUTH_AUTO_CREATE_USER
Default: `False`
If true, NetBox will automatically create local accounts for users authenticated via a remote service. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_BACKEND
Default: `'netbox.authentication.RemoteUserBackend'`
This is the Python path to the custom [Django authentication backend](https://docs.djangoproject.com/en/stable/topics/auth/customizing/) to use for external user authentication. NetBox provides two built-in backends (listed below), though custom authentication backends may also be provided by other packages or plugins.
* `netbox.authentication.RemoteUserBackend`
* `netbox.authentication.LDAPBackend`
---
## REMOTE_AUTH_DEFAULT_GROUPS
Default: `[]` (Empty list)
The list of groups to assign a new user account when created using remote authentication. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_DEFAULT_PERMISSIONS
Default: `{}` (Empty dictionary)
A mapping of permissions to assign a new user account when created using remote authentication. Each key in the dictionary should be set to a dictionary of the attributes to be applied to the permission, or `None` to allow all objects. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_ENABLED
Default: `False`
NetBox can be configured to support remote user authentication by inferring user authentication from an HTTP header set by the HTTP reverse proxy (e.g. nginx or Apache). Set this to `True` to enable this functionality. (Local authentication will still take effect as a fallback.)
---
## REMOTE_AUTH_GROUP_SYNC_ENABLED
Default: `False`
NetBox can be configured to sync remote user groups by inferring user authentication from an HTTP header set by the HTTP reverse proxy (e.g. nginx or Apache). Set this to `True` to enable this functionality. (Local authentication will still take effect as a fallback.) (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_HEADER
Default: `'HTTP_REMOTE_USER'`
When remote user authentication is in use, this is the name of the HTTP header which informs NetBox of the currently authenticated user. For example, to use the request header `X-Remote-User` it needs to be set to `HTTP_X_REMOTE_USER`. (Requires `REMOTE_AUTH_ENABLED`.)
---
## REMOTE_AUTH_GROUP_HEADER
Default: `'HTTP_REMOTE_USER_GROUP'`
When remote user authentication is in use, this is the name of the HTTP header which informs NetBox of the currently authenticated user. For example, to use the request header `X-Remote-User-Groups` it needs to be set to `HTTP_X_REMOTE_USER_GROUPS`. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_SUPERUSER_GROUPS
Default: `[]` (Empty list)
The list of groups that promote an remote User to Superuser on Login. If group isn't present on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_SUPERUSERS
Default: `[]` (Empty list)
The list of users that get promoted to Superuser on Login. If user isn't present in list on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_STAFF_GROUPS
Default: `[]` (Empty list)
The list of groups that promote an remote User to Staff on Login. If group isn't present on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_STAFF_USERS
Default: `[]` (Empty list)
The list of users that get promoted to Staff on Login. If user isn't present in list on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )
---
## REMOTE_AUTH_GROUP_SEPARATOR
Default: `|` (Pipe)
The Seperator upon which `REMOTE_AUTH_GROUP_HEADER` gets split into individual Groups. This needs to be coordinated with your authentication Proxy. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` )

View File

@@ -25,7 +25,7 @@ ALLOWED_HOSTS = ['*']
## DATABASE
NetBox requires access to a PostgreSQL 9.6 or later database service to store data. This service can run locally on the NetBox server or on a remote system. The following parameters must be defined within the `DATABASE` dictionary:
NetBox requires access to a PostgreSQL 10 or later database service to store data. This service can run locally on the NetBox server or on a remote system. The following parameters must be defined within the `DATABASE` dictionary:
* `NAME` - Database name
* `USER` - PostgreSQL username

View File

@@ -0,0 +1,5 @@
# Contacts
{!models/tenancy/contact.md!}
{!models/tenancy/contactgroup.md!}
{!models/tenancy/contactrole.md!}

View File

@@ -27,3 +27,13 @@ Device components represent discrete objects within a device which are used to t
---
{!models/dcim/cable.md!}
In the example below, three individual cables comprise a path between devices A and D:
![Cable path](../media/models/dcim_cable_trace.png)
Traced from Interface 1 on Device A, NetBox will show the following path:
* Cable 1: Interface 1 to Front Port 1
* Cable 2: Rear Port 1 to Rear Port 2
* Cable 3: Front Port 2 to Interface 2

View File

@@ -17,3 +17,11 @@
{!models/ipam/vrf.md!}
{!models/ipam/routetarget.md!}
---
{!models/ipam/fhrpgroup.md!}
---
{!models/ipam/asn.md!}

View File

@@ -5,4 +5,4 @@
# Example Power Topology
![Power distribution model](/media/power_distribution.png)
![Power distribution model](../media/power_distribution.png)

View File

@@ -0,0 +1,8 @@
# Wireless Networks
{!models/wireless/wirelesslan.md!}
{!models/wireless/wirelesslangroup.md!}
---
{!models/wireless/wirelesslink.md!}

View File

@@ -1 +0,0 @@
{!models/extras/customlink.md!}

View File

@@ -240,7 +240,7 @@ An IPv4 or IPv6 network with a mask. Returns a `netaddr.IPNetwork` object. Two a
!!! note
To run a custom script, a user must be assigned the `extras.run_script` permission. This is achieved by assigning the user (or group) a permission on the Script object and specifying the `run` action in the admin UI as shown below.
![Adding the run action to a permission](/media/admin_ui_run_permission.png)
![Adding the run action to a permission](../media/admin_ui_run_permission.png)
### Via the Web UI
@@ -259,6 +259,22 @@ http://netbox/api/extras/scripts/example.MyReport/ \
--data '{"data": {"foo": "somevalue", "bar": 123}, "commit": true}'
```
### Via the CLI
Scripts can be run on the CLI by invoking the management command:
```
python3 manage.py runscript [--commit] [--loglevel {debug,info,warning,error,critical}] [--data "<data>"] <module>.<script>
```
The required ``<module>.<script>`` argument is the script to run where ``<module>`` is the name of the python file in the ``scripts`` directory without the ``.py`` extension and ``<script>`` is the name of the script class in the ``<module>`` to run.
The optional ``--data "<data>"`` argument is the data to send to the script
The optional ``--loglevel`` argument is the desired logging level to output to the console.
The optional ``--commit`` argument will commit any changes in the script to the database.
## Example
Below is an example script that creates new objects for a planned site. The user is prompted for three variables:

View File

@@ -1,22 +1,18 @@
# Custom Validation
NetBox validates every object prior to it being written to the database to ensure data integrity. This validation includes things like checking for proper formatting and that references to related objects are valid. However, you may wish to supplement this validation with some rules of your own. For example, perhaps you require that every site's name conforms to a specific pattern. This can be done using NetBox's `CustomValidator` class.
NetBox validates every object prior to it being written to the database to ensure data integrity. This validation includes things like checking for proper formatting and that references to related objects are valid. However, you may wish to supplement this validation with some rules of your own. For example, perhaps you require that every site's name conforms to a specific pattern. This can be done using custom validation rules.
## CustomValidator
## Custom Validation Rules
### Validation Rules
Custom validation rules are expressed as a mapping of model attributes to a set of rules to which that attribute must conform. For example:
A custom validator can be instantiated by passing a mapping of attributes to a set of rules to which that attribute must conform. For example:
```python
from extras.validators import CustomValidator
CustomValidator({
'name': {
'min_length': 5,
'max_length': 30,
}
})
```json
{
"name": {
"min_length": 5,
"max_length": 30
}
}
```
This defines a custom validator which checks that the length of the `name` attribute for an object is at least five characters long, and no longer than 30 characters. This validation is executed _after_ NetBox has performed its own internal validation.
@@ -38,12 +34,13 @@ The `min` and `max` types should be defined for numeric values, whereas `min_len
### Custom Validation Logic
There may be instances where the provided validation types are insufficient. The `CustomValidator` class can be extended to enforce arbitrary validation logic by overriding its `validate()` method, and calling `fail()` when an unsatisfactory condition is detected.
There may be instances where the provided validation types are insufficient. NetBox provides a `CustomValidator` class which can be extended to enforce arbitrary validation logic by overriding its `validate()` method, and calling `fail()` when an unsatisfactory condition is detected.
```python
from extras.validators import CustomValidator
class MyValidator(CustomValidator):
def validate(self, instance):
if instance.status == 'active' and not instance.description:
self.fail("Active sites must have a description set!", field='status')
@@ -53,34 +50,69 @@ The `fail()` method may optionally specify a field with which to associate the s
## Assigning Custom Validators
Custom validators are associated with specific NetBox models under the [CUSTOM_VALIDATORS](../configuration/optional-settings.md#custom_validators) configuration parameter, as such:
Custom validators are associated with specific NetBox models under the [CUSTOM_VALIDATORS](../configuration/optional-settings.md#custom_validators) configuration parameter. There are three manners by which custom validation rules can be defined:
1. Plain JSON mapping (no custom logic)
2. Dotted path to a custom validator class
3. Direct reference to a custom validator class
### Plain Data
For cases where custom logic is not needed, it is sufficient to pass validation rules as plain JSON-compatible objects. This approach typically affords the most portability for your configuration. For instance:
```python
CUSTOM_VALIDATORS = {
"dcim.site": [
{
"name": {
"min_length": 5,
"max_length": 30,
}
}
],
"dcim.device": [
{
"platform": {
"required": True,
}
}
]
}
```
### Dotted Path
In instances where a custom validator class is needed, it can be referenced by its Python path (relative to NetBox's working directory):
```python
CUSTOM_VALIDATORS = {
'dcim.site': (
'my_validators.Validator1',
'my_validators.Validator2',
),
'dcim.device': (
'my_validators.Validator3',
)
}
```
### Direct Class Reference
This approach requires each class being instantiated to be imported directly within the Python configuration file.
```python
from my_validators import Validator1, Validator2, Validator3
CUSTOM_VALIDATORS = {
'dcim.site': (
Validator1,
Validator2,
Validator3
),
'dcim.device': (
Validator3,
)
}
```
!!! note
Even if defining only a single validator, it must be passed as an iterable.
When it is not necessary to define a custom `validate()` method, you may opt to pass a `CustomValidator` instance directly:
```python
from extras.validators import CustomValidator
CUSTOM_VALIDATORS = {
'dcim.site': (
CustomValidator({
'name': {
'min_length': 5,
'max_length': 30,
}
}),
)
}
```

View File

@@ -6,9 +6,9 @@ Models within each app are stored in either `models.py` or within a submodule un
Each model should define, at a minimum:
* A `Meta` class specifying a deterministic ordering (if ordered by fields other than the primary ID)
* A `__str__()` method returning a user-friendly string representation of the instance
* A `get_absolute_url()` method returning an instance's direct URL (using `reverse()`)
* A `Meta` class specifying a deterministic ordering (if ordered by fields other than the primary ID)
## 2. Define field choices
@@ -16,9 +16,9 @@ If the model has one or more fields with static choices, define those choices in
## 3. Generate database migrations
Once your model definition is complete, generate database migrations by running `manage.py -n $NAME --no-header`. Always specify a short unique name when generating migrations.
Once your model definition is complete, generate database migrations by running `manage.py makemigrations -n $NAME --no-header`. Always specify a short unique name when generating migrations.
!!! info
!!! info "Configuration Required"
Set `DEVELOPER = True` in your NetBox configuration to enable the creation of new migrations.
## 4. Add all standard views
@@ -41,9 +41,7 @@ Add the relevant URL path for each view created in the previous step to `urls.py
Each model should have a corresponding FilterSet class defined. This is used to filter UI and API queries. Subclass the appropriate class from `netbox.filtersets` that matches the model's parent class.
Every model FilterSet should define a `q` filter to support general search queries.
## 7. Create the table
## 7. Create the table class
Create a table class for the model in `tables.py` by subclassing `utilities.tables.BaseTable`. Under the table's `Meta` class, be sure to list both the fields and default columns.
@@ -53,7 +51,7 @@ Create the HTML template for the object view. (The other views each typically em
## 9. Add the model to the navigation menu
For NetBox releases prior to v3.0, add the relevant link(s) to the navigation menu template. For later releases, add the relevant items in `netbox/netbox/navigation_menu.py`.
Add the relevant navigation menu items in `netbox/netbox/navigation_menu.py`.
## 10. REST API components
@@ -64,7 +62,7 @@ Create the following for each model:
* API view in `api/views.py`
* Endpoint route in `api/urls.py`
## 11. GraphQL API components (v3.0+)
## 11. GraphQL API components
Create a Graphene object type for the model in `graphql/types.py` by subclassing the appropriate class from `netbox.graphql.types`.

View File

@@ -4,16 +4,16 @@ Below is a list of tasks to consider when adding a new field to a core model.
## 1. Generate and run database migrations
Django migrations are used to express changes to the database schema. In most cases, Django can generate these automatically, however very complex changes may require manual intervention. Always remember to specify a short but descriptive name when generating a new migration.
[Django migrations](https://docs.djangoproject.com/en/stable/topics/migrations/) are used to express changes to the database schema. In most cases, Django can generate these automatically, however very complex changes may require manual intervention. Always remember to specify a short but descriptive name when generating a new migration.
```
./manage.py makemigrations <app> -n <name>
./manage.py migrate
```
Where possible, try to merge related changes into a single migration. For example, if three new fields are being added to different models within an app, these can be expressed in the same migration. You can merge a new migration with an existing one by combining their `operations` lists.
Where possible, try to merge related changes into a single migration. For example, if three new fields are being added to different models within an app, these can be expressed in a single migration. You can merge a newly generated migration with an existing one by combining their `operations` lists.
!!! note
!!! warning "Do not alter existing migrations"
Migrations can only be merged within a release. Once a new release has been published, its migrations cannot be altered (other than for the purpose of correcting a bug).
## 2. Add validation logic to `clean()`
@@ -24,7 +24,6 @@ If the new field introduces additional validation requirements (beyond what's in
class Foo(models.Model):
def clean(self):
super().clean()
# Custom validation goes here
@@ -40,9 +39,9 @@ If you're adding a relational field (e.g. `ForeignKey`) and intend to include th
Extend the model's API serializer in `<app>.api.serializers` to include the new field. In most cases, it will not be necessary to also extend the nested serializer, which produces a minimal representation of the model.
## 5. Add field to forms
## 5. Add fields to forms
Extend any forms to include the new field as appropriate. Common forms include:
Extend any forms to include the new field(s) as appropriate. These are found under the `forms/` directory within each app. Common forms include:
* **Credit/edit** - Manipulating a single object
* **Bulk edit** - Performing a change on many objects at once
@@ -51,11 +50,11 @@ Extend any forms to include the new field as appropriate. Common forms include:
## 6. Extend object filter set
If the new field should be filterable, add it to the `FilterSet` for the model. If the field should be searchable, remember to reference it in the FilterSet's `search()` method.
If the new field should be filterable, add it to the `FilterSet` for the model. If the field should be searchable, remember to query it in the FilterSet's `search()` method.
## 7. Add column to object table
If the new field will be included in the object list view, add a column to the model's table. For simple fields, adding the field name to `Meta.fields` will be sufficient. More complex fields may require declaring a custom column.
If the new field will be included in the object list view, add a column to the model's table. For simple fields, adding the field name to `Meta.fields` will be sufficient. More complex fields may require declaring a custom column. Also add the field name to `default_columns` if the column should be present in the table by default.
## 8. Update the UI templates

View File

@@ -35,6 +35,8 @@ The NetBox project utilizes three persistent git branches to track work:
Typically, you'll base pull requests off of the `develop` branch, or off of `feature` if you're working on a new major release. **Never** merge pull requests into the `master` branch, which receives merged only from the `develop` branch.
For example, assume that the current NetBox release is v3.1.1. Work applied to the `develop` branch will appear in v3.1.2, and work done under the `feature` branch will be included in the next minor release (v3.2.0).
### Enable Pre-Commit Hooks
NetBox ships with a [git pre-commit hook](https://githooks.com/) script that automatically checks for style compliance and missing database migrations prior to committing changes. This helps avoid erroneous commits that result in CI test failures. You are encouraged to enable it by creating a link to `scripts/git-hooks/pre-commit`:
@@ -46,7 +48,7 @@ $ ln -s ../../scripts/git-hooks/pre-commit
### Create a Python Virtual Environment
A [virtual environment](https://docs.python.org/3/tutorial/venv.html) is like a container for a set of Python packages. They allow you to build environments suited to specific projects without interfering with system packages or other projects. When installed per the documentation, NetBox uses a virtual environment in production.
A [virtual environment](https://docs.python.org/3/tutorial/venv.html) (or "venv" for short) is like a container for a set of Python packages. These allow you to build environments suited to specific projects without interfering with system packages or other projects. When installed per the documentation, NetBox uses a virtual environment in production.
Create a virtual environment using the `venv` Python module:
@@ -57,8 +59,8 @@ $ python3 -m venv ~/.venv/netbox
This will create a directory named `.venv/netbox/` in your home directory, which houses a virtual copy of the Python executable and its related libraries and tooling. When running NetBox for development, it will be run using the Python binary at `~/.venv/netbox/bin/python`.
!!! info
Keeping virtual environments in `~/.venv/` is a common convention but entirely optional: Virtual environments can be created wherever you please.
!!! info "Where to Create Your Virtual Environments"
Keeping virtual environments in `~/.venv/` is a common convention but entirely optional: Virtual environments can be created almost wherever you please.
Once created, activate the virtual environment:
@@ -94,7 +96,7 @@ Within the `netbox/netbox/` directory, copy `configuration.example.py` to `confi
### Start the Development Server
Django provides a lightweight, auto-updating HTTP/WSGI server for development use. NetBox extends this slightly to automatically import models and other utilities. Run the NetBox development server with the `nbshell` management command:
Django provides a lightweight, auto-updating HTTP/WSGI server for development use. It is started with the `runserver` management command:
```no-highlight
$ python netbox/manage.py runserver
@@ -109,9 +111,12 @@ Quit the server with CONTROL-C.
This ensures that your development environment is now complete and operational. Any changes you make to the code base will be automatically adapted by the development server.
!!! info "IDE Integration"
Some IDEs, such as PyCharm, will integrate with Django's development server and allow you to run it directly within the IDE. This is strongly encouraged as it makes for a much more convenient development environment.
## Running Tests
Throughout the course of development, it's a good idea to occasionally run NetBox's test suite to catch any potential errors. Tests are run using the `test` management command:
Prior to committing any substantial changes to the code base, be sure to run NetBox's test suite to catch any potential errors. Tests are run using the `test` management command. Remember to ensure the Python virtual environment is active before running this command.
```no-highlight
$ python netbox/manage.py test
@@ -123,9 +128,15 @@ In cases where you haven't made any changes to the database (which is most of th
$ python netbox/manage.py test --keepdb
```
You can also limit the command to running only a specific subset of tests. For example, to run only IPAM and DCIM view tests:
```no-highlight
$ python netbox/manage.py test dcim.tests.test_views ipam.tests.test_views
```
## Submitting Pull Requests
Once you're happy with your work and have verified that all tests pass, commit your changes and push it upstream to your fork. Always provide descriptive (but not excessively verbose) commit messages. When working on a specific issue, be sure to reference it.
Once you're happy with your work and have verified that all tests pass, commit your changes and push it upstream to your fork. Always provide descriptive (but not excessively verbose) commit messages. When working on a specific issue, be sure to prefix your commit message with the word "Fixes" or "Closes" and the issue number (with a hash mark). This tells GitHub to automatically close the referenced issue once the commit has been merged.
```no-highlight
$ git commit -m "Closes #1234: Add IPv5 support"
@@ -136,5 +147,5 @@ Once your fork has the new commit, submit a [pull request](https://github.com/ne
Once submitted, a maintainer will review your pull request and either merge it or request changes. If changes are needed, you can make them via new commits to your fork: The pull request will update automatically.
!!! note
Remember, pull requests are entertained only for **accepted** issues. If an issue you want to work on hasn't been approved by a maintainer yet, it's best to avoid risking your time and effort on a change that might not be accepted.
!!! note "Remember to Open an Issue First"
Remember, pull requests are permitted only for **accepted** issues. If an issue you want to work on hasn't been approved by a maintainer yet, it's best to avoid risking your time and effort on a change that might not be accepted. (The one exception to this is trivial changes to the documentation or other non-critical resources.)

View File

@@ -1,25 +1,25 @@
# NetBox Development
NetBox is maintained as a [GitHub project](https://github.com/netbox-community/netbox) under the Apache 2 license. Users are encouraged to submit GitHub issues for feature requests and bug reports, however we are very selective about pull requests. Please see the `CONTRIBUTING` guide for more direction on contributing to NetBox.
NetBox is maintained as a [GitHub project](https://github.com/netbox-community/netbox) under the Apache 2 license. Users are encouraged to submit GitHub issues for feature requests and bug reports, however we are very selective about pull requests. Each pull request must be preceded by an **approved** issue. Please see the `CONTRIBUTING` guide for more direction on contributing to NetBox.
## Communication
There are several official forums for communication among the developers and community members:
* [GitHub issues](https://github.com/netbox-community/netbox/issues) - All feature requests, bug reports, and other substantial changes to the code base **must** be documented in an issue.
* [GitHub issues](https://github.com/netbox-community/netbox/issues) - All feature requests, bug reports, and other substantial changes to the code base **must** be documented in a GitHub issue.
* [GitHub Discussions](https://github.com/netbox-community/netbox/discussions) - The preferred forum for general discussion and support issues. Ideal for shaping a feature request prior to submitting an issue.
* [#netbox on NetDev Community Slack](https://netdev.chat/) - Good for quick chats. Avoid any discussion that might need to be referenced later on, as the chat history is not retained long.
* [Google Group](https://groups.google.com/g/netbox-discuss) - Legacy mailing list; slowly being phased out in favor of GitHub discussions.
## Governance
NetBox follows the [benevolent dictator](http://oss-watch.ac.uk/resources/benevolentdictatorgovernancemodel) model of governance, with [Jeremy Stretch](https://github.com/jeremystretch) ultimately responsible for all changes to the code base. While community contributions are welcomed and encouraged, the lead maintainer's primary role is to ensure the project's long-term maintainability and continued focus on its primary functions (in other words, avoid scope creep).
NetBox follows the [benevolent dictator](http://oss-watch.ac.uk/resources/benevolentdictatorgovernancemodel) model of governance, with [Jeremy Stretch](https://github.com/jeremystretch) ultimately responsible for all changes to the code base. While community contributions are welcomed and encouraged, the lead maintainer's primary role is to ensure the project's long-term maintainability and continued focus on its primary functions.
## Project Structure
All development of the current NetBox release occurs in the `develop` branch; releases are packaged from the `master` branch. The `master` branch should _always_ represent the current stable release in its entirety, such that installing NetBox by either downloading a packaged release or cloning the `master` branch provides the same code base.
All development of the current NetBox release occurs in the `develop` branch; releases are packaged from the `master` branch. The `master` branch should _always_ represent the current stable release in its entirety, such that installing NetBox by either downloading a packaged release or cloning the `master` branch provides the same code base. Only pull requests representing new releases should be merged into `master`.
NetBox components are arranged into functional subsections called _apps_ (a carryover from Django vernacular). Each app holds the models, views, and templates relevant to a particular function:
NetBox components are arranged into Django apps. Each app holds the models, views, and other resources relevant to a particular function:
* `circuits`: Communications circuits and providers (not to be confused with power circuits)
* `dcim`: Datacenter infrastructure management (sites, racks, and devices)
@@ -29,3 +29,6 @@ NetBox components are arranged into functional subsections called _apps_ (a carr
* `users`: Authentication and user preferences
* `utilities`: Resources which are not user-facing (extendable classes, etc.)
* `virtualization`: Virtual machines and clusters
* `wireless`: Wireless links and LANs
All core functionality is stored within the `netbox/` subdirectory. HTML templates are stored in a common `templates/` directory, with model- and view-specific templates arranged by app. Documentation is kept in the `docs/` root directory.

View File

@@ -17,12 +17,12 @@ The Django [content types](https://docs.djangoproject.com/en/stable/ref/contrib/
* Nesting - These models can be nested recursively to create a hierarchy
| Type | Change Logging | Webhooks | Custom Fields | Export Templates | Tags | Journaling | Nesting |
| ------------------ | ---------------- | ---------------- | ---------------- | ---------------- | ---------------- | ---------------- | ---------------- |
| ------------------ | ---------------- | ---------------- |------------------| ---------------- | ---------------- | ---------------- | ---------------- |
| Primary | :material-check: | :material-check: | :material-check: | :material-check: | :material-check: | :material-check: | |
| Organizational | :material-check: | :material-check: | :material-check: | :material-check: | | | |
| Nested Group | :material-check: | :material-check: | :material-check: | :material-check: | | | :material-check: |
| Organizational | :material-check: | :material-check: | :material-check: | :material-check: | :material-check: | | |
| Nested Group | :material-check: | :material-check: | :material-check: | :material-check: | :material-check: | | :material-check: |
| Component | :material-check: | :material-check: | :material-check: | :material-check: | :material-check: | | |
| Component Template | :material-check: | :material-check: | :material-check: | | | | |
| Component Template | :material-check: | :material-check: | | | | | |
## Models Index
@@ -41,15 +41,21 @@ The Django [content types](https://docs.djangoproject.com/en/stable/ref/contrib/
* [dcim.Site](../models/dcim/site.md)
* [dcim.VirtualChassis](../models/dcim/virtualchassis.md)
* [ipam.Aggregate](../models/ipam/aggregate.md)
* [ipam.ASN](../models/ipam/asn.md)
* [ipam.FHRPGroup](../models/ipam/fhrpgroup.md)
* [ipam.IPAddress](../models/ipam/ipaddress.md)
* [ipam.IPRange](../models/ipam/iprange.md)
* [ipam.Prefix](../models/ipam/prefix.md)
* [ipam.RouteTarget](../models/ipam/routetarget.md)
* [ipam.Service](../models/ipam/service.md)
* [ipam.VLAN](../models/ipam/vlan.md)
* [ipam.VRF](../models/ipam/vrf.md)
* [tenancy.Contact](../models/tenancy/contact.md)
* [tenancy.Tenant](../models/tenancy/tenant.md)
* [virtualization.Cluster](../models/virtualization/cluster.md)
* [virtualization.VirtualMachine](../models/virtualization/virtualmachine.md)
* [wireless.WirelessLAN](../models/wireless/wirelesslan.md)
* [wireless.WirelessLink](../models/wireless/wirelesslink.md)
### Organizational Models
@@ -61,6 +67,7 @@ The Django [content types](https://docs.djangoproject.com/en/stable/ref/contrib/
* [ipam.RIR](../models/ipam/rir.md)
* [ipam.Role](../models/ipam/role.md)
* [ipam.VLANGroup](../models/ipam/vlangroup.md)
* [tenancy.ContactRole](../models/tenancy/contactrole.md)
* [virtualization.ClusterGroup](../models/virtualization/clustergroup.md)
* [virtualization.ClusterType](../models/virtualization/clustertype.md)
@@ -69,7 +76,9 @@ The Django [content types](https://docs.djangoproject.com/en/stable/ref/contrib/
* [dcim.Location](../models/dcim/location.md) (formerly RackGroup)
* [dcim.Region](../models/dcim/region.md)
* [dcim.SiteGroup](../models/dcim/sitegroup.md)
* [tenancy.ContactGroup](../models/tenancy/contactgroup.md)
* [tenancy.TenantGroup](../models/tenancy/tenantgroup.md)
* [wireless.WirelessLANGroup](../models/wireless/wirelesslangroup.md)
### Component Models

View File

@@ -1,6 +1,6 @@
# Style Guide
NetBox generally follows the [Django style guide](https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/), which is itself based on [PEP 8](https://www.python.org/dev/peps/pep-0008/). [Pycodestyle](https://github.com/pycqa/pycodestyle) is used to validate code formatting, ignoring certain violations. See `scripts/cibuild.sh`.
NetBox generally follows the [Django style guide](https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/), which is itself based on [PEP 8](https://www.python.org/dev/peps/pep-0008/). [Pycodestyle](https://github.com/pycqa/pycodestyle) is used to validate code formatting, ignoring certain violations. See `scripts/cibuild.sh` for details.
## PEP 8 Exceptions
@@ -30,7 +30,7 @@ pycodestyle --ignore=W504,E501 netbox/
## Introducing New Dependencies
The introduction of a new dependency is best avoided unless it is absolutely necessary. For small features, it's generally preferable to replicate functionality within the NetBox code base rather than to introduce reliance on an external project. This reduces both the burden of tracking new releases and our exposure to outside bugs and attacks.
The introduction of a new dependency is best avoided unless it is absolutely necessary. For small features, it's generally preferable to replicate functionality within the NetBox code base rather than to introduce reliance on an external project. This reduces both the burden of tracking new releases and our exposure to outside bugs and supply chain attacks.
If there's a strong case for introducing a new dependency, it must meet the following criteria:
@@ -43,7 +43,7 @@ When adding a new dependency, a short description of the package and the URL of
## General Guidance
* When in doubt, remain consistent: It is better to be consistently incorrect than inconsistently correct. If you notice in the course of unrelated work a pattern that should be corrected, continue to follow the pattern for now and open a bug so that the entire code base can be evaluated at a later point.
* When in doubt, remain consistent: It is better to be consistently incorrect than inconsistently correct. If you notice in the course of unrelated work a pattern that should be corrected, continue to follow the pattern for now and submit a separate bug report so that the entire code base can be evaluated at a later point.
* Prioritize readability over concision. Python is a very flexible language that typically offers several options for expressing a given piece of logic, but some may be more friendly to the reader than others. (List comprehensions are particularly vulnerable to over-optimization.) Always remain considerate of the future reader who may need to interpret your code without the benefit of the context within which you are writing it.

View File

@@ -48,7 +48,7 @@ NetBox is built on the [Django](https://djangoproject.com/) Python framework and
| HTTP service | nginx or Apache |
| WSGI service | gunicorn or uWSGI |
| Application | Django/Python |
| Database | PostgreSQL 9.6+ |
| Database | PostgreSQL 10+ |
| Task queuing | Redis/django-rq |
| Live device access | NAPALM |

View File

@@ -2,8 +2,8 @@
This section entails the installation and configuration of a local PostgreSQL database. If you already have a PostgreSQL database service in place, skip to [the next section](2-redis.md).
!!! warning
NetBox requires PostgreSQL 9.6 or higher. Please note that MySQL and other relational databases are **not** currently supported.
!!! warning "PostgreSQL 10 or later required"
NetBox requires PostgreSQL 10 or later. Please note that MySQL and other relational databases are **not** supported.
## Installation
@@ -21,9 +21,6 @@ This section entails the installation and configuration of a local PostgreSQL da
sudo postgresql-setup --initdb
```
!!! info
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/).
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:
```no-highlight
@@ -38,6 +35,12 @@ sudo systemctl start postgresql
sudo systemctl enable postgresql
```
Before continuing, verify that you have installed PostgreSQL 10 or later:
```no-highlight
psql -V
```
## Database Creation
At a minimum, we need to create a database for NetBox and assign it a username and password for authentication. Start by invoking the PostgreSQL shell as the system Postgres user.
@@ -54,7 +57,7 @@ CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
```
!!! danger
!!! danger "Use a strong password"
**Do not use the password from the example.** Choose a strong, random password to ensure secure database authentication for your NetBox installation.
Once complete, enter `\q` to exit the PostgreSQL shell.

View File

@@ -4,7 +4,7 @@
[Redis](https://redis.io/) is an in-memory key-value store which NetBox employs for caching and queuing. This section entails the installation and configuration of a local Redis instance. If you already have a Redis service in place, skip to [the next section](3-netbox.md).
!!! note
!!! warning "Redis v4.0 or later required"
NetBox v2.9.0 and later require Redis v4.0 or higher. If your distribution does not offer a recent enough release, you will need to build Redis from source. Please see [the Redis installation documentation](https://github.com/redis/redis) for further details.
=== "Ubuntu"
@@ -21,6 +21,12 @@
sudo systemctl enable redis
```
Before continuing, verify that your installed version of Redis is at least v4.0:
```no-highlight
redis-server -v
```
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.
## Verify Service Status

View File

@@ -6,8 +6,8 @@ This section of the documentation discusses installing and configuring the NetBo
Begin by installing all system packages required by NetBox and its dependencies.
!!! note
NetBox v3.0 and later require Python 3.7, 3.8, or 3.9.
!!! warning "Python 3.7 or later required"
NetBox v3.0 and v3.1 require Python 3.7, 3.8, or 3.9. It is recommended to install at least Python v3.8, as this will become the minimum supported Python version in NetBox v3.2.
=== "Ubuntu"
@@ -17,14 +17,19 @@ Begin by installing all system packages required by NetBox and its dependencies.
=== "CentOS"
!!! warning
CentOS 8 does not provide Python 3.7 or later via its native package manager. You will need to install it via some other means. [Here is an example](https://tecadmin.net/install-python-3-7-on-centos-8/) of installing Python 3.7 from source.
Once you have Python 3.7 or later installed, install the remaining system packages:
```no-highlight
sudo yum install -y gcc python36 python36-devel python3-pip libxml2-devel libxslt-devel libffi-devel libpq-devel openssl-devel redhat-rpm-config
sudo yum install -y gcc libxml2-devel libxslt-devel libffi-devel libpq-devel openssl-devel redhat-rpm-config
```
Before continuing with either platform, update pip (Python's package management tool) to its latest release:
Before continuing, check that your installed Python version is at least 3.7:
```no-highlight
sudo pip3 install --upgrade pip
python3 -V
```
## Download NetBox
@@ -89,7 +94,7 @@ Resolving deltas: 100% (148/148), done.
```
!!! note
Installation via git also allows you to easily try out development versions of NetBox. The `develop` branch contains all work underway for the next minor release, and the `feature` branch tracks progress on the next major release.
Installation via git also allows you to easily try out different versions of NetBox. To check out a [specific NetBox release](https://github.com/netbox-community/netbox/releases), use the `git checkout` command with the desired release tag. For example, `git checkout v3.0.8`.
## Create the NetBox System User
@@ -190,7 +195,7 @@ A simple Python script named `generate_secret_key.py` is provided in the parent
python3 ../generate_secret_key.py
```
!!! warning
!!! warning "SECRET_KEY values must match"
In the case of a highly available installation with multiple web servers, `SECRET_KEY` must be identical among all servers in order to maintain a persistent user session state.
When you have finished modifying the configuration, remember to save the file.
@@ -229,7 +234,7 @@ Once NetBox has been configured, we're ready to proceed with the actual installa
sudo /opt/netbox/upgrade.sh
```
Note that **Python 3.7 or later is required** for NetBox v3.0 and later releases. If the default Python installation on your server does not meet this requirement, you'll need to install Python 3.7 or later separately, and pass the path to the support installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.)
Note that **Python 3.7 or later is required** for NetBox v3.0 and later releases. If the default Python installation on your server is set to a lesser version, pass the path to the supported installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.)
```no-highlight
sudo PYTHON=/usr/bin/python3.7 /opt/netbox/upgrade.sh
@@ -262,7 +267,7 @@ NetBox includes a `housekeeping` management command that handles some recurring
A shell script which invokes this command is included at `contrib/netbox-housekeeping.sh`. It can be copied to or linked from your system's daily cron task directory, or included within the crontab directly. (If installing NetBox into a nonstandard path, be sure to update the system paths within this script first.)
```shell
ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
```
See the [housekeeping documentation](../administration/housekeeping.md) for further details.
@@ -297,7 +302,7 @@ Next, connect to the name or IP of the server (as defined in `ALLOWED_HOSTS`) on
firewall-cmd --zone=public --add-port=8000/tcp
```
!!! danger
!!! danger "Not for production use"
The development server is for development and testing purposes only. It is neither performant nor secure enough for production use. **Do not use it in production.**
!!! warning

View File

@@ -1,6 +1,6 @@
# Installation
The installation instructions provided here have been tested to work on Ubuntu 20.04 and CentOS 8.2. 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.
The installation instructions provided here have been tested to work on Ubuntu 20.04 and CentOS 8.3. 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.
The following sections detail how to set up a new instance of NetBox:
@@ -20,7 +20,7 @@ The video below demonstrates the installation of NetBox v3.0 on Ubuntu 20.04 for
| Dependency | Minimum Version |
|------------|-----------------|
| Python | 3.7 |
| PostgreSQL | 9.6 |
| PostgreSQL | 10 |
| Redis | 4.0 |
Below is a simplified overview of the NetBox application stack for reference:

View File

@@ -11,7 +11,7 @@ NetBox v3.0 and later requires the following:
| Dependency | Minimum Version |
|------------|-----------------|
| Python | 3.7 |
| PostgreSQL | 9.6 |
| PostgreSQL | 10 |
| Redis | 4.0 |
## Install the Latest Release
@@ -114,7 +114,7 @@ sudo systemctl restart netbox netbox-rq
If upgrading from a release prior to NetBox v3.0, check that a cron task (or similar scheduled process) has been configured to run NetBox's nightly housekeeping command. A shell script which invokes this command is included at `contrib/netbox-housekeeping.sh`. It can be linked from your system's daily cron task directory, or included within the crontab directly. (If NetBox has been installed in a nonstandard path, be sure to update the system paths within this script first.)
```shell
ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
```
See the [housekeeping documentation](../administration/housekeeping.md) for further details.

View File

@@ -22,13 +22,3 @@ Each cable may be assigned a type, label, length, and color. Each cable is also
## Tracing Cables
A cable may be traced from either of its endpoints by clicking the "trace" button. (A REST API endpoint also provides this functionality.) NetBox will follow the path of connected cables from this termination across the directly connected cable to the far-end termination. If the cable connects to a pass-through port, and the peer port has another cable connected, NetBox will continue following the cable path until it encounters a non-pass-through or unconnected termination point. The entire path will be displayed to the user.
In the example below, three individual cables comprise a path between devices A and D:
![Cable path](/media/models/dcim_cable_trace.png)
Traced from Interface 1 on Device A, NetBox will show the following path:
* Cable 1: Interface 1 to Front Port 1
* Cable 2: Rear Port 1 to Rear Port 2
* Cable 3: Front Port 2 to Interface 2

View File

@@ -12,3 +12,5 @@ Some devices house child devices which share physical resources, like space and
!!! note
This parent/child relationship is **not** suitable for modeling chassis-based devices, wherein child members share a common control plane. Instead, line cards and similarly non-autonomous hardware should be modeled as inventory items within a device, with any associated interfaces or other components assigned directly to the device.
A device type may optionally specify an airflow direction, such as front-to-rear, rear-to-front, or passive. Airflow direction may also be set separately per device. If it is not defined for a device at the time of its creation, it will inherit the airflow setting of its device type.

View File

@@ -11,6 +11,17 @@ Interfaces may be physical or virtual in nature, but only physical interfaces ma
Physical interfaces may be arranged into a link aggregation group (LAG) and associated with a parent LAG (virtual) interface. LAG interfaces can be recursively nested to model bonding of trunk groups. Like all virtual interfaces, LAG interfaces cannot be connected physically.
### Wireless Interfaces
Wireless interfaces may additionally track the following attributes:
* **Role** - AP or station
* **Channel** - One of several standard wireless channels
* **Channel Frequency** - The transmit frequency
* **Channel Width** - Channel bandwidth
If a predefined channel is selected, the frequency and width attributes will be assigned automatically. If no channel is selected, these attributes may be defined manually.
### IP Address Assignment
IP addresses can be assigned to interfaces. VLANs can also be assigned to each interface as either tagged or untagged. (An interface may have only one untagged VLAN.)

View File

@@ -2,4 +2,5 @@
Racks and devices can be grouped by location within a site. A location may represent a floor, room, cage, or similar organizational unit. Locations can be nested to form a hierarchy. For example, you may have floors within a site, and rooms within a floor.
The name and facility ID of each rack within a location must be unique. (Racks not assigned to the same location may have identical names and/or facility IDs.)
Each location must have a name that is unique within its parent site and location, if any.

View File

@@ -1,6 +1,6 @@
# Racks
The rack model represents a physical two- or four-post equipment rack in which devices can be installed. Each rack must be assigned to a site, and may optionally be assigned to a location and/or tenant. Racks can also be organized by user-defined functional roles.
The rack model represents a physical two- or four-post equipment rack in which devices can be installed. Each rack must be assigned to a site, and may optionally be assigned to a location and/or tenant. Racks can also be organized by user-defined functional roles. The name and facility ID of each rack within a location must be unique.
Rack height is measured in *rack units* (U); racks are commonly between 42U and 48U tall, but NetBox allows you to define racks of arbitrary height. A toggle is provided to indicate whether rack units are in ascending (from the ground up) or descending order.

View File

@@ -1,3 +1,5 @@
# Regions
Sites can be arranged geographically using regions. A region might represent a continent, country, city, campus, or other area depending on your use case. Regions can be nested recursively to construct a hierarchy. For example, you might define several country regions, and within each of those several state or city regions to which sites are assigned.
Each region must have a name that is unique within its parent region, if any.

View File

@@ -1,3 +1,5 @@
# Site Groups
Like regions, site groups can be used to organize sites. Whereas regions are intended to provide geographic organization, site groups can be used to classify sites by role or function. Also like regions, site groups can be nested to form a hierarchy. Sites which belong to a child group are also considered to be members of any of its parent groups.
Each site group must have a name that is unique within its parent group, if any.

View File

@@ -11,14 +11,16 @@ Within the database, custom fields are stored as JSON data directly alongside ea
Custom fields may be created by navigating to Customization > Custom Fields. NetBox supports six types of custom field:
* Text: Free-form text (up to 255 characters)
* Long text: Free-form of any length; supports Markdown rendering
* Integer: A whole number (positive or negative)
* Boolean: True or false
* Date: A date in ISO 8601 format (YYYY-MM-DD)
* URL: This will be presented as a link in the web UI
* JSON: Arbitrary data stored in JSON format
* Selection: A selection of one of several pre-defined custom choices
* Multiple selection: A selection field which supports the assignment of multiple values
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.
Each custom field must have a name. This should be a simple database-friendly string (e.g. `tps_report`) and may contain only alphanumeric characters and underscores. 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.
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.

View File

@@ -15,6 +15,3 @@ The `tag` filter can be specified multiple times to match only objects which hav
```no-highlight
GET /api/dcim/devices/?tag=monitored&tag=deprecated
```
!!! note
Tags have changed substantially in NetBox v2.9. They are no longer created on-demand when editing an object, and their representation in the REST API now includes a complete depiction of the tag rather than only its label.

View File

@@ -17,6 +17,7 @@ A webhook is a mechanism for conveying to some external system a change that too
* **Additional headers** - Any additional headers to include with the request (optional). Add one header per line in the format `Name: Value`. Jinja2 templating is supported for this field (see below).
* **Body template** - The content of the request being sent (optional). Jinja2 templating is supported for this field (see below). If blank, NetBox will populate the request body with a raw dump of the webhook context. (If the HTTP cotent type is set to `application/json`, this will be formatted as a JSON object.)
* **Secret** - A secret string used to prove authenticity of the request (optional). This will append a `X-Hook-Signature` header to the request, consisting of a HMAC (SHA-512) hex digest of the request body using the secret as the key.
* **Conditions** - An optional set of conditions evaluated to determine whether the webhook fires for a given object.
* **SSL verification** - Uncheck this option to disable validation of the receiver's SSL certificate. (Disable with caution!)
* **CA file path** - The file path to a particular certificate authority (CA) file to use when validating the receiver's SSL certificate (optional).
@@ -80,3 +81,16 @@ If no body template is specified, the request body will be populated with a JSON
}
}
```
## Conditional Webhooks
A webhook may include a set of conditional logic expressed in JSON used to control whether a webhook triggers for a specific object. For example, you may wish to trigger a webhook for devices only when the `status` field of an object is "active":
```json
{
"attr": "status",
"value": "active"
}
```
For more detail, see the reference documentation for NetBox's [conditional logic](../reference/conditions.md).

15
docs/models/ipam/asn.md Normal file
View File

@@ -0,0 +1,15 @@
# ASN
ASN is short for Autonomous System Number. This identifier is used in the BGP protocol to identify which "autonomous system" a particular prefix is originating and transiting through.
The AS number model within NetBox allows you to model some of this real-world relationship.
Within NetBox:
* AS numbers are globally unique
* Each AS number must be associated with a RIR (ARIN, RFC 6996, etc)
* Each AS number can be associated with many different sites
* Each site can have many different AS numbers
* Each AS number can be assigned to a single tenant

View File

@@ -0,0 +1,16 @@
# FHRP Group
A first-hop redundancy protocol (FHRP) enables multiple physical interfaces to present a virtual IP address in a redundant manner. Example of such protocols include:
* Hot Standby Router Protocol (HSRP)
* Virtual Router Redundancy Protocol (VRRP)
* Common Address Redundancy Protocol (CARP)
* Gateway Load Balancing Protocol (GLBP)
NetBox models these redundancy groups by protocol and group ID. Each group may optionally be assigned an authentication type and key. (Note that the authentication key is stored as a plaintext value in NetBox.) Each group may be assigned or more virtual IPv4 and/or IPv6 addresses.
## FHRP Group Assignments
Member device and VM interfaces can be assigned to FHRP groups, along with a numeric priority value. For instance, three interfaces, each belonging to a different router, may each be assigned to the same FHRP group to serve a common virtual IP address. Each of these assignments would typically receive a different priority.
Interfaces are assigned to FHRP groups under the interface detail view.

View File

@@ -0,0 +1,31 @@
# Contacts
A contact represent an individual or group that has been associated with an object in NetBox for administrative reasons. For example, you might assign one or more operational contacts to each site. Contacts can be arranged within nested contact groups.
Each contact must include a name, which is unique to its parent group (if any). The following optional descriptors are also available:
* Title
* Phone
* Email
* Address
## Contact Assignment
Each contact can be assigned to one or more objects, allowing for the efficient reuse of contact information. When assigning a contact to an object, the user may optionally specify a role and/or priority (primary, secondary, tertiary, or inactive) to better convey the nature of the contact's relationship to the assigned object.
The following models support the assignment of contacts:
* circuits.Circuit
* circuits.Provider
* dcim.Device
* dcim.Location
* dcim.Manufacturer
* dcim.PowerPanel
* dcim.Rack
* dcim.Region
* dcim.Site
* dcim.SiteGroup
* tenancy.Tenant
* virtualization.Cluster
* virtualization.ClusterGroup
* virtualization.VirtualMachine

View File

@@ -0,0 +1,3 @@
# Contact Groups
Contacts can be organized into arbitrary groups. These groups can be recursively nested for convenience. Each contact within a group must have a unique name, but other attributes can be repeated.

View File

@@ -0,0 +1,3 @@
# Contact Roles
Contacts can be organized by functional roles, which are fully customizable by the user. For example, you might create roles for administrative, operational, or emergency contacts.

View File

@@ -1,5 +1,5 @@
# Clusters
A cluster is a logical grouping of physical resources within which virtual machines run. A cluster must be assigned a type (technological classification), and may optionally be assigned to a cluster group, site, and/or tenant.
A cluster is a logical grouping of physical resources within which virtual machines run. A cluster must be assigned a type (technological classification), and may optionally be assigned to a cluster group, site, and/or tenant. Each cluster must have a unique name within its assigned group and/or site, if any.
Physical devices may be associated with clusters as hosts. This allows users to track on which host(s) a particular virtual machine may reside. However, NetBox does not support pinning a specific VM within a cluster to a particular host device.

View File

@@ -0,0 +1,11 @@
# Wireless LANs
A wireless LAN is a set of interfaces connected via a common wireless channel. Each instance must have an SSID, and may optionally be correlated to a VLAN. Wireless LANs can be arranged into hierarchical groups.
An interface may be attached to multiple wireless LANs, provided they are all operating on the same channel. Only wireless interfaces may be attached to wireless LANs.
Each wireless LAN may have authentication attributes associated with it, including:
* Authentication type
* Cipher
* Pre-shared key

View File

@@ -0,0 +1,3 @@
# Wireless LAN Groups
Wireless LAN groups can be used to organize and classify wireless LANs. These groups are hierarchical: groups can be nested within parent groups. However, each wireless LAN may assigned only to one group.

View File

@@ -0,0 +1,9 @@
# Wireless Links
A wireless link represents a connection between exactly two wireless interfaces. It may optionally be assigned an SSID and a description. It may also have a status assigned to it, similar to the cable model.
Each wireless link may have authentication attributes associated with it, including:
* Authentication type
* Cipher
* Pre-shared key

View File

@@ -0,0 +1,122 @@
# Conditions
Conditions are NetBox's mechanism for evaluating whether a set data meets a prescribed set of conditions. It allows the author to convey simple logic by declaring an arbitrary number of attribute-value-operation tuples nested within a hierarchy of logical AND and OR statements.
## Conditions
A condition is expressed as a JSON object with the following keys:
| Key name | Required | Default | Description |
|----------|----------|---------|-------------|
| attr | Yes | - | Name of the key within the data being evaluated |
| value | Yes | - | The reference value to which the given data will be compared |
| op | No | `eq` | The logical operation to be performed |
| negate | No | False | Negate (invert) the result of the condition's evaluation |
### Available Operations
* `eq`: Equals
* `gt`: Greater than
* `gte`: Greater than or equal to
* `lt`: Less than
* `lte`: Less than or equal to
* `in`: Is present within a list of values
* `contains`: Contains the specified value
### Accessing Nested Keys
To access nested keys, use dots to denote the path to the desired attribute. For example, assume the following data:
```json
{
"a": {
"b": {
"c": 123
}
}
}
```
The following condition will evaluate as true:
```json
{
"attr": "a.b.c",
"value": 123
}
```
### Examples
`name` equals "foo":
```json
{
"attr": "name",
"value": "foo"
}
```
`name` does not equal "foo"
```json
{
"attr": "name",
"value": "foo",
"negate": true
}
```
`asn` is greater than 65000:
```json
{
"attr": "asn",
"value": 65000,
"op": "gt"
}
```
`status` is not "planned" or "staging":
```json
{
"attr": "status",
"value": ["planned", "staging"],
"op": "in",
"negate": true
}
```
## Condition Sets
Multiple conditions can be combined into nested sets using AND or OR logic. This is done by declaring a JSON object with a single key (`and` or `or`) containing a list of condition objects and/or child condition sets.
### Examples
`status` is "active" and `primary_ip` is defined _or_ the "exempt" tag is applied.
```json
{
"or": [
{
"and": [
{
"attr": "status",
"value": "active"
},
{
"attr": "primary_ip",
"value": "",
"negate": true
}
]
},
{
"attr": "tags",
"value": "exempt",
"op": "contains"
}
]
}
```

View File

@@ -1 +0,0 @@
version-3.0.md

113
docs/release-notes/index.md Normal file
View File

@@ -0,0 +1,113 @@
# Release Notes
Listed below are the major features introduced in each NetBox release. For more detail on a specific release train, see its individual release notes page.
#### [Version 3.1](./version-3.1.md) (December 2021)
* Contact Objects ([#1344](https://github.com/netbox-community/netbox/issues/1344))
* Wireless Networks ([#3979](https://github.com/netbox-community/netbox/issues/3979))
* Dynamic Configuration Updates ([#5883](https://github.com/netbox-community/netbox/issues/5883))
* First Hop Redundancy Protocol (FHRP) Groups ([#6235](https://github.com/netbox-community/netbox/issues/6235))
* Conditional Webhooks ([#6238](https://github.com/netbox-community/netbox/issues/6238))
* Interface Bridging ([#6346](https://github.com/netbox-community/netbox/issues/6346))
* Multiple ASNs per Site ([#6732](https://github.com/netbox-community/netbox/issues/6732))
* Single Sign-On (SSO) Authentication ([#7649](https://github.com/netbox-community/netbox/issues/7649))
#### [Version 3.0](./version-3.0.md) (August 2021)
* Updated User Interface ([#5893](https://github.com/netbox-community/netbox/issues/5893))
* GraphQL API ([#2007](https://github.com/netbox-community/netbox/issues/2007))
* IP Ranges ([#834](https://github.com/netbox-community/netbox/issues/834))
* Custom Model Validation ([#5963](https://github.com/netbox-community/netbox/issues/5963))
* SVG Cable Traces ([#6000](https://github.com/netbox-community/netbox/issues/6000))
* New Views for Models Previously Under the Admin UI ([#6466](https://github.com/netbox-community/netbox/issues/6466))
* REST API Token Provisioning ([#5264](https://github.com/netbox-community/netbox/issues/5264))
* New Housekeeping Command ([#6590](https://github.com/netbox-community/netbox/issues/6590))
* Custom Queue Support for Plugins ([#6651](https://github.com/netbox-community/netbox/issues/6651))
#### [Version 2.11](./version-2.11.md) (April 2021)
* Journaling Support ([#151](https://github.com/netbox-community/netbox/issues/151))
* Parent Interface Assignments ([#1519](https://github.com/netbox-community/netbox/issues/1519))
* Pre- and Post-Change Snapshots in Webhooks ([#3451](https://github.com/netbox-community/netbox/issues/3451))
* Mark as Connected Without a Cable ([#3648](https://github.com/netbox-community/netbox/issues/3648))
* Allow Assigning Devices to Locations ([#4971](https://github.com/netbox-community/netbox/issues/4971))
* Dynamic Object Exports ([#4999](https://github.com/netbox-community/netbox/issues/4999))
* Variable Scope Support for VLAN Groups ([#5284](https://github.com/netbox-community/netbox/issues/5284))
* New Site Group Model ([#5892](https://github.com/netbox-community/netbox/issues/5892))
* Improved Change Logging ([#5913](https://github.com/netbox-community/netbox/issues/5913))
* Provider Network Modeling ([#5986](https://github.com/netbox-community/netbox/issues/5986))
#### [Version 2.10](./version-2.10.md) (December 2020)
* Route Targets ([#259](https://github.com/netbox-community/netbox/issues/259))
* REST API Bulk Deletion ([#3436](https://github.com/netbox-community/netbox/issues/3436))
* REST API Bulk Update ([#4882](https://github.com/netbox-community/netbox/issues/4882))
* Reimplementation of Custom Fields ([#4878](https://github.com/netbox-community/netbox/issues/4878))
* Improved Cable Trace Performance ([#4900](https://github.com/netbox-community/netbox/issues/4900))
#### [Version 2.9](./version-2.9.md) (August 2020)
* Object-Based Permissions ([#554](https://github.com/netbox-community/netbox/issues/554))
* Background Execution of Scripts & Reports ([#2006](https://github.com/netbox-community/netbox/issues/2006))
* Named Virtual Chassis ([#2018](https://github.com/netbox-community/netbox/issues/2018))
* Changes to Tag Creation ([#3703](https://github.com/netbox-community/netbox/issues/3703))
* Dedicated Model for VM Interfaces ([#4721](https://github.com/netbox-community/netbox/issues/4721))
* REST API Endpoints for Users and Groups ([#4877](https://github.com/netbox-community/netbox/issues/4877))
#### [Version 2.8](./version-2.8.md) (April 2020)
* Remote Authentication Support ([#2328](https://github.com/netbox-community/netbox/issues/2328))
* Plugins ([#3351](https://github.com/netbox-community/netbox/issues/3351))
#### [Version 2.7](./version-2.7.md) (January 2020)
* Enhanced Device Type Import ([#451](https://github.com/netbox-community/netbox/issues/451))
* Bulk Import of Device Components ([#822](https://github.com/netbox-community/netbox/issues/822))
* External File Storage ([#1814](https://github.com/netbox-community/netbox/issues/1814))
* Rack Elevations Rendered via SVG ([#2248](https://github.com/netbox-community/netbox/issues/2248))
#### [Version 2.6](./version-2.6.md) (June 2019)
* Power Panels and Feeds ([#54](https://github.com/netbox-community/netbox/issues/54))
* Caching ([#2647](https://github.com/netbox-community/netbox/issues/2647))
* View Permissions ([#323](https://github.com/netbox-community/netbox/issues/323))
* Custom Links ([#969](https://github.com/netbox-community/netbox/issues/969))
* Prometheus Metrics ([#3104](https://github.com/netbox-community/netbox/issues/3104))
#### [Version 2.5](./version-2.5.md) (December 2018)
* Patch Panels and Cables ([#20](https://github.com/netbox-community/netbox/issues/20))
#### [Version 2.4](./version-2.4.md) (August 2018)
* Webhooks ([#81](https://github.com/netbox-community/netbox/issues/81))
* Tagging ([#132](https://github.com/netbox-community/netbox/issues/132))
* Contextual Configuration Data ([#1349](https://github.com/netbox-community/netbox/issues/1349))
* Change Logging ([#1898](https://github.com/netbox-community/netbox/issues/1898))
#### [Version 2.3](./version-2.3.md) (February 2018)
* Virtual Chassis ([#99](https://github.com/netbox-community/netbox/issues/99))
* Interface VLAN Assignments ([#150](https://github.com/netbox-community/netbox/issues/150))
* Bulk Object Creation via the API ([#1553](https://github.com/netbox-community/netbox/issues/1553))
* Automatic Provisioning of Next Available Prefixes ([#1694](https://github.com/netbox-community/netbox/issues/1694))
* Bulk Renaming of Device/VM Components ([#1781](https://github.com/netbox-community/netbox/issues/1781))
#### [Version 2.2](./version-2.2.md) (October 2017)
* Virtual Machines and Clusters ([#142](https://github.com/netbox-community/netbox/issues/142))
* Custom Validation Reports ([#1511](https://github.com/netbox-community/netbox/issues/1511))
#### [Version 2.1](./version-2.1.md) (July 2017)
* IP Address Roles ([#819](https://github.com/netbox-community/netbox/issues/819))
* Automatic Provisioning of Next Available IP ([#1246](https://github.com/netbox-community/netbox/issues/1246))
* NAPALM Integration ([#1348](https://github.com/netbox-community/netbox/issues/1348))
#### [Version 2.0](./version-2.0.md) (May 2017)
* API 2.0 ([#113](https://github.com/netbox-community/netbox/issues/113))
* Image Attachments ([#152](https://github.com/netbox-community/netbox/issues/152))
* Global Search ([#159](https://github.com/netbox-community/netbox/issues/159))
* Rack Elevations View ([#951](https://github.com/netbox-community/netbox/issues/951))

View File

@@ -1,5 +1,119 @@
# NetBox v3.0
## v3.0.12 (2021-12-06)
### Enhancements
* [#7751](https://github.com/netbox-community/netbox/issues/7751) - Get API user from LDAP only when `FIND_GROUP_PERMS` is enabled
* [#7885](https://github.com/netbox-community/netbox/issues/7885) - Linkify VLAN name in VLANs table
* [#7892](https://github.com/netbox-community/netbox/issues/7892) - Add L22-30 power port & outlet types
* [#7932](https://github.com/netbox-community/netbox/issues/7932) - Improve performance of the "quick find" function
* [#7941](https://github.com/netbox-community/netbox/issues/7941) - Add multi-standard ITA power outlet type
### Bug Fixes
* [#7823](https://github.com/netbox-community/netbox/issues/7823) - Fix issue where `return_url` is not honored when 'Save & Continue' button is present
* [#7981](https://github.com/netbox-community/netbox/issues/7981) - Fix Markdown sanitization regex
---
## v3.0.11 (2021-11-24)
### Enhancements
* [#2101](https://github.com/netbox-community/netbox/issues/2101) - Add missing `q` filters for necessary models
* [#7424](https://github.com/netbox-community/netbox/issues/7424) - Add virtual chassis filters for device components
* [#7531](https://github.com/netbox-community/netbox/issues/7531) - Add Markdown support for strikethrough formatting
* [#7542](https://github.com/netbox-community/netbox/issues/7542) - Add optional VLAN group column to prefixes table
* [#7803](https://github.com/netbox-community/netbox/issues/7803) - Improve live reloading of custom scripts
* [#7810](https://github.com/netbox-community/netbox/issues/7810) - Add IEEE 802.15.1 interface type
### Bug Fixes
* [#7399](https://github.com/netbox-community/netbox/issues/7399) - Fix excessive CPU utilization when `AUTH_LDAP_FIND_GROUP_PERMS` is enabled
* [#7657](https://github.com/netbox-community/netbox/issues/7657) - Make change logging middleware thread-safe
* [#7720](https://github.com/netbox-community/netbox/issues/7720) - Fix initialization of custom script MultiObjectVar field with multiple values
* [#7729](https://github.com/netbox-community/netbox/issues/7729) - Fix permissions evaluation when displaying VLAN group VLANs table
* [#7739](https://github.com/netbox-community/netbox/issues/7739) - Fix exception when tracing cable across circuit with no far end termination
* [#7813](https://github.com/netbox-community/netbox/issues/7813) - Fix handling of errors during export template rendering
* [#7851](https://github.com/netbox-community/netbox/issues/7851) - Add missing cluster name filter for virtual machines
* [#7857](https://github.com/netbox-community/netbox/issues/7857) - Fix ordering IP addresses by assignment status
* [#7859](https://github.com/netbox-community/netbox/issues/7859) - Fix styling of form widgets under cable connection views
* [#7864](https://github.com/netbox-community/netbox/issues/7864) - `power_port` can be null when creating power outlets via REST API
* [#7865](https://github.com/netbox-community/netbox/issues/7865) - REST API should support null values for console port speeds
---
## v3.0.10 (2021-11-12)
### Enhancements
* [#7740](https://github.com/netbox-community/netbox/issues/7740) - Add mini-DIN 8 console port type
* [#7760](https://github.com/netbox-community/netbox/issues/7760) - Add `vid` filter field to VLANs list
* [#7767](https://github.com/netbox-community/netbox/issues/7767) - Add visual aids to interfaces table for type, enabled status
### Bug Fixes
* [#7564](https://github.com/netbox-community/netbox/issues/7564) - Fix assignment of members to virtual chassis with initial position of zero
* [#7701](https://github.com/netbox-community/netbox/issues/7701) - Fix conflation of assigned IP status & role in interface tables
* [#7741](https://github.com/netbox-community/netbox/issues/7741) - Fix 404 when attaching multiple images in succession
* [#7752](https://github.com/netbox-community/netbox/issues/7752) - Fix minimum version check under Python v3.10
* [#7766](https://github.com/netbox-community/netbox/issues/7766) - Add missing outer dimension columns to rack table
* [#7780](https://github.com/netbox-community/netbox/issues/7780) - Preserve multi-line values during CSV file import
* [#7783](https://github.com/netbox-community/netbox/issues/7783) - Fix indentation of locations under site view
* [#7788](https://github.com/netbox-community/netbox/issues/7788) - Improve XSS mitigation in Markdown renderer
* [#7791](https://github.com/netbox-community/netbox/issues/7791) - Enable sorting device bays table by installed device status
* [#7802](https://github.com/netbox-community/netbox/issues/7802) - Differentiate ID and VID columns in VLANs table
* [#7808](https://github.com/netbox-community/netbox/issues/7808) - Fix reference values for content type under custom field import form
* [#7809](https://github.com/netbox-community/netbox/issues/7809) - Add missing export template support for various models
* [#7814](https://github.com/netbox-community/netbox/issues/7814) - Fix restriction of user & group objects in GraphQL API queries
---
## v3.0.9 (2021-11-03)
### Enhancements
* [#6529](https://github.com/netbox-community/netbox/issues/6529) - Introduce the `runscript` management command
* [#6930](https://github.com/netbox-community/netbox/issues/6930) - Add an optional "ID" column to all tables
* [#7668](https://github.com/netbox-community/netbox/issues/7668) - Add "view elevations" button to location view
### Bug Fixes
* [#7599](https://github.com/netbox-community/netbox/issues/7599) - Improve color mode preference handling
* [#7601](https://github.com/netbox-community/netbox/issues/7601) - Correct devices count for locations within global search results
* [#7612](https://github.com/netbox-community/netbox/issues/7612) - Strip HTML from custom field descriptions
* [#7628](https://github.com/netbox-community/netbox/issues/7628) - Fix `load_yaml` method for custom scripts
* [#7643](https://github.com/netbox-community/netbox/issues/7643) - Fix circuit assignment when creating multiple terminations simultaneously
* [#7644](https://github.com/netbox-community/netbox/issues/7644) - Prevent inadvertent deletion of prior change records when deleting objects (#7333 revisited)
* [#7647](https://github.com/netbox-community/netbox/issues/7647) - Require interface assignment when designating IP address as primary for device/VM during CSV import
* [#7664](https://github.com/netbox-community/netbox/issues/7664) - Preserve initial form data when bulk edit validation fails
* [#7717](https://github.com/netbox-community/netbox/issues/7717) - Restore missing tags column on IP range table
* [#7721](https://github.com/netbox-community/netbox/issues/7721) - Retain pagination preference when `MAX_PAGE_SIZE` is zero
---
## v3.0.8 (2021-10-20)
### Enhancements
* [#7551](https://github.com/netbox-community/netbox/issues/7551) - Add UI field to filter interfaces by kind
* [#7561](https://github.com/netbox-community/netbox/issues/7561) - Add a utilization column to the IP ranges table
### Bug Fixes
* [#7300](https://github.com/netbox-community/netbox/issues/7300) - Fix incorrect Device LLDP interface row coloring
* [#7495](https://github.com/netbox-community/netbox/issues/7495) - Fix navigation UI issue that caused improper element overlap
* [#7529](https://github.com/netbox-community/netbox/issues/7529) - Restore horizontal scrolling for tables in narrow viewports
* [#7534](https://github.com/netbox-community/netbox/issues/7534) - Avoid exception when utilizing "create and add another" twice in succession
* [#7544](https://github.com/netbox-community/netbox/issues/7544) - Fix multi-value filtering of custom field objects
* [#7545](https://github.com/netbox-community/netbox/issues/7545) - Fix incorrect display of update/delete events for webhooks
* [#7550](https://github.com/netbox-community/netbox/issues/7550) - Fix rendering of UTF8-encoded data in change records
* [#7556](https://github.com/netbox-community/netbox/issues/7556) - Fix display of version when new release is available
* [#7584](https://github.com/netbox-community/netbox/issues/7584) - Fix alignment of object identifier under object view
---
## v3.0.7 (2021-10-08)
### Enhancements
@@ -352,7 +466,7 @@ Note that NetBox's `rqworker` process will _not_ service custom queues by defaul
* [#6154](https://github.com/netbox-community/netbox/issues/6154) - Allow decimal values for cable lengths
* [#6328](https://github.com/netbox-community/netbox/issues/6328) - Build and serve documentation locally
### Bug Fixes (from v3.2-beta2)
### Bug Fixes (from v3.0-beta2)
* [#6977](https://github.com/netbox-community/netbox/issues/6977) - Truncate global search dropdown on small screens
* [#6979](https://github.com/netbox-community/netbox/issues/6979) - Hide "create & add another" button for circuit terminations

View File

@@ -0,0 +1,248 @@
# NetBox v3.1
## v3.1.2 (2021-12-20)
### Enhancements
* [#7661](https://github.com/netbox-community/netbox/issues/7661) - Remove forced styling of custom banners
* [#7665](https://github.com/netbox-community/netbox/issues/7665) - Add toggle to show only available child prefixes
* [#7999](https://github.com/netbox-community/netbox/issues/7999) - Add 6 GHz and 60 GHz wireless channels
* [#8057](https://github.com/netbox-community/netbox/issues/8057) - Dynamic object tables using HTMX
* [#8080](https://github.com/netbox-community/netbox/issues/8080) - Link to NAT IPs for device/VM primary IPs
* [#8081](https://github.com/netbox-community/netbox/issues/8081) - Allow creating services directly from navigation menu
* [#8083](https://github.com/netbox-community/netbox/issues/8083) - Removed "related devices" panel from device view
* [#8108](https://github.com/netbox-community/netbox/issues/8108) - Improve breadcrumb links for device/VM components
### Bug Fixes
* [#7674](https://github.com/netbox-community/netbox/issues/7674) - Fix inadvertent application of device type context to virtual machines
* [#8074](https://github.com/netbox-community/netbox/issues/8074) - Ordering VMs by name should reference naturalized value
* [#8077](https://github.com/netbox-community/netbox/issues/8077) - Fix exception when attaching image to location, circuit, or power panel
* [#8078](https://github.com/netbox-community/netbox/issues/8078) - Add missing wireless models to `lsmodels()` in `nbshell`
* [#8079](https://github.com/netbox-community/netbox/issues/8079) - Fix validation of LLDP neighbors when connected device has an asset tag
* [#8088](https://github.com/netbox-community/netbox/issues/8088) - Improve legibility of text in labels with light-colored backgrounds
* [#8092](https://github.com/netbox-community/netbox/issues/8092) - Rack elevations should not include device asset tags
* [#8096](https://github.com/netbox-community/netbox/issues/8096) - Fix DataError during change logging of objects with very long string representations
* [#8101](https://github.com/netbox-community/netbox/issues/8101) - Preserve return URL when using "create and add another" button
* [#8102](https://github.com/netbox-community/netbox/issues/8102) - Raise validation error when attempting to assign an IP address to multiple objects
---
## v3.1.1 (2021-12-13)
### Enhancements
* [#8047](https://github.com/netbox-community/netbox/issues/8047) - Display sorting indicator in table column headers
### Bug Fixes
* [#5869](https://github.com/netbox-community/netbox/issues/5869) - Fix permissions evaluation under available prefix/IP REST API endpoints
* [#7519](https://github.com/netbox-community/netbox/issues/7519) - Return a 409 status for unfulfillable available prefix/IP requests
* [#7690](https://github.com/netbox-community/netbox/issues/7690) - Fix custom field integer support for MultiValueNumberFilter
* [#7990](https://github.com/netbox-community/netbox/issues/7990) - Fix `title` display on contact detail view
* [#7996](https://github.com/netbox-community/netbox/issues/7996) - Show WWN field in interface creation form
* [#8001](https://github.com/netbox-community/netbox/issues/8001) - Correct verbose name for wireless LAN group model
* [#8003](https://github.com/netbox-community/netbox/issues/8003) - Fix cable tracing across bridged interfaces with no cable
* [#8005](https://github.com/netbox-community/netbox/issues/8005) - Fix contact email display
* [#8009](https://github.com/netbox-community/netbox/issues/8009) - Validate IP addresses for uniqueness when creating an FHRP group
* [#8010](https://github.com/netbox-community/netbox/issues/8010) - Allow filtering devices by multiple serial numbers
* [#8019](https://github.com/netbox-community/netbox/issues/8019) - Exclude metrics endpoint when `LOGIN_REQUIRED` is true
* [#8030](https://github.com/netbox-community/netbox/issues/8030) - Validate custom field names
* [#8033](https://github.com/netbox-community/netbox/issues/8033) - Fix display of zero values for custom integer fields in tables
* [#8035](https://github.com/netbox-community/netbox/issues/8035) - Redirect back to parent prefix after creating IP address(es) where applicable
* [#8038](https://github.com/netbox-community/netbox/issues/8038) - Placeholder filter should display zero integer values
* [#8042](https://github.com/netbox-community/netbox/issues/8042) - Fix filtering cables list by site slug or rack name
* [#8051](https://github.com/netbox-community/netbox/issues/8051) - Contact group parent assignment should not be required under REST API
---
## v3.1.0 (2021-12-06)
!!! warning "PostgreSQL 10 Required"
NetBox v3.1 requires PostgreSQL 10 or later.
### Breaking Changes
* The `tenant` and `tenant_id` filters for the Cable model now filter on the tenant assigned directly to each cable, rather than on the parent object of either termination.
* The `cable_peer` and `cable_peer_type` attributes of cable termination models have been renamed to `link_peer` and `link_peer_type`, respectively, to accommodate wireless links between interfaces.
* Exported webhooks and custom fields now reference associated content types by raw string value (e.g. "dcim.site") rather than by human-friendly name.
* The 128GFC interface type has been corrected from `128gfc-sfp28` to `128gfc-qsfp28`.
### New Features
#### Contact Objects ([#1344](https://github.com/netbox-community/netbox/issues/1344))
A set of new models for tracking contact information has been introduced within the tenancy app. Users may now create individual contact objects to be associated with various models within NetBox. Each contact has a name, title, email address, etc. Contacts can be arranged in hierarchical groups for ease of management.
When assigning a contact to an object, the user must select a predefined role (e.g. "billing" or "technical") and may optionally indicate a priority relative to other contacts associated with the object. There is no limit on how many contacts can be assigned to an object, nor on how many objects to which a contact can be assigned.
#### Wireless Networks ([#3979](https://github.com/netbox-community/netbox/issues/3979))
This release introduces two new models to represent wireless networks:
* Wireless LAN - A multi-access wireless segment to which any number of wireless interfaces may be attached
* Wireless Link - A point-to-point connection between exactly two wireless interfaces
Both types of connection include SSID and authentication attributes. Additionally, the interface model has been extended to include several attributes pertinent to wireless operation:
* Wireless role - Access point or station
* Channel - A predefined channel within a standardized band
* Channel frequency & width - Customizable channel attributes (e.g. for licensed bands)
#### Dynamic Configuration Updates ([#5883](https://github.com/netbox-community/netbox/issues/5883))
Some parameters of NetBox's configuration are now accessible via the admin UI. These parameters can be modified by an administrator and take effect immediately upon application: There is no need to restart NetBox. Additionally, each iteration of the dynamic configuration is preserved in the database, and can be restored by an administrator at any time.
Dynamic configuration parameters may also still be defined within `configuration.py`, and the settings defined here take precedence over those defined via the user interface.
For a complete list of supported parameters, please see the [dynamic configuration documentation](../configuration/dynamic-settings.md).
#### First Hop Redundancy Protocol (FHRP) Groups ([#6235](https://github.com/netbox-community/netbox/issues/6235))
A new FHRP group model has been introduced to aid in modeling the configurations of protocols such as HSRP, VRRP, and GLBP. Each FHRP group may be assigned one or more virtual IP addresses, as well as an authentication type and key. Member device and VM interfaces may be associated with one or more FHRP groups, with each assignment receiving a numeric priority designation.
#### Conditional Webhooks ([#6238](https://github.com/netbox-community/netbox/issues/6238))
Webhooks now include a `conditions` field, which may be used to specify conditions under which a webhook triggers. For example, you may wish to generate outgoing requests for a device webhook only when its status is "active" or "staged". This can be done by declaring conditional logic in JSON:
```json
{
"attr": "status.value",
"op": "in",
"value": ["active", "staged"]
}
```
Multiple conditions may be nested using AND/OR logic as well. For more information, please see the [conditional logic documentation](../reference/conditions.md).
#### Interface Bridging ([#6346](https://github.com/netbox-community/netbox/issues/6346))
A `bridge` field has been added to the interface model for devices and virtual machines. This can be set to reference another interface on the same parent device/VM to indicate a direct layer two bridging adjacency. Additionally, "bridge" has been added as an interface type. (However, interfaces of any type may be designated as bridged.)
Multiple interfaces can be bridged to a single virtual interface to effect a bridge group. Alternatively, two physical interfaces can be bridged to one another, to effect an internal cross-connect.
#### Multiple ASNs per Site ([#6732](https://github.com/netbox-community/netbox/issues/6732))
With the introduction of the new ASN model, NetBox now supports the assignment of multiple ASNs per site. Each ASN instance must have a 32-bit AS number, and may optionally be assigned to a RIR and/or Tenant.
The `asn` integer field on the site model has been preserved to maintain backward compatability until a later release.
#### Single Sign-On (SSO) Authentication ([#7649](https://github.com/netbox-community/netbox/issues/7649))
Support for single sign-on (SSO) authentication has been added via the [python-social-auth](https://github.com/python-social-auth) library. NetBox administrators can configure one of the [supported authentication backends](https://python-social-auth.readthedocs.io/en/latest/intro.html#auth-providers) to enable SSO authentication for users.
### Enhancements
* [#1337](https://github.com/netbox-community/netbox/issues/1337) - Add WWN field to interfaces
* [#1943](https://github.com/netbox-community/netbox/issues/1943) - Relax uniqueness constraint on cluster names
* [#3839](https://github.com/netbox-community/netbox/issues/3839) - Add `airflow` field for devices types and devices
* [#5143](https://github.com/netbox-community/netbox/issues/5143) - Include a device's asset tag in its display value
* [#6497](https://github.com/netbox-community/netbox/issues/6497) - Extend tag support to organizational models
* [#6615](https://github.com/netbox-community/netbox/issues/6615) - Add filter lookups for custom fields
* [#6711](https://github.com/netbox-community/netbox/issues/6711) - Add `longtext` custom field type with Markdown support
* [#6715](https://github.com/netbox-community/netbox/issues/6715) - Add tenant assignment for cables
* [#6874](https://github.com/netbox-community/netbox/issues/6874) - Add tenant assignment for locations
* [#7354](https://github.com/netbox-community/netbox/issues/7354) - Relax uniqueness constraints on region, site group, and location names
* [#7452](https://github.com/netbox-community/netbox/issues/7452) - Add `json` custom field type
* [#7530](https://github.com/netbox-community/netbox/issues/7530) - Move device type component lists to separate views
* [#7606](https://github.com/netbox-community/netbox/issues/7606) - Model transmit power for interfaces
* [#7619](https://github.com/netbox-community/netbox/issues/7619) - Permit custom validation rules to be defined as plain data or dotted path to class
* [#7761](https://github.com/netbox-community/netbox/issues/7761) - Extend cable tracing across bridged interfaces
* [#7812](https://github.com/netbox-community/netbox/issues/7812) - Enable change logging for image attachments
* [#7858](https://github.com/netbox-community/netbox/issues/7858) - Standardize the representation of content types across import & export functions
### Bug Fixes
* [#7589](https://github.com/netbox-community/netbox/issues/7589) - Correct 128GFC interface type identifier
### Other Changes
* [#7318](https://github.com/netbox-community/netbox/issues/7318) - Raise minimum required PostgreSQL version from 9.6 to 10
### REST API Changes
* Added the following endpoints for ASNs:
* `/api/ipam/asn/`
* Added the following endpoints for FHRP groups:
* `/api/ipam/fhrp-groups/`
* `/api/ipam/fhrp-group-assignments/`
* Added the following endpoints for contacts:
* `/api/tenancy/contact-assignments/`
* `/api/tenancy/contact-groups/`
* `/api/tenancy/contact-roles/`
* `/api/tenancy/contacts/`
* Added the following endpoints for wireless networks:
* `/api/wireless/wireless-lans/`
* `/api/wireless/wireless-lan-groups/`
* `/api/wireless/wireless-links/`
* Added `tags` field to the following models:
* circuits.CircuitType
* dcim.DeviceRole
* dcim.Location
* dcim.Manufacturer
* dcim.Platform
* dcim.RackRole
* dcim.Region
* dcim.SiteGroup
* ipam.RIR
* ipam.Role
* ipam.VLANGroup
* tenancy.ContactGroup
* tenancy.ContactRole
* tenancy.TenantGroup
* virtualization.ClusterGroup
* virtualization.ClusterType
* circuits.CircuitTermination
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.Cable
* Added `tenant` field
* dcim.ConsolePort
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.ConsoleServerPort
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.Device
* The `display` field now includes the device's asset tag, if set
* Added `airflow` field
* dcim.DeviceType
* Added `airflow` field
* dcim.FrontPort
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.Interface
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* Added `bridge` field
* Added `rf_channel` field
* Added `rf_channel_frequency` field
* Added `rf_channel_width` field
* Added `rf_role` field
* Added `tx_power` field
* Added `wireless_link` field
* Added `wwn` field
* Added `count_fhrp_groups` read-only field
* dcim.Location
* Added `tenant` field
* dcim.PowerFeed
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.PowerOutlet
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.PowerPort
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.RearPort
* `cable_peer` has been renamed to `link_peer`
* `cable_peer_type` has been renamed to `link_peer_type`
* dcim.Site
* Added `asns` relationship to ipam.ASN
* extras.ImageAttachment
* Added the `last_updated` field
* extras.Webhook
* Added the `conditions` field
* virtualization.VMInterface
* Added `bridge` field
* Added `count_fhrp_groups` read-only field

View File

@@ -308,7 +308,7 @@ Vary: Accept
}
```
The default page is determined by the [`PAGINATE_COUNT`](../configuration/optional-settings.md#paginate_count) configuration parameter, which defaults to 50. However, this can be overridden per request by specifying the desired `offset` and `limit` query parameters. For example, if you wish to retrieve a hundred devices at a time, you would make a request for:
The default page is determined by the [`PAGINATE_COUNT`](../configuration/dynamic-settings.md#paginate_count) configuration parameter, which defaults to 50. However, this can be overridden per request by specifying the desired `offset` and `limit` query parameters. For example, if you wish to retrieve a hundred devices at a time, you would make a request for:
```
http://netbox/api/dcim/devices/?limit=100
@@ -325,7 +325,7 @@ The response will return devices 1 through 100. The URL provided in the `next` a
}
```
The maximum number of objects that can be returned is limited by the [`MAX_PAGE_SIZE`](../configuration/optional-settings.md#max_page_size) configuration parameter, which is 1000 by default. Setting this to `0` or `None` will remove the maximum limit. An API consumer can then pass `?limit=0` to retrieve _all_ matching objects with a single request.
The maximum number of objects that can be returned is limited by the [`MAX_PAGE_SIZE`](../configuration/dynamic-settings.md#max_page_size) configuration parameter, which is 1000 by default. Setting this to `0` or `None` will remove the maximum limit. An API consumer can then pass `?limit=0` to retrieve _all_ matching objects with a single request.
!!! warning
Disabling the page size limit introduces a potential for very resource-intensive requests, since one API request can effectively retrieve an entire table from the database.

View File

@@ -51,6 +51,8 @@ nav:
- Configuring NetBox: 'configuration/index.md'
- Required Settings: 'configuration/required-settings.md'
- Optional Settings: 'configuration/optional-settings.md'
- Dynamic Settings: 'configuration/dynamic-settings.md'
- Remote Authentication: 'configuration/remote-authentication.md'
- Core Functionality:
- IP Address Management: 'core-functionality/ipam.md'
- VLAN Management: 'core-functionality/vlans.md'
@@ -60,12 +62,14 @@ nav:
- Virtualization: 'core-functionality/virtualization.md'
- Service Mapping: 'core-functionality/services.md'
- Circuits: 'core-functionality/circuits.md'
- Wireless: 'core-functionality/wireless.md'
- Power Tracking: 'core-functionality/power.md'
- Tenancy: 'core-functionality/tenancy.md'
- Contacts: 'core-functionality/contacts.md'
- Customization:
- Custom Fields: 'customization/custom-fields.md'
- Custom Validation: 'customization/custom-validation.md'
- Custom Links: 'customization/custom-links.md'
- Custom Links: 'models/extras/customlink.md'
- Export Templates: 'customization/export-templates.md'
- Custom Scripts: 'customization/custom-scripts.md'
- Reports: 'customization/reports.md'
@@ -81,6 +85,7 @@ nav:
- Using Plugins: 'plugins/index.md'
- Developing Plugins: 'plugins/development.md'
- Administration:
- Authentication: 'administration/authentication.md'
- Permissions: 'administration/permissions.md'
- Housekeeping: 'administration/housekeeping.md'
- Replicating NetBox: 'administration/replicating-netbox.md'
@@ -91,6 +96,8 @@ nav:
- Authentication: 'rest-api/authentication.md'
- GraphQL API:
- Overview: 'graphql-api/overview.md'
- Reference:
- Conditions: 'reference/conditions.md'
- Development:
- Introduction: 'development/index.md'
- Getting Started: 'development/getting-started.md'
@@ -104,6 +111,8 @@ nav:
- Web UI: 'development/web-ui.md'
- Release Checklist: 'development/release-checklist.md'
- Release Notes:
- Summary: 'release-notes/index.md'
- Version 3.1: 'release-notes/version-3.1.md'
- Version 3.0: 'release-notes/version-3.0.md'
- Version 2.11: 'release-notes/version-2.11.md'
- Version 2.10: 'release-notes/version-2.10.md'

View File

@@ -3,11 +3,9 @@ from rest_framework import serializers
from circuits.choices import CircuitStatusChoices
from circuits.models import *
from dcim.api.nested_serializers import NestedCableSerializer, NestedSiteSerializer
from dcim.api.serializers import CableTerminationSerializer
from dcim.api.serializers import LinkTerminationSerializer
from netbox.api import ChoiceField
from netbox.api.serializers import (
OrganizationalModelSerializer, PrimaryModelSerializer, ValidatedModelSerializer, WritableNestedSerializer
)
from netbox.api.serializers import PrimaryModelSerializer, ValidatedModelSerializer, WritableNestedSerializer
from tenancy.api.nested_serializers import NestedTenantSerializer
from .nested_serializers import *
@@ -48,14 +46,14 @@ class ProviderNetworkSerializer(PrimaryModelSerializer):
# Circuits
#
class CircuitTypeSerializer(OrganizationalModelSerializer):
class CircuitTypeSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='circuits-api:circuittype-detail')
circuit_count = serializers.IntegerField(read_only=True)
class Meta:
model = CircuitType
fields = [
'id', 'url', 'display', 'name', 'slug', 'description', 'custom_fields', 'created', 'last_updated',
'id', 'url', 'display', 'name', 'slug', 'description', 'tags', 'custom_fields', 'created', 'last_updated',
'circuit_count',
]
@@ -90,7 +88,7 @@ class CircuitSerializer(PrimaryModelSerializer):
]
class CircuitTerminationSerializer(ValidatedModelSerializer, CableTerminationSerializer):
class CircuitTerminationSerializer(ValidatedModelSerializer, LinkTerminationSerializer):
url = serializers.HyperlinkedIdentityField(view_name='circuits-api:circuittermination-detail')
circuit = NestedCircuitSerializer()
site = NestedSiteSerializer(required=False, allow_null=True)
@@ -101,6 +99,6 @@ class CircuitTerminationSerializer(ValidatedModelSerializer, CableTerminationSer
model = CircuitTermination
fields = [
'id', 'url', 'display', 'circuit', 'term_side', 'site', 'provider_network', 'port_speed', 'upstream_speed',
'xconnect_id', 'pp_info', 'description', 'mark_connected', 'cable', 'cable_peer', 'cable_peer_type',
'xconnect_id', 'pp_info', 'description', 'mark_connected', 'cable', 'link_peer', 'link_peer_type',
'_occupied',
]

View File

@@ -34,7 +34,7 @@ class ProviderViewSet(CustomFieldModelViewSet):
#
class CircuitTypeViewSet(CustomFieldModelViewSet):
queryset = CircuitType.objects.annotate(
queryset = CircuitType.objects.prefetch_related('tags').annotate(
circuit_count=count_related(Circuit, 'type')
)
serializer_class = serializers.CircuitTypeSerializer

View File

@@ -111,6 +111,7 @@ class ProviderNetworkFilterSet(PrimaryModelFilterSet):
class CircuitTypeFilterSet(OrganizationalModelFilterSet):
tag = TagFilter()
class Meta:
model = CircuitType

View File

@@ -4,9 +4,7 @@ from circuits.choices import CircuitStatusChoices
from circuits.models import *
from extras.forms import AddRemoveTagsForm, CustomFieldModelBulkEditForm
from tenancy.models import Tenant
from utilities.forms import (
add_blank_choice, BootstrapMixin, CommentField, DynamicModelChoiceField, SmallTextarea, StaticSelect,
)
from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, SmallTextarea, StaticSelect
__all__ = (
'CircuitBulkEditForm',
@@ -16,7 +14,7 @@ __all__ = (
)
class ProviderBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class ProviderBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Provider.objects.all(),
widget=forms.MultipleHiddenInput
@@ -55,7 +53,7 @@ class ProviderBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBu
]
class ProviderNetworkBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class ProviderNetworkBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=ProviderNetwork.objects.all(),
widget=forms.MultipleHiddenInput
@@ -79,7 +77,7 @@ class ProviderNetworkBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomField
]
class CircuitTypeBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class CircuitTypeBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=CircuitType.objects.all(),
widget=forms.MultipleHiddenInput
@@ -93,7 +91,7 @@ class CircuitTypeBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['description']
class CircuitBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class CircuitBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Circuit.objects.all(),
widget=forms.MultipleHiddenInput

View File

@@ -6,7 +6,7 @@ from circuits.models import *
from dcim.models import Region, Site, SiteGroup
from extras.forms import CustomFieldModelFilterForm
from tenancy.forms import TenancyFilterForm
from utilities.forms import BootstrapMixin, DynamicModelMultipleChoiceField, StaticSelectMultiple, TagFilterField
from utilities.forms import DynamicModelMultipleChoiceField, StaticSelectMultiple, TagFilterField
__all__ = (
'CircuitFilterForm',
@@ -16,18 +16,13 @@ __all__ = (
)
class ProviderFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class ProviderFilterForm(CustomFieldModelFilterForm):
model = Provider
field_groups = [
['q', 'tag'],
['region_id', 'site_group_id', 'site_id'],
['asn'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -57,17 +52,12 @@ class ProviderFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
tag = TagFilterField(model)
class ProviderNetworkFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class ProviderNetworkFilterForm(CustomFieldModelFilterForm):
model = ProviderNetwork
field_groups = (
('q', 'tag'),
('provider_id',),
)
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
provider_id = DynamicModelMultipleChoiceField(
queryset=Provider.objects.all(),
required=False,
@@ -77,19 +67,12 @@ class ProviderNetworkFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
tag = TagFilterField(model)
class CircuitTypeFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class CircuitTypeFilterForm(CustomFieldModelFilterForm):
model = CircuitType
field_groups = [
['q'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
tag = TagFilterField(model)
class CircuitFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterForm):
class CircuitFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = Circuit
field_groups = [
['q', 'tag'],
@@ -98,11 +81,6 @@ class CircuitFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilte
['region_id', 'site_group_id', 'site_id'],
['tenant_group_id', 'tenant_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
type_id = DynamicModelMultipleChoiceField(
queryset=CircuitType.objects.all(),
required=False,

View File

@@ -19,7 +19,7 @@ __all__ = (
)
class ProviderForm(BootstrapMixin, CustomFieldModelForm):
class ProviderForm(CustomFieldModelForm):
slug = SlugField()
comments = CommentField()
tags = DynamicModelMultipleChoiceField(
@@ -53,7 +53,7 @@ class ProviderForm(BootstrapMixin, CustomFieldModelForm):
}
class ProviderNetworkForm(BootstrapMixin, CustomFieldModelForm):
class ProviderNetworkForm(CustomFieldModelForm):
provider = DynamicModelChoiceField(
queryset=Provider.objects.all()
)
@@ -73,17 +73,21 @@ class ProviderNetworkForm(BootstrapMixin, CustomFieldModelForm):
)
class CircuitTypeForm(BootstrapMixin, CustomFieldModelForm):
class CircuitTypeForm(CustomFieldModelForm):
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = CircuitType
fields = [
'name', 'slug', 'description',
'name', 'slug', 'description', 'tags',
]
class CircuitForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class CircuitForm(TenancyForm, CustomFieldModelForm):
provider = DynamicModelChoiceField(
queryset=Provider.objects.all()
)

View File

@@ -0,0 +1,20 @@
# Generated by Django 3.2.8 on 2021-10-21 14:50
from django.db import migrations
import taggit.managers
class Migration(migrations.Migration):
dependencies = [
('extras', '0062_clear_secrets_changelog'),
('circuits', '0002_squashed_0029'),
]
operations = [
migrations.AddField(
model_name='circuittype',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
]

View File

@@ -0,0 +1,21 @@
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('circuits', '0003_extend_tag_support'),
]
operations = [
migrations.RenameField(
model_name='circuittermination',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='circuittermination',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
]

View File

@@ -0,0 +1,2 @@
from .circuits import *
from .providers import *

View File

@@ -3,127 +3,19 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.urls import reverse
from dcim.fields import ASNField
from dcim.models import CableTermination, PathEndpoint
from extras.models import ObjectChange
from circuits.choices import *
from dcim.models import LinkTermination
from extras.utils import extras_features
from netbox.models import BigIDModel, ChangeLoggedModel, OrganizationalModel, PrimaryModel
from utilities.querysets import RestrictedQuerySet
from .choices import *
from netbox.models import ChangeLoggedModel, OrganizationalModel, PrimaryModel
__all__ = (
'Circuit',
'CircuitTermination',
'CircuitType',
'ProviderNetwork',
'Provider',
)
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class Provider(PrimaryModel):
"""
Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model
stores information pertinent to the user's relationship with the Provider.
"""
name = models.CharField(
max_length=100,
unique=True
)
slug = models.SlugField(
max_length=100,
unique=True
)
asn = ASNField(
blank=True,
null=True,
verbose_name='ASN',
help_text='32-bit autonomous system number'
)
account = models.CharField(
max_length=30,
blank=True,
verbose_name='Account number'
)
portal_url = models.URLField(
blank=True,
verbose_name='Portal URL'
)
noc_contact = models.TextField(
blank=True,
verbose_name='NOC contact'
)
admin_contact = models.TextField(
blank=True,
verbose_name='Admin contact'
)
comments = models.TextField(
blank=True
)
objects = RestrictedQuerySet.as_manager()
clone_fields = [
'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact',
]
class Meta:
ordering = ['name']
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('circuits:provider', args=[self.pk])
#
# Provider networks
#
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class ProviderNetwork(PrimaryModel):
"""
This represents a provider network which exists outside of NetBox, the details of which are unknown or
unimportant to the user.
"""
name = models.CharField(
max_length=100
)
provider = models.ForeignKey(
to='circuits.Provider',
on_delete=models.PROTECT,
related_name='networks'
)
description = models.CharField(
max_length=200,
blank=True
)
comments = models.TextField(
blank=True
)
objects = RestrictedQuerySet.as_manager()
class Meta:
ordering = ('provider', 'name')
constraints = (
models.UniqueConstraint(
fields=('provider', 'name'),
name='circuits_providernetwork_provider_name'
),
)
unique_together = ('provider', 'name')
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('circuits:providernetwork', args=[self.pk])
@extras_features('custom_fields', 'custom_links', 'export_templates', 'webhooks')
class CircuitType(OrganizationalModel):
"""
Circuits can be organized by their functional role. For example, a user might wish to define CircuitTypes named
@@ -142,8 +34,6 @@ class CircuitType(OrganizationalModel):
blank=True,
)
objects = RestrictedQuerySet.as_manager()
class Meta:
ordering = ['name']
@@ -203,6 +93,11 @@ class Circuit(PrimaryModel):
comments = models.TextField(
blank=True
)
# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
@@ -225,8 +120,6 @@ class Circuit(PrimaryModel):
null=True
)
objects = RestrictedQuerySet.as_manager()
clone_fields = [
'provider', 'type', 'status', 'tenant', 'install_date', 'commit_rate', 'description',
]
@@ -246,7 +139,7 @@ class Circuit(PrimaryModel):
@extras_features('webhooks')
class CircuitTermination(ChangeLoggedModel, CableTermination):
class CircuitTermination(ChangeLoggedModel, LinkTermination):
circuit = models.ForeignKey(
to='circuits.Circuit',
on_delete=models.CASCADE,
@@ -265,7 +158,7 @@ class CircuitTermination(ChangeLoggedModel, CableTermination):
null=True
)
provider_network = models.ForeignKey(
to=ProviderNetwork,
to='circuits.ProviderNetwork',
on_delete=models.PROTECT,
related_name='circuit_terminations',
blank=True,
@@ -297,8 +190,6 @@ class CircuitTermination(ChangeLoggedModel, CableTermination):
blank=True
)
objects = RestrictedQuerySet.as_manager()
class Meta:
ordering = ['circuit', 'term_side']
unique_together = ['circuit', 'term_side']

View File

@@ -0,0 +1,112 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.urls import reverse
from dcim.fields import ASNField
from extras.utils import extras_features
from netbox.models import PrimaryModel
from utilities.querysets import RestrictedQuerySet
__all__ = (
'ProviderNetwork',
'Provider',
)
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class Provider(PrimaryModel):
"""
Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model
stores information pertinent to the user's relationship with the Provider.
"""
name = models.CharField(
max_length=100,
unique=True
)
slug = models.SlugField(
max_length=100,
unique=True
)
asn = ASNField(
blank=True,
null=True,
verbose_name='ASN',
help_text='32-bit autonomous system number'
)
account = models.CharField(
max_length=30,
blank=True,
verbose_name='Account number'
)
portal_url = models.URLField(
blank=True,
verbose_name='Portal URL'
)
noc_contact = models.TextField(
blank=True,
verbose_name='NOC contact'
)
admin_contact = models.TextField(
blank=True,
verbose_name='Admin contact'
)
comments = models.TextField(
blank=True
)
# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
clone_fields = [
'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact',
]
class Meta:
ordering = ['name']
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('circuits:provider', args=[self.pk])
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class ProviderNetwork(PrimaryModel):
"""
This represents a provider network which exists outside of NetBox, the details of which are unknown or
unimportant to the user.
"""
name = models.CharField(
max_length=100
)
provider = models.ForeignKey(
to='circuits.Provider',
on_delete=models.PROTECT,
related_name='networks'
)
description = models.CharField(
max_length=200,
blank=True
)
comments = models.TextField(
blank=True
)
class Meta:
ordering = ('provider', 'name')
constraints = (
models.UniqueConstraint(
fields=('provider', 'name'),
name='circuits_providernetwork_provider_name'
),
)
unique_together = ('provider', 'name')
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('circuits:providernetwork', args=[self.pk])

View File

@@ -11,6 +11,7 @@ def update_circuit(instance, **kwargs):
When a CircuitTermination has been modified, update its parent Circuit.
"""
termination_name = f'termination_{instance.term_side.lower()}'
instance.circuit.refresh_from_db()
setattr(instance.circuit, termination_name, instance)
instance.circuit.save()

View File

@@ -44,8 +44,8 @@ class ProviderTable(BaseTable):
class Meta(BaseTable.Meta):
model = Provider
fields = (
'pk', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count', 'comments',
'tags',
'pk', 'id', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count',
'comments', 'tags',
)
default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')
@@ -69,7 +69,7 @@ class ProviderNetworkTable(BaseTable):
class Meta(BaseTable.Meta):
model = ProviderNetwork
fields = ('pk', 'name', 'provider', 'description', 'comments', 'tags')
fields = ('pk', 'id', 'name', 'provider', 'description', 'comments', 'tags')
default_columns = ('pk', 'name', 'provider', 'description')
@@ -82,6 +82,9 @@ class CircuitTypeTable(BaseTable):
name = tables.Column(
linkify=True
)
tags = TagColumn(
url_name='circuits:circuittype_list'
)
circuit_count = tables.Column(
verbose_name='Circuits'
)
@@ -89,7 +92,7 @@ class CircuitTypeTable(BaseTable):
class Meta(BaseTable.Meta):
model = CircuitType
fields = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')
fields = ('pk', 'id', 'name', 'circuit_count', 'description', 'slug', 'tags', 'actions')
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')
@@ -101,7 +104,7 @@ class CircuitTable(BaseTable):
pk = ToggleColumn()
cid = tables.Column(
linkify=True,
verbose_name='ID'
verbose_name='Circuit ID'
)
provider = tables.Column(
linkify=True
@@ -124,7 +127,7 @@ class CircuitTable(BaseTable):
class Meta(BaseTable.Meta):
model = Circuit
fields = (
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'install_date',
'pk', 'id', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'install_date',
'commit_rate', 'description', 'comments', 'tags',
)
default_columns = (

View File

@@ -64,10 +64,13 @@ class CircuitTypeTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
CircuitType(name='Circuit Type 3', slug='circuit-type-3'),
])
tags = create_tags('Alpha', 'Bravo', 'Charlie')
cls.form_data = {
'name': 'Circuit Type X',
'slug': 'circuit-type-x',
'description': 'A new circuit type',
'tags': [t.pk for t in tags],
}
cls.csv_data = (

View File

@@ -340,7 +340,7 @@ class NestedVirtualChassisSerializer(WritableNestedSerializer):
class Meta:
model = models.VirtualChassis
fields = ['id', 'name', 'url', 'master', 'member_count']
fields = ['id', 'url', 'display', 'name', 'master', 'member_count']
#

View File

@@ -1,46 +1,47 @@
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from drf_yasg.utils import swagger_serializer_method
from rest_framework import serializers
from rest_framework.validators import UniqueTogetherValidator
from timezone_field.rest_framework import TimeZoneSerializerField
from dcim.choices import *
from dcim.constants import *
from dcim.models import *
from ipam.api.nested_serializers import NestedIPAddressSerializer, NestedVLANSerializer
from ipam.models import VLAN
from ipam.api.nested_serializers import NestedASNSerializer, NestedIPAddressSerializer, NestedVLANSerializer
from ipam.models import ASN, VLAN
from netbox.api import ChoiceField, ContentTypeField, SerializedPKRelatedField
from netbox.api.serializers import (
NestedGroupModelSerializer, OrganizationalModelSerializer, PrimaryModelSerializer, ValidatedModelSerializer,
WritableNestedSerializer,
NestedGroupModelSerializer, PrimaryModelSerializer, ValidatedModelSerializer, WritableNestedSerializer,
)
from netbox.config import ConfigItem
from tenancy.api.nested_serializers import NestedTenantSerializer
from users.api.nested_serializers import NestedUserSerializer
from utilities.api import get_serializer_for_model
from virtualization.api.nested_serializers import NestedClusterSerializer
from wireless.api.nested_serializers import NestedWirelessLANSerializer, NestedWirelessLinkSerializer
from wireless.choices import *
from wireless.models import WirelessLAN
from .nested_serializers import *
class CableTerminationSerializer(serializers.ModelSerializer):
cable_peer_type = serializers.SerializerMethodField(read_only=True)
cable_peer = serializers.SerializerMethodField(read_only=True)
class LinkTerminationSerializer(serializers.ModelSerializer):
link_peer_type = serializers.SerializerMethodField(read_only=True)
link_peer = serializers.SerializerMethodField(read_only=True)
_occupied = serializers.SerializerMethodField(read_only=True)
def get_cable_peer_type(self, obj):
if obj._cable_peer is not None:
return f'{obj._cable_peer._meta.app_label}.{obj._cable_peer._meta.model_name}'
def get_link_peer_type(self, obj):
if obj._link_peer is not None:
return f'{obj._link_peer._meta.app_label}.{obj._link_peer._meta.model_name}'
return None
@swagger_serializer_method(serializer_or_field=serializers.DictField)
def get_cable_peer(self, obj):
def get_link_peer(self, obj):
"""
Return the appropriate serializer for the cable termination model.
Return the appropriate serializer for the link termination model.
"""
if obj._cable_peer is not None:
serializer = get_serializer_for_model(obj._cable_peer, prefix='Nested')
if obj._link_peer is not None:
serializer = get_serializer_for_model(obj._link_peer, prefix='Nested')
context = {'request': self.context['request']}
return serializer(obj._cable_peer, context=context).data
return serializer(obj._link_peer, context=context).data
return None
@swagger_serializer_method(serializer_or_field=serializers.BooleanField)
@@ -82,27 +83,27 @@ class ConnectedEndpointSerializer(serializers.ModelSerializer):
class RegionSerializer(NestedGroupModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:region-detail')
parent = NestedRegionSerializer(required=False, allow_null=True)
parent = NestedRegionSerializer(required=False, allow_null=True, default=None)
site_count = serializers.IntegerField(read_only=True)
class Meta:
model = Region
fields = [
'id', 'url', 'display', 'name', 'slug', 'parent', 'description', 'custom_fields', 'created', 'last_updated',
'site_count', '_depth',
'id', 'url', 'display', 'name', 'slug', 'parent', 'description', 'tags', 'custom_fields', 'created',
'last_updated', 'site_count', '_depth',
]
class SiteGroupSerializer(NestedGroupModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:sitegroup-detail')
parent = NestedSiteGroupSerializer(required=False, allow_null=True)
parent = NestedSiteGroupSerializer(required=False, allow_null=True, default=None)
site_count = serializers.IntegerField(read_only=True)
class Meta:
model = SiteGroup
fields = [
'id', 'url', 'display', 'name', 'slug', 'parent', 'description', 'custom_fields', 'created', 'last_updated',
'site_count', '_depth',
'id', 'url', 'display', 'name', 'slug', 'parent', 'description', 'tags', 'custom_fields', 'created',
'last_updated', 'site_count', '_depth',
]
@@ -113,6 +114,14 @@ class SiteSerializer(PrimaryModelSerializer):
group = NestedSiteGroupSerializer(required=False, allow_null=True)
tenant = NestedTenantSerializer(required=False, allow_null=True)
time_zone = TimeZoneSerializerField(required=False)
asns = SerializedPKRelatedField(
queryset=ASN.objects.all(),
serializer=NestedASNSerializer,
required=False,
many=True
)
# Related object counts
circuit_count = serializers.IntegerField(read_only=True)
device_count = serializers.IntegerField(read_only=True)
prefix_count = serializers.IntegerField(read_only=True)
@@ -123,7 +132,7 @@ class SiteSerializer(PrimaryModelSerializer):
class Meta:
model = Site
fields = [
'id', 'url', 'display', 'name', 'slug', 'status', 'region', 'group', 'tenant', 'facility', 'asn',
'id', 'url', 'display', 'name', 'slug', 'status', 'region', 'group', 'tenant', 'facility', 'asn', 'asns',
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name',
'contact_phone', 'contact_email', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
'circuit_count', 'device_count', 'prefix_count', 'rack_count', 'virtualmachine_count', 'vlan_count',
@@ -138,26 +147,27 @@ class LocationSerializer(NestedGroupModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:location-detail')
site = NestedSiteSerializer()
parent = NestedLocationSerializer(required=False, allow_null=True)
tenant = NestedTenantSerializer(required=False, allow_null=True)
rack_count = serializers.IntegerField(read_only=True)
device_count = serializers.IntegerField(read_only=True)
class Meta:
model = Location
fields = [
'id', 'url', 'display', 'name', 'slug', 'site', 'parent', 'description', 'custom_fields', 'created',
'last_updated', 'rack_count', 'device_count', '_depth',
'id', 'url', 'display', 'name', 'slug', 'site', 'parent', 'tenant', 'description', 'tags', 'custom_fields',
'created', 'last_updated', 'rack_count', 'device_count', '_depth',
]
class RackRoleSerializer(OrganizationalModelSerializer):
class RackRoleSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:rackrole-detail')
rack_count = serializers.IntegerField(read_only=True)
class Meta:
model = RackRole
fields = [
'id', 'url', 'display', 'name', 'slug', 'color', 'description', 'custom_fields', 'created', 'last_updated',
'rack_count',
'id', 'url', 'display', 'name', 'slug', 'color', 'description', 'tags', 'custom_fields', 'created',
'last_updated', 'rack_count',
]
@@ -169,6 +179,8 @@ class RackSerializer(PrimaryModelSerializer):
status = ChoiceField(choices=RackStatusChoices, required=False)
role = NestedRackRoleSerializer(required=False, allow_null=True)
type = ChoiceField(choices=RackTypeChoices, allow_blank=True, required=False)
facility_id = serializers.CharField(max_length=50, allow_blank=True, allow_null=True, label='Facility ID',
default=None)
width = ChoiceField(choices=RackWidthChoices, required=False)
outer_unit = ChoiceField(choices=RackDimensionUnitChoices, allow_blank=True, required=False)
device_count = serializers.IntegerField(read_only=True)
@@ -181,23 +193,6 @@ class RackSerializer(PrimaryModelSerializer):
'asset_tag', 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit',
'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', 'powerfeed_count',
]
# Omit the UniqueTogetherValidator that would be automatically added to validate (location, facility_id). This
# prevents facility_id from being interpreted as a required field.
validators = [
UniqueTogetherValidator(queryset=Rack.objects.all(), fields=('location', 'name'))
]
def validate(self, data):
# Validate uniqueness of (location, facility_id) since we omitted the automatically-created validator from Meta.
if data.get('facility_id', None):
validator = UniqueTogetherValidator(queryset=Rack.objects.all(), fields=('location', 'facility_id'))
validator(data, self)
# Enforce model validation
super().validate(data)
return data
class RackUnitSerializer(serializers.Serializer):
@@ -243,10 +238,10 @@ class RackElevationDetailFilterSerializer(serializers.Serializer):
default=RackElevationDetailRenderChoices.RENDER_JSON
)
unit_width = serializers.IntegerField(
default=settings.RACK_ELEVATION_DEFAULT_UNIT_WIDTH
default=ConfigItem('RACK_ELEVATION_DEFAULT_UNIT_WIDTH')
)
unit_height = serializers.IntegerField(
default=settings.RACK_ELEVATION_DEFAULT_UNIT_HEIGHT
default=ConfigItem('RACK_ELEVATION_DEFAULT_UNIT_HEIGHT')
)
legend_width = serializers.IntegerField(
default=RACK_ELEVATION_LEGEND_WIDTH_DEFAULT
@@ -269,7 +264,7 @@ class RackElevationDetailFilterSerializer(serializers.Serializer):
# Device types
#
class ManufacturerSerializer(OrganizationalModelSerializer):
class ManufacturerSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:manufacturer-detail')
devicetype_count = serializers.IntegerField(read_only=True)
inventoryitem_count = serializers.IntegerField(read_only=True)
@@ -278,7 +273,7 @@ class ManufacturerSerializer(OrganizationalModelSerializer):
class Meta:
model = Manufacturer
fields = [
'id', 'url', 'display', 'name', 'slug', 'description', 'custom_fields', 'created', 'last_updated',
'id', 'url', 'display', 'name', 'slug', 'description', 'tags', 'custom_fields', 'created', 'last_updated',
'devicetype_count', 'inventoryitem_count', 'platform_count',
]
@@ -287,13 +282,14 @@ class DeviceTypeSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:devicetype-detail')
manufacturer = NestedManufacturerSerializer()
subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False)
airflow = ChoiceField(choices=DeviceAirflowChoices, allow_blank=True, required=False)
device_count = serializers.IntegerField(read_only=True)
class Meta:
model = DeviceType
fields = [
'id', 'url', 'display', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth',
'subdevice_role', 'front_image', 'rear_image', 'comments', 'tags', 'custom_fields', 'created',
'subdevice_role', 'airflow', 'front_image', 'rear_image', 'comments', 'tags', 'custom_fields', 'created',
'last_updated', 'device_count',
]
@@ -356,7 +352,8 @@ class PowerOutletTemplateSerializer(ValidatedModelSerializer):
required=False
)
power_port = NestedPowerPortTemplateSerializer(
required=False
required=False,
allow_null=True
)
feed_leg = ChoiceField(
choices=PowerOutletFeedLegChoices,
@@ -425,7 +422,7 @@ class DeviceBayTemplateSerializer(ValidatedModelSerializer):
# Devices
#
class DeviceRoleSerializer(OrganizationalModelSerializer):
class DeviceRoleSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:devicerole-detail')
device_count = serializers.IntegerField(read_only=True)
virtualmachine_count = serializers.IntegerField(read_only=True)
@@ -433,12 +430,12 @@ class DeviceRoleSerializer(OrganizationalModelSerializer):
class Meta:
model = DeviceRole
fields = [
'id', 'url', 'display', 'name', 'slug', 'color', 'vm_role', 'description', 'custom_fields', 'created',
'last_updated', 'device_count', 'virtualmachine_count',
'id', 'url', 'display', 'name', 'slug', 'color', 'vm_role', 'description', 'tags', 'custom_fields',
'created', 'last_updated', 'device_count', 'virtualmachine_count',
]
class PlatformSerializer(OrganizationalModelSerializer):
class PlatformSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:platform-detail')
manufacturer = NestedManufacturerSerializer(required=False, allow_null=True)
device_count = serializers.IntegerField(read_only=True)
@@ -448,7 +445,7 @@ class PlatformSerializer(OrganizationalModelSerializer):
model = Platform
fields = [
'id', 'url', 'display', 'name', 'slug', 'manufacturer', 'napalm_driver', 'napalm_args', 'description',
'custom_fields', 'created', 'last_updated', 'device_count', 'virtualmachine_count',
'tags', 'custom_fields', 'created', 'last_updated', 'device_count', 'virtualmachine_count',
]
@@ -456,41 +453,31 @@ class DeviceSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:device-detail')
device_type = NestedDeviceTypeSerializer()
device_role = NestedDeviceRoleSerializer()
tenant = NestedTenantSerializer(required=False, allow_null=True)
tenant = NestedTenantSerializer(required=False, allow_null=True, default=None)
platform = NestedPlatformSerializer(required=False, allow_null=True)
site = NestedSiteSerializer()
location = NestedLocationSerializer(required=False, allow_null=True, default=None)
rack = NestedRackSerializer(required=False, allow_null=True)
face = ChoiceField(choices=DeviceFaceChoices, allow_blank=True, required=False)
rack = NestedRackSerializer(required=False, allow_null=True, default=None)
face = ChoiceField(choices=DeviceFaceChoices, allow_blank=True, default='')
position = serializers.IntegerField(allow_null=True, label='Position (U)', min_value=1, default=None)
status = ChoiceField(choices=DeviceStatusChoices, required=False)
airflow = ChoiceField(choices=DeviceAirflowChoices, allow_blank=True, required=False)
primary_ip = NestedIPAddressSerializer(read_only=True)
primary_ip4 = NestedIPAddressSerializer(required=False, allow_null=True)
primary_ip6 = NestedIPAddressSerializer(required=False, allow_null=True)
parent_device = serializers.SerializerMethodField()
cluster = NestedClusterSerializer(required=False, allow_null=True)
virtual_chassis = NestedVirtualChassisSerializer(required=False, allow_null=True)
virtual_chassis = NestedVirtualChassisSerializer(required=False, allow_null=True, default=None)
vc_position = serializers.IntegerField(allow_null=True, max_value=255, min_value=0, default=None)
class Meta:
model = Device
fields = [
'id', 'url', 'display', 'name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag',
'site', 'location', 'rack', 'position', 'face', 'parent_device', 'status', 'primary_ip', 'primary_ip4',
'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'local_context_data',
'tags', 'custom_fields', 'created', 'last_updated',
'site', 'location', 'rack', 'position', 'face', 'parent_device', 'status', 'airflow', 'primary_ip',
'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments',
'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated',
]
validators = []
def validate(self, data):
# Validate uniqueness of (rack, position, face) since we omitted the automatically-created validator from Meta.
if data.get('rack') and data.get('position') and data.get('face'):
validator = UniqueTogetherValidator(queryset=Device.objects.all(), fields=('rack', 'position', 'face'))
validator(data, self)
# Enforce model validation
super().validate(data)
return data
@swagger_serializer_method(serializer_or_field=NestedDeviceSerializer)
def get_parent_device(self, obj):
@@ -528,7 +515,7 @@ class DeviceNAPALMSerializer(serializers.Serializer):
# Device components
#
class ConsoleServerPortSerializer(PrimaryModelSerializer, CableTerminationSerializer, ConnectedEndpointSerializer):
class ConsoleServerPortSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleserverport-detail')
device = NestedDeviceSerializer()
type = ChoiceField(
@@ -538,7 +525,7 @@ class ConsoleServerPortSerializer(PrimaryModelSerializer, CableTerminationSerial
)
speed = ChoiceField(
choices=ConsolePortSpeedChoices,
allow_blank=True,
allow_null=True,
required=False
)
cable = NestedCableSerializer(read_only=True)
@@ -547,12 +534,12 @@ class ConsoleServerPortSerializer(PrimaryModelSerializer, CableTerminationSerial
model = ConsoleServerPort
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'speed', 'description', 'mark_connected',
'cable', 'cable_peer', 'cable_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'cable', 'link_peer', 'link_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'connected_endpoint_reachable', 'tags', 'custom_fields', 'created', 'last_updated', '_occupied',
]
class ConsolePortSerializer(PrimaryModelSerializer, CableTerminationSerializer, ConnectedEndpointSerializer):
class ConsolePortSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleport-detail')
device = NestedDeviceSerializer()
type = ChoiceField(
@@ -562,7 +549,7 @@ class ConsolePortSerializer(PrimaryModelSerializer, CableTerminationSerializer,
)
speed = ChoiceField(
choices=ConsolePortSpeedChoices,
allow_blank=True,
allow_null=True,
required=False
)
cable = NestedCableSerializer(read_only=True)
@@ -571,12 +558,12 @@ class ConsolePortSerializer(PrimaryModelSerializer, CableTerminationSerializer,
model = ConsolePort
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'speed', 'description', 'mark_connected',
'cable', 'cable_peer', 'cable_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'cable', 'link_peer', 'link_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'connected_endpoint_reachable', 'tags', 'custom_fields', 'created', 'last_updated', '_occupied',
]
class PowerOutletSerializer(PrimaryModelSerializer, CableTerminationSerializer, ConnectedEndpointSerializer):
class PowerOutletSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:poweroutlet-detail')
device = NestedDeviceSerializer()
type = ChoiceField(
@@ -585,7 +572,8 @@ class PowerOutletSerializer(PrimaryModelSerializer, CableTerminationSerializer,
required=False
)
power_port = NestedPowerPortSerializer(
required=False
required=False,
allow_null=True
)
feed_leg = ChoiceField(
choices=PowerOutletFeedLegChoices,
@@ -600,12 +588,12 @@ class PowerOutletSerializer(PrimaryModelSerializer, CableTerminationSerializer,
model = PowerOutlet
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description',
'mark_connected', 'cable', 'cable_peer', 'cable_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'mark_connected', 'cable', 'link_peer', 'link_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'connected_endpoint_reachable', 'tags', 'custom_fields', 'created', 'last_updated', '_occupied',
]
class PowerPortSerializer(PrimaryModelSerializer, CableTerminationSerializer, ConnectedEndpointSerializer):
class PowerPortSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:powerport-detail')
device = NestedDeviceSerializer()
type = ChoiceField(
@@ -619,18 +607,21 @@ class PowerPortSerializer(PrimaryModelSerializer, CableTerminationSerializer, Co
model = PowerPort
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description',
'mark_connected', 'cable', 'cable_peer', 'cable_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'mark_connected', 'cable', 'link_peer', 'link_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'connected_endpoint_reachable', 'tags', 'custom_fields', 'created', 'last_updated', '_occupied',
]
class InterfaceSerializer(PrimaryModelSerializer, CableTerminationSerializer, ConnectedEndpointSerializer):
class InterfaceSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:interface-detail')
device = NestedDeviceSerializer()
type = ChoiceField(choices=InterfaceTypeChoices)
parent = NestedInterfaceSerializer(required=False, allow_null=True)
bridge = NestedInterfaceSerializer(required=False, allow_null=True)
lag = NestedInterfaceSerializer(required=False, allow_null=True)
mode = ChoiceField(choices=InterfaceModeChoices, allow_blank=True, required=False)
rf_role = ChoiceField(choices=WirelessRoleChoices, required=False, allow_null=True)
rf_channel = ChoiceField(choices=WirelessChannelChoices, required=False)
untagged_vlan = NestedVLANSerializer(required=False, allow_null=True)
tagged_vlans = SerializedPKRelatedField(
queryset=VLAN.objects.all(),
@@ -639,16 +630,25 @@ class InterfaceSerializer(PrimaryModelSerializer, CableTerminationSerializer, Co
many=True
)
cable = NestedCableSerializer(read_only=True)
wireless_link = NestedWirelessLinkSerializer(read_only=True)
wireless_lans = SerializedPKRelatedField(
queryset=WirelessLAN.objects.all(),
serializer=NestedWirelessLANSerializer,
required=False,
many=True
)
count_ipaddresses = serializers.IntegerField(read_only=True)
count_fhrp_groups = serializers.IntegerField(read_only=True)
class Meta:
model = Interface
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'enabled', 'parent', 'lag', 'mtu', 'mac_address',
'mgmt_only', 'description', 'mode', 'untagged_vlan', 'tagged_vlans', 'mark_connected', 'cable',
'cable_peer', 'cable_peer_type', 'connected_endpoint', 'connected_endpoint_type',
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'enabled', 'parent', 'bridge', 'lag', 'mtu',
'mac_address', 'wwn', 'mgmt_only', 'description', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency',
'rf_channel_width', 'tx_power', 'untagged_vlan', 'tagged_vlans', 'mark_connected', 'cable', 'wireless_link',
'link_peer', 'link_peer_type', 'wireless_lans', 'connected_endpoint', 'connected_endpoint_type',
'connected_endpoint_reachable', 'tags', 'custom_fields', 'created', 'last_updated', 'count_ipaddresses',
'_occupied',
'count_fhrp_groups', '_occupied',
]
def validate(self, data):
@@ -665,7 +665,7 @@ class InterfaceSerializer(PrimaryModelSerializer, CableTerminationSerializer, Co
return super().validate(data)
class RearPortSerializer(PrimaryModelSerializer, CableTerminationSerializer):
class RearPortSerializer(PrimaryModelSerializer, LinkTerminationSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:rearport-detail')
device = NestedDeviceSerializer()
type = ChoiceField(choices=PortTypeChoices)
@@ -675,7 +675,7 @@ class RearPortSerializer(PrimaryModelSerializer, CableTerminationSerializer):
model = RearPort
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'color', 'positions', 'description',
'mark_connected', 'cable', 'cable_peer', 'cable_peer_type', 'tags', 'custom_fields', 'created',
'mark_connected', 'cable', 'link_peer', 'link_peer_type', 'tags', 'custom_fields', 'created',
'last_updated', '_occupied',
]
@@ -691,7 +691,7 @@ class FrontPortRearPortSerializer(WritableNestedSerializer):
fields = ['id', 'url', 'display', 'name', 'label']
class FrontPortSerializer(PrimaryModelSerializer, CableTerminationSerializer):
class FrontPortSerializer(PrimaryModelSerializer, LinkTerminationSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:frontport-detail')
device = NestedDeviceSerializer()
type = ChoiceField(choices=PortTypeChoices)
@@ -702,7 +702,7 @@ class FrontPortSerializer(PrimaryModelSerializer, CableTerminationSerializer):
model = FrontPort
fields = [
'id', 'url', 'display', 'device', 'name', 'label', 'type', 'color', 'rear_port', 'rear_port_position',
'description', 'mark_connected', 'cable', 'cable_peer', 'cable_peer_type', 'tags', 'custom_fields',
'description', 'mark_connected', 'cable', 'link_peer', 'link_peer_type', 'tags', 'custom_fields',
'created', 'last_updated', '_occupied',
]
@@ -727,7 +727,6 @@ class DeviceBaySerializer(PrimaryModelSerializer):
class InventoryItemSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:inventoryitem-detail')
device = NestedDeviceSerializer()
# Provide a default value to satisfy UniqueTogetherValidator
parent = serializers.PrimaryKeyRelatedField(queryset=InventoryItem.objects.all(), allow_null=True, default=None)
manufacturer = NestedManufacturerSerializer(required=False, allow_null=True, default=None)
_depth = serializers.IntegerField(source='level', read_only=True)
@@ -754,15 +753,16 @@ class CableSerializer(PrimaryModelSerializer):
)
termination_a = serializers.SerializerMethodField(read_only=True)
termination_b = serializers.SerializerMethodField(read_only=True)
status = ChoiceField(choices=CableStatusChoices, required=False)
status = ChoiceField(choices=LinkStatusChoices, required=False)
tenant = NestedTenantSerializer(required=False, allow_null=True)
length_unit = ChoiceField(choices=CableLengthUnitChoices, allow_blank=True, required=False)
class Meta:
model = Cable
fields = [
'id', 'url', 'display', 'termination_a_type', 'termination_a_id', 'termination_a', 'termination_b_type',
'termination_b_id', 'termination_b', 'type', 'status', 'label', 'color', 'length', 'length_unit', 'tags',
'custom_fields',
'termination_b_id', 'termination_b', 'type', 'status', 'tenant', 'label', 'color', 'length', 'length_unit',
'tags', 'custom_fields',
]
def _get_termination(self, obj, side):
@@ -878,7 +878,7 @@ class PowerPanelSerializer(PrimaryModelSerializer):
fields = ['id', 'url', 'display', 'site', 'location', 'name', 'tags', 'custom_fields', 'powerfeed_count']
class PowerFeedSerializer(PrimaryModelSerializer, CableTerminationSerializer, ConnectedEndpointSerializer):
class PowerFeedSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:powerfeed-detail')
power_panel = NestedPowerPanelSerializer()
rack = NestedRackSerializer(
@@ -908,7 +908,7 @@ class PowerFeedSerializer(PrimaryModelSerializer, CableTerminationSerializer, Co
model = PowerFeed
fields = [
'id', 'url', 'display', 'power_panel', 'rack', 'name', 'status', 'type', 'supply', 'phase', 'voltage',
'amperage', 'max_utilization', 'comments', 'mark_connected', 'cable', 'cable_peer', 'cable_peer_type',
'amperage', 'max_utilization', 'comments', 'mark_connected', 'cable', 'link_peer', 'link_peer_type',
'connected_endpoint', 'connected_endpoint_type', 'connected_endpoint_reachable', 'tags', 'custom_fields',
'created', 'last_updated', '_occupied',
]

View File

@@ -1,7 +1,6 @@
import socket
from collections import OrderedDict
from django.conf import settings
from django.http import Http404, HttpResponse, HttpResponseForbidden
from django.shortcuts import get_object_or_404
from drf_yasg import openapi
@@ -16,11 +15,12 @@ from circuits.models import Circuit
from dcim import filtersets
from dcim.models import *
from extras.api.views import ConfigContextQuerySetMixin, CustomFieldModelViewSet
from ipam.models import Prefix, VLAN
from ipam.models import Prefix, VLAN, ASN
from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired
from netbox.api.exceptions import ServiceUnavailable
from netbox.api.metadata import ContentTypeMetadata
from netbox.api.views import ModelViewSet
from netbox.config import get_config
from utilities.api import get_serializer_for_model
from utilities.utils import count_related, decode_dict
from virtualization.models import VirtualMachine
@@ -110,7 +110,7 @@ class RegionViewSet(CustomFieldModelViewSet):
'region',
'site_count',
cumulative=True
)
).prefetch_related('tags')
serializer_class = serializers.RegionSerializer
filterset_class = filtersets.RegionFilterSet
@@ -126,7 +126,7 @@ class SiteGroupViewSet(CustomFieldModelViewSet):
'group',
'site_count',
cumulative=True
)
).prefetch_related('tags')
serializer_class = serializers.SiteGroupSerializer
filterset_class = filtersets.SiteGroupFilterSet
@@ -137,7 +137,7 @@ class SiteGroupViewSet(CustomFieldModelViewSet):
class SiteViewSet(CustomFieldModelViewSet):
queryset = Site.objects.prefetch_related(
'region', 'tenant', 'tags'
'region', 'tenant', 'asns', 'tags'
).annotate(
device_count=count_related(Device, 'site'),
rack_count=count_related(Rack, 'site'),
@@ -167,7 +167,7 @@ class LocationViewSet(CustomFieldModelViewSet):
'location',
'rack_count',
cumulative=True
).prefetch_related('site')
).prefetch_related('site', 'tags')
serializer_class = serializers.LocationSerializer
filterset_class = filtersets.LocationFilterSet
@@ -177,7 +177,7 @@ class LocationViewSet(CustomFieldModelViewSet):
#
class RackRoleViewSet(CustomFieldModelViewSet):
queryset = RackRole.objects.annotate(
queryset = RackRole.objects.prefetch_related('tags').annotate(
rack_count=count_related(Rack, 'role')
)
serializer_class = serializers.RackRoleSerializer
@@ -261,7 +261,7 @@ class RackReservationViewSet(ModelViewSet):
#
class ManufacturerViewSet(CustomFieldModelViewSet):
queryset = Manufacturer.objects.annotate(
queryset = Manufacturer.objects.prefetch_related('tags').annotate(
devicetype_count=count_related(DeviceType, 'manufacturer'),
inventoryitem_count=count_related(InventoryItem, 'manufacturer'),
platform_count=count_related(Platform, 'manufacturer')
@@ -340,7 +340,7 @@ class DeviceBayTemplateViewSet(ModelViewSet):
#
class DeviceRoleViewSet(CustomFieldModelViewSet):
queryset = DeviceRole.objects.annotate(
queryset = DeviceRole.objects.prefetch_related('tags').annotate(
device_count=count_related(Device, 'device_role'),
virtualmachine_count=count_related(VirtualMachine, 'role')
)
@@ -353,7 +353,7 @@ class DeviceRoleViewSet(CustomFieldModelViewSet):
#
class PlatformViewSet(CustomFieldModelViewSet):
queryset = Platform.objects.annotate(
queryset = Platform.objects.prefetch_related('tags').annotate(
device_count=count_related(Device, 'platform'),
virtualmachine_count=count_related(VirtualMachine, 'platform')
)
@@ -457,9 +457,12 @@ class DeviceViewSet(ConfigContextQuerySetMixin, CustomFieldModelViewSet):
napalm_methods = request.GET.getlist('method')
response = OrderedDict([(m, None) for m in napalm_methods])
username = settings.NAPALM_USERNAME
password = settings.NAPALM_PASSWORD
optional_args = settings.NAPALM_ARGS.copy()
config = get_config()
username = config.NAPALM_USERNAME
password = config.NAPALM_PASSWORD
timeout = config.NAPALM_TIMEOUT
optional_args = config.NAPALM_ARGS.copy()
if device.platform.napalm_args is not None:
optional_args.update(device.platform.napalm_args)
@@ -481,7 +484,7 @@ class DeviceViewSet(ConfigContextQuerySetMixin, CustomFieldModelViewSet):
hostname=host,
username=username,
password=password,
timeout=settings.NAPALM_TIMEOUT,
timeout=timeout,
optional_args=optional_args
)
try:
@@ -513,7 +516,7 @@ class DeviceViewSet(ConfigContextQuerySetMixin, CustomFieldModelViewSet):
#
class ConsolePortViewSet(PathEndpointMixin, ModelViewSet):
queryset = ConsolePort.objects.prefetch_related('device', '_path__destination', 'cable', '_cable_peer', 'tags')
queryset = ConsolePort.objects.prefetch_related('device', '_path__destination', 'cable', '_link_peer', 'tags')
serializer_class = serializers.ConsolePortSerializer
filterset_class = filtersets.ConsolePortFilterSet
brief_prefetch_fields = ['device']
@@ -521,7 +524,7 @@ class ConsolePortViewSet(PathEndpointMixin, ModelViewSet):
class ConsoleServerPortViewSet(PathEndpointMixin, ModelViewSet):
queryset = ConsoleServerPort.objects.prefetch_related(
'device', '_path__destination', 'cable', '_cable_peer', 'tags'
'device', '_path__destination', 'cable', '_link_peer', 'tags'
)
serializer_class = serializers.ConsoleServerPortSerializer
filterset_class = filtersets.ConsoleServerPortFilterSet
@@ -529,14 +532,14 @@ class ConsoleServerPortViewSet(PathEndpointMixin, ModelViewSet):
class PowerPortViewSet(PathEndpointMixin, ModelViewSet):
queryset = PowerPort.objects.prefetch_related('device', '_path__destination', 'cable', '_cable_peer', 'tags')
queryset = PowerPort.objects.prefetch_related('device', '_path__destination', 'cable', '_link_peer', 'tags')
serializer_class = serializers.PowerPortSerializer
filterset_class = filtersets.PowerPortFilterSet
brief_prefetch_fields = ['device']
class PowerOutletViewSet(PathEndpointMixin, ModelViewSet):
queryset = PowerOutlet.objects.prefetch_related('device', '_path__destination', 'cable', '_cable_peer', 'tags')
queryset = PowerOutlet.objects.prefetch_related('device', '_path__destination', 'cable', '_link_peer', 'tags')
serializer_class = serializers.PowerOutletSerializer
filterset_class = filtersets.PowerOutletFilterSet
brief_prefetch_fields = ['device']
@@ -544,7 +547,8 @@ class PowerOutletViewSet(PathEndpointMixin, ModelViewSet):
class InterfaceViewSet(PathEndpointMixin, ModelViewSet):
queryset = Interface.objects.prefetch_related(
'device', 'parent', 'lag', '_path__destination', 'cable', '_cable_peer', 'ip_addresses', 'tags'
'device', 'parent', 'bridge', 'lag', '_path__destination', 'cable', '_link_peer', 'wireless_lans',
'untagged_vlan', 'tagged_vlans', 'ip_addresses', 'fhrp_group_assignments', 'tags'
)
serializer_class = serializers.InterfaceSerializer
filterset_class = filtersets.InterfaceFilterSet
@@ -625,7 +629,7 @@ class PowerPanelViewSet(ModelViewSet):
class PowerFeedViewSet(PathEndpointMixin, CustomFieldModelViewSet):
queryset = PowerFeed.objects.prefetch_related(
'power_panel', 'rack', '_path__destination', 'cable', '_cable_peer', 'tags'
'power_panel', 'rack', '_path__destination', 'cable', '_link_peer', 'tags'
)
serializer_class = serializers.PowerFeedSerializer
filterset_class = filtersets.PowerFeedFilterSet

View File

@@ -174,6 +174,25 @@ class DeviceStatusChoices(ChoiceSet):
}
class DeviceAirflowChoices(ChoiceSet):
AIRFLOW_FRONT_TO_REAR = 'front-to-rear'
AIRFLOW_REAR_TO_FRONT = 'rear-to-front'
AIRFLOW_LEFT_TO_RIGHT = 'left-to-right'
AIRFLOW_RIGHT_TO_LEFT = 'right-to-left'
AIRFLOW_SIDE_TO_REAR = 'side-to-rear'
AIRFLOW_PASSIVE = 'passive'
CHOICES = (
(AIRFLOW_FRONT_TO_REAR, 'Front to rear'),
(AIRFLOW_REAR_TO_FRONT, 'Rear to front'),
(AIRFLOW_LEFT_TO_RIGHT, 'Left to right'),
(AIRFLOW_RIGHT_TO_LEFT, 'Right to left'),
(AIRFLOW_SIDE_TO_REAR, 'Side to rear'),
(AIRFLOW_PASSIVE, 'Passive'),
)
#
# ConsolePorts
#
@@ -185,6 +204,7 @@ class ConsolePortTypeChoices(ChoiceSet):
TYPE_RJ11 = 'rj-11'
TYPE_RJ12 = 'rj-12'
TYPE_RJ45 = 'rj-45'
TYPE_MINI_DIN_8 = 'mini-din-8'
TYPE_USB_A = 'usb-a'
TYPE_USB_B = 'usb-b'
TYPE_USB_C = 'usb-c'
@@ -202,6 +222,7 @@ class ConsolePortTypeChoices(ChoiceSet):
(TYPE_RJ11, 'RJ-11'),
(TYPE_RJ12, 'RJ-12'),
(TYPE_RJ45, 'RJ-45'),
(TYPE_MINI_DIN_8, 'Mini-DIN 8'),
)),
('USB', (
(TYPE_USB_A, 'USB Type A'),
@@ -310,6 +331,7 @@ class PowerPortTypeChoices(ChoiceSet):
TYPE_NEMA_L1560P = 'nema-l15-60p'
TYPE_NEMA_L2120P = 'nema-l21-20p'
TYPE_NEMA_L2130P = 'nema-l21-30p'
TYPE_NEMA_L2230P = 'nema-l22-30p'
# California style
TYPE_CS6361C = 'cs6361c'
TYPE_CS6365C = 'cs6365c'
@@ -415,6 +437,7 @@ class PowerPortTypeChoices(ChoiceSet):
(TYPE_NEMA_L1560P, 'NEMA L15-60P'),
(TYPE_NEMA_L2120P, 'NEMA L21-20P'),
(TYPE_NEMA_L2130P, 'NEMA L21-30P'),
(TYPE_NEMA_L2230P, 'NEMA L22-30P'),
)),
('California Style', (
(TYPE_CS6361C, 'CS6361C'),
@@ -426,7 +449,7 @@ class PowerPortTypeChoices(ChoiceSet):
)),
('International/ITA', (
(TYPE_ITA_C, 'ITA Type C (CEE 7/16)'),
(TYPE_ITA_E, 'ITA Type E (CEE 7/5)'),
(TYPE_ITA_E, 'ITA Type E (CEE 7/6)'),
(TYPE_ITA_F, 'ITA Type F (CEE 7/4)'),
(TYPE_ITA_EF, 'ITA Type E/F (CEE 7/7)'),
(TYPE_ITA_G, 'ITA Type G (BS 1363)'),
@@ -531,6 +554,7 @@ class PowerOutletTypeChoices(ChoiceSet):
TYPE_NEMA_L1560R = 'nema-l15-60r'
TYPE_NEMA_L2120R = 'nema-l21-20r'
TYPE_NEMA_L2130R = 'nema-l21-30r'
TYPE_NEMA_L2230R = 'nema-l22-30r'
# California style
TYPE_CS6360C = 'CS6360C'
TYPE_CS6364C = 'CS6364C'
@@ -550,6 +574,7 @@ class PowerOutletTypeChoices(ChoiceSet):
TYPE_ITA_M = 'ita-m'
TYPE_ITA_N = 'ita-n'
TYPE_ITA_O = 'ita-o'
TYPE_ITA_MULTISTANDARD = 'ita-multistandard'
# USB
TYPE_USB_A = 'usb-a'
TYPE_USB_MICROB = 'usb-micro-b'
@@ -628,6 +653,7 @@ class PowerOutletTypeChoices(ChoiceSet):
(TYPE_NEMA_L1560R, 'NEMA L15-60R'),
(TYPE_NEMA_L2120R, 'NEMA L21-20R'),
(TYPE_NEMA_L2130R, 'NEMA L21-30R'),
(TYPE_NEMA_L2230R, 'NEMA L22-30R'),
)),
('California Style', (
(TYPE_CS6360C, 'CS6360C'),
@@ -638,8 +664,8 @@ class PowerOutletTypeChoices(ChoiceSet):
(TYPE_CS8464C, 'CS8464C'),
)),
('ITA/International', (
(TYPE_ITA_E, 'ITA Type E (CEE7/5)'),
(TYPE_ITA_F, 'ITA Type F (CEE7/3)'),
(TYPE_ITA_E, 'ITA Type E (CEE 7/5)'),
(TYPE_ITA_F, 'ITA Type F (CEE 7/3)'),
(TYPE_ITA_G, 'ITA Type G (BS 1363)'),
(TYPE_ITA_H, 'ITA Type H'),
(TYPE_ITA_I, 'ITA Type I'),
@@ -649,6 +675,7 @@ class PowerOutletTypeChoices(ChoiceSet):
(TYPE_ITA_M, 'ITA Type M (BS 546)'),
(TYPE_ITA_N, 'ITA Type N'),
(TYPE_ITA_O, 'ITA Type O'),
(TYPE_ITA_MULTISTANDARD, 'ITA Multistandard'),
)),
('USB', (
(TYPE_USB_A, 'USB Type A'),
@@ -685,10 +712,23 @@ class PowerOutletFeedLegChoices(ChoiceSet):
# Interfaces
#
class InterfaceKindChoices(ChoiceSet):
KIND_PHYSICAL = 'physical'
KIND_VIRTUAL = 'virtual'
KIND_WIRELESS = 'wireless'
CHOICES = (
(KIND_PHYSICAL, 'Physical'),
(KIND_VIRTUAL, 'Virtual'),
(KIND_WIRELESS, 'Wireless'),
)
class InterfaceTypeChoices(ChoiceSet):
# Virtual
TYPE_VIRTUAL = 'virtual'
TYPE_BRIDGE = 'bridge'
TYPE_LAG = 'lag'
# Ethernet
@@ -725,6 +765,7 @@ class InterfaceTypeChoices(ChoiceSet):
TYPE_80211AC = 'ieee802.11ac'
TYPE_80211AD = 'ieee802.11ad'
TYPE_80211AX = 'ieee802.11ax'
TYPE_802151 = 'ieee802.15.1'
# Cellular
TYPE_GSM = 'gsm'
@@ -748,7 +789,7 @@ class InterfaceTypeChoices(ChoiceSet):
TYPE_16GFC_SFP_PLUS = '16gfc-sfpp'
TYPE_32GFC_SFP28 = '32gfc-sfp28'
TYPE_64GFC_QSFP_PLUS = '64gfc-qsfpp'
TYPE_128GFC_QSFP28 = '128gfc-sfp28'
TYPE_128GFC_QSFP28 = '128gfc-qsfp28'
# InfiniBand
TYPE_INFINIBAND_SDR = 'infiniband-sdr'
@@ -789,6 +830,7 @@ class InterfaceTypeChoices(ChoiceSet):
'Virtual interfaces',
(
(TYPE_VIRTUAL, 'Virtual'),
(TYPE_BRIDGE, 'Bridge'),
(TYPE_LAG, 'Link Aggregation Group (LAG)'),
),
),
@@ -836,6 +878,7 @@ class InterfaceTypeChoices(ChoiceSet):
(TYPE_80211AC, 'IEEE 802.11ac'),
(TYPE_80211AD, 'IEEE 802.11ad'),
(TYPE_80211AX, 'IEEE 802.11ax'),
(TYPE_802151, 'IEEE 802.15.1 (Bluetooth)'),
)
),
(
@@ -1030,7 +1073,7 @@ class PortTypeChoices(ChoiceSet):
#
# Cables
# Cables/links
#
class CableTypeChoices(ChoiceSet):
@@ -1094,7 +1137,7 @@ class CableTypeChoices(ChoiceSet):
)
class CableStatusChoices(ChoiceSet):
class LinkStatusChoices(ChoiceSet):
STATUS_CONNECTED = 'connected'
STATUS_PLANNED = 'planned'

View File

@@ -34,6 +34,7 @@ INTERFACE_MTU_MAX = 65536
VIRTUAL_IFACE_TYPES = [
InterfaceTypeChoices.TYPE_VIRTUAL,
InterfaceTypeChoices.TYPE_LAG,
InterfaceTypeChoices.TYPE_BRIDGE,
]
WIRELESS_IFACE_TYPES = [
@@ -42,6 +43,7 @@ WIRELESS_IFACE_TYPES = [
InterfaceTypeChoices.TYPE_80211N,
InterfaceTypeChoices.TYPE_80211AC,
InterfaceTypeChoices.TYPE_80211AD,
InterfaceTypeChoices.TYPE_80211AX,
]
NONCONNECTABLE_IFACE_TYPES = VIRTUAL_IFACE_TYPES + WIRELESS_IFACE_TYPES

View File

@@ -2,11 +2,30 @@ from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models
from netaddr import AddrFormatError, EUI, mac_unix_expanded
from netaddr import AddrFormatError, EUI, eui64_unix_expanded, mac_unix_expanded
from ipam.constants import BGP_ASN_MAX, BGP_ASN_MIN
from .lookups import PathContains
__all__ = (
'ASNField',
'MACAddressField',
'PathField',
'WWNField',
)
class mac_unix_expanded_uppercase(mac_unix_expanded):
word_fmt = '%.2X'
class eui64_unix_expanded_uppercase(eui64_unix_expanded):
word_fmt = '%.2X'
#
# Fields
#
class ASNField(models.BigIntegerField):
description = "32-bit ASN field"
@@ -24,10 +43,6 @@ class ASNField(models.BigIntegerField):
return super().formfield(**defaults)
class mac_unix_expanded_uppercase(mac_unix_expanded):
word_fmt = '%.2X'
class MACAddressField(models.Field):
description = "PostgreSQL MAC Address field"
@@ -42,8 +57,8 @@ class MACAddressField(models.Field):
return value
try:
return EUI(value, version=48, dialect=mac_unix_expanded_uppercase)
except AddrFormatError as e:
raise ValidationError("Invalid MAC address format: {}".format(value))
except AddrFormatError:
raise ValidationError(f"Invalid MAC address format: {value}")
def db_type(self, connection):
return 'macaddr'
@@ -54,6 +69,32 @@ class MACAddressField(models.Field):
return str(self.to_python(value))
class WWNField(models.Field):
description = "World Wide Name field"
def python_type(self):
return EUI
def from_db_value(self, value, expression, connection):
return self.to_python(value)
def to_python(self, value):
if value is None:
return value
try:
return EUI(value, version=64, dialect=eui64_unix_expanded_uppercase)
except AddrFormatError:
raise ValidationError(f"Invalid WWN format: {value}")
def db_type(self, connection):
return 'macaddr8'
def get_prep_value(self, value):
if not value:
return None
return str(self.to_python(value))
class PathField(ArrayField):
"""
An ArrayField which holds a set of objects, each identified by a (type, ID) tuple.

View File

@@ -3,6 +3,7 @@ from django.contrib.auth.models import User
from extras.filters import TagFilter
from extras.filtersets import LocalConfigContextFilterSet
from ipam.models import ASN
from netbox.filtersets import (
BaseFilterSet, ChangeLoggedModelFilterSet, OrganizationalModelFilterSet, PrimaryModelFilterSet,
)
@@ -10,10 +11,11 @@ from tenancy.filtersets import TenancyFilterSet
from tenancy.models import Tenant
from utilities.choices import ColorChoices
from utilities.filters import (
ContentTypeFilter, MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter,
ContentTypeFilter, MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter, MultiValueWWNFilter,
TreeNodeMultipleChoiceFilter,
)
from virtualization.models import Cluster
from wireless.choices import WirelessRoleChoices, WirelessChannelChoices
from .choices import *
from .constants import *
from .models import *
@@ -71,6 +73,7 @@ class RegionFilterSet(OrganizationalModelFilterSet):
to_field_name='slug',
label='Parent region (slug)',
)
tag = TagFilter()
class Meta:
model = Region
@@ -88,6 +91,7 @@ class SiteGroupFilterSet(OrganizationalModelFilterSet):
to_field_name='slug',
label='Parent site group (slug)',
)
tag = TagFilter()
class Meta:
model = SiteGroup
@@ -127,6 +131,11 @@ class SiteFilterSet(PrimaryModelFilterSet, TenancyFilterSet):
to_field_name='slug',
label='Group (slug)',
)
asn_id = django_filters.ModelMultipleChoiceFilter(
field_name='asns',
queryset=ASN.objects.all(),
label='AS (ID)',
)
tag = TagFilter()
class Meta:
@@ -152,12 +161,13 @@ class SiteFilterSet(PrimaryModelFilterSet, TenancyFilterSet):
)
try:
qs_filter |= Q(asn=int(value.strip()))
qs_filter |= Q(asns__asn=int(value.strip()))
except ValueError:
pass
return queryset.filter(qs_filter)
class LocationFilterSet(OrganizationalModelFilterSet):
class LocationFilterSet(TenancyFilterSet, OrganizationalModelFilterSet):
region_id = TreeNodeMultipleChoiceFilter(
queryset=Region.objects.all(),
field_name='site__region',
@@ -207,6 +217,7 @@ class LocationFilterSet(OrganizationalModelFilterSet):
to_field_name='slug',
label='Location (slug)',
)
tag = TagFilter()
class Meta:
model = Location
@@ -222,6 +233,7 @@ class LocationFilterSet(OrganizationalModelFilterSet):
class RackRoleFilterSet(OrganizationalModelFilterSet):
tag = TagFilter()
class Meta:
model = RackRole
@@ -387,6 +399,7 @@ class RackReservationFilterSet(PrimaryModelFilterSet, TenancyFilterSet):
class ManufacturerFilterSet(OrganizationalModelFilterSet):
tag = TagFilter()
class Meta:
model = Manufacturer
@@ -441,7 +454,7 @@ class DeviceTypeFilterSet(PrimaryModelFilterSet):
class Meta:
model = DeviceType
fields = [
'id', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
'id', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
]
def search(self, queryset, name, value):
@@ -569,6 +582,7 @@ class DeviceBayTemplateFilterSet(ChangeLoggedModelFilterSet, DeviceTypeComponent
class DeviceRoleFilterSet(OrganizationalModelFilterSet):
tag = TagFilter()
class Meta:
model = DeviceRole
@@ -587,6 +601,7 @@ class PlatformFilterSet(OrganizationalModelFilterSet):
to_field_name='slug',
label='Manufacturer (slug)',
)
tag = TagFilter()
class Meta:
model = Platform
@@ -703,7 +718,7 @@ class DeviceFilterSet(PrimaryModelFilterSet, TenancyFilterSet, LocalConfigContex
field_name='interfaces__mac_address',
label='MAC address',
)
serial = django_filters.CharFilter(
serial = MultiValueCharFilter(
lookup_expr='iexact'
)
has_primary_ip = django_filters.BooleanFilter(
@@ -751,7 +766,7 @@ class DeviceFilterSet(PrimaryModelFilterSet, TenancyFilterSet, LocalConfigContex
class Meta:
model = Device
fields = ['id', 'name', 'asset_tag', 'face', 'position', 'vc_position', 'vc_priority']
fields = ['id', 'name', 'asset_tag', 'face', 'position', 'airflow', 'vc_position', 'vc_priority']
def search(self, queryset, name, value):
if not value.strip():
@@ -861,6 +876,17 @@ class DeviceComponentFilterSet(django_filters.FilterSet):
to_field_name='name',
label='Device (name)',
)
virtual_chassis_id = django_filters.ModelMultipleChoiceFilter(
field_name='device__virtual_chassis',
queryset=VirtualChassis.objects.all(),
label='Virtual Chassis (ID)'
)
virtual_chassis = django_filters.ModelMultipleChoiceFilter(
field_name='device__virtual_chassis__name',
queryset=VirtualChassis.objects.all(),
to_field_name='name',
label='Virtual Chassis',
)
tag = TagFilter()
def search(self, queryset, name, value):
@@ -967,12 +993,18 @@ class InterfaceFilterSet(PrimaryModelFilterSet, DeviceComponentFilterSet, CableT
queryset=Interface.objects.all(),
label='Parent interface (ID)',
)
bridge_id = django_filters.ModelMultipleChoiceFilter(
field_name='bridge',
queryset=Interface.objects.all(),
label='Bridged interface (ID)',
)
lag_id = django_filters.ModelMultipleChoiceFilter(
field_name='lag',
queryset=Interface.objects.all(),
label='LAG interface (ID)',
)
mac_address = MultiValueMACAddressFilter()
wwn = MultiValueWWNFilter()
tag = TagFilter()
vlan_id = django_filters.CharFilter(
method='filter_vlan_id',
@@ -986,10 +1018,19 @@ class InterfaceFilterSet(PrimaryModelFilterSet, DeviceComponentFilterSet, CableT
choices=InterfaceTypeChoices,
null_value=None
)
rf_role = django_filters.MultipleChoiceFilter(
choices=WirelessRoleChoices
)
rf_channel = django_filters.MultipleChoiceFilter(
choices=WirelessChannelChoices
)
class Meta:
model = Interface
fields = ['id', 'name', 'label', 'type', 'enabled', 'mtu', 'mgmt_only', 'mode', 'description']
fields = [
'id', 'name', 'label', 'type', 'enabled', 'mtu', 'mgmt_only', 'mode', 'rf_role', 'rf_channel',
'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description',
]
def filter_device(self, queryset, name, value):
try:
@@ -1188,7 +1229,7 @@ class VirtualChassisFilterSet(PrimaryModelFilterSet):
return queryset.filter(qs_filter).distinct()
class CableFilterSet(PrimaryModelFilterSet):
class CableFilterSet(TenancyFilterSet, PrimaryModelFilterSet):
q = django_filters.CharFilter(
method='search',
label='Search',
@@ -1201,7 +1242,7 @@ class CableFilterSet(PrimaryModelFilterSet):
choices=CableTypeChoices
)
status = django_filters.MultipleChoiceFilter(
choices=CableStatusChoices
choices=LinkStatusChoices
)
color = django_filters.MultipleChoiceFilter(
choices=ColorChoices
@@ -1217,7 +1258,7 @@ class CableFilterSet(PrimaryModelFilterSet):
method='filter_device',
field_name='device__rack_id'
)
rack = MultiValueNumberFilter(
rack = MultiValueCharFilter(
method='filter_device',
field_name='device__rack__name'
)
@@ -1225,18 +1266,10 @@ class CableFilterSet(PrimaryModelFilterSet):
method='filter_device',
field_name='device__site_id'
)
site = MultiValueNumberFilter(
site = MultiValueCharFilter(
method='filter_device',
field_name='device__site__slug'
)
tenant_id = MultiValueNumberFilter(
method='filter_device',
field_name='device__tenant_id'
)
tenant = MultiValueNumberFilter(
method='filter_device',
field_name='device__tenant__slug'
)
tag = TagFilter()
class Meta:
@@ -1394,6 +1427,10 @@ class PowerFeedFilterSet(PrimaryModelFilterSet, CableTerminationFilterSet, PathE
#
class ConnectionFilterSet(BaseFilterSet):
q = django_filters.CharFilter(
method='search',
label='Search',
)
site_id = MultiValueNumberFilter(
method='filter_connections',
field_name='device__site_id'
@@ -1416,6 +1453,15 @@ class ConnectionFilterSet(BaseFilterSet):
return queryset
return queryset.filter(**{f'{name}__in': value})
def search(self, queryset, name, value):
if not value.strip():
return queryset
qs_filter = (
Q(device__name__icontains=value) |
Q(cable__label__icontains=value)
)
return queryset.filter(qs_filter)
class ConsoleConnectionFilterSet(ConnectionFilterSet):

View File

@@ -1,4 +1,3 @@
from .fields import *
from .models import *
from .filtersets import *
from .object_create import *

View File

@@ -3,7 +3,7 @@ from django import forms
from dcim.models import *
from extras.forms import CustomFieldsMixin
from extras.models import Tag
from utilities.forms import BootstrapMixin, DynamicModelMultipleChoiceField, form_from_model
from utilities.forms import DynamicModelMultipleChoiceField, form_from_model
from .object_create import ComponentForm
__all__ = (
@@ -23,7 +23,7 @@ __all__ = (
# Device components
#
class DeviceBulkAddComponentForm(BootstrapMixin, CustomFieldsMixin, ComponentForm):
class DeviceBulkAddComponentForm(CustomFieldsMixin, ComponentForm):
pk = forms.ModelMultipleChoiceField(
queryset=Device.objects.all(),
widget=forms.MultipleHiddenInput()

View File

@@ -1,4 +1,5 @@
from django import forms
from django.utils.translation import gettext as _
from django.contrib.auth.models import User
from timezone_field import TimeZoneFormField
@@ -6,12 +7,12 @@ from dcim.choices import *
from dcim.constants import *
from dcim.models import *
from extras.forms import AddRemoveTagsForm, CustomFieldModelBulkEditForm
from ipam.constants import BGP_ASN_MAX, BGP_ASN_MIN
from ipam.models import VLAN
from ipam.constants import BGP_ASN_MIN, BGP_ASN_MAX
from ipam.models import VLAN, ASN
from tenancy.models import Tenant
from utilities.forms import (
add_blank_choice, BootstrapMixin, BulkEditForm, BulkEditNullBooleanSelect, ColorField, CommentField,
DynamicModelChoiceField, DynamicModelMultipleChoiceField, form_from_model, SmallTextarea, StaticSelect,
add_blank_choice, BulkEditForm, BulkEditNullBooleanSelect, ColorField, CommentField, DynamicModelChoiceField,
DynamicModelMultipleChoiceField, form_from_model, SmallTextarea, StaticSelect,
)
__all__ = (
@@ -51,7 +52,7 @@ __all__ = (
)
class RegionBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class RegionBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Region.objects.all(),
widget=forms.MultipleHiddenInput
@@ -69,7 +70,7 @@ class RegionBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['parent', 'description']
class SiteGroupBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class SiteGroupBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=SiteGroup.objects.all(),
widget=forms.MultipleHiddenInput
@@ -87,7 +88,7 @@ class SiteGroupBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['parent', 'description']
class SiteBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class SiteBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Site.objects.all(),
widget=forms.MultipleHiddenInput
@@ -116,6 +117,11 @@ class SiteBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEd
required=False,
label='ASN'
)
asns = DynamicModelMultipleChoiceField(
queryset=ASN.objects.all(),
label=_('ASNs'),
required=False
)
description = forms.CharField(
max_length=100,
required=False
@@ -128,11 +134,11 @@ class SiteBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEd
class Meta:
nullable_fields = [
'region', 'group', 'tenant', 'asn', 'description', 'time_zone',
'region', 'group', 'tenant', 'asn', 'asns', 'description', 'time_zone',
]
class LocationBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class LocationBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Location.objects.all(),
widget=forms.MultipleHiddenInput
@@ -148,16 +154,20 @@ class LocationBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
'site_id': '$site'
}
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
required=False
)
description = forms.CharField(
max_length=200,
required=False
)
class Meta:
nullable_fields = ['parent', 'description']
nullable_fields = ['parent', 'tenant', 'description']
class RackRoleBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class RackRoleBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=RackRole.objects.all(),
widget=forms.MultipleHiddenInput
@@ -174,7 +184,7 @@ class RackRoleBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['color', 'description']
class RackBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class RackBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Rack.objects.all(),
widget=forms.MultipleHiddenInput
@@ -274,7 +284,7 @@ class RackBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEd
]
class RackReservationBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class RackReservationBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=RackReservation.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -299,7 +309,7 @@ class RackReservationBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomField
nullable_fields = []
class ManufacturerBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class ManufacturerBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Manufacturer.objects.all(),
widget=forms.MultipleHiddenInput
@@ -313,7 +323,7 @@ class ManufacturerBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['description']
class DeviceTypeBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class DeviceTypeBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=DeviceType.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -331,12 +341,17 @@ class DeviceTypeBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModel
widget=BulkEditNullBooleanSelect(),
label='Is full depth'
)
airflow = forms.ChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelect()
)
class Meta:
nullable_fields = []
nullable_fields = ['airflow']
class DeviceRoleBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class DeviceRoleBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=DeviceRole.objects.all(),
widget=forms.MultipleHiddenInput
@@ -358,7 +373,7 @@ class DeviceRoleBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['color', 'description']
class PlatformBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
class PlatformBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Platform.objects.all(),
widget=forms.MultipleHiddenInput
@@ -381,7 +396,7 @@ class PlatformBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
nullable_fields = ['manufacturer', 'napalm_driver', 'description']
class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class DeviceBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Device.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -425,6 +440,11 @@ class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulk
required=False,
widget=StaticSelect()
)
airflow = forms.ChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelect()
)
serial = forms.CharField(
max_length=50,
required=False,
@@ -433,11 +453,11 @@ class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulk
class Meta:
nullable_fields = [
'tenant', 'platform', 'serial',
'tenant', 'platform', 'serial', 'airflow',
]
class CableBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class CableBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=Cable.objects.all(),
widget=forms.MultipleHiddenInput
@@ -449,11 +469,15 @@ class CableBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkE
widget=StaticSelect()
)
status = forms.ChoiceField(
choices=add_blank_choice(CableStatusChoices),
choices=add_blank_choice(LinkStatusChoices),
required=False,
widget=StaticSelect(),
initial=''
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
required=False
)
label = forms.CharField(
max_length=100,
required=False
@@ -474,7 +498,7 @@ class CableBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkE
class Meta:
nullable_fields = [
'type', 'status', 'label', 'color', 'length',
'type', 'status', 'tenant', 'label', 'color', 'length',
]
def clean(self):
@@ -489,7 +513,7 @@ class CableBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkE
})
class VirtualChassisBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class VirtualChassisBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=VirtualChassis.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -503,7 +527,7 @@ class VirtualChassisBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldM
nullable_fields = ['domain']
class PowerPanelBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class PowerPanelBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=PowerPanel.objects.all(),
widget=forms.MultipleHiddenInput
@@ -542,7 +566,7 @@ class PowerPanelBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModel
nullable_fields = ['location']
class PowerFeedBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulkEditForm):
class PowerFeedBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=PowerFeed.objects.all(),
widget=forms.MultipleHiddenInput
@@ -607,7 +631,7 @@ class PowerFeedBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelB
# Device component templates
#
class ConsolePortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class ConsolePortTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=ConsolePortTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -626,7 +650,7 @@ class ConsolePortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
nullable_fields = ('label', 'type', 'description')
class ConsoleServerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class ConsoleServerPortTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=ConsoleServerPortTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -648,7 +672,7 @@ class ConsoleServerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
nullable_fields = ('label', 'type', 'description')
class PowerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class PowerPortTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=PowerPortTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -680,7 +704,7 @@ class PowerPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
nullable_fields = ('label', 'type', 'maximum_draw', 'allocated_draw', 'description')
class PowerOutletTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class PowerOutletTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=PowerOutletTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -728,7 +752,7 @@ class PowerOutletTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
self.fields['power_port'].widget.attrs['disabled'] = True
class InterfaceTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class InterfaceTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=InterfaceTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -755,7 +779,7 @@ class InterfaceTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
nullable_fields = ('label', 'description')
class FrontPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class FrontPortTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=FrontPortTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -780,7 +804,7 @@ class FrontPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
nullable_fields = ('description',)
class RearPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class RearPortTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=RearPortTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -805,7 +829,7 @@ class RearPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
nullable_fields = ('description',)
class DeviceBayTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class DeviceBayTemplateBulkEditForm(BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=DeviceBayTemplate.objects.all(),
widget=forms.MultipleHiddenInput()
@@ -828,7 +852,6 @@ class DeviceBayTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
class ConsolePortBulkEditForm(
form_from_model(ConsolePort, ['label', 'type', 'speed', 'mark_connected', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -847,7 +870,6 @@ class ConsolePortBulkEditForm(
class ConsoleServerPortBulkEditForm(
form_from_model(ConsoleServerPort, ['label', 'type', 'speed', 'mark_connected', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -866,7 +888,6 @@ class ConsoleServerPortBulkEditForm(
class PowerPortBulkEditForm(
form_from_model(PowerPort, ['label', 'type', 'maximum_draw', 'allocated_draw', 'mark_connected', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -885,7 +906,6 @@ class PowerPortBulkEditForm(
class PowerOutletBulkEditForm(
form_from_model(PowerOutlet, ['label', 'type', 'feed_leg', 'power_port', 'mark_connected', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -921,9 +941,9 @@ class PowerOutletBulkEditForm(
class InterfaceBulkEditForm(
form_from_model(Interface, [
'label', 'type', 'parent', 'lag', 'mac_address', 'mtu', 'mgmt_only', 'mark_connected', 'description', 'mode',
'label', 'type', 'parent', 'bridge', 'lag', 'mac_address', 'wwn', 'mtu', 'mgmt_only', 'mark_connected',
'description', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power',
]),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -945,6 +965,10 @@ class InterfaceBulkEditForm(
queryset=Interface.objects.all(),
required=False
)
bridge = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False
)
lag = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False,
@@ -972,7 +996,8 @@ class InterfaceBulkEditForm(
class Meta:
nullable_fields = [
'label', 'parent', 'lag', 'mac_address', 'mtu', 'description', 'mode', 'untagged_vlan', 'tagged_vlans'
'label', 'parent', 'bridge', 'lag', 'mac_address', 'wwn', 'mtu', 'description', 'mode', 'rf_channel',
'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'untagged_vlan', 'tagged_vlans',
]
def __init__(self, *args, **kwargs):
@@ -980,8 +1005,9 @@ class InterfaceBulkEditForm(
if 'device' in self.initial:
device = Device.objects.filter(pk=self.initial['device']).first()
# Restrict parent/LAG interface assignment by device
# Restrict parent/bridge/LAG interface assignment by device
self.fields['parent'].widget.add_query_param('device_id', device.pk)
self.fields['bridge'].widget.add_query_param('device_id', device.pk)
self.fields['lag'].widget.add_query_param('device_id', device.pk)
# Limit VLAN choices by device
@@ -1009,6 +1035,8 @@ class InterfaceBulkEditForm(
self.fields['parent'].choices = ()
self.fields['parent'].widget.attrs['disabled'] = True
self.fields['bridge'].choices = ()
self.fields['bridge'].widget.attrs['disabled'] = True
self.fields['lag'].choices = ()
self.fields['lag'].widget.attrs['disabled'] = True
@@ -1028,7 +1056,6 @@ class InterfaceBulkEditForm(
class FrontPortBulkEditForm(
form_from_model(FrontPort, ['label', 'type', 'color', 'mark_connected', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -1043,7 +1070,6 @@ class FrontPortBulkEditForm(
class RearPortBulkEditForm(
form_from_model(RearPort, ['label', 'type', 'color', 'mark_connected', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -1058,7 +1084,6 @@ class RearPortBulkEditForm(
class DeviceBayBulkEditForm(
form_from_model(DeviceBay, ['label', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):
@@ -1073,7 +1098,6 @@ class DeviceBayBulkEditForm(
class InventoryItemBulkEditForm(
form_from_model(InventoryItem, ['label', 'manufacturer', 'part_id', 'description']),
BootstrapMixin,
AddRemoveTagsForm,
CustomFieldModelBulkEditForm
):

View File

@@ -11,6 +11,7 @@ from extras.forms import CustomFieldModelCSVForm
from tenancy.models import Tenant
from utilities.forms import CSVChoiceField, CSVContentTypeField, CSVModelChoiceField, CSVTypedChoiceField, SlugField
from virtualization.models import Cluster
from wireless.choices import WirelessRoleChoices
__all__ = (
'CableCSVForm',
@@ -94,7 +95,7 @@ class SiteCSVForm(CustomFieldModelCSVForm):
class Meta:
model = Site
fields = (
'name', 'slug', 'status', 'region', 'group', 'tenant', 'facility', 'asn', 'time_zone', 'description',
'name', 'slug', 'status', 'region', 'group', 'tenant', 'facility', 'time_zone', 'description',
'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone',
'contact_email', 'comments',
)
@@ -120,10 +121,16 @@ class LocationCSVForm(CustomFieldModelCSVForm):
'invalid_choice': 'Location not found.',
}
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
)
class Meta:
model = Location
fields = ('site', 'parent', 'name', 'slug', 'description')
fields = ('site', 'parent', 'name', 'slug', 'tenant', 'description')
class RackRoleCSVForm(CustomFieldModelCSVForm):
@@ -363,12 +370,17 @@ class DeviceCSVForm(BaseDeviceCSVForm):
required=False,
help_text='Mounted rack face'
)
airflow = CSVChoiceField(
choices=DeviceAirflowChoices,
required=False,
help_text='Airflow direction'
)
class Meta(BaseDeviceCSVForm.Meta):
fields = [
'name', 'device_role', 'tenant', 'manufacturer', 'device_type', 'platform', 'serial', 'asset_tag', 'status',
'site', 'location', 'rack', 'position', 'face', 'virtual_chassis', 'vc_position', 'vc_priority', 'cluster',
'comments',
'site', 'location', 'rack', 'position', 'face', 'airflow', 'virtual_chassis', 'vc_position', 'vc_priority',
'cluster', 'comments',
]
def __init__(self, data=None, *args, **kwargs):
@@ -558,6 +570,12 @@ class InterfaceCSVForm(CustomFieldModelCSVForm):
to_field_name='name',
help_text='Parent interface'
)
bridge = CSVModelChoiceField(
queryset=Interface.objects.all(),
required=False,
to_field_name='name',
help_text='Bridged interface'
)
lag = CSVModelChoiceField(
queryset=Interface.objects.all(),
required=False,
@@ -573,42 +591,20 @@ class InterfaceCSVForm(CustomFieldModelCSVForm):
required=False,
help_text='IEEE 802.1Q operational mode (for L2 interfaces)'
)
rf_role = CSVChoiceField(
choices=WirelessRoleChoices,
required=False,
help_text='Wireless role (AP/station)'
)
class Meta:
model = Interface
fields = (
'device', 'name', 'label', 'parent', 'lag', 'type', 'enabled', 'mark_connected', 'mac_address', 'mtu',
'mgmt_only', 'description', 'mode',
'device', 'name', 'label', 'parent', 'bridge', 'lag', 'type', 'enabled', 'mark_connected', 'mac_address',
'wwn', 'mtu', 'mgmt_only', 'description', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency',
'rf_channel_width', 'tx_power',
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Limit LAG choices to interfaces belonging to this device (or virtual chassis)
device = None
if self.is_bound and 'device' in self.data:
try:
device = self.fields['device'].to_python(self.data['device'])
except forms.ValidationError:
pass
if device and device.virtual_chassis:
self.fields['lag'].queryset = Interface.objects.filter(
Q(device=device) | Q(device__virtual_chassis=device.virtual_chassis),
type=InterfaceTypeChoices.TYPE_LAG
)
self.fields['parent'].queryset = Interface.objects.filter(
Q(device=device) | Q(device__virtual_chassis=device.virtual_chassis)
)
elif device:
self.fields['lag'].queryset = Interface.objects.filter(
device=device,
type=InterfaceTypeChoices.TYPE_LAG
)
self.fields['parent'].queryset = Interface.objects.filter(device=device)
else:
self.fields['lag'].queryset = Interface.objects.none()
self.fields['parent'].queryset = Interface.objects.none()
def clean_enabled(self):
# Make sure enabled is True when it's not included in the uploaded data
if 'enabled' not in self.data:
@@ -801,7 +797,7 @@ class CableCSVForm(CustomFieldModelCSVForm):
# Cable attributes
status = CSVChoiceField(
choices=CableStatusChoices,
choices=LinkStatusChoices,
required=False,
help_text='Connection status'
)
@@ -810,6 +806,12 @@ class CableCSVForm(CustomFieldModelCSVForm):
required=False,
help_text='Physical medium classification'
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
)
length_unit = CSVChoiceField(
choices=CableLengthUnitChoices,
required=False,
@@ -820,7 +822,7 @@ class CableCSVForm(CustomFieldModelCSVForm):
model = Cable
fields = [
'side_a_device', 'side_a_type', 'side_a_name', 'side_b_device', 'side_b_type', 'side_b_name', 'type',
'status', 'label', 'color', 'length', 'length_unit',
'status', 'tenant', 'label', 'color', 'length', 'length_unit',
]
help_texts = {
'color': mark_safe('RGB color in hexadecimal (e.g. <code>00ff00</code>)'),

View File

@@ -2,7 +2,8 @@ from circuits.models import Circuit, CircuitTermination, Provider
from dcim.models import *
from extras.forms import CustomFieldModelForm
from extras.models import Tag
from utilities.forms import BootstrapMixin, DynamicModelChoiceField, DynamicModelMultipleChoiceField, StaticSelect
from tenancy.forms import TenancyForm
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField, StaticSelect
__all__ = (
'ConnectCableToCircuitTerminationForm',
@@ -17,7 +18,7 @@ __all__ = (
)
class ConnectCableToDeviceForm(BootstrapMixin, CustomFieldModelForm):
class ConnectCableToDeviceForm(TenancyForm, CustomFieldModelForm):
"""
Base form for connecting a Cable to a Device component
"""
@@ -78,7 +79,8 @@ class ConnectCableToDeviceForm(BootstrapMixin, CustomFieldModelForm):
model = Cable
fields = [
'termination_b_region', 'termination_b_site', 'termination_b_rack', 'termination_b_device',
'termination_b_id', 'type', 'status', 'label', 'color', 'length', 'length_unit', 'tags',
'termination_b_id', 'type', 'status', 'tenant_group', 'tenant', 'label', 'color', 'length', 'length_unit',
'tags',
]
widgets = {
'status': StaticSelect,
@@ -169,7 +171,7 @@ class ConnectCableToRearPortForm(ConnectCableToDeviceForm):
)
class ConnectCableToCircuitTerminationForm(BootstrapMixin, CustomFieldModelForm):
class ConnectCableToCircuitTerminationForm(TenancyForm, CustomFieldModelForm):
termination_b_provider = DynamicModelChoiceField(
queryset=Provider.objects.all(),
label='Provider',
@@ -215,11 +217,11 @@ class ConnectCableToCircuitTerminationForm(BootstrapMixin, CustomFieldModelForm)
required=False
)
class Meta:
model = Cable
class Meta(ConnectCableToDeviceForm.Meta):
fields = [
'termination_b_provider', 'termination_b_region', 'termination_b_site', 'termination_b_circuit',
'termination_b_id', 'type', 'status', 'label', 'color', 'length', 'length_unit', 'tags',
'termination_b_id', 'type', 'status', 'tenant_group', 'tenant', 'label', 'color', 'length', 'length_unit',
'tags',
]
def clean_termination_b_id(self):
@@ -227,7 +229,7 @@ class ConnectCableToCircuitTerminationForm(BootstrapMixin, CustomFieldModelForm)
return getattr(self.cleaned_data['termination_b_id'], 'pk', None)
class ConnectCableToPowerFeedForm(BootstrapMixin, CustomFieldModelForm):
class ConnectCableToPowerFeedForm(TenancyForm, CustomFieldModelForm):
termination_b_region = DynamicModelChoiceField(
queryset=Region.objects.all(),
label='Region',
@@ -277,11 +279,10 @@ class ConnectCableToPowerFeedForm(BootstrapMixin, CustomFieldModelForm):
required=False
)
class Meta:
model = Cable
class Meta(ConnectCableToDeviceForm.Meta):
fields = [
'termination_b_location', 'termination_b_powerpanel', 'termination_b_id', 'type', 'status', 'label',
'color', 'length', 'length_unit', 'tags',
'termination_b_location', 'termination_b_powerpanel', 'termination_b_id', 'type', 'status', 'tenant_group',
'tenant', 'label', 'color', 'length', 'length_unit', 'tags',
]
def clean_termination_b_id(self):

View File

@@ -1,25 +0,0 @@
from django import forms
from netaddr import EUI
from netaddr.core import AddrFormatError
__all__ = (
'MACAddressField',
)
class MACAddressField(forms.Field):
widget = forms.CharField
default_error_messages = {
'invalid': 'MAC address must be in EUI-48 format',
}
def to_python(self, value):
value = super().to_python(value)
# Validate MAC address format
try:
value = EUI(value.strip())
except AddrFormatError:
raise forms.ValidationError(self.error_messages['invalid'], code='invalid')
return value

View File

@@ -6,12 +6,13 @@ from dcim.choices import *
from dcim.constants import *
from dcim.models import *
from extras.forms import CustomFieldModelFilterForm, LocalConfigContextFilterForm
from ipam.models import ASN
from tenancy.forms import TenancyFilterForm
from tenancy.models import Tenant
from utilities.forms import (
APISelectMultiple, add_blank_choice, BootstrapMixin, ColorField, DynamicModelMultipleChoiceField, StaticSelect,
APISelectMultiple, add_blank_choice, ColorField, DynamicModelMultipleChoiceField, FilterForm, StaticSelect,
StaticSelectMultiple, TagFilterField, BOOLEAN_WITH_BLANK_CHOICES,
)
from wireless.choices import *
__all__ = (
'CableFilterForm',
@@ -46,15 +47,7 @@ __all__ = (
)
class DeviceComponentFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
field_order = [
'q', 'name', 'label', 'region_id', 'site_group_id', 'site_id',
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
class DeviceComponentFilterForm(CustomFieldModelFilterForm):
name = forms.CharField(
required=False
)
@@ -92,69 +85,55 @@ class DeviceComponentFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
label=_('Location'),
fetch_trigger='open'
)
virtual_chassis_id = DynamicModelMultipleChoiceField(
queryset=VirtualChassis.objects.all(),
required=False,
label=_('Virtual Chassis'),
fetch_trigger='open'
)
device_id = DynamicModelMultipleChoiceField(
queryset=Device.objects.all(),
required=False,
query_params={
'site_id': '$site_id',
'location_id': '$location_id',
'virtual_chassis_id': '$virtual_chassis_id'
},
label=_('Device'),
fetch_trigger='open'
)
class RegionFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class RegionFilterForm(CustomFieldModelFilterForm):
model = Region
field_groups = [
['q'],
['parent_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
parent_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
label=_('Parent region'),
fetch_trigger='open'
)
tag = TagFilterField(model)
class SiteGroupFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class SiteGroupFilterForm(CustomFieldModelFilterForm):
model = SiteGroup
field_groups = [
['q'],
['parent_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
parent_id = DynamicModelMultipleChoiceField(
queryset=SiteGroup.objects.all(),
required=False,
label=_('Parent group'),
fetch_trigger='open'
)
tag = TagFilterField(model)
class SiteFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterForm):
class SiteFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = Site
field_order = ['q', 'status', 'region_id', 'tenant_group_id', 'tenant_id']
field_groups = [
['q', 'tag'],
['status', 'region_id', 'group_id'],
['tenant_group_id', 'tenant_id'],
['asn_id']
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
status = forms.MultipleChoiceField(
choices=SiteStatusChoices,
required=False,
@@ -172,16 +151,22 @@ class SiteFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterFo
label=_('Site group'),
fetch_trigger='open'
)
asn_id = DynamicModelMultipleChoiceField(
queryset=ASN.objects.all(),
required=False,
label=_('ASNs'),
fetch_trigger='open'
)
tag = TagFilterField(model)
class LocationFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class LocationFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = Location
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
field_groups = [
['q'],
['region_id', 'site_group_id', 'site_id', 'parent_id'],
['tenant_group_id', 'tenant_id'],
]
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -214,23 +199,16 @@ class LocationFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
label=_('Parent'),
fetch_trigger='open'
)
tag = TagFilterField(model)
class RackRoleFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class RackRoleFilterForm(CustomFieldModelFilterForm):
model = RackRole
field_groups = [
['q'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
tag = TagFilterField(model)
class RackFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterForm):
class RackFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = Rack
field_order = ['q', 'region_id', 'site_id', 'location_id', 'status', 'role_id', 'tenant_group_id', 'tenant_id']
field_groups = [
['q', 'tag'],
['region_id', 'site_id', 'location_id'],
@@ -238,11 +216,6 @@ class RackFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterFo
['type', 'width', 'serial', 'asset_tag'],
['tenant_group_id', 'tenant_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -300,10 +273,6 @@ class RackFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterFo
class RackElevationFilterForm(RackFilterForm):
field_order = [
'q', 'region_id', 'site_id', 'location_id', 'id', 'status', 'role_id', 'tenant_group_id',
'tenant_id',
]
id = DynamicModelMultipleChoiceField(
queryset=Rack.objects.all(),
label=_('Rack'),
@@ -316,20 +285,14 @@ class RackElevationFilterForm(RackFilterForm):
)
class RackReservationFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterForm):
class RackReservationFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = RackReservation
field_order = ['q', 'region_id', 'site_id', 'location_id', 'user_id', 'tenant_group_id', 'tenant_id']
field_groups = [
['q', 'tag'],
['user_id'],
['region_id', 'site_id', 'location_id'],
['tenant_group_id', 'tenant_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -364,30 +327,18 @@ class RackReservationFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldMo
tag = TagFilterField(model)
class ManufacturerFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class ManufacturerFilterForm(CustomFieldModelFilterForm):
model = Manufacturer
field_groups = [
['q'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
tag = TagFilterField(model)
class DeviceTypeFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class DeviceTypeFilterForm(CustomFieldModelFilterForm):
model = DeviceType
field_groups = [
['q', 'tag'],
['manufacturer_id', 'subdevice_role'],
['manufacturer_id', 'subdevice_role', 'airflow'],
['console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
manufacturer_id = DynamicModelMultipleChoiceField(
queryset=Manufacturer.objects.all(),
required=False,
@@ -399,6 +350,11 @@ class DeviceTypeFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
required=False,
widget=StaticSelectMultiple()
)
airflow = forms.MultipleChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelectMultiple()
)
console_ports = forms.NullBooleanField(
required=False,
label='Has console ports',
@@ -444,43 +400,28 @@ class DeviceTypeFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
tag = TagFilterField(model)
class DeviceRoleFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class DeviceRoleFilterForm(CustomFieldModelFilterForm):
model = DeviceRole
field_groups = [
['q'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
tag = TagFilterField(model)
class PlatformFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class PlatformFilterForm(CustomFieldModelFilterForm):
model = Platform
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
manufacturer_id = DynamicModelMultipleChoiceField(
queryset=Manufacturer.objects.all(),
required=False,
label=_('Manufacturer'),
fetch_trigger='open'
)
tag = TagFilterField(model)
class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilterForm, CustomFieldModelFilterForm):
class DeviceFilterForm(LocalConfigContextFilterForm, TenancyFilterForm, CustomFieldModelFilterForm):
model = Device
field_order = [
'q', 'region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'status', 'role_id', 'tenant_group_id',
'tenant_id', 'manufacturer_id', 'device_type_id', 'asset_tag', 'mac_address', 'has_primary_ip',
]
field_groups = [
['q', 'tag'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id'],
['status', 'role_id', 'serial', 'asset_tag', 'mac_address'],
['status', 'role_id', 'airflow', 'serial', 'asset_tag', 'mac_address'],
['manufacturer_id', 'device_type_id', 'platform_id'],
['tenant_group_id', 'tenant_id'],
[
@@ -488,11 +429,6 @@ class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilt
'power_outlets', 'interfaces', 'pass_through_ports', 'local_context_data',
],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -569,6 +505,11 @@ class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilt
required=False,
widget=StaticSelectMultiple()
)
airflow = forms.MultipleChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelectMultiple()
)
serial = forms.CharField(
required=False
)
@@ -638,19 +579,13 @@ class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilt
tag = TagFilterField(model)
class VirtualChassisFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldModelFilterForm):
class VirtualChassisFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = VirtualChassis
field_order = ['q', 'region_id', 'site_group_id', 'site_id', 'tenant_group_id', 'tenant_id']
field_groups = [
['q', 'tag'],
['region_id', 'site_group_id', 'site_id'],
['tenant_group_id', 'tenant_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -676,19 +611,14 @@ class VirtualChassisFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldMod
tag = TagFilterField(model)
class CableFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class CableFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
model = Cable
field_groups = [
['q', 'tag'],
['site_id', 'rack_id', 'device_id'],
['type', 'status', 'color'],
['tenant_id'],
['tenant_group_id', 'tenant_id'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -704,12 +634,6 @@ class CableFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
label=_('Site'),
fetch_trigger='open'
)
tenant_id = DynamicModelMultipleChoiceField(
queryset=Tenant.objects.all(),
required=False,
label=_('Tenant'),
fetch_trigger='open'
)
rack_id = DynamicModelMultipleChoiceField(
queryset=Rack.objects.all(),
required=False,
@@ -727,7 +651,7 @@ class CableFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
)
status = forms.ChoiceField(
required=False,
choices=add_blank_choice(CableStatusChoices),
choices=add_blank_choice(LinkStatusChoices),
widget=StaticSelect()
)
color = ColorField(
@@ -747,17 +671,12 @@ class CableFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
tag = TagFilterField(model)
class PowerPanelFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class PowerPanelFilterForm(CustomFieldModelFilterForm):
model = PowerPanel
field_groups = (
('q', 'tag'),
('region_id', 'site_group_id', 'site_id', 'location_id')
)
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -793,7 +712,7 @@ class PowerPanelFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
tag = TagFilterField(model)
class PowerFeedFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
class PowerFeedFilterForm(CustomFieldModelFilterForm):
model = PowerFeed
field_groups = [
['q', 'tag'],
@@ -801,11 +720,6 @@ class PowerFeedFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
['power_panel_id', 'rack_id'],
['status', 'type', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization'],
]
q = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'placeholder': _('All Fields')}),
label=_('Search')
)
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -888,7 +802,7 @@ class ConsolePortFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'type', 'speed'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
type = forms.MultipleChoiceField(
choices=ConsolePortTypeChoices,
@@ -908,7 +822,7 @@ class ConsoleServerPortFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'type', 'speed'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
type = forms.MultipleChoiceField(
choices=ConsolePortTypeChoices,
@@ -928,7 +842,7 @@ class PowerPortFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'type'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
type = forms.MultipleChoiceField(
choices=PowerPortTypeChoices,
@@ -943,7 +857,7 @@ class PowerOutletFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'type'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
type = forms.MultipleChoiceField(
choices=PowerOutletTypeChoices,
@@ -957,9 +871,15 @@ class InterfaceFilterForm(DeviceComponentFilterForm):
model = Interface
field_groups = [
['q', 'tag'],
['name', 'label', 'type', 'enabled', 'mgmt_only', 'mac_address'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['name', 'label', 'kind', 'type', 'enabled', 'mgmt_only', 'mac_address', 'wwn'],
['rf_role', 'rf_channel', 'rf_channel_width', 'tx_power'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
kind = forms.MultipleChoiceField(
choices=InterfaceKindChoices,
required=False,
widget=StaticSelectMultiple()
)
type = forms.MultipleChoiceField(
choices=InterfaceTypeChoices,
required=False,
@@ -981,6 +901,36 @@ class InterfaceFilterForm(DeviceComponentFilterForm):
required=False,
label='MAC address'
)
wwn = forms.CharField(
required=False,
label='WWN'
)
rf_role = forms.MultipleChoiceField(
choices=WirelessRoleChoices,
required=False,
widget=StaticSelectMultiple(),
label='Wireless role'
)
rf_channel = forms.MultipleChoiceField(
choices=WirelessChannelChoices,
required=False,
widget=StaticSelectMultiple(),
label='Wireless channel'
)
rf_channel_frequency = forms.IntegerField(
required=False,
label='Channel frequency (MHz)'
)
rf_channel_width = forms.IntegerField(
required=False,
label='Channel width (MHz)'
)
tx_power = forms.IntegerField(
required=False,
label='Transmit power (dBm)',
min_value=0,
max_value=127
)
tag = TagFilterField(model)
@@ -988,7 +938,7 @@ class FrontPortFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'type', 'color'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
model = FrontPort
type = forms.MultipleChoiceField(
@@ -1007,7 +957,7 @@ class RearPortFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'type', 'color'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
type = forms.MultipleChoiceField(
choices=PortTypeChoices,
@@ -1025,7 +975,7 @@ class DeviceBayFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
tag = TagFilterField(model)
@@ -1035,7 +985,7 @@ class InventoryItemFilterForm(DeviceComponentFilterForm):
field_groups = [
['q', 'tag'],
['name', 'label', 'manufacturer_id', 'serial', 'asset_tag', 'discovered'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'device_id'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id'],
]
manufacturer_id = DynamicModelMultipleChoiceField(
queryset=Manufacturer.objects.all(),
@@ -1062,7 +1012,7 @@ class InventoryItemFilterForm(DeviceComponentFilterForm):
# Connections
#
class ConsoleConnectionFilterForm(BootstrapMixin, forms.Form):
class ConsoleConnectionFilterForm(FilterForm):
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -1089,7 +1039,7 @@ class ConsoleConnectionFilterForm(BootstrapMixin, forms.Form):
)
class PowerConnectionFilterForm(BootstrapMixin, forms.Form):
class PowerConnectionFilterForm(FilterForm):
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -1116,7 +1066,7 @@ class PowerConnectionFilterForm(BootstrapMixin, forms.Form):
)
class InterfaceConnectionFilterForm(BootstrapMixin, forms.Form):
class InterfaceConnectionFilterForm(FilterForm):
region_id = DynamicModelMultipleChoiceField(
queryset=Region.objects.all(),
required=False,

View File

@@ -1,4 +1,5 @@
from django import forms
from django.utils.translation import gettext as _
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from timezone_field import TimeZoneFormField
@@ -8,7 +9,7 @@ from dcim.constants import *
from dcim.models import *
from extras.forms import CustomFieldModelForm
from extras.models import Tag
from ipam.models import IPAddress, VLAN, VLANGroup
from ipam.models import IPAddress, VLAN, VLANGroup, ASN
from tenancy.forms import TenancyForm
from utilities.forms import (
APISelect, add_blank_choice, BootstrapMixin, ClearableFileInput, CommentField, DynamicModelChoiceField,
@@ -16,6 +17,7 @@ from utilities.forms import (
SlugField, StaticSelect,
)
from virtualization.models import Cluster, ClusterGroup
from wireless.models import WirelessLAN, WirelessLANGroup
from .common import InterfaceCommonForm
__all__ = (
@@ -64,35 +66,43 @@ Tagged (All): Implies all VLANs are available (w/optional untagged VLAN)
"""
class RegionForm(BootstrapMixin, CustomFieldModelForm):
class RegionForm(CustomFieldModelForm):
parent = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False
)
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = Region
fields = (
'parent', 'name', 'slug', 'description',
'parent', 'name', 'slug', 'description', 'tags',
)
class SiteGroupForm(BootstrapMixin, CustomFieldModelForm):
class SiteGroupForm(CustomFieldModelForm):
parent = DynamicModelChoiceField(
queryset=SiteGroup.objects.all(),
required=False
)
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = SiteGroup
fields = (
'parent', 'name', 'slug', 'description',
'parent', 'name', 'slug', 'description', 'tags',
)
class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class SiteForm(TenancyForm, CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False
@@ -101,6 +111,11 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
queryset=SiteGroup.objects.all(),
required=False
)
asns = DynamicModelMultipleChoiceField(
queryset=ASN.objects.all(),
label=_('ASNs'),
required=False
)
slug = SlugField()
time_zone = TimeZoneFormField(
choices=add_blank_choice(TimeZoneFormField().choices),
@@ -116,13 +131,14 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class Meta:
model = Site
fields = [
'name', 'slug', 'status', 'region', 'group', 'tenant_group', 'tenant', 'facility', 'asn', 'time_zone',
'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name',
'name', 'slug', 'status', 'region', 'group', 'tenant_group', 'tenant', 'facility', 'asn', 'asns',
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name',
'contact_phone', 'contact_email', 'comments', 'tags',
]
fieldsets = (
('Site', (
'name', 'slug', 'status', 'region', 'group', 'facility', 'asn', 'time_zone', 'description', 'tags',
'name', 'slug', 'status', 'region', 'group', 'facility', 'asn', 'asns', 'time_zone', 'description',
'tags',
)),
('Tenancy', ('tenant_group', 'tenant')),
('Contact Info', (
@@ -146,8 +162,8 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
}
help_texts = {
'name': "Full name of the site",
'asn': "BGP autonomous system number. This field is depreciated in favour of the ASN model",
'facility': "Data center provider and facility (e.g. Equinix NY7)",
'asn': "BGP autonomous system number",
'time_zone': "Local time zone",
'description': "Short description (will appear in sites list)",
'physical_address': "Physical location of the building (e.g. for GPS)",
@@ -157,7 +173,7 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
}
class LocationForm(BootstrapMixin, CustomFieldModelForm):
class LocationForm(TenancyForm, CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -187,25 +203,39 @@ class LocationForm(BootstrapMixin, CustomFieldModelForm):
}
)
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = Location
fields = (
'region', 'site_group', 'site', 'parent', 'name', 'slug', 'description',
'region', 'site_group', 'site', 'parent', 'name', 'slug', 'description', 'tenant_group', 'tenant', 'tags',
)
fieldsets = (
('Location', (
'region', 'site_group', 'site', 'parent', 'name', 'slug', 'description', 'tags',
)),
('Tenancy', ('tenant_group', 'tenant')),
)
class RackRoleForm(BootstrapMixin, CustomFieldModelForm):
class RackRoleForm(CustomFieldModelForm):
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = RackRole
fields = [
'name', 'slug', 'color', 'description',
'name', 'slug', 'color', 'description', 'tags',
]
class RackForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class RackForm(TenancyForm, CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -265,7 +295,7 @@ class RackForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
}
class RackReservationForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class RackReservationForm(TenancyForm, CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -335,17 +365,21 @@ class RackReservationForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
)
class ManufacturerForm(BootstrapMixin, CustomFieldModelForm):
class ManufacturerForm(CustomFieldModelForm):
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = Manufacturer
fields = [
'name', 'slug', 'description',
'name', 'slug', 'description', 'tags',
]
class DeviceTypeForm(BootstrapMixin, CustomFieldModelForm):
class DeviceTypeForm(CustomFieldModelForm):
manufacturer = DynamicModelChoiceField(
queryset=Manufacturer.objects.all()
)
@@ -361,12 +395,15 @@ class DeviceTypeForm(BootstrapMixin, CustomFieldModelForm):
class Meta:
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'front_image', 'rear_image', 'comments', 'tags',
]
fieldsets = (
('Device Type', (
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'tags',
'manufacturer', 'model', 'slug', 'part_number', 'tags',
)),
('Chassis', (
'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
)),
('Images', ('front_image', 'rear_image')),
)
@@ -381,17 +418,21 @@ class DeviceTypeForm(BootstrapMixin, CustomFieldModelForm):
}
class DeviceRoleForm(BootstrapMixin, CustomFieldModelForm):
class DeviceRoleForm(CustomFieldModelForm):
slug = SlugField()
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = DeviceRole
fields = [
'name', 'slug', 'color', 'vm_role', 'description',
'name', 'slug', 'color', 'vm_role', 'description', 'tags',
]
class PlatformForm(BootstrapMixin, CustomFieldModelForm):
class PlatformForm(CustomFieldModelForm):
manufacturer = DynamicModelChoiceField(
queryset=Manufacturer.objects.all(),
required=False
@@ -399,18 +440,22 @@ class PlatformForm(BootstrapMixin, CustomFieldModelForm):
slug = SlugField(
max_length=64
)
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
)
class Meta:
model = Platform
fields = [
'name', 'slug', 'manufacturer', 'napalm_driver', 'napalm_args', 'description',
'name', 'slug', 'manufacturer', 'napalm_driver', 'napalm_args', 'description', 'tags',
]
widgets = {
'napalm_args': SmallTextarea(),
}
class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class DeviceForm(TenancyForm, CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -513,8 +558,8 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
model = Device
fields = [
'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'region', 'site_group', 'site', 'rack',
'location', 'position', 'face', 'status', 'platform', 'primary_ip4', 'primary_ip6', 'cluster_group',
'cluster', 'tenant_group', 'tenant', 'comments', 'tags', 'local_context_data'
'location', 'position', 'face', 'status', 'airflow', 'platform', 'primary_ip4', 'primary_ip6',
'cluster_group', 'cluster', 'tenant_group', 'tenant', 'comments', 'tags', 'local_context_data'
]
help_texts = {
'device_role': "The function this device serves",
@@ -525,6 +570,7 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
widgets = {
'face': StaticSelect(),
'status': StaticSelect(),
'airflow': StaticSelect(),
'primary_ip4': StaticSelect(),
'primary_ip6': StaticSelect(),
}
@@ -591,7 +637,7 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
self.fields['position'].widget.choices = [(position, f'U{position}')]
class CableForm(BootstrapMixin, CustomFieldModelForm):
class CableForm(TenancyForm, CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -600,7 +646,7 @@ class CableForm(BootstrapMixin, CustomFieldModelForm):
class Meta:
model = Cable
fields = [
'type', 'status', 'label', 'color', 'length', 'length_unit', 'tags',
'type', 'status', 'tenant_group', 'tenant', 'label', 'color', 'length', 'length_unit', 'tags',
]
widgets = {
'status': StaticSelect,
@@ -614,7 +660,7 @@ class CableForm(BootstrapMixin, CustomFieldModelForm):
}
class PowerPanelForm(BootstrapMixin, CustomFieldModelForm):
class PowerPanelForm(CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -658,7 +704,7 @@ class PowerPanelForm(BootstrapMixin, CustomFieldModelForm):
)
class PowerFeedForm(BootstrapMixin, CustomFieldModelForm):
class PowerFeedForm(CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -726,7 +772,7 @@ class PowerFeedForm(BootstrapMixin, CustomFieldModelForm):
# Virtual chassis
#
class VirtualChassisForm(BootstrapMixin, CustomFieldModelForm):
class VirtualChassisForm(CustomFieldModelForm):
master = forms.ModelChoiceField(
queryset=Device.objects.all(),
required=False,
@@ -752,7 +798,6 @@ class VirtualChassisForm(BootstrapMixin, CustomFieldModelForm):
class DeviceVCMembershipForm(forms.ModelForm):
class Meta:
model = Device
fields = [
@@ -848,7 +893,6 @@ class VCMemberSelectForm(BootstrapMixin, forms.Form):
class ConsolePortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsolePortTemplate
fields = [
@@ -860,7 +904,6 @@ class ConsolePortTemplateForm(BootstrapMixin, forms.ModelForm):
class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsoleServerPortTemplate
fields = [
@@ -872,7 +915,6 @@ class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = PowerPortTemplate
fields = [
@@ -884,7 +926,6 @@ class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
class PowerOutletTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = PowerOutletTemplate
fields = [
@@ -895,7 +936,6 @@ class PowerOutletTemplateForm(BootstrapMixin, forms.ModelForm):
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Limit power_port choices to current DeviceType
@@ -906,7 +946,6 @@ class PowerOutletTemplateForm(BootstrapMixin, forms.ModelForm):
class InterfaceTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = InterfaceTemplate
fields = [
@@ -919,7 +958,6 @@ class InterfaceTemplateForm(BootstrapMixin, forms.ModelForm):
class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = FrontPortTemplate
fields = [
@@ -931,7 +969,6 @@ class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Limit rear_port choices to current DeviceType
@@ -942,7 +979,6 @@ class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
class RearPortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = RearPortTemplate
fields = [
@@ -955,7 +991,6 @@ class RearPortTemplateForm(BootstrapMixin, forms.ModelForm):
class DeviceBayTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = DeviceBayTemplate
fields = [
@@ -970,7 +1005,7 @@ class DeviceBayTemplateForm(BootstrapMixin, forms.ModelForm):
# Device components
#
class ConsolePortForm(BootstrapMixin, CustomFieldModelForm):
class ConsolePortForm(CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -986,7 +1021,7 @@ class ConsolePortForm(BootstrapMixin, CustomFieldModelForm):
}
class ConsoleServerPortForm(BootstrapMixin, CustomFieldModelForm):
class ConsoleServerPortForm(CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -1002,7 +1037,7 @@ class ConsoleServerPortForm(BootstrapMixin, CustomFieldModelForm):
}
class PowerPortForm(BootstrapMixin, CustomFieldModelForm):
class PowerPortForm(CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -1019,7 +1054,7 @@ class PowerPortForm(BootstrapMixin, CustomFieldModelForm):
}
class PowerOutletForm(BootstrapMixin, CustomFieldModelForm):
class PowerOutletForm(CustomFieldModelForm):
power_port = forms.ModelChoiceField(
queryset=PowerPort.objects.all(),
required=False
@@ -1048,12 +1083,17 @@ class PowerOutletForm(BootstrapMixin, CustomFieldModelForm):
)
class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
class InterfaceForm(InterfaceCommonForm, CustomFieldModelForm):
parent = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False,
label='Parent interface'
)
bridge = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False,
label='Bridged interface'
)
lag = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False,
@@ -1062,6 +1102,19 @@ class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
'type': 'lag',
}
)
wireless_lan_group = DynamicModelChoiceField(
queryset=WirelessLANGroup.objects.all(),
required=False,
label='Wireless LAN group'
)
wireless_lans = DynamicModelMultipleChoiceField(
queryset=WirelessLAN.objects.all(),
required=False,
label='Wireless LANs',
query_params={
'group_id': '$wireless_lan_group',
}
)
vlan_group = DynamicModelChoiceField(
queryset=VLANGroup.objects.all(),
required=False,
@@ -1091,19 +1144,24 @@ class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
class Meta:
model = Interface
fields = [
'device', 'name', 'label', 'type', 'enabled', 'parent', 'lag', 'mac_address', 'mtu', 'mgmt_only',
'mark_connected', 'description', 'mode', 'untagged_vlan', 'tagged_vlans', 'tags',
'device', 'name', 'label', 'type', 'enabled', 'parent', 'bridge', 'lag', 'mac_address', 'wwn', 'mtu',
'mgmt_only', 'mark_connected', 'description', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency',
'rf_channel_width', 'tx_power', 'wireless_lans', 'untagged_vlan', 'tagged_vlans', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
'type': StaticSelect(),
'mode': StaticSelect(),
'rf_role': StaticSelect(),
'rf_channel': StaticSelect(),
}
labels = {
'mode': '802.1Q Mode',
}
help_texts = {
'mode': INTERFACE_MODE_HELP_TEXT,
'rf_channel_frequency': "Populated by selected channel (if set)",
'rf_channel_width': "Populated by selected channel (if set)",
}
def __init__(self, *args, **kwargs):
@@ -1111,20 +1169,21 @@ class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
device = Device.objects.get(pk=self.data['device']) if self.is_bound else self.instance.device
# Restrict parent/LAG interface assignment by device/VC
# Restrict parent/bridge/LAG interface assignment by device/VC
self.fields['parent'].widget.add_query_param('device_id', device.pk)
self.fields['bridge'].widget.add_query_param('device_id', device.pk)
self.fields['lag'].widget.add_query_param('device_id', device.pk)
if device.virtual_chassis and device.virtual_chassis.master:
# Get available LAG interfaces by VirtualChassis master
self.fields['parent'].widget.add_query_param('device_id', device.virtual_chassis.master.pk)
self.fields['bridge'].widget.add_query_param('device_id', device.virtual_chassis.master.pk)
self.fields['lag'].widget.add_query_param('device_id', device.virtual_chassis.master.pk)
else:
self.fields['lag'].widget.add_query_param('device_id', device.pk)
# Limit VLAN choices by device
self.fields['untagged_vlan'].widget.add_query_param('available_on_device', device.pk)
self.fields['tagged_vlans'].widget.add_query_param('available_on_device', device.pk)
class FrontPortForm(BootstrapMixin, CustomFieldModelForm):
class FrontPortForm(CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -1152,7 +1211,7 @@ class FrontPortForm(BootstrapMixin, CustomFieldModelForm):
)
class RearPortForm(BootstrapMixin, CustomFieldModelForm):
class RearPortForm(CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -1169,7 +1228,7 @@ class RearPortForm(BootstrapMixin, CustomFieldModelForm):
}
class DeviceBayForm(BootstrapMixin, CustomFieldModelForm):
class DeviceBayForm(CustomFieldModelForm):
tags = DynamicModelMultipleChoiceField(
queryset=Tag.objects.all(),
required=False
@@ -1194,7 +1253,6 @@ class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
)
def __init__(self, device_bay, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['installed_device'].queryset = Device.objects.filter(
@@ -1206,7 +1264,7 @@ class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
).exclude(pk=device_bay.device.pk)
class InventoryItemForm(BootstrapMixin, CustomFieldModelForm):
class InventoryItemForm(CustomFieldModelForm):
device = DynamicModelChoiceField(
queryset=Device.objects.all()
)

View File

@@ -10,6 +10,7 @@ from utilities.forms import (
add_blank_choice, BootstrapMixin, ColorField, DynamicModelChoiceField, DynamicModelMultipleChoiceField,
ExpandableNameField, StaticSelect,
)
from wireless.choices import *
from .common import InterfaceCommonForm
__all__ = (
@@ -34,7 +35,7 @@ __all__ = (
)
class ComponentForm(forms.Form):
class ComponentForm(BootstrapMixin, forms.Form):
"""
Subclass this form when facilitating the creation of one or more device component or component templates based on
a name pattern.
@@ -62,7 +63,7 @@ class ComponentForm(forms.Form):
}, code='label_pattern_mismatch')
class VirtualChassisCreateForm(BootstrapMixin, CustomFieldModelForm):
class VirtualChassisCreateForm(CustomFieldModelForm):
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
@@ -117,12 +118,18 @@ class VirtualChassisCreateForm(BootstrapMixin, CustomFieldModelForm):
'name', 'domain', 'region', 'site_group', 'site', 'rack', 'members', 'initial_position', 'tags',
]
def clean(self):
if self.cleaned_data['members'] and self.cleaned_data['initial_position'] is None:
raise forms.ValidationError({
'initial_position': "A position must be specified for the first VC member."
})
def save(self, *args, **kwargs):
instance = super().save(*args, **kwargs)
# Assign VC members
if instance.pk:
initial_position = self.cleaned_data.get('initial_position') or 1
if instance.pk and self.cleaned_data['members']:
initial_position = self.cleaned_data.get('initial_position', 1)
for i, member in enumerate(self.cleaned_data['members'], start=initial_position):
member.virtual_chassis = instance
member.vc_position = i
@@ -135,7 +142,7 @@ class VirtualChassisCreateForm(BootstrapMixin, CustomFieldModelForm):
# Component templates
#
class ComponentTemplateCreateForm(BootstrapMixin, ComponentForm):
class ComponentTemplateCreateForm(ComponentForm):
"""
Base form for the creation of device component templates (subclassed from ComponentTemplateModel).
"""
@@ -328,7 +335,7 @@ class DeviceBayTemplateCreateForm(ComponentTemplateCreateForm):
# Device components
#
class ComponentCreateForm(BootstrapMixin, CustomFieldsMixin, ComponentForm):
class ComponentCreateForm(CustomFieldsMixin, ComponentForm):
"""
Base form for the creation of device components (models subclassed from ComponentModel).
"""
@@ -445,18 +452,30 @@ class InterfaceCreateForm(ComponentCreateForm, InterfaceCommonForm):
'device_id': '$device',
}
)
bridge = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False,
query_params={
'device_id': '$device',
}
)
lag = DynamicModelChoiceField(
queryset=Interface.objects.all(),
required=False,
query_params={
'device_id': '$device',
'type': 'lag',
}
},
label='LAG'
)
mac_address = forms.CharField(
required=False,
label='MAC Address'
)
wwn = forms.CharField(
required=False,
label='WWN'
)
mgmt_only = forms.BooleanField(
required=False,
label='Management only',
@@ -465,19 +484,42 @@ class InterfaceCreateForm(ComponentCreateForm, InterfaceCommonForm):
mode = forms.ChoiceField(
choices=add_blank_choice(InterfaceModeChoices),
required=False,
widget=StaticSelect()
)
rf_role = forms.ChoiceField(
choices=add_blank_choice(WirelessRoleChoices),
required=False,
widget=StaticSelect(),
label='Wireless role'
)
rf_channel = forms.ChoiceField(
choices=add_blank_choice(WirelessChannelChoices),
required=False,
widget=StaticSelect(),
label='Wireless channel'
)
rf_channel_frequency = forms.DecimalField(
required=False,
label='Channel frequency (MHz)'
)
rf_channel_width = forms.DecimalField(
required=False,
label='Channel width (MHz)'
)
untagged_vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False
required=False,
label='Untagged VLAN'
)
tagged_vlans = DynamicModelMultipleChoiceField(
queryset=VLAN.objects.all(),
required=False
required=False,
label='Tagged VLANs'
)
field_order = (
'device', 'name_pattern', 'label_pattern', 'type', 'enabled', 'parent', 'lag', 'mtu', 'mac_address',
'description', 'mgmt_only', 'mark_connected', 'mode', 'untagged_vlan', 'tagged_vlans', 'tags'
'device', 'name_pattern', 'label_pattern', 'type', 'enabled', 'parent', 'bridge', 'lag', 'mtu', 'mac_address',
'wwn', 'description', 'mgmt_only', 'mark_connected', 'rf_role', 'rf_channel', 'rf_channel_frequency',
'rf_channel_width', 'mode', 'untagged_vlan', 'tagged_vlans', 'tags'
)
def __init__(self, *args, **kwargs):

View File

@@ -26,7 +26,7 @@ class DeviceTypeImportForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'comments',
]

View File

@@ -1,8 +1,11 @@
import graphene
from dcim import filtersets, models
from extras.graphql.mixins import (
ChangelogMixin, ConfigContextMixin, CustomFieldsMixin, ImageAttachmentsMixin, TagsMixin,
)
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
from netbox.graphql.scalars import BigInt
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, PrimaryObjectType
__all__ = (
@@ -144,6 +147,9 @@ class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, PrimaryObjectType):
def resolve_face(self, info):
return self.face or None
def resolve_airflow(self, info):
return self.airflow or None
class DeviceBayType(ComponentObjectType):
@@ -179,6 +185,9 @@ class DeviceTypeType(PrimaryObjectType):
def resolve_subdevice_role(self, info):
return self.subdevice_role or None
def resolve_airflow(self, info):
return self.airflow or None
class FrontPortType(ComponentObjectType):
@@ -206,6 +215,12 @@ class InterfaceType(IPAddressesMixin, ComponentObjectType):
def resolve_mode(self, info):
return self.mode or None
def resolve_rf_role(self, info):
return self.rf_role or None
def resolve_rf_channel(self, info):
return self.rf_channel or None
class InterfaceTemplateType(ComponentTemplateObjectType):
@@ -368,6 +383,7 @@ class RegionType(VLANGroupsMixin, OrganizationalObjectType):
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, PrimaryObjectType):
asn = graphene.Field(BigInt)
class Meta:
model = models.Site

View File

@@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand
from django.core.management.color import no_style
from django.db import connection
from django.db.models import Q
from dcim.models import CablePath, ConsolePort, ConsoleServerPort, Interface, PowerFeed, PowerOutlet, PowerPort
from dcim.signals import create_cablepath
@@ -67,7 +68,10 @@ class Command(BaseCommand):
# Retrace paths
for model in ENDPOINT_MODELS:
origins = model.objects.filter(cable__isnull=False)
params = Q(cable__isnull=False)
if hasattr(model, 'wireless_link'):
params |= Q(wireless_link__isnull=False)
origins = model.objects.filter(params)
if not options['force']:
origins = origins.filter(_path__isnull=True)
origins_count = origins.count()

View File

@@ -0,0 +1,23 @@
import dcim.fields
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0133_port_colors'),
]
operations = [
migrations.AddField(
model_name='interface',
name='wwn',
field=dcim.fields.WWNField(blank=True, null=True),
),
migrations.AddField(
model_name='interface',
name='bridge',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='bridge_interfaces', to='dcim.interface'),
),
]

View File

@@ -0,0 +1,23 @@
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tenancy', '0002_tenant_ordering'),
('dcim', '0134_interface_wwn_bridge'),
]
operations = [
migrations.AddField(
model_name='location',
name='tenant',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='locations', to='tenancy.tenant'),
),
migrations.AddField(
model_name='cable',
name='tenant',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='cables', to='tenancy.tenant'),
),
]

View File

@@ -0,0 +1,21 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0135_tenancy_extensions'),
]
operations = [
migrations.AddField(
model_name='devicetype',
name='airflow',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='device',
name='airflow',
field=models.CharField(blank=True, max_length=50),
),
]

View File

@@ -0,0 +1,83 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0136_device_airflow'),
]
operations = [
migrations.AlterField(
model_name='region',
name='name',
field=models.CharField(max_length=100),
),
migrations.AlterField(
model_name='region',
name='slug',
field=models.SlugField(max_length=100),
),
migrations.AlterField(
model_name='sitegroup',
name='name',
field=models.CharField(max_length=100),
),
migrations.AlterField(
model_name='sitegroup',
name='slug',
field=models.SlugField(max_length=100),
),
migrations.AlterUniqueTogether(
name='location',
unique_together=set(),
),
migrations.AddConstraint(
model_name='location',
constraint=models.UniqueConstraint(fields=('site', 'parent', 'name'), name='dcim_location_parent_name'),
),
migrations.AddConstraint(
model_name='location',
constraint=models.UniqueConstraint(condition=models.Q(('parent', None)), fields=('site', 'name'), name='dcim_location_name'),
),
migrations.AddConstraint(
model_name='location',
constraint=models.UniqueConstraint(fields=('site', 'parent', 'slug'), name='dcim_location_parent_slug'),
),
migrations.AddConstraint(
model_name='location',
constraint=models.UniqueConstraint(condition=models.Q(('parent', None)), fields=('site', 'slug'), name='dcim_location_slug'),
),
migrations.AddConstraint(
model_name='region',
constraint=models.UniqueConstraint(fields=('parent', 'name'), name='dcim_region_parent_name'),
),
migrations.AddConstraint(
model_name='region',
constraint=models.UniqueConstraint(condition=models.Q(('parent', None)), fields=('name',), name='dcim_region_name'),
),
migrations.AddConstraint(
model_name='region',
constraint=models.UniqueConstraint(fields=('parent', 'slug'), name='dcim_region_parent_slug'),
),
migrations.AddConstraint(
model_name='region',
constraint=models.UniqueConstraint(condition=models.Q(('parent', None)), fields=('slug',), name='dcim_region_slug'),
),
migrations.AddConstraint(
model_name='sitegroup',
constraint=models.UniqueConstraint(fields=('parent', 'name'), name='dcim_sitegroup_parent_name'),
),
migrations.AddConstraint(
model_name='sitegroup',
constraint=models.UniqueConstraint(condition=models.Q(('parent', None)), fields=('name',), name='dcim_sitegroup_name'),
),
migrations.AddConstraint(
model_name='sitegroup',
constraint=models.UniqueConstraint(fields=('parent', 'slug'), name='dcim_sitegroup_parent_slug'),
),
migrations.AddConstraint(
model_name='sitegroup',
constraint=models.UniqueConstraint(condition=models.Q(('parent', None)), fields=('slug',), name='dcim_sitegroup_slug'),
),
]

View File

@@ -0,0 +1,50 @@
# Generated by Django 3.2.8 on 2021-10-21 14:50
from django.db import migrations
import taggit.managers
class Migration(migrations.Migration):
dependencies = [
('extras', '0062_clear_secrets_changelog'),
('dcim', '0137_relax_uniqueness_constraints'),
]
operations = [
migrations.AddField(
model_name='devicerole',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
migrations.AddField(
model_name='location',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
migrations.AddField(
model_name='manufacturer',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
migrations.AddField(
model_name='platform',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
migrations.AddField(
model_name='rackrole',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
migrations.AddField(
model_name='region',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
migrations.AddField(
model_name='sitegroup',
name='tags',
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
),
]

View File

@@ -0,0 +1,91 @@
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('dcim', '0138_extend_tag_support'),
]
operations = [
migrations.RenameField(
model_name='consoleport',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='consoleport',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='consoleserverport',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='consoleserverport',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='frontport',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='frontport',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='interface',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='interface',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='powerfeed',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='powerfeed',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='poweroutlet',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='poweroutlet',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='powerport',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='powerport',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
migrations.RenameField(
model_name='rearport',
old_name='_cable_peer_id',
new_name='_link_peer_id',
),
migrations.RenameField(
model_name='rearport',
old_name='_cable_peer_type',
new_name='_link_peer_type',
),
]

View File

@@ -0,0 +1,49 @@
from django.db import migrations, models
import django.core.validators
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('dcim', '0139_rename_cable_peer'),
('wireless', '0001_wireless'),
]
operations = [
migrations.AddField(
model_name='interface',
name='rf_role',
field=models.CharField(blank=True, max_length=30),
),
migrations.AddField(
model_name='interface',
name='rf_channel',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='interface',
name='rf_channel_frequency',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True),
),
migrations.AddField(
model_name='interface',
name='rf_channel_width',
field=models.DecimalField(blank=True, decimal_places=3, max_digits=7, null=True),
),
migrations.AddField(
model_name='interface',
name='tx_power',
field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(127)]),
),
migrations.AddField(
model_name='interface',
name='wireless_lans',
field=models.ManyToManyField(blank=True, related_name='interfaces', to='wireless.WirelessLAN'),
),
migrations.AddField(
model_name='interface',
name='wireless_link',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wireless.wirelesslink'),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 3.2.8 on 2021-11-02 16:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ipam', '0053_asn_model'),
('dcim', '0140_wireless'),
]
operations = [
migrations.AddField(
model_name='site',
name='asns',
field=models.ManyToManyField(blank=True, related_name='sites', to='ipam.ASN'),
),
]

Some files were not shown because too many files have changed in this diff Show More