Skip to content

Commit 2d71d7c

Browse files
authored
vmware_vm_vss_dvs_migrate: Inherit from PyVmomi (#2325)
SUMMARY It feels wrong that this module uses vmware.connect_to_api directly. I think it would be better to inherit from / sub-class PyVmomi ISSUE TYPE Feature Pull Request COMPONENT NAME vmware_vm_vss_dvs_migrate ADDITIONAL INFORMATION #2318 #2324
1 parent a4e3aa1 commit 2d71d7c

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- vmware_vm_vss_dvs_migrate - Inherit from / sub-class PyVmomi (https://github.com/ansible-collections/community.vmware/pull/2325).

plugins/modules/vmware_vm_vss_dvs_migrate.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@
4646

4747
try:
4848
from pyVmomi import vim, vmodl
49-
HAS_PYVMOMI = True
5049
except ImportError:
51-
HAS_PYVMOMI = False
50+
pass
5251

5352
from ansible.module_utils.basic import AnsibleModule
5453
from ansible_collections.community.vmware.plugins.module_utils.vmware import (
55-
HAS_PYVMOMI, connect_to_api, get_all_objs,
56-
vmware_argument_spec, wait_for_task)
54+
PyVmomi, get_all_objs, vmware_argument_spec, wait_for_task)
5755

5856

59-
class VMwareVmVssDvsMigrate(object):
57+
class VMwareVmVssDvsMigrate(PyVmomi):
6058
def __init__(self, module):
61-
self.module = module
62-
self.content = connect_to_api(module)
6359
self.vm = None
6460
self.vm_name = module.params['vm_name']
6561
self.dvportgroup_name = module.params['dvportgroup_name']
@@ -140,8 +136,6 @@ def main():
140136
dvportgroup_name=dict(required=True, type='str')))
141137

142138
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)
143-
if not HAS_PYVMOMI:
144-
module.fail_json(msg='pyvmomi is required for this module')
145139

146140
vmware_vmnic_migrate = VMwareVmVssDvsMigrate(module)
147141
vmware_vmnic_migrate.process_state()

0 commit comments

Comments
 (0)