Skip to content

Commit a79a9c8

Browse files
committed
Include additional values
Working on including "mgmt_only" as an interface value that gets moved across when adding an interface.
1 parent c8d4484 commit a79a9c8

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

netbox_interface_synchronization/templates/netbox_interface_synchronization/interface_comparison.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737

3838
<p>
3939
{% if templates_count == interfaces_count %}
40-
The Device Type and Device have the same Interfaces.
40+
The Device Type and Device have the same number of Interfaces.
4141
{% else %}
42-
The Device Type and Device have different Interfaces.<br>
42+
The Device Type and Device have a different number of Interfaces.<br>
4343
Device Type: {{ templates_count }}<br>
4444
Device: {{ interfaces_count }}
4545
{% endif %}
@@ -154,7 +154,7 @@
154154
{% endfor %}
155155
</table>
156156
<div class="text-right">
157-
<input type="submit" value="Apply" class="btn btn-primary">
157+
<input type="submit" value="Apply Changes" class="btn btn-green">
158158
</div>
159159
</form>
160160

netbox_interface_synchronization/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class UnifiedInterface:
2424
name: str
2525
type: str
2626
type_display: str
27+
mgmt_only: bool
2728
is_template: bool = False
2829

2930
def __eq__(self, other):

netbox_interface_synchronization/views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get(self, request, device_id):
2424

2525
unified_interfaces = [UnifiedInterface(i.id, i.name, i.type, i.get_type_display()) for i in interfaces]
2626
unified_interface_templates = [
27-
UnifiedInterface(i.id, i.name, i.type, i.get_type_display(), is_template=True) for i in interface_templates]
27+
UnifiedInterface(i.id, i.name, i.type, i.get_type_display(), i.mgmt_only, is_template=True) for i in interface_templates]
2828

2929
# List of interfaces and interface templates presented in the unified format
3030
overall_interfaces = list(set(unified_interface_templates + unified_interfaces))
@@ -79,19 +79,19 @@ def post(self, request, device_id):
7979
# Add selected interfaces to the device and count them
8080
add_to_device_interfaces = InterfaceTemplate.objects.filter(id__in=add_to_device)
8181
interfaces_created = len(Interface.objects.bulk_create([
82-
Interface(device=device, name=i.name, type=i.type) for i in add_to_device_interfaces
82+
Interface(device=device, name=i.name, type=i.type, mgmt_only=i.mgmt_only) for i in add_to_device_interfaces
8383
]))
8484

8585
# Getting and validating a list of interfaces to rename
8686
fix_name_interfaces = filter(lambda i: str(i.id) in request.POST.getlist("fix_name"), interfaces)
8787
# Casting interface templates into UnifiedInterface objects for proper comparison with interfaces for renaming
8888
unified_interface_templates = [
89-
UnifiedInterface(i.id, i.name, i.type, i.get_type_display()) for i in interface_templates]
89+
UnifiedInterface(i.id, i.name, i.type,i.mgmt_only, i.get_type_display()) for i in interface_templates]
9090

9191
# Rename selected interfaces
9292
interfaces_fixed = 0
9393
for interface in fix_name_interfaces:
94-
unified_interface = UnifiedInterface(interface.id, interface.name, interface.type, interface.get_type_display())
94+
unified_interface = UnifiedInterface(interface.id, interface.name, interface.type, interface.mgmt_only, interface.get_type_display())
9595
try:
9696
# Try to extract an interface template with the corresponding name
9797
corresponding_template = unified_interface_templates[unified_interface_templates.index(unified_interface)]

0 commit comments

Comments
 (0)