Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Sync-vmware Issue with non-unique host names #4

Open
mmahacek opened this issue Sep 21, 2018 · 1 comment
Open

Sync-vmware Issue with non-unique host names #4

mmahacek opened this issue Sep 21, 2018 · 1 comment

Comments

@mmahacek
Copy link

We have some VMs that have an operating system hostname that is not unique, which was causing them to not be provisioned properly into Netbox. I made the following workaround to have all VMs named by their VM name and not the guest host name.

Line 192:
Old: $Hostname = $Guest.Hostname.ToLower()
New: $Hostname = $VM.Name.ToLower()

@mmahacek mmahacek changed the title Issue with non-unique host names Sync-vmware Issue with non-unique host names Sep 21, 2018
@jwegner89
Copy link
Owner

jwegner89 commented Sep 21, 2018

Netbox forces unique names for all VM objects, and this script intentionally canonicalizes to the OS hostname when it can be determined (lines 196-204). I understand the issue you're encountering, but I'm kind of anticipating that most people will adapt this script to their own environments. In particular, this is not the version of the script that I use in our organization because I insert a lot of organization-specific logic into our version. So I'm inclined to say that the current logic is fine and your use case is specific to your environment. Does that make sense?

With that said, I could understand adding in some logic to handle getting around the uniqueness requirement, e.g. if you've cloned a machine or are recovering from a Veeam backup. Do you have a suggestion for how you want to handle the case of another machine with the same hostname? When does that arise? Is it better simply to mirror the VM inventory name? I personally like the network hostname from in-guest, but I could see the other way as well.

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

No branches or pull requests

2 participants