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

Open
opened 2023-09-13 23:14:17 +02:00 by bit · 2 comments
bit commented 2023-09-13 23:14:17 +02:00 (Migrated from github.com)

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'
register fails with: ```python 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 commented 2023-09-17 19:51:59 +02:00 (Migrated from github.com)

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

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 commented 2024-07-04 09:34:57 +02:00 (Migrated from github.com)

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

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 in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: DGNum/netbox-agent#281
No description provided.