mirror of
https://github.com/netbox-community/Device-Type-Library-Import.git
synced 2024-11-26 01:23:33 +01:00
add: fix for missing powerport when multiple are available i.e. AP7721 template
This commit is contained in:
parent
0d9e8d0c05
commit
c6bc1fbbc8
@ -178,13 +178,16 @@ def createPowerOutlets(poweroutlets, deviceType, nb):
|
||||
if poGet:
|
||||
print(f'Power Outlet Template Exists: {poGet.name} - {poGet.type} - {poGet.device_type.id} - {poGet.id}')
|
||||
else:
|
||||
ppGet = nb.dcim.power_port_templates.get(devicetype_id=deviceType)
|
||||
if ppGet:
|
||||
poweroutlet["power_port"] = ppGet.id
|
||||
poweroutlet["device_type"] = deviceType
|
||||
poSuccess = nb.dcim.power_outlet_templates.create(poweroutlet)
|
||||
print(f'Power Outlet Created: {poSuccess.name} - {poSuccess.type} - {poSuccess.device_type.id} - {poSuccess.id}')
|
||||
counter.update({'updated':1})
|
||||
try:
|
||||
ppGet = nb.dcim.power_port_templates.get(devicetype_id=deviceType)
|
||||
if ppGet:
|
||||
poweroutlet["power_port"] = ppGet.id
|
||||
poweroutlet["device_type"] = deviceType
|
||||
poSuccess = nb.dcim.power_outlet_templates.create(poweroutlet)
|
||||
print(f'Power Outlet Created: {poSuccess.name} - {poSuccess.type} - {poSuccess.device_type.id} - {poSuccess.id}')
|
||||
counter.update({'updated':1})
|
||||
except:
|
||||
print(f'Error assining Power Port to Power Outlet in Outlet: {poweroutlet["name"]}')
|
||||
except pynetbox.RequestError as e:
|
||||
print(e.error)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user