@depends(HAS_PYVMOMI)
def update_host_password(host, username, password, new_password, protocol=None, port=None):
 service_instance = salt.utils.vmware.get_service_instance(host=host, username=username, password=password, protocol=protocol, port=port)
 account_manager = salt.utils.vmware.get_inventory(service_instance).accountManager
 user_account = vim.host.LocalAccountManager.AccountSpecification()
 user_account.id = username
 user_account.password = new_password
 try:
  account_manager.UpdateUser(user_account)
 except vmodl.fault.SystemError as err:
  raise CommandExecutionError(err.msg)
 except vim.fault.UserNotFound:
  raise CommandExecutionError("'vsphere.update_host_password' failed for host {0}: User was not found.".format(host))
 except vim.fault.AlreadyExists:
  pass
 return True

@ depends ( HAS_PYVMOMI ) def update_host_password ( host , username , password , new_password , protocol = None , port = None ) : service_instance = salt . utils . vmware . get_service_instance ( host = host , username = username , password = password , protocol = protocol , port = port ) account_manager = salt . utils . vmware . get_inventory ( service_instance ) . accountManager user_account = vim . host . LocalAccountManager . AccountSpecification ( ) user_account . id = username user_account . password = new_password try : account_manager . UpdateUser ( user_account ) except vmodl . fault . SystemError as err : raise CommandExecutionError ( err . msg ) except vim . fault . UserNotFound : raise CommandExecutionError ( "'vsphere.update_host_password' failed for host {0}: User was not found." . format ( host ) ) except vim . fault . AlreadyExists : pass return True
update the password for a given host .