agent configuration help #142

Closed
opened 2020-06-30 20:02:57 +02:00 by wolfman2g1 · 12 comments
wolfman2g1 commented 2020-06-30 20:02:57 +02:00 (Migrated from github.com)

I'm pretty embarrassed to ask this but I've spent hours trying to sort this out with no luck.

I get
ValueError: get() returned more than one result. Check that the kwarg(s) passed are valid for this endpoint or use filter() or all() instead.
when running python3 -m netbox_agent.cli -c ./agent.yaml --register

Here is the /etc/qualification file ( where I suspect the real issue is)

DATACENTER:

id: dmin-1 # I've also tried setting this to the id number in the data base (1)

agent.yaml

 # Netbox configuration

netbox:

url: 'http://netbox'

token: xxxx

# 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

## 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]"

regex: "DATACENTER: (?P<datacenter>[A-Za-z0-9]+)"

# 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
I'm pretty embarrassed to ask this but I've spent hours trying to sort this out with no luck. I get `ValueError: get() returned more than one result. Check that the kwarg(s) passed are valid for this endpoint or use filter() or all() instead.` when running python3 -m netbox_agent.cli -c ./agent.yaml --register Here is the /etc/qualification file ( where I suspect the real issue is) DATACENTER: id: dmin-1 # I've also tried setting this to the id number in the data base (1) agent.yaml ``` # Netbox configuration netbox: url: 'http://netbox' token: xxxx # 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 ## 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]" regex: "DATACENTER: (?P<datacenter>[A-Za-z0-9]+)" # 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 ```
Solvik commented 2020-06-30 21:02:11 +02:00 (Migrated from github.com)

Hi,

From reading the code, it seems that I didn't manage the case where you only specify the datacenter.
You should also specify the rack

I'll see if I can manage a PR to make your case work

Hi, From reading the code, it seems that I didn't manage the case where you only specify the datacenter. You should also specify the rack I'll see if I can manage a PR to make your case work
wolfman2g1 commented 2020-06-30 21:41:06 +02:00 (Migrated from github.com)

Thanks for your help. In my situation, I have hundreds of servers already deployed and I currently don't have a good way of managing elevations ( hence netbox). My plan was to get all the gear in netbox then update their locations afterwards.

Thanks for your help. In my situation, I have hundreds of servers already deployed and I currently don't have a good way of managing elevations ( hence netbox). My plan was to get all the gear in netbox then update their locations afterwards.
Solvik commented 2020-07-01 09:51:41 +02:00 (Migrated from github.com)

Ok :)
I understand the workflow and make sure it's supported

Ok :) I understand the workflow and make sure it's supported
Solvik commented 2020-07-01 12:45:15 +02:00 (Migrated from github.com)

would you be able to test the #143 branch and let me know if it's ok for you ?

would you be able to test the #143 branch and let me know if it's ok for you ?
wolfman2g1 commented 2020-07-01 17:48:16 +02:00 (Migrated from github.com)

Thanks for the quick turn around!!.still getting an error but not the same error

Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/rjones/netbox-agent/netbox_agent/cli.py", line 48, in <module>
    main()
  File "/home/rjones/netbox-agent/netbox_agent/cli.py", line 44, in main
    return run(config)
  File "/home/rjones/netbox-agent/netbox_agent/cli.py", line 39, in run
    server.netbox_create_or_update(config)
  File "/home/rjones/netbox-agent/netbox_agent/server.py", line 271, in netbox_create_or_update
    self._netbox_create_server(datacenter, rack)
  File "/home/rjones/netbox-agent/netbox_agent/server.py", line 185, in _netbox_create_server
    device_role = get_device_role('Server')
  File "/home/rjones/netbox-agent/netbox_agent/server.py", line 20, in get_device_role
    raise Exception('DeviceRole "{}" does not exist, please create it'.format(role))
Exception: DeviceRole "Server" does not exist, please create it

Thanks for the quick turn around!!.still getting an error but not the same error ``` Traceback (most recent call last): File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/rjones/netbox-agent/netbox_agent/cli.py", line 48, in <module> main() File "/home/rjones/netbox-agent/netbox_agent/cli.py", line 44, in main return run(config) File "/home/rjones/netbox-agent/netbox_agent/cli.py", line 39, in run server.netbox_create_or_update(config) File "/home/rjones/netbox-agent/netbox_agent/server.py", line 271, in netbox_create_or_update self._netbox_create_server(datacenter, rack) File "/home/rjones/netbox-agent/netbox_agent/server.py", line 185, in _netbox_create_server device_role = get_device_role('Server') File "/home/rjones/netbox-agent/netbox_agent/server.py", line 20, in get_device_role raise Exception('DeviceRole "{}" does not exist, please create it'.format(role)) Exception: DeviceRole "Server" does not exist, please create it ```
Solvik commented 2020-07-01 17:50:58 +02:00 (Migrated from github.com)

the agent assumes that you have an existing DeviceRole called Server to be assigned to the server created or updated

the agent assumes that you have an existing `DeviceRole` called Server to be assigned to the server created or updated
wolfman2g1 commented 2020-07-01 17:51:59 +02:00 (Migrated from github.com)

Makes sense, is there a way to override this in the agent?

Makes sense, is there a way to override this in the agent?
Solvik commented 2020-07-01 17:53:17 +02:00 (Migrated from github.com)

there's a PR in #110 that I didn't merge so I guess it's time

there's a PR in #110 that I didn't merge so I guess it's time
wolfman2g1 commented 2020-07-01 18:40:46 +02:00 (Migrated from github.com)

Thanks that would be awesome. I'm doing this manually to start but the plan is to wrap this all up with ansible. I'll Define the roles in the inventory.

Thanks that would be awesome. I'm doing this manually to start but the plan is to wrap this all up with ansible. I'll Define the roles in the inventory.
Solvik commented 2020-07-01 18:56:20 +02:00 (Migrated from github.com)

Issue has been closed automatically, but I've also merged the role support that you can use by passing --device.chassis_role my_chassis_role --device.blade_role my_blade_role

Let me know if it works for you

From the tests I've done everything's ok :)

Issue has been closed automatically, but I've also merged the role support that you can use by passing `--device.chassis_role my_chassis_role --device.blade_role my_blade_role` Let me know if it works for you From the tests I've done everything's ok :)
wolfman2g1 commented 2020-07-01 19:58:03 +02:00 (Migrated from github.com)

I pulled the changes. I'm still having issues just different issues. I think maybe I just don't quite understand the info I need to provide.

netbox-agent]$ python3 -m netbox_agent.cli -c ../agent.yml --register --device.chassis_role docker-host
ERROR:root:Specificing a datacenter (Site) is mandatory in Netbox
I pulled the changes. I'm still having issues just different issues. I think maybe I just don't quite understand the info I need to provide. ``` netbox-agent]$ python3 -m netbox_agent.cli -c ../agent.yml --register --device.chassis_role docker-host ERROR:root:Specificing a datacenter (Site) is mandatory in Netbox ```
Solvik commented 2020-07-02 17:48:01 +02:00 (Migrated from github.com)

I made the datacenter mandatory to create your device, you must specify the datacenter like:

datacenter_location:
  driver: "cmd:echo my-dc"
  regex: "(.*)"
I made the datacenter mandatory to create your device, you must specify the datacenter like: ``` datacenter_location: driver: "cmd:echo my-dc" regex: "(.*)" ```
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#142
No description provided.