Skip to content

Commit 7d29c62

Browse files
committed
Merge branch 'fr/custom-attributes-filter' into development
2 parents 16f1e6f + a166fc4 commit 7d29c62

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

module/sources/vmware/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ def __init__(self):
337337
""",
338338
config_example="AA:BB:CC:11:22:33, 66:77:88:AA:BB:CC"
339339
),
340+
ConfigOption("custom_attribute_exclude",
341+
str,
342+
description="""defines a comma separated list of custom attribute which should be excluded
343+
from sync. Any custom attribute with a matching attribute key will be excluded from sync.
344+
""",
345+
config_example="VB_LAST_BACKUP, VB_LAST_BACKUP2"
346+
),
340347

341348
# removed settings
342349
ConfigOption("netbox_host_device_role",
@@ -498,6 +505,12 @@ def validate_options(self):
498505

499506
option.set_value(value_list)
500507

508+
if option.key == "custom_attribute_exclude":
509+
510+
option.set_value(quoted_split(option.value))
511+
512+
continue
513+
501514
permitted_subnets_option = self.get_option_by_name("permitted_subnets")
502515

503516
if permitted_subnets_option is not None:

module/sources/vmware/connection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ def get_object_custom_fields(self, obj):
822822
if label is None:
823823
continue
824824

825+
if self.settings.custom_attribute_exclude is not None and \
826+
label in self.settings.custom_attribute_exclude:
827+
log.debug(f"Custom attribute '{label}' excluded from sync. Skipping")
828+
continue
829+
825830
custom_field = self.add_update_custom_field({
826831
"name": f"vcsa_{label}",
827832
"label": label,

settings-example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ password = super-secret
354354
; host NIC with a matching MAC address will be excluded from sync.
355355
;host_nic_exclude_by_mac_list = AA:BB:CC:11:22:33, 66:77:88:AA:BB:CC
356356

357+
; defines a comma separated list of custom attribute which should be excluded from sync.
358+
; Any custom attribute with a matching attribute key will be excluded from sync.
359+
;custom_attribute_exclude = VB_LAST_BACKUP, VB_LAST_BACKUP2
360+
357361
[source/my-redfish-example]
358362

359363
; Defines if this source is enabled or not

0 commit comments

Comments
 (0)