def apply_snapshot_op(self, vm):
        result = {}
        if self.module.params["state"] == "present":
            if self.module.params["new_snapshot_name"] or self.module.params[
                    "new_description"]:
                self.rename_snapshot(vm)
                result = {'changed': True, 'failed': False, 'renamed': True}
                task = None
            else:
                task = self.snapshot_vm(vm)
        elif self.module.params["state"] in ["absent", "revert"]:
            task = self.remove_or_revert_snapshot(vm)
        elif self.module.params["state"] == "remove_all":
            task = vm.RemoveAllSnapshots()
        else:
            # This should not happen
            raise AssertionError()

        if task:
            self.wait_for_task(task)
            if task.info.state == 'error':
                result = {
                    'changed': False,
                    'failed': True,
                    'msg': task.info.error.msg
                }
            else:
                result = {
                    'changed': True,
                    'failed': False,
                    'snapshot_results': list_snapshots(vm)
                }

        return result
    def gather_guest_snapshot_info(vm_obj=None):
        """
        Return snapshot related information about given virtual machine
        Args:
            vm_obj: Virtual Machine Managed object

        Returns: Dictionary containing snapshot information

        """
        if vm_obj is None:
            return {}
        return list_snapshots(vm=vm_obj)