Project

Profile

Help

Story #262

closed

[RFE] Define API call to search for a package in all the consumers

Added by contact@andreagiardini.com about 9 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Platform Release:
2.6.0
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

++ This bug was initially created as a clone of Bugzilla Bug #1155513 ++

Description of problem:

Description of problem:

It makes sense to have an API call to search for a specific package, reporting his status for each consumers.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.
2.
3.

Actual results:

Expected results:

Additional info:

--- Additional comment from at 10/27/2014 12:45:58 ---

Do you have suggestion or guideline about the API implementation?

--- Additional comment from at 11/04/2014 16:35:15 ---

I think that this is already possible without any code changes. Can you try to achieve a search like that using the Advanced Search for Consumers [0]? You should be able to form GET style parameters that adhere to the search API [1].

When playing with the API I like to use a tool called pic [2]. Here's a pic hello world example:

from pulp.common import pic
pic.connect()
pic.GET ('/pulp/api/v2/consumers/search/')

[0]: https://pulp-dev-guide.readthedocs.org/en/latest/integration/rest-api/consumer/retrieval.html#advanced-search-for-consumers
[1]: https://pulp-dev-guide.readthedocs.org/en/latest/conventions/criteria.html#search-api
[2]: https://github.com/pulp/pulp/blob/master/common/pulp/common/pic.py

--- Additional comment from at 11/04/2014 22:17:12 ---

Here is an unrelated example, except that it uses the search API. Here is how I search for tasks that are in the running state:

from pulp.common import pic
pic.connect()

body = {"criteria": {"filters": {"state":"running"}}}
pic.POST ('/pulp/api/v2/tasks/search/', body)

The Search API json is used as the payload of the POST to the URL. I wanted to paste this here since I already had it and it is a related example.

--- Additional comment from at 11/05/2014 09:42:41 ---

I don't think that's possible but i will try to investigate...

Tell me if i'm wrong:
/pulp/api/v2/tasks/search/ -> search on the 'tasks_status' mongo table
/pulp/api/v2/consumers/search/ -> search on the 'consumers' mongo table

Is it correct?

--- Additional comment from at 11/06/2014 14:17:03 ---

After some discussion on IRC it was determined:

The URLs in comment 4 don't search on the consumer_unit_profile. Apparently no URL actually provides search on that table so introducing a new URL seems like the right thing to do.

I propose the following URL be introduced:

/pulp/api/v2/consumers/profile/search/

This is consistent with the existing consumer search URLs for bindings for example:

/pulp/api/v2/consumers/binding/search/

Also, since this is a reverse compatible new API change it would need to be introduced in a 2.Y release.

--- Additional comment from at 11/12/2014 09:24:36 ---

Pull request submitted here:

https://github.com/pulp/pulp/pull/1292

--- Additional comment from at 11/13/2014 16:39:02 ---

Merged to master. QA, please see the docs that were added [0] to test this feature.

[0]: http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/profile.html#searching-profiles

--- Additional comment from at 12/23/2014 20:52:59 ---

fixed in pulp 2.6.0-0.2.beta

--- Additional comment from at 02/02/2015 21:34:13 ---

Fails-qa

GET worked fine for me
but for post doesnt return any respone

pic.POST ('/v2/consumers/profile/search/',body={"criteria": { "filters": {"profile_name": "screen"},"fields": ["consumer_id","foo"] }})

Request Body
{
"criteria": {
"fields": [
"consumer_id",
"foo"
],
"filters": {
"profile_name": "screen"
}
}
}
Response Body
[]
(200, [])

I do have a consumer foo.

pic.GET ('/v2/consumers/')

Response Body
[
{
"display_name": "foo",
"description": null,
"_ns": "consumers",
"notes": {
"_node-update-strategy": "additive",
"_child-node": true
},

--- Additional comment from at 02/03/2015 14:57:37 ---

Looks like it was user error.
Moving to verified
[root@cloud-qe-4 ~]# rpm -qa |grep pulp-server
pulp-server-2.6.0-0.5.beta.el7
I used profile_name instead of profile.name

When used with profile.name the correct response is given.

pic.POST ('/v2/consumers/profile/search/',body={"criteria": { "filters": {"profile.name": "screen"},"fields": ["consumer_id","foo"] }})

Request Body
{
"criteria": {
"fields": [
"consumer_id",
"foo"
],
"filters": {
"profile.name": "screen"
}
}
}
Response Body
[
{
"_id": {
"$oid": "54cad13f9f9b813d5b604cfc"
},
"id": "54cad13f9f9b813d5b604cfc",
"consumer_id": "foo"
}
]
(200, [{u'_id': {u'$oid': u'54cad13f9f9b813d5b604cfc'}, u'id': u'54cad13f9f9b813d5b604cfc', u'consumer_id': u'foo'}])

--- Additional comment from at 02/05/2015 21:49:57 ---

Moving to verified, as per Preethi's comment.

Also available in: Atom PDF