maas-cli listing nodes filtered by hostname doesn't work

Bug #1248893 reported by Geoff Teale
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Chris Glass

Bug Description

When trying to scripting against maas-cli it's often necessary to acquire the system-id via a listing filtered by some other attribute. This works well with, for example mac_address:

    tealeg@vmaasserver:~$ maas-cli mymaas nodes list mac_address="AA:AA:AA:AA:AA:01" | grep system_id | cut -d \" -f4
    node-7757fbc4-4703-11e3-bd5a-aaaaaaaaaa00

.. but if I try to do the same thing with a hostname instead of MAC address I don't get the result I'd expect:

    tealeg@vmaasserver:~$ maas-cli mymaas nodes list hostname="client08.master" | grep system_id | cut -d \" -f4
    node-08dcf110-4701-11e3-bd5a-aaaaaaaaaa00
    node-73b6985e-4703-11e3-9381-aaaaaaaaaa00
    node-744e8326-4703-11e3-bd5a-aaaaaaaaaa00
    node-74cdaafc-4703-11e3-9381-aaaaaaaaaa00
    node-75585724-4703-11e3-bd5a-aaaaaaaaaa00
    node-75ccb51a-4703-11e3-9381-aaaaaaaaaa00
    node-76567c3c-4703-11e3-bd5a-aaaaaaaaaa00
    node-76c48c90-4703-11e3-9381-aaaaaaaaaa00
    node-7757fbc4-4703-11e3-bd5a-aaaaaaaaaa00

.. that is a listing of all nodes on my maas. I'd rather see a syntax error if filtering on hostname is not allowed, but better still it should work.

Related branches

Revision history for this message
Geoff Teale (tealeg) wrote :
Revision history for this message
Geoff Teale (tealeg) wrote :
summary: - maas-cli listing nodes filtered by hostname doesn't work
+ Unused API parameters are silently dropped
Changed in maas:
status: New → Triaged
importance: Undecided → High
tags: added: api papercut
Revision history for this message
Chris Glass (tribaal) wrote : Re: Unused API parameters are silently dropped

Hi all,

I have link a related branch that adds the capability of filtering by hostname to the list API call, which is really what's biting us at the moment.
Maybe we could defer the more general case of raising errors instead of returning unfiltered results to another bug?

Revision history for this message
Chris Glass (tribaal) wrote :

I take the liberty to change the description of this bug back to its original version, and will open a new bug for the general case

summary: - Unused API parameters are silently dropped
+ maas-cli listing nodes filtered by hostname doesn't work
Changed in maas:
assignee: nobody → Chris Glass (tribaal)
status: Triaged → In Progress
Chris Glass (tribaal)
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: none → 14.04
Changed in maas:
status: Fix Committed → Fix Released
Revision history for this message
Peter Matulis (petermatulis) wrote :

This happened to me today.

$ maas root nodes list | grep hostname
        "hostname": "usable-group.maas",
        "hostname": "eager-insurance.maas",
        "hostname": "funny-shape.maas",
        "hostname": "fast-hospital.maas",

$ maas root nodes list hostname=usable-group.maas
Success.
Machine-readable output follows:
[]

$ maas root nodes list | grep -e hostname -e mac_address
                "mac_address": "52:54:00:99:41:84"
        "hostname": "usable-group.maas",
                "mac_address": "52:54:00:76:ed:b3"
                "mac_address": "52:54:00:cd:c6:00"
        "hostname": "eager-insurance.maas",
                "mac_address": "52:54:00:6f:25:b0"
        "hostname": "funny-shape.maas",
                "mac_address": "52:54:00:ab:a7:da"
        "hostname": "fast-hospital.maas",

$ maas root nodes list mac_address="52:54:00:99:41:84"
Success.
Machine-readable output follows:
[
    {
        "ip_addresses": [],
        "cpu_count": 0,
        "power_type": "",
        "tag_names": [],
        "swap_size": null,
        "owner": null,
        "macaddress_set": [
            {
                "resource_uri": "/MAAS/api/1.0/nodes/node-5b20bbb4-833b-11e5-af6f-525400aabbcc/macs/52%3A54%3A00%3A99%3A41%3A84/",
                "mac_address": "52:54:00:99:41:84"
            }
        ],
        "zone": {
            "resource_uri": "/MAAS/api/1.0/zones/default/",
            "name": "default",
            "description": ""
        },
        "hostname": "usable-group.maas",
        "storage": 0,
        "system_id": "node-5b20bbb4-833b-11e5-af6f-525400aabbcc",
        "boot_type": "fastpath",
        "memory": 0,
        "disable_ipv4": false,
        "status": 0,
        "power_state": "unknown",
        "routers": null,
        "pxe_mac": null,
        "netboot": true,
        "osystem": "",
        "substatus": 0,
        "architecture": "amd64/generic",
        "distro_series": "",
        "resource_uri": "/MAAS/api/1.0/nodes/node-5b20bbb4-833b-11e5-af6f-525400aabbcc/"
    }
]

$ dpkg-query -W maas
maas 1.8.3+bzr4053-0ubuntu1~trusty1

Revision history for this message
Blake Rouse (blake-rouse) wrote :

maas root nodes list hostname=usable-group

You need to remove the ".maas" from the list query.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.