Skip to content

Conversation

@EnigmaXV
Copy link
Contributor

@EnigmaXV EnigmaXV commented Dec 9, 2025

  • Implemented both backend and frontend parts of the bulk power state feature
  • Added backend unit tests
  • Implemented new endpoint for changing the power state
  • Synced power state updates with the power status icon

@EnigmaXV EnigmaXV force-pushed the 38948-add-power-state-bulk-actions branch from 4a1e36d to 10df08a Compare December 9, 2025 23:13
@sbernhard sbernhard requested a review from jeremylenz December 19, 2025 12:50
Copy link
Contributor

@sbernhard sbernhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Omar. Very cool addition.

@nadjaheitmann
Copy link
Contributor

It looks great @EnigmaXV !

@jeremylenz
Copy link
Contributor

@chris1984 is going to give this a quick test, stand by :)

id="power-state-modal"
ouiaId="power-state-modal-title"
>
{__('Change power state')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part can be achieved by adding title to Modal.

@lfu
Copy link
Contributor

lfu commented Dec 19, 2025

The tests looked good to me. Power state was updated correctly on the host index page.
power on

Sometimes I noticed each host was called for power state twice. And sometimes only some hosts got called for power state twice.
And I think each host should be called only once for power state after the power change.
Not sure what is exactly going on here. Maybe it is expected.

12:31:12 rails.1   | 2025-12-19T12:31:12 [I|app|25b30605] Started PUT "/api/v2/hosts/bulk/change_power_state" for xxx at 2025-12-19 12:31:12 -0500
12:31:12 rails.1   | 2025-12-19T12:31:12 [I|app|25b30605] Processing by Api::V2::HostsBulkActionsController#change_power_state as JSON
12:31:12 rails.1   | 2025-12-19T12:31:12 [I|app|25b30605]   Parameters: {"included"=>{"search"=>"id ^ (12)"}, "power"=>"start", "apiv"=>"v2", "hosts_bulk_action"=>{"included"=>{"search"=>"id ^ (12)"}, "power"=>"start"}}
12:31:13 rails.1   | 2025-12-19T12:31:13 [D|app|25b30605] Body: {"message":"The power state of the selected hosts will be set to start"}
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|25b30605] Completed 200 OK in 861ms (Views: 0.2ms | ActiveRecord: 2.7ms | Allocations: 36098)
12:31:13 rails.1   |  25b30605 | 
12:31:13 rails.1   |  25b30605 | 
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|4a7f8dd9] Started GET _"/api/v2/hosts/xxxx-67-29.x.com/power"_ for xxx at 2025-12-19 12:31:13 -0500
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|b803c564] Started GET "/api/hosts" for xxx at 2025-12-19 12:31:13 -0500
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|2752c148] Started GET "/api/v2/hosts/xxxx-85.lx.com/power" for xxx at 2025-12-19 12:31:13 -0500
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|f1ee1942] Started GET "/api/v2/hosts/xxxx-249.x.com-1/power" for xxx at 2025-12-19 12:31:13 -0500
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|9e2c0602] Started GET "/api/v2/hosts/xxxx-175.x.com/power" for xxx at 2025-12-19 12:31:13 -0500
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|4a7f8dd9] Processing by Api::V2::HostsController#power_status as JSON
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|4a7f8dd9]   Parameters: {"apiv"=>"v2", "id"=>"xxxx-67-29.x.com"}
...
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|16def301] Started GET _"/api/v2/hosts/xxxx-67-29.x.com/power"_ for xxx at 2025-12-19 12:31:13 -0500
...
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|16def301] Processing by Api::V2::HostsController#power_status as JSON
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|16def301]   Parameters: {"apiv"=>"v2", "id"=>"xxxx-67-29.x.com"}
12:31:13 rails.1   | 2025-12-19T12:31:13 [D|app|16def301] Body: {"id":1,"state":"na","title":"N/A","statusText":"Power operations are not enabled on this host."}
12:31:13 rails.1   | 2025-12-19T12:31:13 [I|app|16def301] Completed 200 OK in 22ms (Views: 0.2ms | ActiveRecord: 8.7ms | Allocations: 8018)
12:31:13 rails.1   |  16def301 | 
12:31:13 rails.1   |  16def301 | 

@chris1984
Copy link
Member

Tested and working good as far as turning on and off the hosts. I did notice what @lfu mentioned as well with it being called twice.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants