From b516bb542197b73c68810a2d90e5c79079c3c24e Mon Sep 17 00:00:00 2001 From: Mika Busch Date: Thu, 7 May 2020 17:11:30 +0200 Subject: [PATCH] Adding comments to vm sync vm.config.annotation is synced as comment to netbox --- run.py | 1 + templates/netbox.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 23601b2..4ef19e4 100644 --- a/run.py +++ b/run.py @@ -711,6 +711,7 @@ def get_objects(self, vc_obj_type): results["virtual_machines"].append(nbt.virtual_machine( name=truncate(obj_name, max_len=64), cluster=cluster, + comments=getattr(obj.config, "annotation", None), status=int( 1 if obj.runtime.powerState == "poweredOn" else 0 ), diff --git a/templates/netbox.py b/templates/netbox.py index b1eed35..ece2fcf 100644 --- a/templates/netbox.py +++ b/templates/netbox.py @@ -625,7 +625,7 @@ def virtual_machine(self, name, cluster, status=None, role=None, "vcpus": vcpus, "memory": memory, "disk": disk, - "comments": comments, + "comments": comments.replace("\n", "\r\n\r") if comments else None, "local_context_data": local_context_data, "tags": tags }