Skip to content

Commit a74dba8

Browse files
committed
Merge branch 'develop' into feature
2 parents 32322e9 + c81c3d1 commit a74dba8

File tree

11 files changed

+64
-30
lines changed

11 files changed

+64
-30
lines changed

.github/workflows/stale.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ jobs:
2727
This issue has been automatically marked as stale because it has not had
2828
recent activity. It will be closed if no further activity occurs. NetBox
2929
is governed by a small group of core maintainers which means not all opened
30-
issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
30+
issues may receive direct feedback. **Do not** attempt to circumvent this
31+
process by "bumping" the issue; doing so will result in its immediate closure
32+
and you may be barred from participating in any future discussions. Please see
33+
our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
3134
stale-pr-label: 'pending closure'
3235
stale-pr-message: >
3336
This PR has been automatically marked as stale because it has not had

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ to aid in issue management.
160160

161161
It is natural that some new issues get more attention than others. The stale
162162
bot helps bring renewed attention to potentially valuable issues that may have
163-
been overlooked. **Do not** comment on an issue that has been marked stale in
164-
an effort to circumvent the bot: Doing so will not remove the stale label.
165-
(Stale labels can be removed only by maintainers.)
163+
been overlooked. **Do not** comment on a stale issue merely to "bump" it in an
164+
effort to circumvent the bot: This will result in the immediate closure of the
165+
issue, and you may be barred from participating in future discussions.
166166

167167
## Maintainer Guidance
168168

docs/release-notes/version-3.2.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
## v3.2.5 (FUTURE)
44

