Project

General

Profile

Bug #7975

Querying subnets by name no longer works

Added by Jiri Stransky almost 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When querying subnets via the API, only querying by ID works, not querying by name. Example:


curl -s -k -u admin:changeme https://r6-staypuft/api/subnets | python -m json.tool
[
    {
        "subnet": {
            "dhcp_id": 1, 
            "dns_id": 1, 
            "dns_primary": "192.168.130.5", 
            "dns_secondary": null, 
            "domain_ids": [
                1
            ], 
            "from": "192.168.130.100", 
            "gateway": "192.168.130.1", 
            "id": 1, 
            "ipam": "DHCP", 
            "mask": "255.255.255.0", 
            "name": "default", 
            "network": "192.168.130.0", 
            "priority": null, 
            "tftp_id": 1, 
            "to": "192.168.130.254", 
            "vlanid": null
        }
    }
]

[root@r6-staypuft ~]# curl -s -k -u admin:changeme https://r6-staypuft/api/subnets/1 | python -m json.tool
{
    "subnet": {
        "cidr": 24, 
        "dhcp": {
            "id": 1, 
            "name": "r6-staypuft.example.org", 
            "url": "https://r6-staypuft.example.org:8443" 
        }, 
        "dhcp_id": 1, 
        "dns": {
            "id": 1, 
            "name": "r6-staypuft.example.org", 
            "url": "https://r6-staypuft.example.org:8443" 
        }, 
        "dns_id": 1, 
        "dns_primary": "192.168.130.5", 
        "dns_secondary": null, 
        "domain_ids": [
            1
        ], 
        "from": "192.168.130.100", 
        "gateway": "192.168.130.1", 
        "id": 1, 
        "ipam": "DHCP", 
        "mask": "255.255.255.0", 
        "name": "default", 
        "network": "192.168.130.0", 
        "priority": null, 
        "tftp": {
            "id": 1, 
            "name": "r6-staypuft.example.org", 
            "url": "https://r6-staypuft.example.org:8443" 
        }, 
        "tftp_id": 1, 
        "to": "192.168.130.254", 
        "vlanid": null
    }
}

[root@r6-staypuft ~]# curl -s -k -u admin:changeme https://r6-staypuft/api/subnets/default | python -m json.tool
{
    "message": "Resource subnet not found by id 'default'" 
}

Associated revisions

Revision 4af1e2ba (diff)
Added by Shlomi Zadok almost 5 years ago

fixes #7975 - Subnet names should be unique

Revision 953adc32 (diff)
Added by Shlomi Zadok almost 5 years ago

fixes #7975 - Subnet names should be unique

(cherry picked from commit 4af1e2bacaa43c7dc3bb535cb087a6584b87719e)

History

#1 Updated by Dominic Cleal almost 5 years ago

  • Category set to API
  • Target version set to 1.7.2
  • Legacy Backlogs Release (now unused) set to 21

#2 Updated by Shlomi Zadok almost 5 years ago

  • Status changed from New to Feedback
  • Assignee set to Shlomi Zadok

On subnets, we use a combination of the id & name (as defined in def to_param, see subnet.rb )

The right api call would be curl -s -k -u admin:changeme https://r6-staypuft/api/subnets/1-default | python -m json.tool

#3 Updated by Dominic Cleal almost 5 years ago

  • Status changed from Feedback to New

The API should accept the ID or the name as per the docs (http://theforeman.org/manuals/1.6/index.html#5.1API). We've never used "id-name" as an identifier in the API.

#4 Updated by The Foreman Bot almost 5 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/1867 added
  • Pull request deleted ()

#5 Updated by Shlomi Zadok almost 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF