Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.8.5 #4693

Merged
merged 27 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
422eedd
Post-release version bump
jeremystretch May 13, 2020
2c2d6c6
fixes #3304 - primary IP address caching invalidation
lampwins May 15, 2020
14744da
fixes #4647 - caching invalidation related to assinging new IP addres…
lampwins May 15, 2020
8394ff5
Fixes #4644: Fix ordering of services table by parent
jeremystretch May 15, 2020
ba91b3a
Fixes #4646: Correct UI link for reports with custom name
jeremystretch May 15, 2020
a643512
Fixes #4648: Fix bulk CSV import of child devices
jeremystretch May 15, 2020
3c8e7e7
Fixes #4649: Fix interface assignment for bulk-imported IP addresses
jeremystretch May 15, 2020
cd236aa
Closes #4645: Update minimum required version of PostgreSQL to 9.6
jeremystretch May 15, 2020
d2e1428
Closes #4665: Add NEMA L14 and L21 power port/outlet types
jeremystretch May 20, 2020
1f5d252
Formatting fix
jeremystretch May 20, 2020
27700d3
Add `perms` to PluginTemplateExtension context
steffann May 22, 2020
ff3b348
Add `csrf_token` to PluginTemplateExtension context
steffann May 22, 2020
74c29b0
Fixes #4684: Fix ignored comment when importing DeviceType
kobayashi May 26, 2020
9cde377
Closes #4676: Set default value of REMOTE_AUTH_AUTO_CREATE_USER as Fa…
kobayashi May 26, 2020
b7cf85e
Merge pull request #4681 from netbox-community/4652-perms-in-pluginte…
jeremystretch May 26, 2020
4545c15
Merge branch 'develop' into 4651-csrf-in-plugintemplateextension
jeremystretch May 26, 2020
abcd26d
Merge pull request #4682 from netbox-community/4651-csrf-in-plugintem…
jeremystretch May 26, 2020
a578555
Changelog for #4651, #4652
jeremystretch May 26, 2020
7f5583c
Merge pull request #4690 from kobayashi/4676-docs-default-remote-auth
jeremystretch May 26, 2020
f043406
Merge branch 'develop' into 4684-devicetype-import-comment
jeremystretch May 26, 2020
faf3885
Merge pull request #4689 from kobayashi/4684-devicetype-import-comment
jeremystretch May 26, 2020
92f49b4
Closes #4672: Set default color for rack and devices roles
jeremystretch May 26, 2020
88cffca
Closes #4650: Expose INTERNAL_IPS configuration parameter
jeremystretch May 26, 2020
e54d441
Remove "disable plugins" from bug report to prevent irrelevant search…
jeremystretch May 26, 2020
ccc31b2
Fixes #4525: Allow passing initial data to custom script MultiObjectVar
jeremystretch May 26, 2020
5f9b254
Merge pull request #4692 from netbox-community/4525-objectvar-initial…
jeremystretch May 26, 2020
c9a7527
Release v2.8.5
jeremystretch May 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ about: Report a reproducible bug in the current release of NetBox
library such as pynetbox.
-->
### Steps to Reproduce
1. Disable any installed plugins by commenting out the `PLUGINS` setting in
`configuration.py`.
2.
3.
1.
2.
3.

