Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter machines by power address (BMC, iLO, DRAC, etc.) #2927

Closed
webteam-app opened this issue Aug 4, 2021 · 2 comments
Closed

Filter machines by power address (BMC, iLO, DRAC, etc.) #2927

webteam-app opened this issue Aug 4, 2021 · 2 comments

Comments

@webteam-app
Copy link

Bug originally filed by jmcvaughn at https://bugs.launchpad.net/bugs/1938927

This comes from a customer request.

As per title, would it be possible to filter machines by power address (BMC, iLO, iDRAC, etc.)?

In case anybody else wants this feature and comes across this request, at the moment, I can think of a couple of workarounds (of varying suitability):

  • Use tags. It isn't possible to partially match a tag (e.g. tag "192.168.1.10" won't be matched by a search for "192"), so it makes most sense to implement some sort of tagging scheme to achieve this, e.g. if you have a BMC network of 192.168.1.0/24 and a machine with a power address of 192.168.1.10, you could have "power:192.168.1.0/24" and "power:192.168.1.10" as tags for that machine.

  • Use jq in the CLI. This was thrown together quickly, but the following could be used to return the power parameters and "system_id" of every machine managed by MAAS:

for i in $(maas "$MAAS_USER" machines read | jq -r '.[].system_id'); do maas <LOGIN> machine power-parameters "$i" | jq ". + {\"system_id\": \"$i\"}"; done | jq -s

Alternatively, to filter by particular attributes, such as "power_type":

for i in $(maas "$MAAS_USER" machines read | jq -r '.[] | select(.power_type == "moonshot") | .system_id'); do maas <LOGIN> machine power-parameters "$i" | jq ". + {\"system_id\": \"$i\"}"; done | jq -s

These would return:

[
  {
    "power_pass": "notapass",
    "power_user": "notauser",
    "power_address": "10.188.127.24",
    "power_hwaddress": "52:54:00:5e:28:8f",
    "system_id": "ybb6aq"
  },
  {
    "power_pass": "notauser2",
    "power_user": "notapass2",
    "power_address": "10.188.127.25",
    "power_hwaddress": "52:54:00:71:ef:f3",
    "system_id": "8wyxah"
  }
]

Which can then further be filtered with jq. Of course, given that a power-parameters query is made for every MAAS machine, this is slow. Additionally, "system_id" is not a particularly human-readable attribute; including "fqdn", for example, would be much more useful. However, this is beyond the scope here.

Reference to a case link: https://canonical.lightning.force.com/lightning/r/Case/5004K000009Vg1LQAS/view

@huwshimi
Copy link
Contributor

huwshimi commented Nov 8, 2021

Blocked on API support.

@amylily1011
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants