Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Add notes and tags field of VM from vCenter to Netbox #57

Open
inetman28 opened this issue Feb 6, 2020 · 2 comments
Open

Add notes and tags field of VM from vCenter to Netbox #57

inetman28 opened this issue Feb 6, 2020 · 2 comments

Comments

@inetman28
Copy link

Is your feature request related to a problem? Please describe.
We can also add sync between notes and tags fields from vCenter to NetBox

@Haeki
Copy link

Haeki commented May 6, 2020

I'm not sure if notes mean what i think, but I implemented the synchronization of VM annotations to NetBox.
I can open a pull request with my changes, they are not that big.

The Template already supports a comment parameter. So i added this line in get_objects() to set it: comments=getattr(obj.config, "annotation", None).

The vCenter api documentation has annotations marked as "Need not be set" that's why I used getattr() to prevent an AttributeError from happening.
According to the vCenter api documentation annotations can also be found under vm.summary.config.annotations
I don't know what the difference between the two is and if one is preferable to the other.

Line breaks in annotations are marked with \n but to display them properly in NetBox they have to use \r\n\r.
To fix this I changed a line in netbox.py:
"comments": comments.replace("\n", "\r\n\r") if comments else None

@Haeki
Copy link

Haeki commented Jun 23, 2020

I created a Pull request for my Implementation: Sync VM comments #117

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

No branches or pull requests

2 participants