Skip to content

Commit c57244c

Browse files
authored
vmware_vmkernel - add enable_backup_nfc setting (#1979)
vmware_vmkernel - add enable_backup_nfc setting SUMMARY Add the possibility to set the enable_backup_nfc setting. ISSUE TYPE Feature Pull Request COMPONENT NAME vmware_vmkernel.py ADDITIONAL INFORMATION Reviewed-by: Mario Lenz <m@riolenz.de>
1 parent 322f0c2 commit c57244c

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
minor_changes:
2+
- vmware_vmkernel - Add the function to set the enable_backup_nfc setting
3+
(https://github.com/ansible-collections/community.vmware/pull/1978)

plugins/modules/vmware_vmkernel.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- Russell Teague (@mtnbikenc)
2727
- Abhijeet Kasurde (@Akasurde)
2828
- Christian Kotte (@ckotte)
29+
- Nina Loser (@Nina2244)
2930
notes:
3031
- The option O(device) need to be used with DHCP because otherwise it's not possible to check if a VMkernel device is already present
3132
- You can only change from DHCP to static, and vSS to vDS, or vice versa, in one step, without creating a new device, with O(device) specified.
@@ -139,6 +140,12 @@
139140
- This option is only allowed if the default TCP/IP stack is used.
140141
type: bool
141142
default: false
143+
enable_backup_nfc:
144+
description:
145+
- Enable vSphere Backup NFC traffic on the VMKernel adapter.
146+
- This option is only allowed if the default TCP/IP stack is used.
147+
type: bool
148+
default: false
142149
state:
143150
description:
144151
- If set to V(present), the VMKernel adapter will be created with the given specifications.
@@ -301,6 +308,7 @@ def __init__(self, module):
301308
self.enable_provisioning = self.params['enable_provisioning']
302309
self.enable_replication = self.params['enable_replication']
303310
self.enable_replication_nfc = self.params['enable_replication_nfc']
311+
self.enable_backup_nfc = self.params['enable_backup_nfc']
304312

305313
self.vswitch_name = self.params['vswitch_name']
306314
self.vds_name = self.params['dvswitch_name']
@@ -494,7 +502,7 @@ def host_vmk_update(self):
494502
"""
495503
changed = changed_settings = changed_vds = changed_services = \
496504
changed_service_vmotion = changed_service_mgmt = changed_service_ft = \
497-
changed_service_vsan = changed_service_prov = changed_service_rep = changed_service_rep_nfc = False
505+
changed_service_vsan = changed_service_prov = changed_service_rep = changed_service_rep_nfc = changed_service_backup_nfc = False
498506
changed_list = []
499507
results = dict(changed=False, msg='')
500508

@@ -623,6 +631,11 @@ def host_vmk_update(self):
623631
if (self.enable_replication_nfc and self.vnic.device not in service_type_vmks['vSphereReplicationNFC']) or \
624632
(not self.enable_replication_nfc and self.vnic.device in service_type_vmks['vSphereReplicationNFC']):
625633
changed_services = changed_service_rep_nfc = True
634+
635+
if (self.enable_backup_nfc and self.vnic.device not in service_type_vmks['vSphereBackupNFC']) or \
636+
(not self.enable_backup_nfc and self.vnic.device in service_type_vmks['vSphereBackupNFC']):
637+
changed_services = changed_service_backup_nfc = True
638+
626639
if changed_services:
627640
changed_list.append("services")
628641

@@ -744,6 +757,14 @@ def host_vmk_update(self):
744757
vnic_manager=vnic_manager, vmk=self.vnic, service_type='vSphereReplicationNFC', operation=operation
745758
)
746759

760+
if changed_service_backup_nfc:
761+
if self.vnic.device in service_type_vmks['vSphereBackupNFC']:
762+
services_previous.append('Backup_NFC')
763+
operation = 'select' if self.enable_backup_nfc else 'deselect'
764+
self.set_service_type(
765+
vnic_manager=vnic_manager, vmk=self.vnic, service_type='vSphereBackupNFC', operation=operation
766+
)
767+
747768
if changed_service_vsan:
748769
if self.vnic.device in service_type_vmks['vsan']:
749770
services_previous.append('VSAN')
@@ -918,7 +939,7 @@ def host_vmk_create(self):
918939
option is False for option in [self.enable_vsan, self.enable_vmotion,
919940
self.enable_mgmt, self.enable_ft,
920941
self.enable_provisioning, self.enable_replication,
921-
self.enable_replication_nfc]):
942+
self.enable_replication_nfc, self.enable_backup_nfc]):
922943
self.vnic = self.get_vmkernel_by_device(device_name=vmk_device)
923944

924945
# VSAN
@@ -945,6 +966,9 @@ def host_vmk_create(self):
945966
if self.enable_replication_nfc:
946967
self.set_service_type(host_vnic_manager, self.vnic, 'vSphereReplicationNFC')
947968

969+
if self.enable_backup_nfc:
970+
self.set_service_type(host_vnic_manager, self.vnic, 'vSphereBackupNFC')
971+
948972
self.module.exit_json(**results)
949973

950974
def set_service_type(self, vnic_manager, vmk, service_type, operation='select'):
@@ -984,6 +1008,7 @@ def get_all_vmks_by_service_type(self):
9841008
vSphereProvisioning=[],
9851009
vSphereReplication=[],
9861010
vSphereReplicationNFC=[],
1011+
vSphereBackupNFC=[],
9871012
)
9881013

9891014
for service_type in list(service_type_vmk):
@@ -1037,6 +1062,8 @@ def create_enabled_services_string(self):
10371062
services.append('Repl')
10381063
if self.enable_replication_nfc:
10391064
services.append('Repl_NFC')
1065+
if self.enable_backup_nfc:
1066+
services.append('Backup_NFC')
10401067
return ', '.join(services)
10411068

10421069
@staticmethod
@@ -1075,6 +1102,7 @@ def main():
10751102
enable_provisioning=dict(type='bool', default=False),
10761103
enable_replication=dict(type='bool', default=False),
10771104
enable_replication_nfc=dict(type='bool', default=False),
1105+
enable_backup_nfc=dict(type='bool', default=False),
10781106
vswitch_name=dict(required=False, type='str', aliases=['vswitch']),
10791107
dvswitch_name=dict(required=False, type='str', aliases=['dvswitch']),
10801108
network=dict(

0 commit comments

Comments
 (0)