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
device_name = "FW-CN-SIA-LAN-001" # Replace with your device name
try:
# Get the specific device
device = nb.dcim.devices.get(name=device_name)
if not device:
print("Device not found")
else:
# Get all secrets associated with the device
secrets = nb.plugins.secrets.secrets.filter(assigned_object_id=device.id)
print(f"Secrets list for device '{device.name}':")
for secret in secrets:
print(f"- Name: {secret.name}, ID: {secret.id}, Secret: {secret.plaintext}")
except Exception as e:
print(f"An error occurred: {e}")
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
-
I installed the NetBox plugin 'secret' to record device passwords.
When I use pynetbox to retrieve secrets, the returned value is None.
Here is my code.
import pynetbox
NetBox API URL and Token
netbox_url = "http://172.18.105.148:8000"
api_token = "3532d718a4cc0fe73147aaf6863642a5a63ceccc"
Initialize NetBox API connection
nb = pynetbox.api(netbox_url, token=api_token)
Device name or ID to look up
device_name = "FW-CN-SIA-LAN-001" # Replace with your device name
try:
# Get the specific device
device = nb.dcim.devices.get(name=device_name)
except Exception as e:
print(f"An error occurred: {e}")
Beta Was this translation helpful? Give feedback.
All reactions