Skip to content

Commit 05d438c

Browse files
authored
Merge pull request #3 from NetTech2001/4.0.2-development
4.0.3 Update
2 parents fd3b848 + f4632b2 commit 05d438c

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# netbox-interface-synchronization
22
## Overview
3-
This plugin allows you to compare and synchronize interfaces between devices and device types in NetBox. It can be useful for finding and correcting inconsistencies between interfaces.
3+
This plugin allows you to compare and synchronize interface names and types between devices and device types in NetBox. It can be useful for finding and correcting inconsistencies between interfaces when changing the device type.
44
## Compatibility
5-
Tested with NetBox versions 4.0.0, 4.0.1, 4.0.2. This plugin is not compatible with Netbox 2 or 3
5+
Tested with NetBox versions 4.0.0 - 4.0.3. This plugin is not compatible with Netbox 2 or 3
66
## Installation
77
If your NetBox 4 installation uses virtualenv, activate it like this:
88
```
@@ -27,7 +27,7 @@ Don't forget to restart NetBox:
2727
sudo systemctl restart netbox
2828
```
2929
## Usage
30-
To sync the interfaces, edit the device and set the new device type and save the device. Then find the "Sync Interfaces" button:
30+
To sync the interfaces, edit the device and set the new device type and save the device. Then find the "Sync Interfaces" button at the bottom of the page:
3131
![Device page](docs/images/1_device_page.png)
3232
Mark the required actions with the checkboxes and click "Apply".
3333
![Interface comparison](docs/images/2_interface_comparison.png)

netbox_interface_synchronization/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
class Config(PluginConfig):
55
name = 'netbox_interface_synchronization'
66
verbose_name = 'NetBox Interface Synchronization'
7-
description = 'Syncing existing interfaces with the interfaces from a new device type in NetBox'
8-
version = '4.0.1'
7+
description = 'Syncing existing interface names and types with those from a new device type in NetBox'
8+
version = '4.0.3'
99
author = 'Keith Knowles'
1010
author_email = '[email protected]'
1111
default_settings = {

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 = False
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)]

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
setup(
77
name='netbox-interface-synchronization',
8-
version='4.0.1',
9-
description='Syncing existing interfaces with the interfaces from a new device type in NetBox',
8+
version='4.0.3',
9+
description='Syncing existing interfaces with the interfaces from a device type template in NetBox 4+',
1010
long_description=long_description,
1111
long_description_content_type='text/markdown',
1212
author='Keith Knowles',

0 commit comments

Comments
 (0)