{"action":"created","comment":{"url":"https://api.github.com/repos/ansible/ansible/pulls/comments/115594617","pull_request_review_id":37146495,"id":115594617,"diff_hunk":"@@ -0,0 +1,142 @@\n+from __future__ import (absolute_import, division, print_function)\n+__metaclass__ = type\n+\n+import os\n+import re\n+\n+from ansible.module_utils.facts.hardware.base import Hardware\n+from ansible.module_utils.facts.timeout import TimeoutError, timeout\n+\n+from ansible.module_utils.facts.utils import get_file_content, get_file_lines, get_mount_size\n+from ansible.module_utils.facts.sysctl import get_sysctl\n+\n+\n+class NetBSDHardware(Hardware):\n+    \"\"\"\n+    NetBSD-specific subclass of Hardware.  Defines memory and CPU facts:\n+    - memfree_mb\n+    - memtotal_mb\n+    - swapfree_mb\n+    - swaptotal_mb\n+    - processor (a list)\n+    - processor_cores\n+    - processor_count\n+    - devices\n+    \"\"\"\n+    platform = 'NetBSD'\n+    MEMORY_FACTS = ['MemTotal', 'SwapTotal', 'MemFree', 'SwapFree']\n+\n+    def populate(self, collected_facts=None):\n+        hardware_facts = {}\n+        self.sysctl = get_sysctl(self.module, ['machdep'])\n+        cpu_facts = self.get_cpu_facts()\n+        memory_facts = self.get_memory_facts()\n+\n+        mount_facts = {}\n+        try:\n+            mount_facts = self.get_mount_facts()\n+        except TimeoutError:\n+            pass\n+\n+        dmi_facts = self.get_dmi_facts()\n+\n+        hardware_facts.update(cpu_facts)\n+        hardware_facts.update(memory_facts)\n+        hardware_facts.update(mount_facts)\n+        hardware_facts.update(dmi_facts)\n+\n+        return hardware_facts\n+\n+    def get_cpu_facts(self):\n+        cpu_facts = {}\n+\n+        i = 0\n+        physid = 0\n+        sockets = {}\n+        if not os.access(\"/proc/cpuinfo\", os.R_OK):\n+            return cpu_facts\n+        cpu_facts['processor'] = []\n+        for line in get_file_lines(\"/proc/cpuinfo\"):\n+            data = line.split(\":\", 1)\n+            key = data[0].strip()\n+            # model name is for Intel arch, Processor (mind the uppercase P)\n+            # works for some ARM devices, like the Sheevaplug.\n+            if key == 'model name' or key == 'Processor':\n+                if 'processor' not in cpu_facts:\n+                    cpu_facts['processor'] = []\n+                cpu_facts['processor'].append(data[1].strip())\n+                i += 1\n+            elif key == 'physical id':\n+                physid = data[1].strip()\n+                if physid not in sockets:\n+                    sockets[physid] = 1\n+            elif key == 'cpu cores':\n+                sockets[physid] = int(data[1].strip())\n+        if len(sockets) > 0:\n+            cpu_facts['processor_count'] = len(sockets)\n+            cpu_facts['processor_cores'] = reduce(lambda x, y: x + y, sockets.values())","path":"lib/ansible/module_utils/facts/hardware/netbsd.py","position":77,"original_position":77,"commit_id":"de798250c94f6b2c38b6cfcc95f1759ef1c64c20","original_commit_id":"42112f2972439bfebda1e9ddef524c9e0d8062d0","user":{"login":"abadger","id":209242,"avatar_url":"https://avatars1.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"body":"Need to import reduce from ansible.module_utils.six.moves.","created_at":"2017-05-09T20:31:15Z","updated_at":"2017-05-09T20:31:15Z","html_url":"https://github.com/ansible/ansible/pull/23012#discussion_r115594617","pull_request_url":"https://api.github.com/repos/ansible/ansible/pulls/23012","_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments/115594617"},"html":{"href":"https://github.com/ansible/ansible/pull/23012#discussion_r115594617"},"pull_request":{"href":"https://api.github.com/repos/ansible/ansible/pulls/23012"}}},"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/23012","id":112838160,"html_url":"https://github.com/ansible/ansible/pull/23012","diff_url":"https://github.com/ansible/ansible/pull/23012.diff","patch_url":"https://github.com/ansible/ansible/pull/23012.patch","issue_url":"https://api.github.com/repos/ansible/ansible/issues/23012","number":23012,"state":"open","locked":false,"title":"[WIP] Facts refactor","user":{"login":"alikins","id":15162,"avatar_url":"https://avatars3.githubusercontent.com/u/15162?v=3","gravatar_id":"","url":"https://api.github.com/users/alikins","html_url":"https://github.com/alikins","followers_url":"https://api.github.com/users/alikins/followers","following_url":"https://api.github.com/users/alikins/following{/other_user}","gists_url":"https://api.github.com/users/alikins/gists{/gist_id}","starred_url":"https://api.github.com/users/alikins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikins/subscriptions","organizations_url":"https://api.github.com/users/alikins/orgs","repos_url":"https://api.github.com/users/alikins/repos","events_url":"https://api.github.com/users/alikins/events{/privacy}","received_events_url":"https://api.github.com/users/alikins/received_events","type":"User","site_admin":false},"body":"##### SUMMARY\r\nwip of making facts.py more modular (using feature available via ansiballz and module_utils plugins) and testable. Also first steps towards pluggable facts.\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Feature Pull Request\r\n - Bugfix Pull Request\r\n\r\n##### COMPONENT NAME\r\n<!--- Name of the module/plugin/module/task -->\r\nlib/ansible/module_utils/facts.py\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 2.4.0 (facts_notes 8ebd5ab3ba) last updated 2017/03/27 16:52:56 (GMT -400)\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n  python version = 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]\r\n\r\n```\r\n\r\n\r\n##### ADDITIONAL INFORMATION\r\n<!---\r\nInclude additional information to help people understand the change here.\r\nFor bugs that don't have a linked bug report, a step-by-step reproduction\r\nof the problem is helpful.\r\n  -->\r\n\r\n<!--- Paste verbatim command output below, e.g. before and after your change -->\r\n```\r\n\r\n```\r\n","created_at":"2017-03-27T21:03:00Z","updated_at":"2017-05-09T20:31:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c5ec14e35dcd3711fa63ad060e86dc83bd10be26","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible/pulls/23012/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible/pulls/23012/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/23012/comments","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/de798250c94f6b2c38b6cfcc95f1759ef1c64c20","head":{"label":"alikins:facts_notes","ref":"facts_notes","sha":"de798250c94f6b2c38b6cfcc95f1759ef1c64c20","user":{"login":"alikins","id":15162,"avatar_url":"https://avatars3.githubusercontent.com/u/15162?v=3","gravatar_id":"","url":"https://api.github.com/users/alikins","html_url":"https://github.com/alikins","followers_url":"https://api.github.com/users/alikins/followers","following_url":"https://api.github.com/users/alikins/following{/other_user}","gists_url":"https://api.github.com/users/alikins/gists{/gist_id}","starred_url":"https://api.github.com/users/alikins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikins/subscriptions","organizations_url":"https://api.github.com/users/alikins/orgs","repos_url":"https://api.github.com/users/alikins/repos","events_url":"https://api.github.com/users/alikins/events{/privacy}","received_events_url":"https://api.github.com/users/alikins/received_events","type":"User","site_admin":false},"repo":{"id":54061420,"name":"ansible","full_name":"alikins/ansible","owner":{"login":"alikins","id":15162,"avatar_url":"https://avatars3.githubusercontent.com/u/15162?v=3","gravatar_id":"","url":"https://api.github.com/users/alikins","html_url":"https://github.com/alikins","followers_url":"https://api.github.com/users/alikins/followers","following_url":"https://api.github.com/users/alikins/following{/other_user}","gists_url":"https://api.github.com/users/alikins/gists{/gist_id}","starred_url":"https://api.github.com/users/alikins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikins/subscriptions","organizations_url":"https://api.github.com/users/alikins/orgs","repos_url":"https://api.github.com/users/alikins/repos","events_url":"https://api.github.com/users/alikins/events{/privacy}","received_events_url":"https://api.github.com/users/alikins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alikins/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.","fork":true,"url":"https://api.github.com/repos/alikins/ansible","forks_url":"https://api.github.com/repos/alikins/ansible/forks","keys_url":"https://api.github.com/repos/alikins/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alikins/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alikins/ansible/teams","hooks_url":"https://api.github.com/repos/alikins/ansible/hooks","issue_events_url":"https://api.github.com/repos/alikins/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/alikins/ansible/events","assignees_url":"https://api.github.com/repos/alikins/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/alikins/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/alikins/ansible/tags","blobs_url":"https://api.github.com/repos/alikins/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alikins/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alikins/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/alikins/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alikins/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/alikins/ansible/languages","stargazers_url":"https://api.github.com/repos/alikins/ansible/stargazers","contributors_url":"https://api.github.com/repos/alikins/ansible/contributors","subscribers_url":"https://api.github.com/repos/alikins/ansible/subscribers","subscription_url":"https://api.github.com/repos/alikins/ansible/subscription","commits_url":"https://api.github.com/repos/alikins/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/alikins/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/alikins/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/alikins/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/alikins/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/alikins/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alikins/ansible/merges","archive_url":"https://api.github.com/repos/alikins/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alikins/ansible/downloads","issues_url":"https://api.github.com/repos/alikins/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/alikins/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/alikins/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/alikins/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alikins/ansible/labels{/name}","releases_url":"https://api.github.com/repos/alikins/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/alikins/ansible/deployments","created_at":"2016-03-16T19:41:33Z","updated_at":"2016-11-01T16:01:23Z","pushed_at":"2017-05-09T20:28:29Z","git_url":"git://github.com/alikins/ansible.git","ssh_url":"git@github.com:alikins/ansible.git","clone_url":"https://github.com/alikins/ansible.git","svn_url":"https://github.com/alikins/ansible","homepage":"http://ansible.com/","size":75488,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"192606c59289db65fa69270d2b2297b89a65d118","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars1.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":3638964,"name":"ansible","full_name":"ansible/ansible","owner":{"login":"ansible","id":1507452,"avatar_url":"https://avatars1.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.","fork":false,"url":"https://api.github.com/repos/ansible/ansible","forks_url":"https://api.github.com/repos/ansible/ansible/forks","keys_url":"https://api.github.com/repos/ansible/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible/teams","hooks_url":"https://api.github.com/repos/ansible/ansible/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible/events","assignees_url":"https://api.github.com/repos/ansible/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible/tags","blobs_url":"https://api.github.com/repos/ansible/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible/subscription","commits_url":"https://api.github.com/repos/ansible/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible/merges","archive_url":"https://api.github.com/repos/ansible/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible/downloads","issues_url":"https://api.github.com/repos/ansible/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/ansible/ansible/deployments","created_at":"2012-03-06T14:58:02Z","updated_at":"2017-05-09T19:42:37Z","pushed_at":"2017-05-09T20:28:32Z","git_url":"git://github.com/ansible/ansible.git","ssh_url":"git@github.com:ansible/ansible.git","clone_url":"https://github.com/ansible/ansible.git","svn_url":"https://github.com/ansible/ansible","homepage":"http://ansible.com/","size":73015,"stargazers_count":23016,"watchers_count":23016,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7648,"mirror_url":null,"open_issues_count":3053,"forks":7648,"open_issues":3053,"watchers":23016,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/23012"},"html":{"href":"https://github.com/ansible/ansible/pull/23012"},"issue":{"href":"https://api.github.com/repos/ansible/ansible/issues/23012"},"comments":{"href":"https://api.github.com/repos/ansible/ansible/issues/23012/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible/pulls/23012/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible/pulls/23012/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible/statuses/de798250c94f6b2c38b6cfcc95f1759ef1c64c20"}}}}
{"actor":{"display_login":"abadger"}}