Просмотр исходного кода

Merge branch 'develop' into feature

jeremystretch 3 лет назад
Родитель
Сommit
9ae25e9449
29 измененных файлов с 120 добавлено и 72 удалено
  1. 1 1
      .github/ISSUE_TEMPLATE/bug_report.yaml
  2. 1 1
      .github/ISSUE_TEMPLATE/feature_request.yaml
  3. 2 3
      base_requirements.txt
  4. 9 1
      docs/release-notes/version-3.2.md
  5. 1 1
      netbox/dcim/models/device_components.py
  6. 12 8
      netbox/ipam/models/ip.py
  7. 12 0
      netbox/ipam/tests/test_models.py
  8. 2 1
      netbox/templates/dcim/device/consoleports.html
  9. 2 1
      netbox/templates/dcim/device/consoleserverports.html
  10. 2 1
      netbox/templates/dcim/device/devicebays.html
  11. 2 1
      netbox/templates/dcim/device/frontports.html
  12. 36 34
      netbox/templates/dcim/device/interfaces.html
  13. 2 1
      netbox/templates/dcim/device/inventory.html
  14. 2 1
      netbox/templates/dcim/device/modulebays.html
  15. 2 1
      netbox/templates/dcim/device/poweroutlets.html
  16. 2 1
      netbox/templates/dcim/device/powerports.html
  17. 2 1
      netbox/templates/dcim/device/rearports.html
  18. 5 1
      netbox/templates/dcim/inc/cable_termination.html
  19. 2 1
      netbox/templates/ipam/aggregate/prefixes.html
  20. 2 1
      netbox/templates/ipam/iprange/ip_addresses.html
  21. 2 1
      netbox/templates/ipam/prefix/ip_addresses.html
  22. 2 1
      netbox/templates/ipam/prefix/ip_ranges.html
  23. 2 1
      netbox/templates/ipam/prefix/prefixes.html
  24. 2 1
      netbox/templates/ipam/vlan/interfaces.html
  25. 2 1
      netbox/templates/ipam/vlan/vminterfaces.html
  26. 2 1
      netbox/templates/virtualization/cluster/devices.html
  27. 2 1
      netbox/templates/virtualization/cluster/virtual_machines.html
  28. 2 1
      netbox/templates/virtualization/virtualmachine/interfaces.html
  29. 3 3
      requirements.txt

+ 1 - 1
.github/ISSUE_TEMPLATE/bug_report.yaml

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

+ 1 - 1
.github/ISSUE_TEMPLATE/feature_request.yaml

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

+ 2 - 3
base_requirements.txt

@@ -68,8 +68,7 @@ gunicorn
 
 # Platform-agnostic template rendering engine
 # https://github.com/pallets/jinja
-# Pin to v3.0 for mkdocstrings
-Jinja2<3.1
+Jinja2
 
 # Simple markup language for rendering HTML
 # https://github.com/Python-Markdown/markdown
@@ -85,7 +84,7 @@ mkdocs-material
 
 # Introspection for embedded code
 # https://github.com/mkdocstrings/mkdocstrings
-mkdocstrings<=0.17.0
+mkdocstrings[python-legacy]
 
 # Library for manipulating IP prefixes and addresses
 # https://github.com/netaddr/netaddr

+ 9 - 1
docs/release-notes/version-3.2.md

@@ -1,6 +1,10 @@
 # NetBox v3.2
 
-## v3.2.2 (FUTURE)
+## v3.2.3 (FUTURE)
+
+---
+
+## v3.2.2 (2022-04-28)
 
 ### Enhancements
 
@@ -11,15 +15,19 @@
 
 ### Bug Fixes
 
