synackray / vcenter-netbox-sync

Sync objects between vCenter and Netbox via Python3
Apache License 2.0
108 stars 28 forks source link

Same name vm in other vcenter #93

Open MalfuncEddie opened 4 years ago

MalfuncEddie commented 4 years ago

Steps to Reproduce

  1. Have the same VM in 2 different vcenters (in this case a template server that you roll out)
  2. run the script
  3. VM is "updated" twice (once for cluster A and once for cluster B

Expected Behavior

The vm should be create two times, one in each cluster.

Observed Behavior

When the script searches if a vm exists it finds the VM of CLUSTER B and changes is to CLUSTER A. When the script is processing CLUSTER B and it finds the same VM the VM is updated from CLUSTER A to B

synackray commented 4 years ago

Hello, @MalfuncEddie.

Thanks for the report. You are indeed correct we should only update the VM relevant to the vCenter it was detected on originally. I'll work on improving this behavior. Thanks for the report!

synackray commented 4 years ago

I have merged this into develop. Thanks!

MalfuncEddie commented 4 years ago

Hi,

I juist checkt the develop branch te see the fix. but it looks like the problem is still there. The vm is create in the last cluster but it has the tags "Vcenter A" and "Vcenter B".

synackray commented 4 years ago

@MalfuncEddie I am requesting the resources to test this again. Was the sync done in an already populated NetBox instance? I had to remove the second vCenter tag from the existing VM object as it had already been synced that way and I didn't see a duplication on a fresh sync, but I am going to fully retest this on my side. Thanks!

MalfuncEddie commented 4 years ago

I'll clean my setup and run the sync again. results tomorrow :)

On Tue, May 12, 2020 at 1:44 PM Raymond Beaudoin notifications@github.com wrote:

@MalfuncEddie https://github.com/MalfuncEddie I am requesting the resources to test this again. Was the sync done in an already populated NetBox instance? I had to remove the second vCenter tag from the existing VM object as it had already been synced that way and I didn't see a duplication on a fresh sync, but I am going to fully retest this on my side. Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/synackray/vcenter-netbox-sync/issues/93#issuecomment-627292135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANDKCZPDB5WHKGCM64VJODRREZC3ANCNFSM4MOIO36Q .

MalfuncEddie commented 4 years ago

Hi,

run.py -c Did a check an there were no vm/ tag/ ...

ran run.py again: same result vm gets created vm get updated run it again vm get updated

the diff shows update 1 { "cluster": 23, "platform": 28 } to { "cluster": 29, "platform": 1 } update 2: { "cluster": 29, "platform": 1 } to { "cluster": 23, "platform": 28 }

MalfuncEddie commented 4 years ago

and the vm has 2 vcenter tags

bb-Ricardo commented 3 years ago

I didn't try it myself but can you have two virtual machines with the same name in netbox?

gstorme commented 3 years ago

No, VM name is unique

bb-Ricardo commented 3 years ago

Id and name are the primary keys. Then the only solution would be to rename both VMs in netbox with their cluster name as suffix.

MalfuncEddie commented 3 years ago

Hi,

This could be solved by adding a custom field UUID and using that as the primary key. In either case I've written a custom script that does juist that since I also had the same cluster names in different vcenters :( .

kind regards

On Fri, Sep 25, 2020 at 11:01 PM Ricardo notifications@github.com wrote:

Id and name are the primary keys. Then the only solution would be to rename both VMs in netbox with their cluster name as suffix.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/synackray/vcenter-netbox-sync/issues/93#issuecomment-699153263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANDKC4O54VSCVUPZRIGTNTSHUALPANCNFSM4MOIO36Q .

bb-Ricardo commented 3 years ago

I was thinking the same.

How did you name your clusters then? Vcenter name as prefix?

MalfuncEddie commented 3 years ago

Yes I did

On Sat, Sep 26, 2020, 08:28 Ricardo notifications@github.com wrote:

I was thinking the same.

How did you name your clusters then? Vcenter name as prefeix?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/synackray/vcenter-netbox-sync/issues/93#issuecomment-699438362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANDKC4VOAVCU4Y35IPD3H3SHWCYFANCNFSM4MOIO36Q .

bb-Ricardo commented 3 years ago

Just stumbled across this issue. VM and Device names are NOT unique. Here a long discussion on this topic: https://github.com/netbox-community/netbox/issues/2669