Skip to content

Commit

Permalink
Drop using guest.toolsStatus (ansible-collections#2174)
Browse files Browse the repository at this point in the history
Fixes ansible-collections#2167
SUMMARY
vmware_vm_shell and vmware_guest_tools_upgrade use guest.toolsStatus which is deprecated.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
vmware_vm_shell.py
vmware_guest_tools_upgrade.py
ADDITIONAL INFORMATION
  • Loading branch information
mariolenz authored Sep 18, 2024
1 parent 8724ae9 commit fbae9dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions changelogs/2174.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
major_changes:
- vmware_vm_shell - Subsitute the deprecated ``guest.toolsStatus`` collection
(https://github.com/ansible-collections/community.vmware/pull/2174).
- vmware_guest_tools_upgrade - Subsitute the deprecated ``guest.toolsStatus`` collection
(https://github.com/ansible-collections/community.vmware/pull/2174).
14 changes: 10 additions & 4 deletions plugins/modules/vmware_guest_tools_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, module):
def upgrade_tools(self, vm):
result = {'failed': False, 'changed': False, 'msg': ''}
# Exit if VMware tools is already up to date
if vm.guest.toolsStatus == "toolsOk":
if vm.guest.toolsVersionStatus2 == "guestToolsCurrent":
result.update(
changed=False,
msg="VMware tools is already up to date",
Expand All @@ -145,16 +145,22 @@ def upgrade_tools(self, vm):
return result

# Fail if VMware tools is either not running or not installed
elif vm.guest.toolsStatus in ["toolsNotRunning", "toolsNotInstalled"]:
elif vm.guest.toolsVersionStatus2 == 'guestToolsNotInstalled':
result.update(
failed=True,
msg="VMware tools is either not running or not installed",
msg="The VMwareTools are not installed."
)
return result
elif vm.guest.toolsRunningStatus != 'guestToolsRunning':
result.update(
failed=True,
msg="The VMwareTools are not running."
)
return result

# If vmware tools is out of date, check major OS family
# Upgrade tools on Linux and Windows guests
elif vm.guest.toolsStatus == "toolsOld":
elif vm.guest.guestToolsTooOld == "guestToolsTooOld":
try:
force = self.module.params.get('force_upgrade')
installer_options = self.module.params.get('installer_options')
Expand Down
10 changes: 6 additions & 4 deletions plugins/modules/vmware_vm_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,12 @@ def __init__(self, module):
if not vm:
module.fail_json(msg='Unable to find virtual machine.')

tools_status = vm.guest.toolsStatus
if tools_status in ['toolsNotInstalled', 'toolsNotRunning']:
self.module.fail_json(msg="VMwareTools is not installed or is not running in the guest."
" VMware Tools are necessary to run this module.")
if vm.guest.toolsVersionStatus2 == 'guestToolsNotInstalled':
self.module.fail_json(msg="The VMwareTools are not installed. "
"VMware Tools are necessary to run this module.")
if vm.guest.toolsRunningStatus != 'guestToolsRunning':
self.module.fail_json(msg="The VMwareTools are not running ."
"VMware Tools are necessary to run this module.")

try:
self.execute_command(vm, module.params)
Expand Down

0 comments on commit fbae9dd

Please sign in to comment.