canonical / python-libmaas

Unofficial python client library for MAAS
https://maas.io
Other
63 stars 71 forks source link

machines.list should accept the same criteria for filtering as the official MaaS CLI Client #238

Closed dandruczyk closed 8 months ago

dandruczyk commented 4 years ago

The python-libmaas API is missing the ability to query by anyting other than system_id in client.machines.list

The CLI distributed with maas allows you to read a machine's details with its system_id or a large number of other optional criteria (see below for list as of 2.6.2).

i.e. maas machines read hostname= This call is fast typically under a couple seconds (depends on how complex the machine is)

The python-libmaas API only allows you to query a machine by system_id, which is a giant pain when you are trying to deploy a machine and don't know it's system_id but you do knows its hostname or other criteria, which forces you to use the client.machines.list() call which is extremely slow as noted in https://github.com/maas/python-libmaas/issues/208 (And it gets progressively worse the more machines that maas knows about)

tl;dr please add all the other possible search criteria (starting with hostname) argument to client.machines.list call to allow filtering on that as well as system_id like the maas CLI has already (since 2.6.2 at least for sure)

2.6.2 CLI allows querying machines with these optional options: List nodes visible to current user, optionally filtered by criteria.

Nodes are sorted by id (i.e. most recent last) and grouped by type.

:param hostname: Optional. Only nodes relating to the node with the matching hostname will be returned. This can be specified multiple times to see multiple nodes. :type hostname: String

:param cpu_count: Optional. Only nodes with the specified minimum number of CPUs will be included. :type cpu_count: Int

:param mem: Optional. Only nodes with the specified minimum amount of RAM (in MiB) will be included. :type mem: String

:param mac_address: Optional. Only nodes relating to the node owning the specified MAC address will be returned. This can be specified multiple times to see multiple nodes. :type mac_address: String

:param id: Optional. Only nodes relating to the nodes with matching system ids will be returned. :type id: String

:param domain: Optional. Only nodes relating to the nodes in the domain will be returned. :type domain: String

:param zone: Optional. Only nodes relating to the nodes in the zone will be returned. :type zone: String

:param pool: Optional. Only nodes belonging to the pool will be returned. :type pool: String

:param agent_name: Optional. Only nodes relating to the nodes with matching agent names will be returned. :type agent_name: String

:param fabrics: Optional. Only nodes with interfaces in specified fabrics will be returned. :type fabrics: String

:param not_fabrics: Optional. Only nodes with interfaces not in specified fabrics will be returned. :type not_fabrics: String

:param vlans: Optional. Only nodes with interfaces in specified VLANs will be returned. :type vlans: String

:param not_vlans: Optional. Only nodes with interfaces not in specified VLANs will be returned. :type not_vlans: String

:param subnets: Optional. Only nodes with interfaces in specified subnets will be returned. :type subnets: String

:param not_subnets: Optional. Only nodes with interfaces not in specified subnets will be returned. :type not_subnets: String

:param status: Optional. Only nodes with specified status will be returned. :type status: String

:param pod: Optional. Only nodes that belong to a specified pod will be returned. :type pod: String

:param not_pod: Optional. Only nodes that don't belong to a specified pod will be returned. :type not_pod: String

:param pod_type: Optional. Only nodes that belong to a pod of the specified type will be returned. :type pod_type: String

:param not_pod_type: Optional. Only nodes that don't belong a pod of the specified type will be returned. :type not_pod_type: String

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 8 months ago

This issue was closed because it has been inactive for 30 days since being marked as stale.