dannf
1
I’m currently using the following code to look up a machine by hostname:
client = maas.client.connect(endpoint, apikey=oauthkey)
machine = None
for m in client.machines.list():
if m.hostname == hostname:
machine = m
break
Is there a faster way? If not, I’m thinking of just implementing a cache in my app.
When you list you can specify the hostname parameter for each hostname
$ maas $PROFILE machines read hostname=maas-test-1 hostname=maas-test-2 | jq -r '.[] | .hostname + ": " + .system_id'
maas-test-1: dken44
maas-test-2: kgntx8
dannf
3
Thanks @ltrager. Do you know if there’s an equivalent in python-libmaas?
client.machines.list(hostnames=[hostname])
2 Likes
system
Closed
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.