You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to copy the cables and create new ones that will be on other terminations with customs scripts. For that I make this script :
from django.utils.text import slugify
from extras.scripts import *
from dcim.choices import DeviceStatusChoices, SiteStatusChoices, RackStatusChoices, LocationStatusChoices
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Site, Rack, Location, Interface, Cable
from extras.scripts import *
class test(Script):
...
def run(self, data, commit):
# PARTIE CABLE
for cable in Cable.objects.all():
if "FR01" in cable.a_terminations[0].device.name :
ret = cable.a_terminations[0].device.name.replace('FR01','FR02')
for device in Device.objects.filter(site=siteToUpdate):
if ret1 == device.name :
for interface in device.interfaces.all():
if interface.name == cable.a_terminations[0].name:
cable.a_terminations[0].id = interface.id
allCable.append(cable)
for y in allCable:
cableSet = Cable(
label = y.label,
type = y.type,
status = y.status,
tenant = y.tenant,
description = y.description,
color = y.color,
length = y.length,
length_unit = y.length_unit,
a_terminations = y.a_terminations,
comments = y.comments,
tags = y.tags
)
cableSet.full_clean()
cableSet.save()
self.log_success(f"Created new device : {cableSet}")
However when I change the id of interface of a_termination[0], termination keeps its old ID.
Please does anyone know how to change the terminations of a cable ?
Thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I would like to copy the cables and create new ones that will be on other terminations with customs scripts. For that I make this script :
from django.utils.text import slugify
from extras.scripts import *
from dcim.choices import DeviceStatusChoices, SiteStatusChoices, RackStatusChoices, LocationStatusChoices
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Site, Rack, Location, Interface, Cable
from extras.scripts import *
class test(Script):
...
However when I change the id of interface of a_termination[0], termination keeps its old ID.
Please does anyone know how to change the terminations of a cable ?
Thanks
Best regard
Beta Was this translation helpful? Give feedback.
All reactions