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

Allow to avoid overriding the Devices Site with the default site (vCenter: <vcenter-name>) #409

Open
joachimBurket opened this issue Aug 22, 2024 · 3 comments

Comments

@joachimBurket
Copy link

joachimBurket commented Aug 22, 2024

I have some Hosts in the vCenter for which the site can't be inferred from the name, and therefore are set to the default site (vCenter: <vcenter-name>) by the sync.
I then manually put the Devices in the right Site and Rack. But then on the next run of the sync script, those Devices generates errors because the sync tries to override the Site to the default.
Example of error:

2024-08-10 02:20:02,151 - ERROR: NetBox returned: PATCH /api/dcim/devices/4707/ Bad Request
2024-08-10 02:20:02,151 - ERROR: NetBox returned body: {'rack': ['Rack XYZ does not belong to site vCenter: <vcenter-name>.']}

Is there a way to bypass the override of the Site when the device already has a Site in NetBox that is not the default one?

@joachimBurket joachimBurket changed the title Allow to avoid overriding the Devices Site with the default site (vCenter: vcenter-hvs) Allow to avoid overriding the Devices Site with the default site (vCenter: <vcenter-name>) Aug 28, 2024
@bb-Ricardo
Copy link
Owner

Hi,

do these devices belong to a cluster? Or are they stand alone ESXi hosts? Please have a look at the cluster_site_relation setting.

@joachimBurket
Copy link
Author

Hi!
They do belong to clusters, but these clusters have their Site to <NONE>, because our Clusters aren't specific to a Site
We therefore used the host_site_relation to place the Hosts depdending on their name, which works for most of our devices. But we still have some devices that aren't named conventionally and are placed in the default site.

A workaround could be to add those Devices in the host_site_relation, but it is not very practical, as we would need to update the settings.yaml for any new unconventional Device.

An interesting feature for us would be to be able to set a default value for the different relations in the settings file (for instance the host_site_relation), and then being able to configure the sync so that it doesn't override the values in NetBox that were changed from the default one to another value. Would it make sense to you?

@bb-Ricardo
Copy link
Owner

This sounds like to be solvable with some bash, yq and curl glue.

Quick idea:

  • assign this hand assind host a special tag
  • use curl to query the hosts with that tag
  • get the site for each of the hosts
  • update the settings.yaml with yq
  • run the sync

This way you can automate this process. Or you can set the config option via an environment variable.

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