Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'id' #281

Open
bit opened this issue Sep 13, 2023 · 2 comments
Open

AttributeError: 'NoneType' object has no attribute 'id' #281

bit opened this issue Sep 13, 2023 · 2 comments

Comments

@bit
Copy link

bit commented Sep 13, 2023

register fails with:

netbox_agent/power.py", line 14, in __init__
    self.device_id = self.netbox_server.parent_device.id if self.netbox_server else None
AttributeError: 'NoneType' object has no attribute 'id'
@bit
Copy link
Author

bit commented Sep 17, 2023

This happened for an HP Blade where the bays did not have the names expected. An error was printed earlier but it did not fail.

"Could not find slot {slot} for chassis" was printed

so might be better fail in that case instead of throwing an error later. or adjust the check in power so it can handle the missing parent

@n1nj444
Copy link

n1nj444 commented Jul 4, 2024

Hi, I got the same issue @Solvik if you have an idea please.

Traceback (most recent call last):
  File "/opt/pyenv/versions/3.9.2/bin/netbox_agent", line 8, in <module>
    sys.exit(main())
  File "/opt/pyenv/versions/3.9.2/lib/python3.9/site-packages/netbox_agent/cli.py", line 50, in main
    return run(config)
  File "/opt/pyenv/versions/3.9.2/lib/python3.9/site-packages/netbox_agent/cli.py", line 43, in run
    server.netbox_create_or_update(config)
  File "/opt/pyenv/versions/3.9.2/lib/python3.9/site-packages/netbox_agent/server.py", line 422, in netbox_create_or_update
    self.power = PowerSupply(server=self)
  File "/opt/pyenv/versions/3.9.2/lib/python3.9/site-packages/netbox_agent/power.py", line 14, in __init__
    self.device_id = self.netbox_server.parent_device.id if self.netbox_server else None
AttributeError: 'NoneType' object has no attribute 'id'

My file :

# Network configuration
network:
  # Regex to ignore interfaces
  ignore_interfaces: "(dummy.*|docker.*)"
  # Regex to ignore IP addresses
  ignore_ips: (127\.0\.0\..*)
  # enable auto-cabling by parsing LLDP answers
  #lldp: true

#
# You can use these to change the Netbox roles.
# These are the defaults.
#
device:
#  chassis_role: "HPE BladeSystem c7000 Enclosure"
  blade_role: "Blade"
  server_role: "Server"
#  tags: server, blade, ,just a comma,delimited,list
#  custom_fields: field1="value1"
#
# Can use this to set the tenant
#
#tenant:
# driver: "file:/tmp/tenant"
# regex: "(.*)"

## Enable virtual machine support
# virtual:
#   # not mandatory, can be guessed
#   enabled: True
#   # see https://netbox.company.com/virtualization/clusters/
#   cluster_name: my_vm_cluster

# Enable datacenter location feature in Netbox
datacenter_location:
 #driver: "cmd:cat /etc/qualification | tr [A-Z] [a-z]"
  driver: "cmd:cat /etc/netbox-agent/site | tr [A-Z] [a-z]"
  #regex: "datacenter: (?P<datacenter>[A-Za-z0-9]+)"
  regex: "(?P<datacenter>.+)"
 #driver: 'cmd:lldpctl'
 #regex: 'SysName: .*\.([A-Za-z0-9]+)'
#
# driver: "file:/tmp/datacenter"
# regex: "(.*)"

# Enable rack location feature in Netbox
#rack_location:
# driver: 'cmd:lldpctl'
# match SysName: sw-dist-a1.dc42
# regex: 'SysName:[ ]+[A-Za-z]+-[A-Za-z]+-([A-Za-z0-9]+)'
#
# driver: "file:/tmp/datacenter"
# regex: "(.*)"

# Enable local inventory reporting
inventory: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants