-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from tobiasge/netbox-4.2
Prepare for Netbox 4.2
- Loading branch information
Showing
20 changed files
with
204 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from dcim.models import MACAddress | ||
|
||
from netbox_initializers.initializers.base import BaseInitializer, register_initializer | ||
|
||
|
||
class MACAddressInitializer(BaseInitializer): | ||
data_file_name = "macs.yml" | ||
|
||
def load_data(self): | ||
macs = self.load_yaml() | ||
if macs is None: | ||
return | ||
|
||
for mac in macs: | ||
tags = mac.pop("tags", None) | ||
macaddress, created = MACAddress.objects.get_or_create(**mac) | ||
|
||
if created: | ||
print("🗺️ Created MAC Address", macaddress.mac_address) | ||
|
||
self.set_tags(macaddress, tags) | ||
|
||
|
||
register_initializer("macs", MACAddressInitializer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.contrib.contenttypes.models import ContentType | ||
|
||
|
||
def get_scope_details(scope: dict, allowed_termination_types: list): | ||
try: | ||
scope_type = ContentType.objects.get(app_label__in=["dcim", "circuits"], model=scope["type"]) | ||
if scope["type"] not in allowed_termination_types: | ||
raise ValueError(f"{scope['type']} scope type is not permitted on {scope_type.app_label}") | ||
except ContentType.DoesNotExist: | ||
raise ValueError(f"⚠️ Invalid scope type: {scope['type']}") | ||
|
||
scope_id = scope_type.model_class().objects.get(name=scope["name"]).id | ||
return scope_type, scope_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
# tenant: tenant1 | ||
# - name: cluster2 | ||
# type: Hyper-V | ||
# site: SING 1 | ||
# scope: SING 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# - mac_address: 00:01:11:11:11:11 | ||
# description: MAC address 1 | ||
# - mac_address: 00:01:22:22:22:22 | ||
# description: Mac address 2 | ||
# - mac_address: 00:01:33:33:33:33 | ||
# description: mac address 3 | ||
# - mac_address: 00:02:44:44:44:44 | ||
# description: mac address 4 | ||
# - mac_address: 00:02:55:55:55:55 | ||
# description: mac address 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
src/netbox_initializers/initializers/yaml/virtualization_interfaces.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
# - description: Network Interface 1 | ||
# enabled: true | ||
# mac_address: 00:77:77:77:77:77 | ||
# primary_mac_address: 00:01:11:11:11:11 | ||
# mtu: 1500 | ||
# name: Network Interface 1 | ||
# virtual_machine: virtual machine 1 | ||
# - description: Network Interface 2 | ||
# enabled: true | ||
# mac_address: 00:55:55:55:55:55 | ||
# mac_addresses: | ||
# - 00:01:22:22:22:22 | ||
# - 00:01:33:33:33:33 | ||
# primary_mac_address: 00:01:33:33:33:33 | ||
# mtu: 1500 | ||
# name: Network Interface 2 | ||
# virtual_machine: virtual machine 1 | ||
# - description: Network Interface 3 | ||
# enabled: true | ||
# mtu: 1500 | ||
# name: Network Interface 3 | ||
# virtual_machine: virtual machine 2 | ||
# - description: Network Interface 4 | ||
# enabled: true | ||
# mac_addresses: | ||
# - 00:02:44:44:44:44 | ||
# - 00:02:55:55:55:55 | ||
# mtu: 1500 | ||
# name: Network Interface 4 | ||
# virtual_machine: virtual machine 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = "4.1.0" | ||
VERSION = "4.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.