{"action":"created","comment":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/comments/242132440","pull_request_review_id":185571139,"id":242132440,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MjEzMjQ0MA==","diff_hunk":"@@ -1265,4 +1265,96 @@ def setup\n       assert hosts_response[\"subtotal\"] > hosts_response[\"per_page\"]\n     end\n   end\n+\n+  describe '/host/:id/power_status' do\n+    let(:host) { FactoryBot.create(:host, compute_resource: compute_resources(:vmware)) }\n+\n+    setup { Fog.mock! }\n+    teardown { Fog.unmock! }\n+\n+    test 'show power status for a host' do\n+      expected_resp = {\n+        \"id\" => host.id,\n+        \"state\" => \"on\",\n+        \"title\" => \"On\"\n+      }\n+\n+      Host.any_instance.stubs(:supports_power?).returns(true)\n+      Host.any_instance.stubs(:supports_power_and_running?).returns(true)\n+      get :power_status, params: { :id => host.id }, session: set_session_user, xhr: true\n+      assert_response :success\n+      response = JSON.parse @response.body\n+      assert_equal(expected_resp.sort, response.sort)\n+    end\n+\n+    test 'show power status for a powered off host' do\n+      expected_resp = {\n+        \"id\" => host.id,\n+        \"state\" => \"off\",\n+        \"title\" => \"Off\"\n+      }\n+\n+      Host.any_instance.stubs(:supports_power?).returns(true)\n+      Host.any_instance.stubs(:supports_power_and_running?).returns(false)\n+      get :power_status, params: { :id => host.id }, session: set_session_user, xhr: true\n+      assert_response :success\n+      response = JSON.parse @response.body\n+      assert_equal(expected_resp.sort, response.sort)\n+    end\n+\n+    test 'show power status for a host that has no power' do\n+      expected_resp = {\n+        \"id\" => host.id,\n+        \"state\" => \"na\",\n+        \"title\" => 'N/A',\n+        \"statusText\" => \"Power operations are not enabled on this host.\"\n+      }\n+\n+      Host.any_instance.stubs(:supports_power?).returns(false)\n+      get :power_status, params: { :id => host.id }, session: set_session_user, xhr: true\n+      assert_response :success\n+      response = JSON.parse @response.body\n+      assert_equal(expected_resp.sort, response.sort)\n+    end\n+\n+    test 'shows power status for bmc hosts'  do","path":"test/controllers/api/v2/hosts_controller_test.rb","position":56,"original_position":56,"commit_id":"04ccf629d51a4a9a8b700501eb91b6ae2b0e230c","original_commit_id":"04ccf629d51a4a9a8b700501eb91b6ae2b0e230c","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Layout/ExtraSpacing: Unnecessary spacing detected.","created_at":"2018-12-17T12:44:19Z","updated_at":"2018-12-17T12:44:19Z","html_url":"https://github.com/theforeman/foreman/pull/6271#discussion_r242132440","pull_request_url":"https://api.github.com/repos/theforeman/foreman/pulls/6271","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments/242132440"},"html":{"href":"https://github.com/theforeman/foreman/pull/6271#discussion_r242132440"},"pull_request":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/6271"}}},"pull_request":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/6271","id":233026953,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMDI2OTUz","html_url":"https://github.com/theforeman/foreman/pull/6271","diff_url":"https://github.com/theforeman/foreman/pull/6271.diff","patch_url":"https://github.com/theforeman/foreman/pull/6271.patch","issue_url":"https://api.github.com/repos/theforeman/foreman/issues/6271","number":6271,"state":"open","locked":false,"title":"Fixes #25436 - Add host power state api endpoint","user":{"login":"leewaa","id":5164431,"node_id":"MDQ6VXNlcjUxNjQ0MzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5164431?v=4","gravatar_id":"","url":"https://api.github.com/users/leewaa","html_url":"https://github.com/leewaa","followers_url":"https://api.github.com/users/leewaa/followers","following_url":"https://api.github.com/users/leewaa/following{/other_user}","gists_url":"https://api.github.com/users/leewaa/gists{/gist_id}","starred_url":"https://api.github.com/users/leewaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leewaa/subscriptions","organizations_url":"https://api.github.com/users/leewaa/orgs","repos_url":"https://api.github.com/users/leewaa/repos","events_url":"https://api.github.com/users/leewaa/events{/privacy}","received_events_url":"https://api.github.com/users/leewaa/received_events","type":"User","site_admin":false},"body":"This adds a new enpoint to the api `/hosts/:id/power_status` as per [#25436](https://projects.theforeman.org/issues/25436)\r\n\r\nTo achieve this I also refactored the existing status check in the hosts_controller (non api).\r\n\r\nTODO:\r\n\r\n- [x] Add endpoint using the new HostPowerStatusService","created_at":"2018-11-22T16:08:19Z","updated_at":"2018-12-17T12:44:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0ea8a8257a151523506c7d05d6a7203aae4f1d2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":79040160,"node_id":"MDU6TGFiZWw3OTA0MDE2MA==","url":"https://api.github.com/repos/theforeman/foreman/labels/Needs%20re-review","name":"Needs re-review","color":"0052cc","default":false},{"id":79040689,"node_id":"MDU6TGFiZWw3OTA0MDY4OQ==","url":"https://api.github.com/repos/theforeman/foreman/labels/Needs%20testing","name":"Needs testing","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/theforeman/foreman/pulls/6271/commits","review_comments_url":"https://api.github.com/repos/theforeman/foreman/pulls/6271/comments","review_comment_url":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}","comments_url":"https://api.github.com/repos/theforeman/foreman/issues/6271/comments","statuses_url":"https://api.github.com/repos/theforeman/foreman/statuses/04ccf629d51a4a9a8b700501eb91b6ae2b0e230c","head":{"label":"leewaa:25436-power-on-state","ref":"25436-power-on-state","sha":"04ccf629d51a4a9a8b700501eb91b6ae2b0e230c","user":{"login":"leewaa","id":5164431,"node_id":"MDQ6VXNlcjUxNjQ0MzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5164431?v=4","gravatar_id":"","url":"https://api.github.com/users/leewaa","html_url":"https://github.com/leewaa","followers_url":"https://api.github.com/users/leewaa/followers","following_url":"https://api.github.com/users/leewaa/following{/other_user}","gists_url":"https://api.github.com/users/leewaa/gists{/gist_id}","starred_url":"https://api.github.com/users/leewaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leewaa/subscriptions","organizations_url":"https://api.github.com/users/leewaa/orgs","repos_url":"https://api.github.com/users/leewaa/repos","events_url":"https://api.github.com/users/leewaa/events{/privacy}","received_events_url":"https://api.github.com/users/leewaa/received_events","type":"User","site_admin":false},"repo":{"id":129720395,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk3MjAzOTU=","name":"foreman","full_name":"leewaa/foreman","private":false,"owner":{"login":"leewaa","id":5164431,"node_id":"MDQ6VXNlcjUxNjQ0MzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5164431?v=4","gravatar_id":"","url":"https://api.github.com/users/leewaa","html_url":"https://github.com/leewaa","followers_url":"https://api.github.com/users/leewaa/followers","following_url":"https://api.github.com/users/leewaa/following{/other_user}","gists_url":"https://api.github.com/users/leewaa/gists{/gist_id}","starred_url":"https://api.github.com/users/leewaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leewaa/subscriptions","organizations_url":"https://api.github.com/users/leewaa/orgs","repos_url":"https://api.github.com/users/leewaa/repos","events_url":"https://api.github.com/users/leewaa/events{/privacy}","received_events_url":"https://api.github.com/users/leewaa/received_events","type":"User","site_admin":false},"html_url":"https://github.com/leewaa/foreman","description":"an application that automates the lifecycle of servers ","fork":true,"url":"https://api.github.com/repos/leewaa/foreman","forks_url":"https://api.github.com/repos/leewaa/foreman/forks","keys_url":"https://api.github.com/repos/leewaa/foreman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leewaa/foreman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leewaa/foreman/teams","hooks_url":"https://api.github.com/repos/leewaa/foreman/hooks","issue_events_url":"https://api.github.com/repos/leewaa/foreman/issues/events{/number}","events_url":"https://api.github.com/repos/leewaa/foreman/events","assignees_url":"https://api.github.com/repos/leewaa/foreman/assignees{/user}","branches_url":"https://api.github.com/repos/leewaa/foreman/branches{/branch}","tags_url":"https://api.github.com/repos/leewaa/foreman/tags","blobs_url":"https://api.github.com/repos/leewaa/foreman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leewaa/foreman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leewaa/foreman/git/refs{/sha}","trees_url":"https://api.github.com/repos/leewaa/foreman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leewaa/foreman/statuses/{sha}","languages_url":"https://api.github.com/repos/leewaa/foreman/languages","stargazers_url":"https://api.github.com/repos/leewaa/foreman/stargazers","contributors_url":"https://api.github.com/repos/leewaa/foreman/contributors","subscribers_url":"https://api.github.com/repos/leewaa/foreman/subscribers","subscription_url":"https://api.github.com/repos/leewaa/foreman/subscription","commits_url":"https://api.github.com/repos/leewaa/foreman/commits{/sha}","git_commits_url":"https://api.github.com/repos/leewaa/foreman/git/commits{/sha}","comments_url":"https://api.github.com/repos/leewaa/foreman/comments{/number}","issue_comment_url":"https://api.github.com/repos/leewaa/foreman/issues/comments{/number}","contents_url":"https://api.github.com/repos/leewaa/foreman/contents/{+path}","compare_url":"https://api.github.com/repos/leewaa/foreman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leewaa/foreman/merges","archive_url":"https://api.github.com/repos/leewaa/foreman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leewaa/foreman/downloads","issues_url":"https://api.github.com/repos/leewaa/foreman/issues{/number}","pulls_url":"https://api.github.com/repos/leewaa/foreman/pulls{/number}","milestones_url":"https://api.github.com/repos/leewaa/foreman/milestones{/number}","notifications_url":"https://api.github.com/repos/leewaa/foreman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leewaa/foreman/labels{/name}","releases_url":"https://api.github.com/repos/leewaa/foreman/releases{/id}","deployments_url":"https://api.github.com/repos/leewaa/foreman/deployments","created_at":"2018-04-16T09:43:11Z","updated_at":"2018-10-18T13:17:00Z","pushed_at":"2018-12-17T12:43:52Z","git_url":"git://github.com/leewaa/foreman.git","ssh_url":"git@github.com:leewaa/foreman.git","clone_url":"https://github.com/leewaa/foreman.git","svn_url":"https://github.com/leewaa/foreman","homepage":"http://theforeman.org","size":81681,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"theforeman:develop","ref":"develop","sha":"1653b19061591180823a8d0d2183ce440072a2b1","user":{"login":"theforeman","id":1439844,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mzk4NDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1439844?v=4","gravatar_id":"","url":"https://api.github.com/users/theforeman","html_url":"https://github.com/theforeman","followers_url":"https://api.github.com/users/theforeman/followers","following_url":"https://api.github.com/users/theforeman/following{/other_user}","gists_url":"https://api.github.com/users/theforeman/gists{/gist_id}","starred_url":"https://api.github.com/users/theforeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theforeman/subscriptions","organizations_url":"https://api.github.com/users/theforeman/orgs","repos_url":"https://api.github.com/users/theforeman/repos","events_url":"https://api.github.com/users/theforeman/events{/privacy}","received_events_url":"https://api.github.com/users/theforeman/received_events","type":"Organization","site_admin":false},"repo":{"id":258750,"node_id":"MDEwOlJlcG9zaXRvcnkyNTg3NTA=","name":"foreman","full_name":"theforeman/foreman","private":false,"owner":{"login":"theforeman","id":1439844,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mzk4NDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1439844?v=4","gravatar_id":"","url":"https://api.github.com/users/theforeman","html_url":"https://github.com/theforeman","followers_url":"https://api.github.com/users/theforeman/followers","following_url":"https://api.github.com/users/theforeman/following{/other_user}","gists_url":"https://api.github.com/users/theforeman/gists{/gist_id}","starred_url":"https://api.github.com/users/theforeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theforeman/subscriptions","organizations_url":"https://api.github.com/users/theforeman/orgs","repos_url":"https://api.github.com/users/theforeman/repos","events_url":"https://api.github.com/users/theforeman/events{/privacy}","received_events_url":"https://api.github.com/users/theforeman/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/theforeman/foreman","description":"an application that automates the lifecycle of servers ","fork":false,"url":"https://api.github.com/repos/theforeman/foreman","forks_url":"https://api.github.com/repos/theforeman/foreman/forks","keys_url":"https://api.github.com/repos/theforeman/foreman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theforeman/foreman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theforeman/foreman/teams","hooks_url":"https://api.github.com/repos/theforeman/foreman/hooks","issue_events_url":"https://api.github.com/repos/theforeman/foreman/issues/events{/number}","events_url":"https://api.github.com/repos/theforeman/foreman/events","assignees_url":"https://api.github.com/repos/theforeman/foreman/assignees{/user}","branches_url":"https://api.github.com/repos/theforeman/foreman/branches{/branch}","tags_url":"https://api.github.com/repos/theforeman/foreman/tags","blobs_url":"https://api.github.com/repos/theforeman/foreman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theforeman/foreman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theforeman/foreman/git/refs{/sha}","trees_url":"https://api.github.com/repos/theforeman/foreman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theforeman/foreman/statuses/{sha}","languages_url":"https://api.github.com/repos/theforeman/foreman/languages","stargazers_url":"https://api.github.com/repos/theforeman/foreman/stargazers","contributors_url":"https://api.github.com/repos/theforeman/foreman/contributors","subscribers_url":"https://api.github.com/repos/theforeman/foreman/subscribers","subscription_url":"https://api.github.com/repos/theforeman/foreman/subscription","commits_url":"https://api.github.com/repos/theforeman/foreman/commits{/sha}","git_commits_url":"https://api.github.com/repos/theforeman/foreman/git/commits{/sha}","comments_url":"https://api.github.com/repos/theforeman/foreman/comments{/number}","issue_comment_url":"https://api.github.com/repos/theforeman/foreman/issues/comments{/number}","contents_url":"https://api.github.com/repos/theforeman/foreman/contents/{+path}","compare_url":"https://api.github.com/repos/theforeman/foreman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theforeman/foreman/merges","archive_url":"https://api.github.com/repos/theforeman/foreman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theforeman/foreman/downloads","issues_url":"https://api.github.com/repos/theforeman/foreman/issues{/number}","pulls_url":"https://api.github.com/repos/theforeman/foreman/pulls{/number}","milestones_url":"https://api.github.com/repos/theforeman/foreman/milestones{/number}","notifications_url":"https://api.github.com/repos/theforeman/foreman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theforeman/foreman/labels{/name}","releases_url":"https://api.github.com/repos/theforeman/foreman/releases{/id}","deployments_url":"https://api.github.com/repos/theforeman/foreman/deployments","created_at":"2009-07-23T15:07:00Z","updated_at":"2018-12-17T11:43:28Z","pushed_at":"2018-12-17T12:43:54Z","git_url":"git://github.com/theforeman/foreman.git","ssh_url":"git@github.com:theforeman/foreman.git","clone_url":"https://github.com/theforeman/foreman.git","svn_url":"https://github.com/theforeman/foreman","homepage":"http://theforeman.org","size":85695,"stargazers_count":1540,"watchers_count":1540,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":772,"mirror_url":null,"archived":false,"open_issues_count":130,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":772,"open_issues":130,"watchers":1540,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/6271"},"html":{"href":"https://github.com/theforeman/foreman/pull/6271"},"issue":{"href":"https://api.github.com/repos/theforeman/foreman/issues/6271"},"comments":{"href":"https://api.github.com/repos/theforeman/foreman/issues/6271/comments"},"review_comments":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/6271/comments"},"review_comment":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/6271/commits"},"statuses":{"href":"https://api.github.com/repos/theforeman/foreman/statuses/04ccf629d51a4a9a8b700501eb91b6ae2b0e230c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"houndci-bot"}}