'list or list_details with given params and validates result'

def _list_by_param_value_and_assert(self, params, with_detail=False):

    if with_detail:
        fetched_vol_list = self.volumes_client.list_volumes(detail=True, params=params)['volumes']
    else:
        fetched_vol_list = self.volumes_client.list_volumes(params=params)['volumes']
    if with_detail:
        for volume in fetched_vol_list:
            for key in params:
                msg = ('Failed    to    list    volumes    %s    by    %s' % (('details' if with_detail else ''), key))
                if (key == 'metadata'):
                    self.assertThat(volume[key].items(), matchers.ContainsAll(params[key].items()), msg)
                else:
                    self.assertEqual(params[key], volume[key], msg)
