Skip to content

Commit 6a14d0e

Browse files
committed
adds config options to skip offline and placeholder VMs
refs: #135 refs: #136
1 parent 69dec29 commit 6a14d0e

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

module/sources/vmware/connection.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class VMWareHandler(SourceBase):
120120
"set_primary_ip": "when-undefined",
121121
"skip_vm_comments": False,
122122
"skip_vm_templates": True,
123+
"skip_offline_vms": False,
124+
"skip_srm_placeholder_vms": False,
123125
"strip_host_domain_name": False,
124126
"strip_vm_domain_name": False,
125127
"sync_tags": False,
@@ -450,6 +452,11 @@ def apply(self):
450452
}
451453
}
452454

455+
# skip virtual machines which are reported offline
456+
if self.skip_offline_vms is True:
457+
log.info("Skipping offline VMs")
458+
del object_mapping["offline virtual machine"]
459+
453460
for view_name, view_details in object_mapping.items():
454461

455462
if self.session is None:
@@ -1795,6 +1802,11 @@ def add_virtual_machine(self, obj):
17951802
log.debug2(f"VM '{name}' is a template. Skipping")
17961803
return
17971804

1805+
if bool(self.skip_srm_placeholder_vms) is True \
1806+
and f"{grab(obj, 'config.managedBy.extensionKey')}".startswith("com.vmware.vcDr"):
1807+
log.debug2(f"VM '{name}' is a SRM placeholder VM. Skipping")
1808+
return
1809+
17981810
# ignore offline VMs during first run
17991811
if self.parsing_vms_the_first_time is True and status == "offline":
18001812
log.debug2(f"Ignoring {status} VM '{name}' on first run")

settings-example.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ permitted_subnets = 172.16.0.0/12, 10.0.0.0/8, 192.168.0.0/16, fd00::/8
219219
# Do not sync template VMs
220220
#skip_vm_templates = True
221221

222+
# Skip virtual machines which are reported as offline.
223+
# ATTENTION: this option will keep purging stopped VMs if activated!
224+
#skip_offline_vms = False
225+
226+
# If the VMware Site Recovery Manager is used to can skip syncing
227+
# placeholder/replicated VMs from fail-over site to NetBox.
228+
#skip_srm_placeholder_vms = False
229+
222230
# strip domain part from host name before syncing device to NetBox
223231
#strip_host_domain_name = False
224232

0 commit comments

Comments
 (0)