{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/52922684","id":52922684,"diff_hunk":"@@ -0,0 +1,80 @@\n+module ManageIQ::Providers\n+  module Hawkular\n+    class MiddlewareManager::RefreshParser\n+      def self.ems_inv_to_hashes(ems, options = nil)\n+        new(ems, options).ems_inv_to_hashes\n+      end\n+\n+      def initialize(ems, _options = nil)\n+        @ems = ems\n+        @eaps = []\n+        @data = {}\n+        @data_index = {}\n+      end\n+\n+      def ems_inv_to_hashes\n+        @data[:middleware_servers] = fetch_middleware_servers\n+        fetch_deployments\n+        @data\n+      end\n+\n+      def fetch_middleware_servers\n+        @data[:middleware_servers] = []\n+        @ems.feeds.map do |feed|\n+          @ems.eaps(feed).map do |eap|\n+            @eaps << eap\n+            server = parse_middleware_server(eap)\n+            @data[:middleware_servers] << server\n+            @data_index.store_path(:middleware_servers, :by_nativeid, server[:nativeid], server)\n+          end\n+        end.flatten\n+      end\n+\n+      def fetch_deployments\n+        @data[:middleware_deployments] = []\n+        @eaps.map do |eap|\n+          @ems.children(eap).map do |child|\n+            next unless child.type_path.end_with? 'Deployment'\n+            server = @data_index.fetch_path(:middleware_servers, :by_nativeid, eap.id)\n+            @data[:middleware_deployments] << parse_deployment(server, child)\n+          end\n+        end\n+      end\n+\n+      def parse_deployment(server, deployment)\n+        {\n+          :name              => parse_deployment_name(deployment.id),\n+          :middleware_server => server, # TODO: does that make sense? What is better?\n+          :nativeid          => deployment.id,\n+          :ems_ref           => deployment.path\n+        }\n+      end\n+\n+      def parse_deployment_name(name)\n+        tmp = name.dup\n+        tmp.sub!(/^.*deployment=/, '')\n+        tmp\n+      end\n+\n+      def parse_middleware_server(eap)\n+        {\n+          :feed       => eap.feed,\n+          :ems_ref    => eap.path,\n+          :nativeid   => eap.id,","path":"app/models/manageiq/providers/hawkular/middleware_manager/refresh_parser.rb","position":61,"original_position":63,"commit_id":"b83105aeb5cb27938da6440be4a708a6eb596630","original_commit_id":"baf393428cb4a14f744f5beaa23b1414b39c5935","user":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"body":"Usually it's for reporting putposes.  For the refresh ems_ref needs to be completely unique.  However, that unique value is not always the same as some native identifier that someone might need look at in the UI.","created_at":"2016-02-15T17:02:58Z","updated_at":"2016-02-15T17:02:58Z","html_url":"https://github.com/ManageIQ/manageiq/pull/6468#discussion_r52922684","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/52922684"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/6468#discussion_r52922684"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468","id":57900165,"html_url":"https://github.com/ManageIQ/manageiq/pull/6468","diff_url":"https://github.com/ManageIQ/manageiq/pull/6468.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/6468.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/6468","number":6468,"state":"open","locked":false,"title":"Initial support of Middleware management","user":{"login":"pilhuhn","id":208246,"avatar_url":"https://avatars.githubusercontent.com/u/208246?v=3","gravatar_id":"","url":"https://api.github.com/users/pilhuhn","html_url":"https://github.com/pilhuhn","followers_url":"https://api.github.com/users/pilhuhn/followers","following_url":"https://api.github.com/users/pilhuhn/following{/other_user}","gists_url":"https://api.github.com/users/pilhuhn/gists{/gist_id}","starred_url":"https://api.github.com/users/pilhuhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pilhuhn/subscriptions","organizations_url":"https://api.github.com/users/pilhuhn/orgs","repos_url":"https://api.github.com/users/pilhuhn/repos","events_url":"https://api.github.com/users/pilhuhn/events{/privacy}","received_events_url":"https://api.github.com/users/pilhuhn/received_events","type":"User","site_admin":false},"body":"This branch contains a very first cut at Middleware management via a Hawkular provider.\r\nMost work has been done by @abonas after initial work from @Fryguy ","created_at":"2016-02-01T21:09:02Z","updated_at":"2016-02-15T17:02:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2a597150160cd61a84523be0c75563ce6337f42","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/6468/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/b83105aeb5cb27938da6440be4a708a6eb596630","head":{"label":"pilhuhn:mw2","ref":"mw2","sha":"b83105aeb5cb27938da6440be4a708a6eb596630","user":{"login":"pilhuhn","id":208246,"avatar_url":"https://avatars.githubusercontent.com/u/208246?v=3","gravatar_id":"","url":"https://api.github.com/users/pilhuhn","html_url":"https://github.com/pilhuhn","followers_url":"https://api.github.com/users/pilhuhn/followers","following_url":"https://api.github.com/users/pilhuhn/following{/other_user}","gists_url":"https://api.github.com/users/pilhuhn/gists{/gist_id}","starred_url":"https://api.github.com/users/pilhuhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pilhuhn/subscriptions","organizations_url":"https://api.github.com/users/pilhuhn/orgs","repos_url":"https://api.github.com/users/pilhuhn/repos","events_url":"https://api.github.com/users/pilhuhn/events{/privacy}","received_events_url":"https://api.github.com/users/pilhuhn/received_events","type":"User","site_admin":false},"repo":{"id":47748414,"name":"manageiq","full_name":"pilhuhn/manageiq","owner":{"login":"pilhuhn","id":208246,"avatar_url":"https://avatars.githubusercontent.com/u/208246?v=3","gravatar_id":"","url":"https://api.github.com/users/pilhuhn","html_url":"https://github.com/pilhuhn","followers_url":"https://api.github.com/users/pilhuhn/followers","following_url":"https://api.github.com/users/pilhuhn/following{/other_user}","gists_url":"https://api.github.com/users/pilhuhn/gists{/gist_id}","starred_url":"https://api.github.com/users/pilhuhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pilhuhn/subscriptions","organizations_url":"https://api.github.com/users/pilhuhn/orgs","repos_url":"https://api.github.com/users/pilhuhn/repos","events_url":"https://api.github.com/users/pilhuhn/events{/privacy}","received_events_url":"https://api.github.com/users/pilhuhn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pilhuhn/manageiq","description":"ManageIQ Cloud Management Platform","fork":true,"url":"https://api.github.com/repos/pilhuhn/manageiq","forks_url":"https://api.github.com/repos/pilhuhn/manageiq/forks","keys_url":"https://api.github.com/repos/pilhuhn/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pilhuhn/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pilhuhn/manageiq/teams","hooks_url":"https://api.github.com/repos/pilhuhn/manageiq/hooks","issue_events_url":"https://api.github.com/repos/pilhuhn/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/pilhuhn/manageiq/events","assignees_url":"https://api.github.com/repos/pilhuhn/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/pilhuhn/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/pilhuhn/manageiq/tags","blobs_url":"https://api.github.com/repos/pilhuhn/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pilhuhn/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pilhuhn/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/pilhuhn/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pilhuhn/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/pilhuhn/manageiq/languages","stargazers_url":"https://api.github.com/repos/pilhuhn/manageiq/stargazers","contributors_url":"https://api.github.com/repos/pilhuhn/manageiq/contributors","subscribers_url":"https://api.github.com/repos/pilhuhn/manageiq/subscribers","subscription_url":"https://api.github.com/repos/pilhuhn/manageiq/subscription","commits_url":"https://api.github.com/repos/pilhuhn/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/pilhuhn/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/pilhuhn/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/pilhuhn/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/pilhuhn/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/pilhuhn/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pilhuhn/manageiq/merges","archive_url":"https://api.github.com/repos/pilhuhn/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pilhuhn/manageiq/downloads","issues_url":"https://api.github.com/repos/pilhuhn/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/pilhuhn/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/pilhuhn/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/pilhuhn/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pilhuhn/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/pilhuhn/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/pilhuhn/manageiq/deployments","created_at":"2015-12-10T08:31:52Z","updated_at":"2016-02-02T09:37:58Z","pushed_at":"2016-02-15T13:13:19Z","git_url":"git://github.com/pilhuhn/manageiq.git","ssh_url":"git@github.com:pilhuhn/manageiq.git","clone_url":"https://github.com/pilhuhn/manageiq.git","svn_url":"https://github.com/pilhuhn/manageiq","homepage":"manageiq.org","size":105729,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"3cdd493054f91809fdc2e4971e89e54847964e88","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":20789757,"name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq","description":"ManageIQ Cloud Management Platform","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq","forks_url":"https://api.github.com/repos/ManageIQ/manageiq/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq/deployments","created_at":"2014-06-13T02:31:26Z","updated_at":"2016-02-15T15:43:52Z","pushed_at":"2016-02-15T16:55:31Z","git_url":"git://github.com/ManageIQ/manageiq.git","ssh_url":"git@github.com:ManageIQ/manageiq.git","clone_url":"https://github.com/ManageIQ/manageiq.git","svn_url":"https://github.com/ManageIQ/manageiq","homepage":"manageiq.org","size":141298,"stargazers_count":216,"watchers_count":216,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":230,"mirror_url":null,"open_issues_count":525,"forks":230,"open_issues":525,"watchers":216,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/6468"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/6468"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/6468/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6468/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/b83105aeb5cb27938da6440be4a708a6eb596630"}}}}