{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/stacki/pulls/comments/325970482","pull_request_review_id":290299156,"id":325970482,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMyNTk3MDQ4Mg==","diff_hunk":"@@ -0,0 +1,104 @@\n+from abc import ABC, abstractmethod\n+from operator import attrgetter\n+import pathlib\n+import importlib\n+import pkgutil\n+import inspect\n+from dataclasses import dataclass\n+\n+class UnrecognizedPallet(Exception):\n+\tpass\n+\n+@dataclass(eq=True, frozen=True)\n+class PalletInfo:\n+\tname: str\n+\tversion: str\n+\trelease: str\n+\tarch: str\n+\tdistro_family: str\n+\n+\tdef is_complete(self):\n+\t\treturn all((self.name, self.version, self.release, self.arch, self.distro_family))\n+\n+\n+class Probe(ABC):\n+\t'''\n+\tBase probe class.  Subclasses must implement probe() and __init__()\n+\tLower weight probes will be attempted first.\n+\n+\tSubclassed `Probe.probe()` must return None or a PalletInfo() object\n+\n+\tProbe instances are callables. `__call__(arg)` will pass through to `Probe.probe()`\n+\t'''\n+\n+\tisProbe = True\n+\n+\t@abstractmethod\n+\tdef __init__(self, weight=90, desc=''):\n+\t\tself.weight = weight\n+\t\tself.desc = desc\n+\n+\t@abstractmethod\n+\tdef probe(self, pallet_root):\n+\t\treturn None\n+\n+\tdef __str__(self):\n+\t\treturn f'{self.__class__.__name__} (supports {self.desc})'\n+\n+\tdef __repr__(self):\n+\t\treturn f'{self.__class__.__name__}(weight={self.weight})'\n+\n+\tdef __call__(self, pallet_root):\n+\t\treturn self.probe(pallet_root)\n+\n+class Prober:\n+\n+\tdef __init__(self):\n+\t\t'''\n+\t\tfind and import all pallet probes in python modules in the directory.\n+\t\tProbes are returned sorted by their weight to allow us to do things like check\n+\t\tfor rolls.xml inside foreign pallets, or potentially insert a probe at the end\n+\t\twhich might false-positive ID something else\n+\t\t'''\n+\t\tpath = pathlib.Path(__file__).resolve().parent\n+\t\tpkg_paths = {fi.parent for fi in path.glob('probe_*.py')}\n+\n+\t\tplugins = {}\n+\t\tfor _, name, _ in pkgutil.walk_packages(pkg_paths):\n+\t\t\tif not name.startswith('probe'):\n+\t\t\t\tcontinue\n+\t\t\tplugins[name] = importlib.import_module('.' + name, 'stack.probepal')\n+\n+\t\tprobes = []\n+\t\tfor module in plugins.values():\n+\t\t\t# Get the listing of all classes defined in the module, and instantiate the\n+\t\t\t# ones that are subclasses of Prober\n+\t\t\t# note, issubclass() doesn't work, as the class as found in the module above\n+\t\t\t# is stack.probepal.Prober, not Prober\n+\t\t\tfor _, cls in inspect.getmembers(module, inspect.isclass):\n+\t\t\t\tif cls.__module__ == module.__name__ and getattr(cls, 'isProbe', False):\n+\t\t\t\t\tprobes.append(cls())\n+\n+\t\tself.probes = sorted(probes, key=attrgetter('weight'))\n+\n+\tdef find_pallets(self, *paths):\n+\t\tpallet_map = {}\n+\t\tfor path in paths:\n+\t\t\tprint(f'====== probing {path} ======')\n+\t\t\tfor probe in self.probes:\n+\t\t\t\t# probes return None if it's a hard non-match\n+\t\t\t\t# or raise UnrecognizedPallet if it's a partial match\n+\t\t\t\t# in both cases, keep looking -- a later probe has a better chance to ID\n+\t\t\t\ttry:\n+\t\t\t\t\tpallet = probe(path)\n+\t\t\t\t\tif pallet is not None:\n+\t\t\t\t\t\t# success!\n+\t\t\t\t\t\tpallet_map[path] = pallet\n+\t\t\t\t\t\tbreak\n+\t\t\t\texcept UnrecognizedPallet as e:\n+\t\t\t\t\tpass\n+\t\t\telse: #nobreak","path":"common/src/stack/pylib/stack/probepal/common.py","position":100,"original_position":100,"commit_id":"329309bc83894b5fced882646682521db7486851","original_commit_id":"329309bc83894b5fced882646682521db7486851","user":{"login":"bsanders","id":1420834,"node_id":"MDQ6VXNlcjE0MjA4MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1420834?v=4","gravatar_id":"","url":"https://api.github.com/users/bsanders","html_url":"https://github.com/bsanders","followers_url":"https://api.github.com/users/bsanders/followers","following_url":"https://api.github.com/users/bsanders/following{/other_user}","gists_url":"https://api.github.com/users/bsanders/gists{/gist_id}","starred_url":"https://api.github.com/users/bsanders/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsanders/subscriptions","organizations_url":"https://api.github.com/users/bsanders/orgs","repos_url":"https://api.github.com/users/bsanders/repos","events_url":"https://api.github.com/users/bsanders/events{/privacy}","received_events_url":"https://api.github.com/users/bsanders/received_events","type":"User","site_admin":false},"body":"It's there to call out / make explicit the `else` statement attached to the `for`.","created_at":"2019-09-19T02:52:44Z","updated_at":"2019-09-19T02:52:45Z","html_url":"https://github.com/Teradata/stacki/pull/632#discussion_r325970482","pull_request_url":"https://api.github.com/repos/Teradata/stacki/pulls/632","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Teradata/stacki/pulls/comments/325970482"},"html":{"href":"https://github.com/Teradata/stacki/pull/632#discussion_r325970482"},"pull_request":{"href":"https://api.github.com/repos/Teradata/stacki/pulls/632"}},"in_reply_to_id":325939764},"pull_request":{"url":"https://api.github.com/repos/Teradata/stacki/pulls/632","id":319035158,"node_id":"MDExOlB1bGxSZXF1ZXN0MzE5MDM1MTU4","html_url":"https://github.com/Teradata/stacki/pull/632","diff_url":"https://github.com/Teradata/stacki/pull/632.diff","patch_url":"https://github.com/Teradata/stacki/pull/632.patch","issue_url":"https://api.github.com/repos/Teradata/stacki/issues/632","number":632,"state":"open","locked":false,"title":"WIP: INTERNAL: adds pallet fingerprinting library to pylib","user":{"login":"bsanders","id":1420834,"node_id":"MDQ6VXNlcjE0MjA4MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1420834?v=4","gravatar_id":"","url":"https://api.github.com/users/bsanders","html_url":"https://github.com/bsanders","followers_url":"https://api.github.com/users/bsanders/followers","following_url":"https://api.github.com/users/bsanders/following{/other_user}","gists_url":"https://api.github.com/users/bsanders/gists{/gist_id}","starred_url":"https://api.github.com/users/bsanders/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsanders/subscriptions","organizations_url":"https://api.github.com/users/bsanders/orgs","repos_url":"https://api.github.com/users/bsanders/repos","events_url":"https://api.github.com/users/bsanders/events{/privacy}","received_events_url":"https://api.github.com/users/bsanders/received_events","type":"User","site_admin":false},"body":"Currently supports identification of CentOS7.x, RHEL 7.x/8, Fedora 30,\r\nUbuntu 18.04 and 19.04 (server and live media), and native stacki\r\npallets.\r\n\r\nI closed #570, as the code has changed slightly.  Overall architecture is the same.  Feedback from that PR was incorporated, but the code was tightened up a bit and refactored to make it more consumable.","created_at":"2019-09-18T23:15:55Z","updated_at":"2019-09-19T02:52:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84a4dae67ee726c0bd3e3b0b38ec76f6547ac7dc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/stacki/pulls/632/commits","review_comments_url":"https://api.github.com/repos/Teradata/stacki/pulls/632/comments","review_comment_url":"https://api.github.com/repos/Teradata/stacki/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/stacki/issues/632/comments","statuses_url":"https://api.github.com/repos/Teradata/stacki/statuses/329309bc83894b5fced882646682521db7486851","head":{"label":"Teradata:feature/probepal","ref":"feature/probepal","sha":"329309bc83894b5fced882646682521db7486851","user":{"login":"Teradata","id":1615979,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MTU5Nzk=","avatar_url":"https://avatars1.githubusercontent.com/u/1615979?v=4","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":35458005,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ1ODAwNQ==","name":"stacki","full_name":"Teradata/stacki","private":false,"owner":{"login":"Teradata","id":1615979,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MTU5Nzk=","avatar_url":"https://avatars1.githubusercontent.com/u/1615979?v=4","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Teradata/stacki","description":"Linux Cluster Builder - Bare Metal RedHat & SuSe","fork":false,"url":"https://api.github.com/repos/Teradata/stacki","forks_url":"https://api.github.com/repos/Teradata/stacki/forks","keys_url":"https://api.github.com/repos/Teradata/stacki/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/stacki/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/stacki/teams","hooks_url":"https://api.github.com/repos/Teradata/stacki/hooks","issue_events_url":"https://api.github.com/repos/Teradata/stacki/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/stacki/events","assignees_url":"https://api.github.com/repos/Teradata/stacki/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/stacki/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/stacki/tags","blobs_url":"https://api.github.com/repos/Teradata/stacki/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/stacki/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/stacki/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/stacki/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/stacki/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/stacki/languages","stargazers_url":"https://api.github.com/repos/Teradata/stacki/stargazers","contributors_url":"https://api.github.com/repos/Teradata/stacki/contributors","subscribers_url":"https://api.github.com/repos/Teradata/stacki/subscribers","subscription_url":"https://api.github.com/repos/Teradata/stacki/subscription","commits_url":"https://api.github.com/repos/Teradata/stacki/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/stacki/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/stacki/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/stacki/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/stacki/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/stacki/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/stacki/merges","archive_url":"https://api.github.com/repos/Teradata/stacki/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/stacki/downloads","issues_url":"https://api.github.com/repos/Teradata/stacki/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/stacki/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/stacki/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/stacki/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/stacki/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/stacki/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/stacki/deployments","created_at":"2015-05-12T00:43:28Z","updated_at":"2019-09-13T13:55:43Z","pushed_at":"2019-09-19T00:49:43Z","git_url":"git://github.com/Teradata/stacki.git","ssh_url":"git@github.com:Teradata/stacki.git","clone_url":"https://github.com/Teradata/stacki.git","svn_url":"https://github.com/Teradata/stacki","homepage":"","size":1587019,"stargazers_count":200,"watchers_count":200,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":63,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":52,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":63,"open_issues":52,"watchers":200,"default_branch":"master"}},"base":{"label":"Teradata:develop","ref":"develop","sha":"335cc94c46fffcee201e03e6d7616c7075e775f9","user":{"login":"Teradata","id":1615979,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MTU5Nzk=","avatar_url":"https://avatars1.githubusercontent.com/u/1615979?v=4","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":35458005,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ1ODAwNQ==","name":"stacki","full_name":"Teradata/stacki","private":false,"owner":{"login":"Teradata","id":1615979,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2MTU5Nzk=","avatar_url":"https://avatars1.githubusercontent.com/u/1615979?v=4","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Teradata/stacki","description":"Linux Cluster Builder - Bare Metal RedHat & SuSe","fork":false,"url":"https://api.github.com/repos/Teradata/stacki","forks_url":"https://api.github.com/repos/Teradata/stacki/forks","keys_url":"https://api.github.com/repos/Teradata/stacki/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/stacki/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/stacki/teams","hooks_url":"https://api.github.com/repos/Teradata/stacki/hooks","issue_events_url":"https://api.github.com/repos/Teradata/stacki/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/stacki/events","assignees_url":"https://api.github.com/repos/Teradata/stacki/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/stacki/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/stacki/tags","blobs_url":"https://api.github.com/repos/Teradata/stacki/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/stacki/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/stacki/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/stacki/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/stacki/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/stacki/languages","stargazers_url":"https://api.github.com/repos/Teradata/stacki/stargazers","contributors_url":"https://api.github.com/repos/Teradata/stacki/contributors","subscribers_url":"https://api.github.com/repos/Teradata/stacki/subscribers","subscription_url":"https://api.github.com/repos/Teradata/stacki/subscription","commits_url":"https://api.github.com/repos/Teradata/stacki/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/stacki/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/stacki/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/stacki/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/stacki/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/stacki/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/stacki/merges","archive_url":"https://api.github.com/repos/Teradata/stacki/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/stacki/downloads","issues_url":"https://api.github.com/repos/Teradata/stacki/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/stacki/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/stacki/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/stacki/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/stacki/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/stacki/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/stacki/deployments","created_at":"2015-05-12T00:43:28Z","updated_at":"2019-09-13T13:55:43Z","pushed_at":"2019-09-19T00:49:43Z","git_url":"git://github.com/Teradata/stacki.git","ssh_url":"git@github.com:Teradata/stacki.git","clone_url":"https://github.com/Teradata/stacki.git","svn_url":"https://github.com/Teradata/stacki","homepage":"","size":1587019,"stargazers_count":200,"watchers_count":200,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":63,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":52,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":63,"open_issues":52,"watchers":200,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/stacki/pulls/632"},"html":{"href":"https://github.com/Teradata/stacki/pull/632"},"issue":{"href":"https://api.github.com/repos/Teradata/stacki/issues/632"},"comments":{"href":"https://api.github.com/repos/Teradata/stacki/issues/632/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/stacki/pulls/632/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/stacki/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/stacki/pulls/632/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/stacki/statuses/329309bc83894b5fced882646682521db7486851"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bsanders"}}