5+
### Enhancements
6+
7+
* [#8882](https://github.com/netbox-community/netbox/issues/8882) - Support filtering IP addresses by multiple parent prefixes
8+
* [#8893](https://github.com/netbox-community/netbox/issues/8893) - Include count of IP ranges under tenant view
9+
10+
### Bug Fixes
11+
12+
* [#9480](https://github.com/netbox-community/netbox/issues/9480) - Fix sorting services & service templates by port numbers
13+
* [#9484](https://github.com/netbox-community/netbox/issues/9484) - Include services listening on "all IPs" under IP address view
14+
* [#9486](https://github.com/netbox-community/netbox/issues/9486) - Fix redirect URL when adding device components from the module view
15+
* [#9495](https://github.com/netbox-community/netbox/issues/9495) - Correct link to contacts in contact groups table column
16+
517
---
618

719
## v3.2.4 (2022-05-31)

netbox/ipam/filtersets.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
464464
field_name='address',
465465
lookup_expr='family'
466466
)
467-
parent = django_filters.CharFilter(
467+
parent = MultiValueCharFilter(
468468
method='search_by_parent',
469469
label='Parent prefix',
470470
)
@@ -571,14 +571,16 @@ def search(self, queryset, name, value):
571571
return queryset.filter(qs_filter)
572572

573573
def search_by_parent(self, queryset, name, value):
574-
value = value.strip()
575574
if not value:
576575
return queryset
577-
try:
578-
query = str(netaddr.IPNetwork(value.strip()).cidr)
579-
return queryset.filter(address__net_host_contained=query)
580-
except (AddrFormatError, ValueError):
581-
return queryset.none()
576+
q = Q()
577+
for prefix in value:
578+
try:
579+
query = str(netaddr.IPNetwork(prefix.strip()).cidr)
580+
q |= Q(address__net_host_contained=query)
581+
except (AddrFormatError, ValueError):
582+
return queryset.none()
583+
return queryset.filter(q)
582584

583585
def filter_address(self, queryset, name, value):
584586
try:

netbox/ipam/tables/services.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class ServiceTemplateTable(NetBoxTable):
1414
linkify=True
1515
)
1616
ports = tables.Column(
17-
accessor=tables.A('port_list')
17+
accessor=tables.A('port_list'),
18+
order_by=tables.A('ports'),
1819
)
1920
tags = columns.TagColumn(
2021
url_name='ipam:servicetemplate_list'
@@ -35,7 +36,8 @@ class ServiceTable(NetBoxTable):
3536
order_by=('device', 'virtual_machine')
3637
)
3738
ports = tables.Column(
38-
accessor=tables.A('port_list')
39+
accessor=tables.A('port_list'),
40+
order_by=tables.A('ports'),
3941
)
4042
tags = columns.TagColumn(
4143
url_name='ipam:service_list'

netbox/ipam/tests/test_filtersets.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,8 @@ def test_description(self):
823823
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
824824

825825
def test_parent(self):
826-
params = {'parent': '10.0.0.0/24'}
827-
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 6)
828-
params = {'parent': '2001:db8::/64'}
829-
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 6)
826+
params = {'parent': ['10.0.0.0/30', '2001:db8::/126']}
827+
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 8)
830828

831829
def test_filter_address(self):
832830
# Check IPv4 and IPv6, with and without a mask

netbox/ipam/views.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from circuits.models import Provider, Circuit
88
from circuits.tables import ProviderTable
99
from dcim.filtersets import InterfaceFilterSet
10-
from dcim.models import Interface, Site
10+
from dcim.models import Interface, Site, Device
1111
from dcim.tables import SiteTable
1212
from netbox.views import generic
1313
from utilities.utils import count_related
1414
from virtualization.filtersets import VMInterfaceFilterSet
15-
from virtualization.models import VMInterface
15+
from virtualization.models import VMInterface, VirtualMachine
1616
from . import filtersets, forms, tables
1717
from .constants import *
1818
from .models import *
@@ -676,7 +676,19 @@ def get_extra_context(self, request, instance):
676676
related_ips_table = tables.IPAddressTable(related_ips, orderable=False)
677677
related_ips_table.configure(request)
678678

679-
services = Service.objects.restrict(request.user, 'view').filter(ipaddresses=instance)
679+
# Find services belonging to the IP
680+
service_filter = Q(ipaddresses=instance)
681+
682+
# Find services listening on all IPs on the assigned device/vm
683+
if instance.assigned_object and instance.assigned_object.parent_object:
684+
parent_object = instance.assigned_object.parent_object
685+
686+
if isinstance(parent_object, VirtualMachine):
687+
service_filter |= (Q(virtual_machine=parent_object) & Q(ipaddresses=None))
688+
elif isinstance(parent_object, Device):
689+
service_filter |= (Q(device=parent_object) & Q(ipaddresses=None))
690+
691+
services = Service.objects.restrict(request.user, 'view').filter(service_filter)
680692

681693
return {
682694
'parent_prefixes_table': parent_prefixes_table,

netbox/templates/dcim/module.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@
1818
</button>
1919
<ul class="dropdown-menu" aria-labeled-by="add-components">
2020
{% if perms.dcim.add_consoleport %}
21-
<li><a class="dropdown-item" href="{% url 'dcim:consoleport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Console Ports</a></li>
21+
<li><a class="dropdown-item" href="{% url 'dcim:consoleport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.device.pk %}">Console Ports</a></li>
2222
{% endif %}
2323
{% if perms.dcim.add_consoleserverport %}
24-
<li><a class="dropdown-item" href="{% url 'dcim:consoleserverport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Console Server Ports</a></li>
24+
<li><a class="dropdown-item" href="{% url 'dcim:consoleserverport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.device.pk %}">Console Server Ports</a></li>
2525
{% endif %}
2626
{% if perms.dcim.add_powerport %}
27-
<li><a class="dropdown-item" href="{% url 'dcim:powerport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Ports</a></li>
27+
<li><a class="dropdown-item" href="{% url 'dcim:powerport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_powerports' pk=object.device.pk %}">Power Ports</a></li>
2828
{% endif %}
2929
{% if perms.dcim.add_poweroutlet %}
30-
<li><a class="dropdown-item" href="{% url 'dcim:poweroutlet_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}">Power Outlets</a></li>
30+
<li><a class="dropdown-item" href="{% url 'dcim:poweroutlet_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.device.pk %}">Power Outlets</a></li>
3131
{% endif %}
3232
{% if perms.dcim.add_interface %}
33-
<li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Interfaces</a></li>
33+
<li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.device.pk %}">Interfaces</a></li>
3434
{% endif %}
3535
{% if perms.dcim.add_frontport %}
36-
<li><a class="dropdown-item" href="{% url 'dcim:frontport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Front Ports</a></li>
36+
<li><a class="dropdown-item" href="{% url 'dcim:frontport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_frontports' pk=object.device.pk %}">Front Ports</a></li>
3737
{% endif %}
3838
{% if perms.dcim.add_rearport %}
39-
<li><a class="dropdown-item" href="{% url 'dcim:rearport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Rear Ports</a></li>
39+
<li><a class="dropdown-item" href="{% url 'dcim:rearport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={% url 'dcim:device_rearports' pk=object.device.pk %}">Rear Ports</a></li>
4040
{% endif %}
4141
</ul>
4242
</div>

netbox/templates/tenancy/tenant.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ <h2><a href="{% url 'ipam:asn_list' %}?tenant_id={{ object.pk }}" class="stat-bt
7777
<h2><a href="{% url 'ipam:prefix_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.prefix_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.prefix_count }}</a></h2>
7878
<p>Prefixes</p>
7979
</div>
80+
<div class="col col-md-4 text-center">
81+
<h2><a href="{% url 'ipam:iprange_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.iprange_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.iprange_count }}</a></h2>
82+
<p>IP Ranges</p>
83+
</div>
8084
<div class="col col-md-4 text-center">
8185
<h2><a href="{% url 'ipam:ipaddress_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.ipaddress_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.ipaddress_count }}</a></h2>
8286
<p>IP addresses</p>

netbox/tenancy/tables/contacts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ContactGroupTable(NetBoxTable):
1818
)
1919
contact_count = columns.LinkedCountColumn(
2020
viewname='tenancy:contact_list',
21-
url_params={'role_id': 'pk'},
21+
url_params={'group_id': 'pk'},
2222
verbose_name='Contacts'
2323
)
2424
tags = columns.TagColumn(

0 commit comments

Comments
 (0)