Trying pyhon-libmaas and unable to match on NodeStatus

I’m following the doc at

I have this

all_machines =  conn.machines.list()

new_machines = [ machine for machine in all_machines if machine.status == NodeStatus.DEFAULT ]

But that errors with “NameError: name ‘NodeStatus’ is not defined”

If I quote NodeStatus.DEFAULT it doesn’t match and I get an empty list

Same result just testing in a for loop

>>> for m in all_machines:
...   machine = conn.machines.get(system_id=m.system_id)
...   print(machine.status)
...   if machine.status == 'NodeStatus.DEFAULT':
...     print(yes)

Oops I see I’m using this with an unsupported version of MAAS. I’m trying it against 3.1.0

It currently supports MAAS versions 2.1 and 2.2-beta3.

Hi, it does work with later versions, but it has not been maintained/kept up to date. It is in our roadmap to bring it up to date with latest release but not yet confirmed.

Remove the quotes around it. You might be missing the correct import to get the enumerations from the library.

1 Like

It should be this ‘from maas.client.enum import NodeStatus’
I had simply ‘import maas.client’

Thanks for the hint

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.