Project

General

Profile

Actions

Bug #29066

closed

API call api/compute_resources/:id/images?operatingsystem_id=:id returns too many results

Added by Mark Hlawatschek almost 5 years ago. Updated over 4 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
Compute resources
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

When I request the API call api/compute_resources/6/images?operatingsystem_id=2 I receive the results below.
2 images belong to compute resource id 6 and 1 images belongs to compute resource id 5
I'd expect to receive only images matching the compute_resource id 6.

{
    "page": 1,
    "per_page": 20,
    "results": [
        {
            "architecture_id": 1,
            "architecture_name": "x86_64",
            "compute_resource_id": 5,
            "compute_resource_name": "AWS",
            "created_at": "2020-02-15 12:48:45 UTC",
            "iam_role": null,
            "id": 5,
            "name": "CentOS",
            "operatingsystem_id": 2,
            "operatingsystem_name": "CentOS 7.X",
            "updated_at": "2020-02-15 12:48:45 UTC",
            "user_data": false,
            "username": "centos",
            "uuid": "ami-0ff760d16d9497662" 
        },
        {
            "architecture_id": 1,
            "architecture_name": "x86_64",
            "compute_resource_id": 6,
            "compute_resource_name": "Azure",
            "created_at": "2020-02-17 16:58:42 UTC",
            "id": 9,
            "name": "CentOS2",
            "operatingsystem_id": 2,
            "operatingsystem_name": "CentOS 7.X",
            "updated_at": "2020-02-17 16:58:42 UTC",
            "username": "centos",
            "uuid": "azure-123" 
        },
        {
            "architecture_id": 1,
            "architecture_name": "x86_64",
            "compute_resource_id": 6,
            "compute_resource_name": "Azure",
            "created_at": "2020-02-18 16:10:17 UTC",
            "id": 11,
            "name": "CentOS",
            "operatingsystem_id": 2,
            "operatingsystem_name": "CentOS 7.X",
            "updated_at": "2020-02-18 16:10:17 UTC",
            "username": "centos",
            "uuid": "azure-456" 
        }
    ],
    "search": null,
    "sort": {
        "by": null,
        "order": null
    },
    "subtotal": 3,
    "total": 3
}


Related issues 1 (1 open0 closed)

Related to Foreman - Tracker #27680: API bugs that need workarounds in foreman-ansible-modulesNew

Actions
Actions #1

Updated by Evgeni Golov over 4 years ago

  • Category set to Compute resources
Actions #2

Updated by Evgeni Golov over 4 years ago

  • Related to Tracker #27680: API bugs that need workarounds in foreman-ansible-modules added
Actions #3

Updated by Evgeni Golov over 4 years ago

I am not 100% sure, but my guess would be that you can only filter by one of CR/OS/arch, and as you pass both, CR and OS, you end up with a search for OS instead of CR?

Actions #4

Updated by Evgeni Golov over 4 years ago

And to get what you want, you'd need to call

/api/compute_resources/:id/images?search=operatingsystem=:operatingsystem_id

Actions #5

Updated by Evgeni Golov over 4 years ago

So after talking to mshira, you cannot use both CR and OS as "normal" parameters, one will be ignored. You need to pass the other one as a search param.

Quoting IRC:

14:02 < mshira> Zhenech, He could achieve that in a different way: send the request with GET /api/compute_resources/<id>/images and in the params send  {"search" => "operatingsystem=1"}
14:03 < Zhenech> mshira, yeah, that's what I'm also thinking, but you can't pass both CR and OS ids as just regular params, that's what the user is trying to
14:06 < mshira> Zhenech, Yes, you cant send it as regular params, it must be inside "search" 

Actions #6

Updated by Evgeni Golov over 4 years ago

  • Status changed from New to Rejected
Actions

Also available in: Atom PDF