فهرست منبع

Merge branch 'develop' of github.com:digitalocean/netbox into select2-ui

John Anderson 7 سال پیش
والد
کامیت
f3216abebf
5فایلهای تغییر یافته به همراه39 افزوده شده و 9 حذف شده
  1. 3 0
      CHANGELOG.md
  2. 8 3
      netbox/dcim/api/views.py
  3. 6 0
      netbox/dcim/constants.py
  4. 17 6
      netbox/ipam/models.py
  5. 5 0
      netbox/templates/inc/paginator.html

+ 3 - 0
CHANGELOG.md

@@ -10,12 +10,15 @@ v2.5.3 (FUTURE)
 * [#1870](https://github.com/digitalocean/netbox/issues/1870) - Add per-page toggle to object lists
 * [#1871](https://github.com/digitalocean/netbox/issues/1871) - Enable filtering sites by parent region
 * [#1983](https://github.com/digitalocean/netbox/issues/1983) - Enable regular expressions when bulk renaming device components
+* [#2682](https://github.com/digitalocean/netbox/issues/2682) - Add DAC and AOC cable types
 * [#2693](https://github.com/digitalocean/netbox/issues/2693) - Additional cable colors
 * [#2726](https://github.com/digitalocean/netbox/issues/2726) - Include cables in global search
 
 ## Bug Fixes
 
 * [#2742](https://github.com/digitalocean/netbox/issues/2742) - Preserve cluster assignment when editing a device
+* [#2757](https://github.com/digitalocean/netbox/issues/2757) - Always treat first/last IPs within a /31 or /127 as usable
+* [#2762](https://github.com/digitalocean/netbox/issues/2762) - Add missing DCIM field values to API `_choices` endpoint
 
 
 ---

+ 8 - 3
netbox/dcim/api/views.py

@@ -35,13 +35,18 @@ from .exceptions import MissingFilterException
 
 class DCIMFieldChoicesViewSet(FieldChoicesViewSet):
     fields = (
-        (Cable, ['length_unit']),
-        (Device, ['face', 'status']),
+        (Cable, ['length_unit', 'status', 'type']),
         (ConsolePort, ['connection_status']),
-        (Interface, ['connection_status', 'form_factor', 'mode']),
+        (Device, ['face', 'status']),
+        (DeviceType, ['subdevice_role']),
+        (FrontPort, ['type']),
+        (FrontPortTemplate, ['type']),
+        (Interface, ['form_factor', 'mode']),
         (InterfaceTemplate, ['form_factor']),
         (PowerPort, ['connection_status']),
         (Rack, ['outer_unit', 'status', 'type', 'width']),
+        (RearPort, ['type']),
+        (RearPortTemplate, ['type']),
         (Site, ['status']),
     )
 

+ 6 - 0
netbox/dcim/constants.py

@@ -339,11 +339,14 @@ CABLE_TYPE_CAT5E = 1510
 CABLE_TYPE_CAT6 = 1600
 CABLE_TYPE_CAT6A = 1610
 CABLE_TYPE_CAT7 = 1700
+CABLE_TYPE_DAC_ACTIVE = 1800
+CABLE_TYPE_DAC_PASSIVE = 1810
 CABLE_TYPE_MMF_OM1 = 3010
 CABLE_TYPE_MMF_OM2 = 3020
 CABLE_TYPE_MMF_OM3 = 3030
 CABLE_TYPE_MMF_OM4 = 3040
 CABLE_TYPE_SMF = 3500
+CABLE_TYPE_AOC = 3800
 CABLE_TYPE_POWER = 5000
 CABLE_TYPE_CHOICES = (
     (
@@ -354,6 +357,8 @@ CABLE_TYPE_CHOICES = (
             (CABLE_TYPE_CAT6, 'CAT6'),
             (CABLE_TYPE_CAT6A, 'CAT6a'),
             (CABLE_TYPE_CAT7, 'CAT7'),
+            (CABLE_TYPE_DAC_ACTIVE, 'Direct Attach Copper (Active)'),
+            (CABLE_TYPE_DAC_PASSIVE, 'Direct Attach Copper (Passive)'),
         ),
     ),
     (
@@ -363,6 +368,7 @@ CABLE_TYPE_CHOICES = (
             (CABLE_TYPE_MMF_OM3, 'Multimode Fiber (OM3)'),
             (CABLE_TYPE_MMF_OM4, 'Multimode Fiber (OM4)'),
             (CABLE_TYPE_SMF, 'Singlemode Fiber'),
+            (CABLE_TYPE_AOC, 'Active Optical Cabling (AOC)'),
         ),
     ),
     (CABLE_TYPE_POWER, 'Power'),

+ 17 - 6
netbox/ipam/models.py

@@ -438,12 +438,23 @@ class Prefix(ChangeLoggedModel, CustomFieldModel):
         child_ips = netaddr.IPSet([ip.address.ip for ip in self.get_child_ips()])
         available_ips = prefix - child_ips
 
-        # Remove unusable IPs from non-pool prefixes
-        if not self.is_pool:
-            available_ips -= netaddr.IPSet([
-                netaddr.IPAddress(self.prefix.first),
-                netaddr.IPAddress(self.prefix.last),
-            ])
+        # All IP addresses within a pool are considered usable
+        if self.is_pool:
+            return available_ips
+
+        # All IP addresses within a point-to-point prefix (IPv4 /31 or IPv6 /127) are considered usable
+        if (
+            self.family == 4 and self.prefix.prefixlen == 31  # RFC 3021
+        ) or (
+            self.family == 6 and self.prefix.prefixlen == 127  # RFC 6164
+        ):
+            return available_ips
+
+        # Omit first and last IP address from the available set
+        available_ips -= netaddr.IPSet([
+            netaddr.IPAddress(self.prefix.first),
+            netaddr.IPAddress(self.prefix.last),
+        ])
 
         return available_ips
 

+ 5 - 0
netbox/templates/inc/paginator.html

@@ -20,6 +20,11 @@
             </ul>
         </nav>
         <form method="get">
+            {% for k, v in request.GET.items %}
+                {% if k != 'per_page' %}
+                    <input type="hidden" name="{{ k }}" value="{{ v }}" />
+                {% endif %}
+            {% endfor %}
             <select name="per_page" id="per_page">
                 {% for n in settings.PER_PAGE_DEFAULTS %}
                     <option value="{{ n }}"{% if page.paginator.per_page == n %} selected="selected"{% endif %}>{{ n }}</option>