Project

General

Profile

Actions

Bug #11642

closed

Fetching host power state using "power_action": "status" fails for VMs

Added by Bryan Kearney about 9 years ago. Updated over 8 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
BMC
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1211376
Description of problem:
User is unable to fetch a power state of a VM using REST API `"power_action": "status"` ; PUT /api/hosts/:id/power.

Version-Release number of selected component (if applicable):
Upstream foreman 1.7.4-1
Downstream Sat 6.0.8

How reproducible:
-

Steps to Reproduce:
1. Setup a compute resource
2. Create a host on that compute resource
3. Run power state check using the rest api against the virtualized host:
[jkrocil@lysandros ~]$ curl --insecure -X PUT -d '{"power_action": "status"}' -u admin -H "Content-Type:application/json" -H "Accept:application/json" https://my-foreman.domain.com/api/v2/hosts/my-vm.nested.lan/power

Actual results: {
"error": {"message":"undefined method `status' for #<PowerManager::Virt:0x007f8e196e0268>"}
}

Expected results:
Valid response with power state info.

Additional info:
Running `"power_action": "state"` instead of "status" works.

The issue is here:
https://github.com/theforeman/foreman/blob/develop/app/services/power_manager/virt.rb#L24

"state" and "status" is being removed from the SUPPORTED_ACTIONS.
There are methods being created dynamically for each power state except the 2.
For "state" though, there is a method defined at L18.
For "status", there is nothing.

Thanks to stbenjam for help.


Related issues 1 (0 open1 closed)

Is duplicate of Foreman - Bug #13430: virt power manager is missing reboot actionClosedTimo Goebel01/28/2016Actions
Actions

Also available in: Atom PDF