{"action":"created","comment":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/comments/189846934","pull_request_review_id":122101841,"id":189846934,"diff_hunk":"@@ -598,6 +599,71 @@ def vm_compute_attributes(vm)\n       vm_attrs\n     end\n \n+    def normalize_vm_attrs(vm_attrs)\n+      normalized = slice_vm_attributes(vm_attrs, ['cpus', 'firmware', 'guest_id', 'annotation', 'resource_pool_id', 'image_id'])\n+\n+      normalized['cores_per_socket'] = vm_attrs['corespersocket']\n+      normalized['memory'] = vm_attrs['memory_mb'].nil? ? nil : (vm_attrs['memory_mb'].to_i * 1024)\n+\n+      normalized['folder_path'] = vm_attrs['path']\n+      normalized['folder_name'] = self.folders.detect { |f| f.path == normalized['folder_path'] }.try(:name)\n+\n+      normalized['cluster_id'] = self.available_clusters.detect { |c| c.name == vm_attrs['cluster'] }.try(:id)\n+      normalized['cluster_name'] = vm_attrs['cluster']\n+      normalized['cluster_name'] = nil if normalized['cluster_name'].empty?\n+\n+      if normalized['cluster_name']\n+        normalized['resource_pool_id'] = self.resource_pools(:cluster_id => normalized['cluster_name']).detect { |p| p.name == vm_attrs['resource_pool'] }.try(:id)\n+      end\n+      normalized['resource_pool_name'] = vm_attrs['resource_pool']\n+      normalized['resource_pool_name'] = nil if normalized['resource_pool_name'].empty?\n+\n+      normalized['guest_name'] = self.guest_types[vm_attrs['guest_id']]\n+\n+      normalized['hardware_version_id'] = vm_attrs['hardware_version']\n+      normalized['hardware_version_name'] = vm_hw_versions[vm_attrs['hardware_version']]\n+\n+      normalized['memory_hot_add_enabled'] = to_bool(vm_attrs['memoryHotAddEnabled'])\n+      normalized['cpu_hot_add_enabled'] = to_bool(vm_attrs['cpuHotAddEnabled'])\n+      normalized['add_cdrom'] = to_bool(vm_attrs['add_cdrom'])\n+\n+      normalized['image_name'] = self.images.where(:uuid => vm_attrs['image_id']).first.try(:name)\n+\n+      scsi_controllers = vm_attrs['scsi_controllers'] || {}\n+      normalized['scsi_controllers'] = scsi_controllers.map.with_index do |ctrl, idx|\n+        ctrl['eager_zero'] = ctrl.delete('eagerzero')\n+        [idx.to_s, ctrl]\n+      end.to_h\n+\n+      stores = self.datastores\n+      volumes_attributes = vm_attrs['volumes_attributes'] || {}\n+      normalized['volumes_attributes'] = volumes_attributes.inject({}) do |volumes, (key, vol)|","path":"app/models/compute_resources/foreman/model/vmware.rb","position":58,"original_position":58,"commit_id":"544c2c35260f9f3e6489172862d09ba02c968adf","original_commit_id":"544c2c35260f9f3e6489172862d09ba02c968adf","user":{"login":"houndci-bot","id":6697940,"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":"Style/EachWithObject: Use each_with_object instead of inject.","created_at":"2018-05-22T10:10:41Z","updated_at":"2018-05-22T10:10:43Z","html_url":"https://github.com/theforeman/foreman/pull/4980#discussion_r189846934","pull_request_url":"https://api.github.com/repos/theforeman/foreman/pulls/4980","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments/189846934"},"html":{"href":"https://github.com/theforeman/foreman/pull/4980#discussion_r189846934"},"pull_request":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/4980"}}},"pull_request":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/4980","id":150748413,"html_url":"https://github.com/theforeman/foreman/pull/4980","diff_url":"https://github.com/theforeman/foreman/pull/4980.diff","patch_url":"https://github.com/theforeman/foreman/pull/4980.patch","issue_url":"https://api.github.com/repos/theforeman/foreman/issues/4980","number":4980,"state":"open","locked":false,"title":"Fixes #21580 - normalize compute attributes","user":{"login":"tstrachota","id":1186631,"avatar_url":"https://avatars2.githubusercontent.com/u/1186631?v=4","gravatar_id":"","url":"https://api.github.com/users/tstrachota","html_url":"https://github.com/tstrachota","followers_url":"https://api.github.com/users/tstrachota/followers","following_url":"https://api.github.com/users/tstrachota/following{/other_user}","gists_url":"https://api.github.com/users/tstrachota/gists{/gist_id}","starred_url":"https://api.github.com/users/tstrachota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tstrachota/subscriptions","organizations_url":"https://api.github.com/users/tstrachota/orgs","repos_url":"https://api.github.com/users/tstrachota/repos","events_url":"https://api.github.com/users/tstrachota/events{/privacy}","received_events_url":"https://api.github.com/users/tstrachota/received_events","type":"User","site_admin":false},"body":"Normalizes compute attributes in API show actions. For backwards compatibility reasons this patch adds a new rabl node instead of replacing 'vm_attrs'.","created_at":"2017-11-05T23:16:11Z","updated_at":"2018-05-22T10:10:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02791b4752c832c7564470f0a534b9ed30aa8c44","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":79040160,"url":"https://api.github.com/repos/theforeman/foreman/labels/Needs%20re-review","name":"Needs re-review","color":"0052cc","default":false},{"id":79040689,"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/4980/commits","review_comments_url":"https://api.github.com/repos/theforeman/foreman/pulls/4980/comments","review_comment_url":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}","comments_url":"https://api.github.com/repos/theforeman/foreman/issues/4980/comments","statuses_url":"https://api.github.com/repos/theforeman/foreman/statuses/544c2c35260f9f3e6489172862d09ba02c968adf","head":{"label":"tstrachota:compute_profiles_cli_support","ref":"compute_profiles_cli_support","sha":"544c2c35260f9f3e6489172862d09ba02c968adf","user":{"login":"tstrachota","id":1186631,"avatar_url":"https://avatars2.githubusercontent.com/u/1186631?v=4","gravatar_id":"","url":"https://api.github.com/users/tstrachota","html_url":"https://github.com/tstrachota","followers_url":"https://api.github.com/users/tstrachota/followers","following_url":"https://api.github.com/users/tstrachota/following{/other_user}","gists_url":"https://api.github.com/users/tstrachota/gists{/gist_id}","starred_url":"https://api.github.com/users/tstrachota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tstrachota/subscriptions","organizations_url":"https://api.github.com/users/tstrachota/orgs","repos_url":"https://api.github.com/users/tstrachota/repos","events_url":"https://api.github.com/users/tstrachota/events{/privacy}","received_events_url":"https://api.github.com/users/tstrachota/received_events","type":"User","site_admin":false},"repo":{"id":4674201,"name":"foreman","full_name":"tstrachota/foreman","owner":{"login":"tstrachota","id":1186631,"avatar_url":"https://avatars2.githubusercontent.com/u/1186631?v=4","gravatar_id":"","url":"https://api.github.com/users/tstrachota","html_url":"https://github.com/tstrachota","followers_url":"https://api.github.com/users/tstrachota/followers","following_url":"https://api.github.com/users/tstrachota/following{/other_user}","gists_url":"https://api.github.com/users/tstrachota/gists{/gist_id}","starred_url":"https://api.github.com/users/tstrachota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tstrachota/subscriptions","organizations_url":"https://api.github.com/users/tstrachota/orgs","repos_url":"https://api.github.com/users/tstrachota/repos","events_url":"https://api.github.com/users/tstrachota/events{/privacy}","received_events_url":"https://api.github.com/users/tstrachota/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tstrachota/foreman","description":"an application that automates the lifecycle of servers ","fork":true,"url":"https://api.github.com/repos/tstrachota/foreman","forks_url":"https://api.github.com/repos/tstrachota/foreman/forks","keys_url":"https://api.github.com/repos/tstrachota/foreman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tstrachota/foreman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tstrachota/foreman/teams","hooks_url":"https://api.github.com/repos/tstrachota/foreman/hooks","issue_events_url":"https://api.github.com/repos/tstrachota/foreman/issues/events{/number}","events_url":"https://api.github.com/repos/tstrachota/foreman/events","assignees_url":"https://api.github.com/repos/tstrachota/foreman/assignees{/user}","branches_url":"https://api.github.com/repos/tstrachota/foreman/branches{/branch}","tags_url":"https://api.github.com/repos/tstrachota/foreman/tags","blobs_url":"https://api.github.com/repos/tstrachota/foreman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tstrachota/foreman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tstrachota/foreman/git/refs{/sha}","trees_url":"https://api.github.com/repos/tstrachota/foreman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tstrachota/foreman/statuses/{sha}","languages_url":"https://api.github.com/repos/tstrachota/foreman/languages","stargazers_url":"https://api.github.com/repos/tstrachota/foreman/stargazers","contributors_url":"https://api.github.com/repos/tstrachota/foreman/contributors","subscribers_url":"https://api.github.com/repos/tstrachota/foreman/subscribers","subscription_url":"https://api.github.com/repos/tstrachota/foreman/subscription","commits_url":"https://api.github.com/repos/tstrachota/foreman/commits{/sha}","git_commits_url":"https://api.github.com/repos/tstrachota/foreman/git/commits{/sha}","comments_url":"https://api.github.com/repos/tstrachota/foreman/comments{/number}","issue_comment_url":"https://api.github.com/repos/tstrachota/foreman/issues/comments{/number}","contents_url":"https://api.github.com/repos/tstrachota/foreman/contents/{+path}","compare_url":"https://api.github.com/repos/tstrachota/foreman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tstrachota/foreman/merges","archive_url":"https://api.github.com/repos/tstrachota/foreman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tstrachota/foreman/downloads","issues_url":"https://api.github.com/repos/tstrachota/foreman/issues{/number}","pulls_url":"https://api.github.com/repos/tstrachota/foreman/pulls{/number}","milestones_url":"https://api.github.com/repos/tstrachota/foreman/milestones{/number}","notifications_url":"https://api.github.com/repos/tstrachota/foreman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tstrachota/foreman/labels{/name}","releases_url":"https://api.github.com/repos/tstrachota/foreman/releases{/id}","deployments_url":"https://api.github.com/repos/tstrachota/foreman/deployments","created_at":"2012-06-15T11:11:21Z","updated_at":"2018-05-17T12:10:42Z","pushed_at":"2018-05-22T10:09:48Z","git_url":"git://github.com/tstrachota/foreman.git","ssh_url":"git@github.com:tstrachota/foreman.git","clone_url":"https://github.com/tstrachota/foreman.git","svn_url":"https://github.com/tstrachota/foreman","homepage":"http://theforeman.org","size":48348,"stargazers_count":2,"watchers_count":2,"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"},"forks":0,"open_issues":0,"watchers":2,"default_branch":"develop"}},"base":{"label":"theforeman:develop","ref":"develop","sha":"b9aa6bdaa0d3a19efe5160d2892c6420ad74e27e","user":{"login":"theforeman","id":1439844,"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,"name":"foreman","full_name":"theforeman/foreman","owner":{"login":"theforeman","id":1439844,"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},"private":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-05-22T10:05:03Z","pushed_at":"2018-05-22T10:09:50Z","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":73569,"stargazers_count":1428,"watchers_count":1428,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":731,"mirror_url":null,"archived":false,"open_issues_count":147,"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"},"forks":731,"open_issues":147,"watchers":1428,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/4980"},"html":{"href":"https://github.com/theforeman/foreman/pull/4980"},"issue":{"href":"https://api.github.com/repos/theforeman/foreman/issues/4980"},"comments":{"href":"https://api.github.com/repos/theforeman/foreman/issues/4980/comments"},"review_comments":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/4980/comments"},"review_comment":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/4980/commits"},"statuses":{"href":"https://api.github.com/repos/theforeman/foreman/statuses/544c2c35260f9f3e6489172862d09ba02c968adf"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"houndci-bot"}}