mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Merge v2.5.11
This commit is contained in:
commit
37c2c4b4a2
22
CHANGELOG.md
22
CHANGELOG.md
@ -195,6 +195,28 @@ functionality provided by the front end UI.
|
||||
|
||||
---
|
||||
|
||||
2.5.11 (2019-04-29)
|
||||
|
||||
## Notes
|
||||
|
||||
This release upgrades the Django framework to version 2.2.
|
||||
|
||||
## Enhancements
|
||||
|
||||
* [#2986](https://github.com/digitalocean/netbox/issues/2986) - Improve natural ordering of device components
|
||||
* [#3023](https://github.com/digitalocean/netbox/issues/3023) - Add support for filtering cables by connected device
|
||||
* [#3070](https://github.com/digitalocean/netbox/issues/3070) - Add decommissioning status for devices
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* [#2621](https://github.com/digitalocean/netbox/issues/2621) - Upgrade Django requirement to 2.2 to fix object deletion issue in the changelog middleware
|
||||
* [#3072](https://github.com/digitalocean/netbox/issues/3072) - Preserve multiselect filter values when updating per-page count for list views
|
||||
* [#3112](https://github.com/digitalocean/netbox/issues/3112) - Fix ordering of interface connections list by termination B name/device
|
||||
* [#3116](https://github.com/digitalocean/netbox/issues/3116) - Fix `tagged_items` count in tags API endpoint
|
||||
* [#3118](https://github.com/digitalocean/netbox/issues/3118) - Disable `last_login` update on login when maintenance mode is enabled
|
||||
|
||||
---
|
||||
|
||||
v2.5.10 (2019-04-08)
|
||||
|
||||
## Enhancements
|
||||
|
@ -318,6 +318,7 @@ DEVICE_STATUS_PLANNED = 2
|
||||
DEVICE_STATUS_STAGED = 3
|
||||
DEVICE_STATUS_FAILED = 4
|
||||
DEVICE_STATUS_INVENTORY = 5
|
||||
DEVICE_STATUS_DECOMMISSIONING = 6
|
||||
DEVICE_STATUS_CHOICES = [
|
||||
[DEVICE_STATUS_ACTIVE, 'Active'],
|
||||
[DEVICE_STATUS_OFFLINE, 'Offline'],
|
||||
@ -325,6 +326,7 @@ DEVICE_STATUS_CHOICES = [
|
||||
[DEVICE_STATUS_STAGED, 'Staged'],
|
||||
[DEVICE_STATUS_FAILED, 'Failed'],
|
||||
[DEVICE_STATUS_INVENTORY, 'Inventory'],
|
||||
[DEVICE_STATUS_DECOMMISSIONING, 'Decommissioning'],
|
||||
]
|
||||
|
||||
# Site statuses
|
||||
@ -345,6 +347,7 @@ STATUS_CLASSES = {
|
||||
3: 'primary',
|
||||
4: 'danger',
|
||||
5: 'default',
|
||||
6: 'warning',
|
||||
}
|
||||
|
||||
# Console/power/interface connection statuses
|
||||
|
@ -1,5 +1,7 @@
|
||||
import django_filters
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db.models import Q
|
||||
from netaddr import EUI
|
||||
from netaddr.core import AddrFormatError
|
||||
@ -969,6 +971,14 @@ class CableFilter(django_filters.FilterSet):
|
||||
color = django_filters.MultipleChoiceFilter(
|
||||
choices=COLOR_CHOICES
|
||||
)
|
||||
device = django_filters.CharFilter(
|
||||
method='filter_connected_device',
|
||||
field_name='name'
|
||||
)
|
||||
device_id = django_filters.CharFilter(
|
||||
method='filter_connected_device',
|
||||
field_name='pk'
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Cable
|
||||
@ -979,6 +989,16 @@ class CableFilter(django_filters.FilterSet):
|
||||
return queryset
|
||||
return queryset.filter(label__icontains=value)
|
||||
|
||||
def filter_connected_device(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
return queryset
|
||||
try:
|
||||
device = Device.objects.get(**{name: value})
|
||||
except ObjectDoesNotExist:
|
||||
return queryset.none()
|
||||
cable_pks = device.get_cables(pk_list=True)
|
||||
return queryset.filter(pk__in=cable_pks)
|
||||
|
||||
|
||||
class ConsoleConnectionFilter(django_filters.FilterSet):
|
||||
site = django_filters.CharFilter(
|
||||
|
@ -3003,6 +3003,10 @@ class CableFilterForm(BootstrapMixin, forms.Form):
|
||||
required=False,
|
||||
widget=ColorSelect()
|
||||
)
|
||||
device = forms.CharField(
|
||||
required=False,
|
||||
label='Device name'
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
|
@ -14,22 +14,6 @@ CHANNEL_RE = r"COALESCE(CAST(SUBSTRING({} FROM '^.*:(\d{{1,9}})(\.\d{{1,9}})?$')
|
||||
VC_RE = r"COALESCE(CAST(SUBSTRING({} FROM '^.*\.(\d{{1,9}})$') AS integer), 0)"
|
||||
|
||||
|
||||
class DeviceComponentManager(Manager):
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
queryset = super().get_queryset()
|
||||
table_name = self.model._meta.db_table
|
||||
sql = r"CONCAT(REGEXP_REPLACE({}.name, '\d+$', ''), LPAD(SUBSTRING({}.name FROM '\d+$'), 8, '0'))"
|
||||
|
||||
# Pad any trailing digits to effect natural sorting
|
||||
return queryset.extra(
|
||||
select={
|
||||
'name_padded': sql.format(table_name, table_name),
|
||||
}
|
||||
).order_by('name_padded', 'pk')
|
||||
|
||||
|
||||
class InterfaceQuerySet(QuerySet):
|
||||
|
||||
def connectable(self):
|
||||
|
@ -23,7 +23,7 @@ from utilities.utils import serialize_object, to_meters
|
||||
from .constants import *
|
||||
from .exceptions import LoopDetected
|
||||
from .fields import ASNField, MACAddressField
|
||||
from .managers import DeviceComponentManager, InterfaceManager
|
||||
from .managers import InterfaceManager
|
||||
|
||||
|
||||
class ComponentTemplateModel(models.Model):
|
||||
@ -982,7 +982,7 @@ class ConsolePortTemplate(ComponentTemplateModel):
|
||||
max_length=50
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1005,7 +1005,7 @@ class ConsoleServerPortTemplate(ComponentTemplateModel):
|
||||
max_length=50
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1040,7 +1040,7 @@ class PowerPortTemplate(ComponentTemplateModel):
|
||||
help_text="Allocated current draw (watts)"
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1076,7 +1076,7 @@ class PowerOutletTemplate(ComponentTemplateModel):
|
||||
help_text="Phase (for three-phase feeds)"
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1166,7 +1166,7 @@ class FrontPortTemplate(ComponentTemplateModel):
|
||||
validators=[MinValueValidator(1), MaxValueValidator(64)]
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1215,7 +1215,7 @@ class RearPortTemplate(ComponentTemplateModel):
|
||||
validators=[MinValueValidator(1), MaxValueValidator(64)]
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1238,7 +1238,7 @@ class DeviceBayTemplate(ComponentTemplateModel):
|
||||
max_length=50
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
@ -1731,6 +1731,21 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
||||
filter |= Q(device__virtual_chassis=self.virtual_chassis, mgmt_only=False)
|
||||
return Interface.objects.filter(filter)
|
||||
|
||||
def get_cables(self, pk_list=False):
|
||||
"""
|
||||
Return a QuerySet or PK list matching all Cables connected to a component of this Device.
|
||||
"""
|
||||
cable_pks = []
|
||||
for component_model in [
|
||||
ConsolePort, ConsoleServerPort, PowerPort, PowerOutlet, Interface, FrontPort, RearPort
|
||||
]:
|
||||
cable_pks += component_model.objects.filter(
|
||||
device=self, cable__isnull=False
|
||||
).values_list('cable', flat=True)
|
||||
if pk_list:
|
||||
return cable_pks
|
||||
return Cable.objects.filter(pk__in=cable_pks)
|
||||
|
||||
def get_children(self):
|
||||
"""
|
||||
Return the set of child Devices installed in DeviceBays within this Device.
|
||||
@ -1769,7 +1784,7 @@ class ConsolePort(CableTermination, ComponentModel):
|
||||
blank=True
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'description']
|
||||
@ -1813,7 +1828,7 @@ class ConsoleServerPort(CableTermination, ComponentModel):
|
||||
blank=True
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'description']
|
||||
@ -1882,7 +1897,7 @@ class PowerPort(CableTermination, ComponentModel):
|
||||
blank=True
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'maximum_draw', 'allocated_draw', 'description']
|
||||
@ -1998,7 +2013,7 @@ class PowerOutlet(CableTermination, ComponentModel):
|
||||
blank=True
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'power_port', 'feed_leg', 'description']
|
||||
@ -2338,7 +2353,7 @@ class FrontPort(CableTermination, ComponentModel):
|
||||
validators=[MinValueValidator(1), MaxValueValidator(64)]
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'type', 'rear_port', 'rear_port_position', 'description']
|
||||
@ -2400,7 +2415,7 @@ class RearPort(CableTermination, ComponentModel):
|
||||
validators=[MinValueValidator(1), MaxValueValidator(64)]
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'type', 'positions', 'description']
|
||||
@ -2447,7 +2462,7 @@ class DeviceBay(ComponentModel):
|
||||
null=True
|
||||
)
|
||||
|
||||
objects = DeviceComponentManager()
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager(through=TaggedItem)
|
||||
|
||||
csv_headers = ['device', 'name', 'installed_device', 'description']
|
||||
|
@ -743,18 +743,18 @@ class InterfaceConnectionTable(BaseTable):
|
||||
)
|
||||
device_b = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
accessor=Accessor('connected_endpoint.device'),
|
||||
args=[Accessor('connected_endpoint.device.pk')],
|
||||
accessor=Accessor('_connected_interface.device'),
|
||||
args=[Accessor('_connected_interface.device.pk')],
|
||||
verbose_name='Device B'
|
||||
)
|
||||
interface_b = tables.LinkColumn(
|
||||
viewname='dcim:interface',
|
||||
accessor=Accessor('connected_endpoint.name'),
|
||||
args=[Accessor('connected_endpoint.pk')],
|
||||
accessor=Accessor('_connected_interface'),
|
||||
args=[Accessor('_connected_interface.pk')],
|
||||
verbose_name='Interface B'
|
||||
)
|
||||
description_b = tables.Column(
|
||||
accessor=Accessor('connected_endpoint.description'),
|
||||
accessor=Accessor('_connected_interface.description'),
|
||||
verbose_name='Description'
|
||||
)
|
||||
|
||||
|
@ -148,7 +148,9 @@ class TopologyMapViewSet(ModelViewSet):
|
||||
#
|
||||
|
||||
class TagViewSet(ModelViewSet):
|
||||
queryset = Tag.objects.annotate(tagged_items=Count('extras_taggeditem_items'))
|
||||
queryset = Tag.objects.annotate(
|
||||
tagged_items=Count('taggit_taggeditem_items', distinct=True)
|
||||
)
|
||||
serializer_class = serializers.TagSerializer
|
||||
filterset_class = filters.TagFilter
|
||||
|
||||
|
@ -29,7 +29,7 @@ from .tables import ConfigContextTable, ObjectChangeTable, TagTable, TaggedItemT
|
||||
|
||||
class TagListView(ObjectListView):
|
||||
queryset = Tag.objects.annotate(
|
||||
items=Count('extras_taggeditem_items')
|
||||
items=Count('taggit_taggeditem_items', distinct=True)
|
||||
).order_by(
|
||||
'name'
|
||||
)
|
||||
|
@ -20,9 +20,11 @@
|
||||
</ul>
|
||||
</nav>
|
||||
<form method="get">
|
||||
{% for k, v in request.GET.items %}
|
||||
{% for k, v_list in request.GET.lists %}
|
||||
{% if k != 'per_page' %}
|
||||
<input type="hidden" name="{{ k }}" value="{{ v }}" />
|
||||
{% for v in v_list %}
|
||||
<input type="hidden" name="{{ k }}" value="{{ v }}" />
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<select name="per_page" id="per_page">
|
||||
|
@ -65,7 +65,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>VLAN</strong>
|
||||
@ -142,7 +142,7 @@
|
||||
{% include 'inc/custom_fields_panel.html' with obj=vlan %}
|
||||
{% include 'extras/inc/tags_panel.html' with tags=vlan.tags.all url='ipam:vlan_list' %}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-8">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Prefixes</strong>
|
||||
|
@ -1,6 +1,9 @@
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import login as auth_login, logout as auth_logout, update_session_auth_hash
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
|
||||
from django.contrib.auth.models import update_last_login
|
||||
from django.contrib.auth.signals import user_logged_in
|
||||
from django.http import HttpResponseForbidden, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.urls import reverse
|
||||
@ -43,6 +46,11 @@ class LoginView(View):
|
||||
if not is_safe_url(url=redirect_to, allowed_hosts=request.get_host()):
|
||||
redirect_to = reverse('home')
|
||||
|
||||
# If maintenance mode is enabled, assume the database is read-only, and disable updating the user's
|
||||
# last_login time upon authentication.
|
||||
if settings.MAINTENANCE_MODE:
|
||||
user_logged_in.disconnect(update_last_login, dispatch_uid='update_last_login')
|
||||
|
||||
# Authenticate user
|
||||
auth_login(request, form.get_user())
|
||||
messages.info(request, "Logged in as {}.".format(request.user))
|
||||
|
@ -1,6 +1,6 @@
|
||||
Django>=2.2,<2.3
|
||||
django-cacheops==4.1
|
||||
django-cors-headers==2.5.2
|
||||
django-cors-headers==2.4.0
|
||||
django-debug-toolbar==1.11
|
||||
django-filter==2.1.0
|
||||
django-mptt==0.9.1
|
||||
|
Loading…
Reference in New Issue
Block a user