<!-- What did you expect to happen? -->
### Expected Behavior
Expand Down
19 changes: 17 additions & 2 deletions docs/configuration/optional-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ CORS_ORIGIN_WHITELIST = [

Default: False

This setting enables debugging. This should be done only during development or troubleshooting. Never enable debugging on a production system, as it can expose sensitive data to unauthenticated users.
This setting enables debugging. This should be done only during development or troubleshooting. Note that only clients
which access NetBox from a recognized [internal IP address](#internal_ips) will see debugging tools in the user
interface.

!!! warning
Never enable debugging on a production system, as it can expose sensitive data to unauthenticated users.

---

Expand Down Expand Up @@ -184,6 +189,16 @@ HTTP_PROXIES = {

---

## INTERNAL_IPS

Default: `('127.0.0.1', '::1',)`

A list of IP addresses recognized as internal to the system, used to control the display of debugging output. For
example, the debugging toolbar will be viewable only when a client is accessing NetBox from one of the listed IP
addresses (and [`DEBUG`](#debug) is true).

---

## LOGGING

By default, all messages of INFO severity or higher will be logged to the console. Additionally, if `DEBUG` is False and email access has been configured, ERROR and CRITICAL messages will be emailed to the users defined in `ADMINS`.
Expand Down Expand Up @@ -385,7 +400,7 @@ When remote user authentication is in use, this is the name of the HTTP header w

## REMOTE_AUTH_AUTO_CREATE_USER

Default: `True`
Default: `False`

If true, NetBox will automatically create local accounts for users authenticated via a remote service. (Requires `REMOTE_AUTH_ENABLED`.)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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.4+ |
| Database | PostgreSQL 9.6+ |
| Task queuing | Redis/django-rq |
| Live device access | NAPALM |

Expand Down
4 changes: 2 additions & 2 deletions docs/installation/1-postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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.4 or higher. Please note that MySQL and other relational databases are **not** supported.
NetBox requires PostgreSQL 9.6 or higher. Please note that MySQL and other relational databases are **not** supported.

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

Expand Down Expand Up @@ -51,7 +51,7 @@ At a minimum, we need to create a database for NetBox and assign it a username a

```no-highlight
# sudo -u postgres psql
psql (9.4.5)
psql (10.10)
Type "help" for help.

postgres=# CREATE DATABASE netbox;
Expand Down
28 changes: 27 additions & 1 deletion docs/release-notes/version-2.8.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# NetBox v2.8

v2.8.4 (2020-05-13)
## v2.8.5 (2020-05-26)

**Note:** The minimum required version of PostgreSQL is now 9.6.

### Enhancements

* [#4650](https://github.com/netbox-community/netbox/issues/4650) - Expose `INTERNAL_IPS` configuration parameter
* [#4651](https://github.com/netbox-community/netbox/issues/4651) - Add `csrf_token` context for plugin templates
* [#4652](https://github.com/netbox-community/netbox/issues/4652) - Add permissions context for plugin templates
* [#4665](https://github.com/netbox-community/netbox/issues/4665) - Add NEMA L14 and L21 power port/outlet types
* [#4672](https://github.com/netbox-community/netbox/issues/4672) - Set default color for rack and devices roles

### Bug Fixes

* [#3304](https://github.com/netbox-community/netbox/issues/3304) - Fix caching invalidation issue related to device/virtual machine primary IP addresses
* [#4525](https://github.com/netbox-community/netbox/issues/4525) - Allow passing initial data to custom script MultiObjectVar
* [#4644](https://github.com/netbox-community/netbox/issues/4644) - Fix ordering of services table by parent
* [#4646](https://github.com/netbox-community/netbox/issues/4646) - Correct UI link for reports with custom name
* [#4647](https://github.com/netbox-community/netbox/issues/4647) - Fix caching invalidation issue related to assigning new IP addresses to interfaces
* [#4648](https://github.com/netbox-community/netbox/issues/4648) - Fix bulk CSV import of child devices
* [#4649](https://github.com/netbox-community/netbox/issues/4649) - Fix interface assignment for bulk-imported IP addresses
* [#4676](https://github.com/netbox-community/netbox/issues/4676) - Set default value of `REMOTE_AUTH_AUTO_CREATE_USER` as `False` in docs
* [#4684](https://github.com/netbox-community/netbox/issues/4684) - Respect `comments` field when importing device type in YAML/JSON format

---

## v2.8.4 (2020-05-13)

### Enhancements

Expand Down
16 changes: 16 additions & 0 deletions netbox/dcim/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ class PowerPortTypeChoices(ChoiceSet):
TYPE_NEMA_L620P = 'nema-l6-20p'
TYPE_NEMA_L630P = 'nema-l6-30p'
TYPE_NEMA_L650P = 'nema-l6-50p'
TYPE_NEMA_L1420P = 'nema-l14-20p'
TYPE_NEMA_L1430P = 'nema-l14-30p'
TYPE_NEMA_L2120P = 'nema-l21-20p'
TYPE_NEMA_L2130P = 'nema-l21-30p'
# California style
TYPE_CS6361C = 'cs6361c'
TYPE_CS6365C = 'cs6365c'
Expand Down Expand Up @@ -337,6 +341,10 @@ class PowerPortTypeChoices(ChoiceSet):
(TYPE_NEMA_L620P, 'NEMA L6-20P'),
(TYPE_NEMA_L630P, 'NEMA L6-30P'),
(TYPE_NEMA_L650P, 'NEMA L6-50P'),
(TYPE_NEMA_L1420P, 'NEMA L14-20P'),
(TYPE_NEMA_L1430P, 'NEMA L14-30P'),
(TYPE_NEMA_L2120P, 'NEMA L21-20P'),
(TYPE_NEMA_L2130P, 'NEMA L21-30P'),
)),
('California Style', (
(TYPE_CS6361C, 'CS6361C'),
Expand Down Expand Up @@ -405,6 +413,10 @@ class PowerOutletTypeChoices(ChoiceSet):
TYPE_NEMA_L620R = 'nema-l6-20r'
TYPE_NEMA_L630R = 'nema-l6-30r'
TYPE_NEMA_L650R = 'nema-l6-50r'
TYPE_NEMA_L1420R = 'nema-l14-20r'
TYPE_NEMA_L1430R = 'nema-l14-30r'
TYPE_NEMA_L2120R = 'nema-l21-20r'
TYPE_NEMA_L2130R = 'nema-l21-30r'
# California style
TYPE_CS6360C = 'CS6360C'
TYPE_CS6364C = 'CS6364C'
Expand Down Expand Up @@ -467,6 +479,10 @@ class PowerOutletTypeChoices(ChoiceSet):
(TYPE_NEMA_L620R, 'NEMA L6-20R'),
(TYPE_NEMA_L630R, 'NEMA L6-30R'),
(TYPE_NEMA_L650R, 'NEMA L6-50R'),
(TYPE_NEMA_L1420R, 'NEMA L14-20R'),
(TYPE_NEMA_L1430R, 'NEMA L14-30R'),
(TYPE_NEMA_L2120R, 'NEMA L21-20R'),
(TYPE_NEMA_L2130R, 'NEMA L21-30R'),
)),
('California Style', (
(TYPE_CS6360C, 'CS6360C'),
Expand Down
4 changes: 2 additions & 2 deletions netbox/dcim/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from extras.filters import CustomFieldFilterSet, LocalConfigContextFilterSet, CreatedUpdatedFilterSet
from tenancy.filters import TenancyFilterSet
from tenancy.models import Tenant
from utilities.constants import COLOR_CHOICES
from utilities.choices import ColorChoices
from utilities.filters import (
BaseFilterSet, MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter,
NameSlugSearchFilterSet, TagFilter, TreeNodeMultipleChoiceFilter,
Expand Down Expand Up @@ -1084,7 +1084,7 @@ class CableFilterSet(BaseFilterSet):
choices=CableStatusChoices
)
color = django_filters.MultipleChoiceFilter(
choices=COLOR_CHOICES
choices=ColorChoices
)
device_id = MultiValueNumberFilter(
method='filter_device'
Expand Down
17 changes: 16 additions & 1 deletion netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ class Meta:
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
'comments',
]


Expand Down Expand Up @@ -1956,7 +1957,7 @@ class ChildDeviceCSVForm(BaseDeviceCSVForm):
help_text='Parent device'
)
device_bay = CSVModelChoiceField(
queryset=Device.objects.all(),
queryset=DeviceBay.objects.all(),
to_field_name='name',
help_text='Device bay in which this device is installed'
)
Expand All @@ -1976,6 +1977,20 @@ def __init__(self, data=None, *args, **kwargs):
params = {f"device__{self.fields['parent'].to_field_name}": data.get('parent')}
self.fields['device_bay'].queryset = self.fields['device_bay'].queryset.filter(**params)

def clean(self):
super().clean()

# Set parent_bay reverse relationship
device_bay = self.cleaned_data.get('device_bay')
if device_bay:
self.instance.parent_bay = device_bay

# Inherit site and rack from parent device
parent = self.cleaned_data.get('parent')
if parent:
self.instance.site = parent.site
self.instance.rack = parent.rack


class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
pk = forms.ModelMultipleChoiceField(
Expand Down
24 changes: 24 additions & 0 deletions netbox/dcim/migrations/0106_role_default_color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.0.6 on 2020-05-26 13:33

from django.db import migrations
import utilities.fields


class Migration(migrations.Migration):

dependencies = [
('dcim', '0105_interface_name_collation'),
]

operations = [
migrations.AlterField(
model_name='devicerole',
name='color',
field=utilities.fields.ColorField(default='9e9e9e', max_length=6),
),
migrations.AlterField(
model_name='rackrole',
name='color',
field=utilities.fields.ColorField(default='9e9e9e', max_length=6),
),
]
9 changes: 7 additions & 2 deletions netbox/dcim/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dcim.elevations import RackElevationSVG
from extras.models import ConfigContextModel, CustomFieldModel, ObjectChange, TaggedItem
from extras.utils import extras_features
from utilities.choices import ColorChoices
from utilities.fields import ColorField, NaturalOrderingField
from utilities.models import ChangeLoggedModel
from utilities.utils import serialize_object, to_meters
Expand Down Expand Up @@ -379,7 +380,9 @@ class RackRole(ChangeLoggedModel):
slug = models.SlugField(
unique=True
)
color = ColorField()
color = ColorField(
default=ColorChoices.COLOR_GREY
)
description = models.CharField(
max_length=200,
blank=True,
Expand Down Expand Up @@ -1190,7 +1193,9 @@ class DeviceRole(ChangeLoggedModel):
slug = models.SlugField(
unique=True
)
color = ColorField()
color = ColorField(
default=ColorChoices.COLOR_GREY
)
vm_role = models.BooleanField(
default=True,
verbose_name='VM Role',
Expand Down
2 changes: 2 additions & 0 deletions netbox/dcim/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def test_import_objects(self):
model: TEST-1000
slug: test-1000
u_height: 2
comments: test comment
console-ports:
- name: Console Port 1
type: de-9
Expand Down Expand Up @@ -456,6 +457,7 @@ def test_import_objects(self):
self.assertHttpStatus(response, 200)

dt = DeviceType.objects.get(model='TEST-1000')
self.assertEqual(dt.comments, 'test comment')

# Verify all of the components were created
self.assertEqual(dt.consoleport_templates.count(), 3)
Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ class DeviceView(PermissionRequiredMixin, View):
def get(self, request, pk):

device = get_object_or_404(Device.objects.prefetch_related(
'site__region', 'rack__group', 'tenant__group', 'device_role', 'platform'
'site__region', 'rack__group', 'tenant__group', 'device_role', 'platform', 'primary_ip4', 'primary_ip6'
), pk=pk)

# VirtualChassis members
Expand Down
6 changes: 3 additions & 3 deletions netbox/extras/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ class ScriptForm(BootstrapMixin, forms.Form):

def __init__(self, vars, *args, commit_default=True, **kwargs):

super().__init__(*args, **kwargs)

# Dynamically populate fields for variables
for name, var in vars.items():
self.fields[name] = var.as_field()
self.base_fields[name] = var.as_field()

super().__init__(*args, **kwargs)

# Toggle default commit behavior based on Meta option
if not commit_default:
Expand Down
3 changes: 2 additions & 1 deletion netbox/extras/models/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.utils.text import slugify
from taggit.models import TagBase, GenericTaggedItemBase

from utilities.choices import ColorChoices
from utilities.fields import ColorField
from utilities.models import ChangeLoggedModel

Expand All @@ -13,7 +14,7 @@

class Tag(TagBase, ChangeLoggedModel):
color = ColorField(
default='9e9e9e'
default=ColorChoices.COLOR_GREY
)
description = models.CharField(
max_length=200,
Expand Down
4 changes: 2 additions & 2 deletions netbox/extras/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self):
self.active_test = None
self.failed = False

self.logger = logging.getLogger(f"netbox.reports.{self.module}.{self.name}")
self.logger = logging.getLogger(f"netbox.reports.{self.full_name}")

# Compile test methods and initialize results skeleton
test_methods = []
Expand Down Expand Up @@ -120,7 +120,7 @@ def name(self):

@property
def full_name(self):
return '.'.join([self.module, self.name])
return '.'.join([self.__module__, self.__class__.__name__])

def _log(self, obj, message, level=LOG_DEFAULT):
"""
Expand Down
2 changes: 2 additions & 0 deletions netbox/extras/templatetags/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def _get_registered_content(obj, method, template_context):
'object': obj,
'request': template_context['request'],
'settings': template_context['settings'],
'csrf_token': template_context['csrf_token'],
'perms': template_context['perms'],
}

model_name = obj._meta.label_lower
Expand Down
19 changes: 6 additions & 13 deletions netbox/ipam/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,12 @@ def __init__(self, *args, **kwargs):
if self.instance and self.instance.interface:
self.fields['interface'].queryset = Interface.objects.filter(
device=self.instance.interface.device, virtual_machine=self.instance.interface.virtual_machine
)
).prefetch_related(
'device__primary_ip4',
'device__primary_ip6',
'virtual_machine__primary_ip4',
'virtual_machine__primary_ip6',
) # We prefetch the primary address fields to ensure cache invalidation does not balk on the save()
else:
self.fields['interface'].choices = []

Expand Down Expand Up @@ -775,18 +780,6 @@ def clean(self):

def save(self, *args, **kwargs):

# Set interface
if self.cleaned_data['device'] and self.cleaned_data['interface_name']:
self.instance.interface = Interface.objects.get(
device=self.cleaned_data['device'],
name=self.cleaned_data['interface_name']
)
elif self.cleaned_data['virtual_machine'] and self.cleaned_data['interface_name']:
self.instance.interface = Interface.objects.get(
virtual_machine=self.cleaned_data['virtual_machine'],
name=self.cleaned_data['interface_name']
)

ipaddress = super().save(*args, **kwargs)

# Set as primary for device/VM
Expand Down
3 changes: 3 additions & 0 deletions netbox/ipam/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ class ServiceTable(BaseTable):
viewname='ipam:service',
args=[Accessor('pk')]
)
parent = tables.LinkColumn(
order_by=('device', 'virtual_machine')
)
tags = TagColumn(
url_name='ipam:service_list'
)
Expand Down
Loading