{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/213211124","pull_request_review_id":149997578,"id":213211124,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzIxMTEyNA==","diff_hunk":"@@ -0,0 +1,102 @@\n+class ManageIQ::Providers::Inventory::Builder\n+  class << self\n+    # Defines collector, persister and parser classes\n+    # and sends them to build inventory\n+    #\n+    # Builder for concrete provider has to define:\n+    # - `allowed_manager_types()`\n+    # - `default_manager_type()`\n+    #\n+    # Example:\n+    # - for ems == target == ManageIQ::Providers::Amazon::CloudManager\n+    #\n+    # collector: ManageIQ::Providers::Amazon::Inventory:Collector::CloudManager\n+    # parser:    ManageIQ::Providers::Amazon::Inventory:Parser::CloudManager\n+    # persister: ManageIQ::Providers::Amazon::Inventory:Persister::CloudManager\n+    def build_inventory(ems, target)\n+      case target\n+      when ManagerRefresh::TargetCollection\n+        build_target_collection_inventory(ems, target)\n+      else\n+        manager_type = ManageIQ::Providers::Inflector.manager_type(target)\n+\n+        manager_type = default_manager_type unless allowed_manager_types.include?(manager_type)\n+\n+        collector_type = \"#{collector_class}::#{manager_type}Manager\".safe_constantize\n+        persister_type = \"#{persister_class}::#{manager_type}Manager\".safe_constantize\n+        parser_type    = \"#{parser_class}::#{manager_type}Manager\".safe_constantize\n+\n+        inventory(ems, target, collector_type, persister_type, [parser_type])\n+      end\n+    end\n+\n+    def build_target_collection_inventory(ems, target)\n+      parsers = allowed_manager_types.collect do |manager_type|\n+        \"#{parser_class}::#{manager_type}Manager\".safe_constantize\n+      end\n+\n+      inventory(\n+        ems,\n+        target,\n+        \"#{collector_class}::TargetCollection\".safe_constantize,\n+        \"#{persister_class}::TargetCollection\".safe_constantize,\n+        parsers\n+      )\n+    end\n+\n+    protected\n+\n+    def inventory(manager, raw_target, collector_class, persister_class, parsers_classes)\n+      collector = collector_class.new(manager, raw_target)\n+      persister = persister_class.new(manager, raw_target)\n+\n+      inventory_class.new(\n+        persister,\n+        collector,\n+        parsers_classes.map(&:new)\n+      )\n+    end\n+\n+    # Concrete provider has to define manager_types as Array\n+    #\n+    # Example:\n+    # %w(Cloud Network Infra)\n+    def allowed_manager_types\n+      raise NotImplementedError","path":"app/models/manageiq/providers/inventory/builder.rb","position":65,"original_position":65,"commit_id":"fbabe325631e657f3371a5336f2c995b685371b2","original_commit_id":"fbabe325631e657f3371a5336f2c995b685371b2","user":{"login":"Ladas","id":1737058,"node_id":"MDQ6VXNlcjE3MzcwNTg=","avatar_url":"https://avatars0.githubusercontent.com/u/1737058?v=4","gravatar_id":"","url":"https://api.github.com/users/Ladas","html_url":"https://github.com/Ladas","followers_url":"https://api.github.com/users/Ladas/followers","following_url":"https://api.github.com/users/Ladas/following{/other_user}","gists_url":"https://api.github.com/users/Ladas/gists{/gist_id}","starred_url":"https://api.github.com/users/Ladas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ladas/subscriptions","organizations_url":"https://api.github.com/users/Ladas/orgs","repos_url":"https://api.github.com/users/Ladas/repos","events_url":"https://api.github.com/users/Ladas/events{/privacy}","received_events_url":"https://api.github.com/users/Ladas/received_events","type":"User","site_admin":false},"body":"lets provide a message to the exception","created_at":"2018-08-28T07:36:48Z","updated_at":"2018-08-28T07:36:48Z","html_url":"https://github.com/ManageIQ/manageiq/pull/17907#discussion_r213211124","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/213211124"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/17907#discussion_r213211124"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907","id":211097583,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExMDk3NTgz","html_url":"https://github.com/ManageIQ/manageiq/pull/17907","diff_url":"https://github.com/ManageIQ/manageiq/pull/17907.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/17907.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/17907","number":17907,"state":"open","locked":false,"title":"[WIP] Generic Builder for inventory","user":{"login":"slemrmartin","id":1814995,"node_id":"MDQ6VXNlcjE4MTQ5OTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1814995?v=4","gravatar_id":"","url":"https://api.github.com/users/slemrmartin","html_url":"https://github.com/slemrmartin","followers_url":"https://api.github.com/users/slemrmartin/followers","following_url":"https://api.github.com/users/slemrmartin/following{/other_user}","gists_url":"https://api.github.com/users/slemrmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/slemrmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slemrmartin/subscriptions","organizations_url":"https://api.github.com/users/slemrmartin/orgs","repos_url":"https://api.github.com/users/slemrmartin/repos","events_url":"https://api.github.com/users/slemrmartin/events{/privacy}","received_events_url":"https://api.github.com/users/slemrmartin/received_events","type":"User","site_admin":false},"body":"Before this PR all providers with graph refresh repeats the same code for their inventory builders.\r\nThey didn't inherit from any common class (except Object, of course :)","created_at":"2018-08-27T12:41:57Z","updated_at":"2018-08-28T07:36:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"337eaac0d57b96d972e70088a51886ded7dbd972","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":176168677,"node_id":"MDU6TGFiZWwxNzYxNjg2Nzc=","url":"https://api.github.com/repos/ManageIQ/manageiq/labels/wip","name":"wip","color":"eeeeee","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/17907/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/fbabe325631e657f3371a5336f2c995b685371b2","head":{"label":"slemrmartin:inventory-builder","ref":"inventory-builder","sha":"fbabe325631e657f3371a5336f2c995b685371b2","user":{"login":"slemrmartin","id":1814995,"node_id":"MDQ6VXNlcjE4MTQ5OTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1814995?v=4","gravatar_id":"","url":"https://api.github.com/users/slemrmartin","html_url":"https://github.com/slemrmartin","followers_url":"https://api.github.com/users/slemrmartin/followers","following_url":"https://api.github.com/users/slemrmartin/following{/other_user}","gists_url":"https://api.github.com/users/slemrmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/slemrmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slemrmartin/subscriptions","organizations_url":"https://api.github.com/users/slemrmartin/orgs","repos_url":"https://api.github.com/users/slemrmartin/repos","events_url":"https://api.github.com/users/slemrmartin/events{/privacy}","received_events_url":"https://api.github.com/users/slemrmartin/received_events","type":"User","site_admin":false},"repo":{"id":123601697,"node_id":"MDEwOlJlcG9zaXRvcnkxMjM2MDE2OTc=","name":"manageiq","full_name":"slemrmartin/manageiq","owner":{"login":"slemrmartin","id":1814995,"node_id":"MDQ6VXNlcjE4MTQ5OTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1814995?v=4","gravatar_id":"","url":"https://api.github.com/users/slemrmartin","html_url":"https://github.com/slemrmartin","followers_url":"https://api.github.com/users/slemrmartin/followers","following_url":"https://api.github.com/users/slemrmartin/following{/other_user}","gists_url":"https://api.github.com/users/slemrmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/slemrmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slemrmartin/subscriptions","organizations_url":"https://api.github.com/users/slemrmartin/orgs","repos_url":"https://api.github.com/users/slemrmartin/repos","events_url":"https://api.github.com/users/slemrmartin/events{/privacy}","received_events_url":"https://api.github.com/users/slemrmartin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/slemrmartin/manageiq","description":"ManageIQ Open-Source Management Platform","fork":true,"url":"https://api.github.com/repos/slemrmartin/manageiq","forks_url":"https://api.github.com/repos/slemrmartin/manageiq/forks","keys_url":"https://api.github.com/repos/slemrmartin/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slemrmartin/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slemrmartin/manageiq/teams","hooks_url":"https://api.github.com/repos/slemrmartin/manageiq/hooks","issue_events_url":"https://api.github.com/repos/slemrmartin/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/slemrmartin/manageiq/events","assignees_url":"https://api.github.com/repos/slemrmartin/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/slemrmartin/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/slemrmartin/manageiq/tags","blobs_url":"https://api.github.com/repos/slemrmartin/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slemrmartin/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slemrmartin/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/slemrmartin/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slemrmartin/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/slemrmartin/manageiq/languages","stargazers_url":"https://api.github.com/repos/slemrmartin/manageiq/stargazers","contributors_url":"https://api.github.com/repos/slemrmartin/manageiq/contributors","subscribers_url":"https://api.github.com/repos/slemrmartin/manageiq/subscribers","subscription_url":"https://api.github.com/repos/slemrmartin/manageiq/subscription","commits_url":"https://api.github.com/repos/slemrmartin/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/slemrmartin/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/slemrmartin/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/slemrmartin/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/slemrmartin/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/slemrmartin/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slemrmartin/manageiq/merges","archive_url":"https://api.github.com/repos/slemrmartin/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slemrmartin/manageiq/downloads","issues_url":"https://api.github.com/repos/slemrmartin/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/slemrmartin/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/slemrmartin/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/slemrmartin/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slemrmartin/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/slemrmartin/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/slemrmartin/manageiq/deployments","created_at":"2018-03-02T16:16:29Z","updated_at":"2018-07-25T07:39:02Z","pushed_at":"2018-08-27T19:18:03Z","git_url":"git://github.com/slemrmartin/manageiq.git","ssh_url":"git@github.com:slemrmartin/manageiq.git","clone_url":"https://github.com/slemrmartin/manageiq.git","svn_url":"https://github.com/slemrmartin/manageiq","homepage":"manageiq.org","size":244435,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"755009802c13e76241d9bf275df67bd684527f61","user":{"login":"ManageIQ","id":1125575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjU1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnkyMDc4OTc1Nw==","name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjU1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","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 Open-Source 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":"2018-08-28T00:01:19Z","pushed_at":"2018-08-27T19:42:32Z","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":256155,"stargazers_count":693,"watchers_count":693,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":651,"mirror_url":null,"archived":false,"open_issues_count":588,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":651,"open_issues":588,"watchers":693,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/17907"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/17907"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/17907/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17907/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/fbabe325631e657f3371a5336f2c995b685371b2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Ladas"}}