Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1211376 - Fetching host power state using "power_action": "status" fails for VMs
Summary: Fetching host power state using "power_action": "status" fails for VMs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Provisioning
Version: 6.0.8
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Shlomi Zadok
QA Contact: Roman Plevka
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On: 1341149
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-13 19:32 UTC by Jan Krocil
Modified: 2019-09-26 16:26 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:22:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 13430 0 None None None 2016-04-22 15:03:39 UTC

Description Jan Krocil 2015-04-13 19:32:38 UTC
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.

Comment 1 RHEL Program Management 2015-04-13 19:33:05 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Lukas Zapletal 2015-04-14 11:04:38 UTC
Valid bug, we should return same flags for both bare metal and hypervisors.

Comment 4 Bryan Kearney 2015-09-01 17:10:40 UTC
Created redmine issue http://projects.theforeman.org/issues/11642 from this bug

Comment 5 Bryan Kearney 2015-09-02 10:03:34 UTC
Upstream bug component is Power & BMC

Comment 6 Bryan Kearney 2016-03-17 12:44:44 UTC
Connecting redmine issue http://projects.theforeman.org/issues/13430 from this bug

Comment 7 Bryan Kearney 2016-03-17 14:11:24 UTC
Upstream bug component is Provisioning

Comment 8 Bryan Kearney 2016-03-17 14:11:27 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/13430 has been closed
-------------
Anonymous
Applied in changeset commit:1bf5ff536572e0209095532d7f5c7dd986d2aa19.

Comment 15 Roman Plevka 2016-07-01 09:20:53 UTC
VERIFIED
on sat6.2.0 snap18.1

<pre>
# curl -ku admin:changeme -X PUT -H 'Content-Type:application/json' -d '{"power_action": "off"}' https://$(hostname)/api/v2/hosts/3/power/
{"power":true}
[root ~]# curl -ku admin:changeme -X PUT -H 'Content-Type:application/json' -d '{"power_action": "state"}' https://$(hostname)/api/v2/hosts/3/power/
{"power":"off"}
[root ~]# curl -ku admin:changeme -X PUT -H 'Content-Type:application/json' -d '{"power_action": "on"}' https://$(hostname)/api/v2/hosts/3/power/
{"power":true}
[root ~]# curl -ku admin:changeme -X PUT -H 'Content-Type:application/json' -d '{"power_action": "state"}' https://$(hostname)/api/v2/hosts/3/power/
{"power":"running"}
</pre>

Comment 16 Bryan Kearney 2016-07-27 11:22:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501


Note You need to log in before you can comment on or make changes to this bug.