Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion aquilon/netbox2aquilon.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,17 @@ def netbox_copy(self, opts):

# Preserve MagDB style machine naming for migrated hosts
# Add a property to the object to store the desired aquilon machine name
device.aq_machine_name = f'netbox-{device.id}'
device.aq_machine_name = None
if 'magdb2netbox' in [t.slug for t in device.tags]:
device.aq_machine_name = f'system{device.custom_fields["magdb_system_id"]}'

if isinstance(device, pynetbox.models.dcim.Devices):
if device.aq_machine_name is None:
device.aq_machine_name = f'netbox-{device.id}'
cmds = self._netbox_copy_device(device)
elif isinstance(device, pynetbox.models.virtualization.VirtualMachines):
if device.aq_machine_name is None:
device.aq_machine_name = f'netboxvm-{device.id}'
cmds = self._netbox_copy_vm(device)
else:
logging.error('Unsupported device type to copy "%s"', type(device))
Expand Down