+* [#4264](https://github.com/netbox-community/netbox/issues/4264) - Treat 0th IP as unusable for IPv6 prefixes (excluding /127s)
 * [#8941](https://github.com/netbox-community/netbox/issues/8941) - Fix dynamic dropdown behavior when browser is zoomed
 * [#8959](https://github.com/netbox-community/netbox/issues/8959) - Prevent exception when refreshing scripts list (avoid race condition)
 * [#9132](https://github.com/netbox-community/netbox/issues/9132) - Limit location options by selected site when creating a wireless link
 * [#9133](https://github.com/netbox-community/netbox/issues/9133) - Upgrade script should require Python 3.8 or later
+* [#9138](https://github.com/netbox-community/netbox/issues/9138) - Avoid inadvertent form submission when utilizing quick search field on object lists
 * [#9151](https://github.com/netbox-community/netbox/issues/9151) - Child prefix counts not annotated on aggregates list under RIR view
 * [#9156](https://github.com/netbox-community/netbox/issues/9156) - Fix loading UserConfig data from fixtures
 * [#9158](https://github.com/netbox-community/netbox/issues/9158) - Do not list tags field for CSV forms which do not support tag assignment
 * [#9194](https://github.com/netbox-community/netbox/issues/9194) - Support position assignment when add module bays to multiple devices
 * [#9206](https://github.com/netbox-community/netbox/issues/9206) - Show header for comments field under module & module type creation views
+* [#9222](https://github.com/netbox-community/netbox/issues/9222) - Fix circuit ID display under cable view
+* [#9227](https://github.com/netbox-community/netbox/issues/9227) - Fix related object assignment when recording change record for interfaces
 
 ---
 

+ 1 - 1
netbox/dcim/models/device_components.py

@@ -77,7 +77,7 @@ class ComponentModel(NetBoxModel):
     def to_objectchange(self, action):
         objectchange = super().to_objectchange(action)
         objectchange.related_object = self.device
-        return super().to_objectchange(action)
+        return objectchange
 
     @property
     def parent_object(self):

+ 12 - 8
netbox/ipam/models/ip.py

@@ -507,16 +507,20 @@ class Prefix(GetAvailablePrefixesMixin, NetBoxModel):
             child_ranges.add(iprange.range)
         available_ips = prefix - child_ips - child_ranges
 
-        # IPv6, pool, or IPv4 /31-/32 sets are fully usable
-        if self.family == 6 or self.is_pool or (self.family == 4 and self.prefix.prefixlen >= 31):
+        # IPv6 /127's, pool, or IPv4 /31-/32 sets are fully usable
+        if (self.family == 6 and self.prefix.prefixlen >= 127) or self.is_pool or (self.family == 4 and self.prefix.prefixlen >= 31):
             return available_ips
 
-        # For "normal" IPv4 prefixes, omit first and last addresses
-        available_ips -= netaddr.IPSet([
-            netaddr.IPAddress(self.prefix.first),
-            netaddr.IPAddress(self.prefix.last),
-        ])
-
+        if self.family == 4:
+            # For "normal" IPv4 prefixes, omit first and last addresses
+            available_ips -= netaddr.IPSet([
+                netaddr.IPAddress(self.prefix.first),
+                netaddr.IPAddress(self.prefix.last),
+            ])
+        else:
+            # For IPv6 prefixes, omit the Subnet-Router anycast address
+            # per RFC 4291
+            available_ips -= netaddr.IPSet([netaddr.IPAddress(self.prefix.first)])
         return available_ips
 
     def get_first_available_ip(self):

+ 12 - 0
netbox/ipam/tests/test_models.py

@@ -185,6 +185,18 @@ class TestPrefix(TestCase):
         IPAddress.objects.create(address=IPNetwork('10.0.0.4/24'))
         self.assertEqual(parent_prefix.get_first_available_ip(), '10.0.0.5/24')
 
+    def test_get_first_available_ip_ipv6(self):
+        parent_prefix = Prefix.objects.create(prefix=IPNetwork('2001:db8:500::/64'))
+        self.assertEqual(parent_prefix.get_first_available_ip(), '2001:db8:500::1/64')
+
+    def test_get_first_available_ip_ipv6_rfc3627(self):
+        parent_prefix = Prefix.objects.create(prefix=IPNetwork('2001:db8:500:4::/126'))
+        self.assertEqual(parent_prefix.get_first_available_ip(), '2001:db8:500:4::1/126')
+
+    def test_get_first_available_ip_ipv6_rfc6164(self):
+        parent_prefix = Prefix.objects.create(prefix=IPNetwork('2001:db8:500:5::/127'))
+        self.assertEqual(parent_prefix.get_first_available_ip(), '2001:db8:500:5::/127')
+
     def test_get_utilization_container(self):
         prefixes = (
             Prefix(prefix=IPNetwork('10.0.0.0/24'), status=PrefixStatusChoices.STATUS_CONTAINER),

+ 2 - 1
netbox/templates/dcim/device/consoleports.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceConsolePortTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceConsolePortTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/consoleserverports.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceConsoleServerPortTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceConsoleServerPortTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/devicebays.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceDeviceBayTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceDeviceBayTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/frontports.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceFrontPortTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceFrontPortTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 36 - 34
netbox/templates/dcim/device/interfaces.html

@@ -4,44 +4,46 @@
 {% load static %}
 
 {% block content %}
-  <form method="post">
-    {% csrf_token %}
-    <div class="row mb-3 justify-content-between">
-      <div class="col col-12 col-lg-4 my-3 my-lg-0 d-flex noprint table-controls">
-        <div class="input-group input-group-sm">
-          <input
-              type="text"
-              name="q"
-              class="form-control"
-              placeholder="Quick search"
-              hx-get="{{ request.full_path }}"
-              hx-target="#object_list"
-              hx-trigger="keyup changed delay:500ms"
-          />
-        </div>
+  <div class="row mb-3 justify-content-between">
+    <div class="col col-12 col-lg-4 my-3 my-lg-0 d-flex noprint table-controls">
+      <div class="input-group input-group-sm">
+        <input
+            type="text"
+            name="q"
+            class="form-control"
+            placeholder="Quick search"
+            hx-get="{{ request.full_path }}"
+            hx-target="#object_list"
+            hx-trigger="keyup changed delay:500ms"
+        />
       </div>
-      <div class="col col-md-3 mb-0 d-flex noprint table-controls">
-        <div class="input-group input-group-sm justify-content-end">
-          {% if request.user.is_authenticated %}
-            <button
-                type="button"
-                class="btn btn-sm btn-outline-dark"
-                data-bs-toggle="modal"
-                data-bs-target="#DeviceInterfaceTable_config"
-                title="Configure Table">
-                <i class="mdi mdi-cog"></i> Configure Table
-            </button>
-          {% endif %}
-          <button class="btn btn-sm btn-outline-dark dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
-            <i class="mdi mdi-eye"></i>
+    </div>
+    <div class="col col-md-3 mb-0 d-flex noprint table-controls">
+      <div class="input-group input-group-sm justify-content-end">
+        {% if request.user.is_authenticated %}
+          <button
+              type="button"
+              class="btn btn-sm btn-outline-dark"
+              data-bs-toggle="modal"
+              data-bs-target="#DeviceInterfaceTable_config"
+              title="Configure Table">
+              <i class="mdi mdi-cog"></i> Configure Table
           </button>
-          <ul class="dropdown-menu">
-            <button type="button" class="dropdown-item toggle-enabled" data-state="show">Hide Enabled</button>
-            <button type="button" class="dropdown-item toggle-disabled" data-state="show">Hide Disabled</button>
-          </ul>
-        </div>
+        {% endif %}
+        <button class="btn btn-sm btn-outline-dark dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
+          <i class="mdi mdi-eye"></i>
+        </button>
+        <ul class="dropdown-menu">
+          <button type="button" class="dropdown-item toggle-enabled" data-state="show">Hide Enabled</button>
+          <button type="button" class="dropdown-item toggle-disabled" data-state="show">Hide Disabled</button>
+        </ul>
       </div>
     </div>
+  </div>
+
+  <form method="post">
+    {% csrf_token %}
+
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/inventory.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceInventoryItemTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceInventoryItemTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/modulebays.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceModuleBayTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceModuleBayTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/poweroutlets.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DevicePowerOutletTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DevicePowerOutletTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/powerports.html

@@ -4,9 +4,10 @@
 {% load static %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DevicePowerPortTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DevicePowerPortTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/dcim/device/rearports.html

@@ -4,9 +4,10 @@
 {% load helpers %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceRearPortTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceRearPortTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 5 - 1
netbox/templates/dcim/inc/cable_termination.html

@@ -32,7 +32,11 @@
         </tr>
         <tr>
             <td>Circuit</td>
-            <td>{{ termination.|linkify }} ({{ termination }})</td>
+            <td>{{ termination.circuit|linkify }}</td>
+        </tr>
+        <tr>
+            <td>Termination</td>
+            <td>{{ termination }}</td>
         </tr>
     {% endif %}
 </table>

+ 2 - 1
netbox/templates/ipam/aggregate/prefixes.html

@@ -12,9 +12,10 @@
 {% endblock %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="PrefixTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="PrefixTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/ipam/iprange/ip_addresses.html

@@ -10,9 +10,10 @@
 {% endblock %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="IPAddressTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="IPAddressTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/ipam/prefix/ip_addresses.html

@@ -10,9 +10,10 @@
 {% endblock %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="IPAddressTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="IPAddressTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/ipam/prefix/ip_ranges.html

@@ -10,9 +10,10 @@
 {% endblock %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="IPRangeTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="IPRangeTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/ipam/prefix/prefixes.html

@@ -12,9 +12,10 @@
 {% endblock %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="PrefixTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="PrefixTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 2 - 1
netbox/templates/ipam/vlan/interfaces.html

@@ -2,9 +2,10 @@
 {% load helpers %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="VLANDevicesTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="VLANDevicesTable_config" %}
     <div class="card">
       <div class="card-body" id="object_list">
         {% include 'htmx/table.html' %}

+ 2 - 1
netbox/templates/ipam/vlan/vminterfaces.html

@@ -2,9 +2,10 @@
 {% load helpers %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="VLANVirtualMachinesTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="VLANVirtualMachinesTable_config" %}
     <div class="card">
       <div class="card-body" id="object_list">
         {% include 'htmx/table.html' %}

+ 2 - 1
netbox/templates/virtualization/cluster/devices.html

@@ -3,9 +3,10 @@
 {% load render_table from django_tables2 %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="DeviceTable_config" %}
+  
   <form action="{% url 'virtualization:cluster_remove_devices' pk=object.pk %}" method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="DeviceTable_config" %}
     <div class="card">
       <div class="card-body" id="object_list">
         {% include 'htmx/table.html' %}

+ 2 - 1
netbox/templates/virtualization/cluster/virtual_machines.html

@@ -3,9 +3,10 @@
 {% load render_table from django_tables2 %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="VirtualMachineTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="VirtualMachineTable_config" %}
     <div class="card">
       <div class="card-body" id="object_list">
         {% include 'htmx/table.html' %}

+ 2 - 1
netbox/templates/virtualization/virtualmachine/interfaces.html

@@ -3,9 +3,10 @@
 {% load helpers %}
 
 {% block content %}
+  {% include 'inc/table_controls_htmx.html' with table_modal="VirtualMachineVMInterfaceTable_config" %}
+  
   <form method="post">
     {% csrf_token %}
-    {% include 'inc/table_controls_htmx.html' with table_modal="VirtualMachineVMInterfaceTable_config" %}
 
     <div class="card">
       <div class="card-body" id="object_list">

+ 3 - 3
requirements.txt

@@ -15,11 +15,11 @@ djangorestframework==3.13.1
 drf-yasg[validation]==1.20.0
 graphene-django==2.15.0
 gunicorn==20.1.0
-Jinja2==3.0.3
+Jinja2==3.1.2
 Markdown==3.3.6
 markdown-include==0.6.0
-mkdocs-material==8.2.9
-mkdocstrings==0.17.0
+mkdocs-material==8.2.11
+mkdocstrings[python-legacy]==0.18.1
 netaddr==0.8.0
 Pillow==9.1.0
 psycopg2-binary==2.9.3