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

Unable to add VMs from Cluster located on two sites #301

Closed
smasharov opened this issue Apr 22, 2023 · 15 comments · Fixed by #333
Closed

Unable to add VMs from Cluster located on two sites #301

smasharov opened this issue Apr 22, 2023 · 15 comments · Fixed by #333
Labels
awaiting reply Awaiting reply from issue owner
Milestone

Comments

@smasharov
Copy link

I have a big cluster located on two different sites with several hundreds VMs. Site field is now empty and it is impossible to set it because hosts are located on the different sites. The script tries to set site for the cluster, but get an error from Netbox and all further steps are also failed.

Is it possible to somehow leave the site of the cluster empty?

@bb-Ricardo
Copy link
Owner

Hey,

Have you tried creating a new site manually which represents both sites "virtual-site-a-and-side-b" and assign this via cluster_side_relation?

@smasharov
Copy link
Author

smasharov commented Apr 23, 2023

Yes, but but dozens of physical servers already assigned to different sites and racks on these sites. And I got an error if I try to assign the cluster: "XX devices are assigned as hosts for this cluster but are not in site YY"
If I try to change site of the server I get an error: "Rack AA does not belong to site YY"

So in my opinion the best way to allow the site of the Cluster be empty in such cases

@bb-Ricardo
Copy link
Owner

Hhmmm, valid point, I probably can add a config option to disable the assignment of a site to the vm. But then the host tracking will not work. Fo you have host_tracking enabled?

@smasharov
Copy link
Author

Thanks! I think this option will be good for the particular cluster in config. I have only one cluster like this, the others are located on the one site.

@IPFox
Copy link

IPFox commented May 29, 2023

Hi, we have similar issue and after some thought our proposal for this would be the following:
Clusters:

  • use the cluster_site_relation parameter to map clusters that are multisite, our keyword MULTISITE
  • modify the connectivity.py under get_site_name function by replacing the default with something like:
    if self.get_object_relation(object_name, relation_name) == "MULTISITE":
    site_name = None # or some similar keyword
    elif site_name is None:
    site_name = self.site_name
  • then catch that on the NBCluster definition and set the site to empty for those multisite clusters, others should go as they do now.
    VMs on the other hand, should get the site name from the hosts instead of clusters to keep tracking the actual location of the VMs.

Still looking which all the parts need to change to make this happen, so any help would be highly appreciated :)

@bb-Ricardo
Copy link
Owner

Hi,

Thank you for this idea. I'm currently unsure if a cluster can have multiple sites. That way it should not matter if site is taken from host or cluster. Maxbe that changed in newer NetBox versions.

@IPFox
Copy link

IPFox commented May 29, 2023

Hi,

Yes it is possible to make cluster without site, composed from hosts on multiple sites.
Similar case was discussed on Netbox discussions as well sometime back: netbox-community/netbox#1976

@worldworm
Copy link
Contributor

worldworm commented Jul 25, 2023

Hi,
Unfortunately I have the same problem as @smasharov, that clusters go over several sites.
The hint from @IPFox that a cluser does not have to be assigned to a site was very helpful, as was the suggestion to solve this via a cluster_site_relation mapping.

I just tried it out myself and got it to work. However, I still have to make the whole thing nice and document it, then I can post a pull request if you like.

What do you think of the keyword "None" @bb-Ricardo?

That would look like this:
cluster_site_relation: Cluster_FFM.* = Frankfurt, Cluster_Shared = None

@bb-Ricardo
Copy link
Owner

Hi,

Great that you already have working code. Just wondering if there would be a conflict if someone hase a site which is literally called None

@worldworm
Copy link
Contributor

Hi,
yes, you are right, that would no longer work.

I only have two more ideas 😃
Either make it more specific. E.g. netbox-sync-none.
Or simply let the user define it himself and give a new option such as
none_site_identifier: NoSite
cluster_site_relation: Cluster_FFM.* = Frankfurt, Cluster_Shared = NoSite

What do you think?

@bb-Ricardo
Copy link
Owner

I would suggest to use a special character and None.

Like:

  • <NONE>
  • %NONE%

What do you think?

@worldworm
Copy link
Contributor

That's a great idea! I prefer <NONE>
The % look like some weird variables. 😆

Pull request coming up #333

@bb-Ricardo
Copy link
Owner

Hey @smasharov and @IPFox,

the pull request #333 has just been merged. You you be able to checkout development and test the changes.

Thank you @worldworm for this PR.

@bb-Ricardo bb-Ricardo added this to the 1.6.0 milestone Sep 14, 2023
@bb-Ricardo bb-Ricardo added the awaiting reply Awaiting reply from issue owner label Sep 14, 2023
@ahellsten
Copy link

Hi,

As per my initial testing this seems to be working as expected.

@smasharov
Copy link
Author

thanks, I have finally tested it today and it works now as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply Awaiting reply from issue owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants