'This method is executed when we want to change the state of some oVirt
entity. The action to be executed on oVirt service is specified by
`action` parameter. Whether the action should be executed can be
specified by passing `action_condition` parameter. State which the
entity should be in after execution of the action can be specified
by `wait_condition` parameter.
Function executed before an action on entity can optionally be specified
in `pre_action` parameter. Function executed after an action on entity can
optionally be specified in `post_action` parameter.
:param action: Action which should be executed by service on entity.
:param entity: Entity we want to run action on.
:param action_condition: Function which is executed when checking if action should be executed.
:param fail_condition: Function which checks incorrect state of entity, if it returns `True` Exception is raised.
:param wait_condition: Function which is executed when waiting on result state.
:param pre_action: Function which is executed before running the action.
:param post_action: Function which is executed after running the action.
:param search_params: Dictionary of parameters to be used for search.
:param kwargs: Additional parameters passed to action.
:return: Dictionary with values returned by Ansible module.'

def action(self, action, entity=None, action_condition=(lambda e: e), wait_condition=(lambda e: e), fail_condition=(lambda e: False), pre_action=(lambda e: e), post_action=(lambda e: None), search_params=None, **kwargs):

    if (entity is None):
        entity = self.search_entity(search_params)
    entity = pre_action(entity)
    if (entity is None):
        self._module.fail_json(msg="Entity    not    found,    can't    run    action    '{}'.".format(action))
    entity_service = self._service.service(entity.id)
    entity = entity_service.get()
    if action_condition(entity):
        if (not self._module.check_mode):
            getattr(entity_service, action)(**kwargs)
        self.changed = True
    post_action(entity)
    wait(service=self._service.service(entity.id), condition=wait_condition, fail_condition=fail_condition, wait=self._module.params['wait'], timeout=self._module.params['timeout'], poll_interval=self._module.params['poll_interval'])
    return {'changed': self.changed, 'id': entity.id, type(entity).__name__.lower(): get_dict_of_struct(struct=entity, connection=self._connection, fetch_nested=self._module.params.get('fetch_nested'), attributes=self._module.params.get('nested_attributes')), 'diff': self._diff}
