{"action":"created","comment":{"url":"https://api.github.com/repos/rthallisey/clapper/pulls/comments/49406673","id":49406673,"diff_hunk":"@@ -0,0 +1,59 @@\n+#!/usr/bin/env python\n+\n+from os import path\n+\n+from ansible.module_utils.basic import *\n+\n+\n+def read_int(module, file_path):\n+    '''\n+    Read a file and convert its value to int.\n+\n+    Raise ansible failure otherwise.\n+    '''\n+    try:\n+        with open(file_path) as f:\n+            file_contents = f.read()\n+        return int(file_contents)\n+    except IOError:\n+        module.fail_json(msg=\"Cannot open '%s'\" % file_path)\n+    except ValueError:\n+        module.fail_json(msg=\"The '%s' file doesn't contain an integer value\" %\n+                         file_path)\n+\n+def main():\n+    module = AnsibleModule(argument_spec=dict(\n+        drive=dict(required=True, type='str')\n+    ))\n+\n+    drive = module.params.get('drive')\n+    queue_path = path.join('/sys/class/block', drive, 'queue')\n+\n+    physical_block_size_path = path.join(queue_path, 'physical_block_size')\n+    logical_block_size_path = path.join(queue_path, 'logical_block_size')\n+\n+    physical_block_size = read_int(module, physical_block_size_path)\n+    logical_block_size = read_int(module, logical_block_size_path)\n+\n+    if physical_block_size == logical_block_size:\n+        module.exit_json(\n+            changed=False,\n+            msg=\"The disk %s probably doesn't use Advance Format.\" % drive,\n+        )\n+    else:\n+        module.exit_json(\n+            # NOTE(shadower): we're marking this as `changed`, to make it\n+            # visually stand out when running via Ansible directly instead of\n+            # using the API.\n+            #\n+            # The API & UI is planned to look for the `warnings` field and\n+            # display it differently.\n+            changed=True,\n+            warnings=[\"Physical and logical block sizes of drive %s differ \"\n+            \"(%s vs. %s). This can mean the disk uses Advance Format.\" % (","path":"ansible-tests/validations/library/advanced_format.py","position":53,"original_position":53,"commit_id":"baae0496cfa908d88ff263a6958c853cf1b41433","original_commit_id":"baae0496cfa908d88ff263a6958c853cf1b41433","user":{"login":"mandre","id":225909,"avatar_url":"https://avatars.githubusercontent.com/u/225909?v=3","gravatar_id":"","url":"https://api.github.com/users/mandre","html_url":"https://github.com/mandre","followers_url":"https://api.github.com/users/mandre/followers","following_url":"https://api.github.com/users/mandre/following{/other_user}","gists_url":"https://api.github.com/users/mandre/gists{/gist_id}","starred_url":"https://api.github.com/users/mandre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mandre/subscriptions","organizations_url":"https://api.github.com/users/mandre/orgs","repos_url":"https://api.github.com/users/mandre/repos","events_url":"https://api.github.com/users/mandre/events{/privacy}","received_events_url":"https://api.github.com/users/mandre/received_events","type":"User","site_admin":false},"body":"The validation description (\"Advanced Format is required\") doesn't quite match the actual validation code.","created_at":"2016-01-12T01:47:34Z","updated_at":"2016-01-12T01:47:34Z","html_url":"https://github.com/rthallisey/clapper/pull/32#discussion_r49406673","pull_request_url":"https://api.github.com/repos/rthallisey/clapper/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/rthallisey/clapper/pulls/comments/49406673"},"html":{"href":"https://github.com/rthallisey/clapper/pull/32#discussion_r49406673"},"pull_request":{"href":"https://api.github.com/repos/rthallisey/clapper/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/rthallisey/clapper/pulls/32","id":55469532,"html_url":"https://github.com/rthallisey/clapper/pull/32","diff_url":"https://github.com/rthallisey/clapper/pull/32.diff","patch_url":"https://github.com/rthallisey/clapper/pull/32.patch","issue_url":"https://api.github.com/repos/rthallisey/clapper/issues/32","number":32,"state":"open","locked":false,"title":"Show warning in the Advanced Format validation","user":{"login":"tomassedovic","id":104339,"avatar_url":"https://avatars.githubusercontent.com/u/104339?v=3","gravatar_id":"","url":"https://api.github.com/users/tomassedovic","html_url":"https://github.com/tomassedovic","followers_url":"https://api.github.com/users/tomassedovic/followers","following_url":"https://api.github.com/users/tomassedovic/following{/other_user}","gists_url":"https://api.github.com/users/tomassedovic/gists{/gist_id}","starred_url":"https://api.github.com/users/tomassedovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomassedovic/subscriptions","organizations_url":"https://api.github.com/users/tomassedovic/orgs","repos_url":"https://api.github.com/users/tomassedovic/repos","events_url":"https://api.github.com/users/tomassedovic/events{/privacy}","received_events_url":"https://api.github.com/users/tomassedovic/received_events","type":"User","site_admin":false},"body":"The validation should now more correctly detect advanced format (by\r\ncomparing the physical and logical size) and issues a warning instead of\r\na failure.","created_at":"2016-01-08T14:54:47Z","updated_at":"2016-01-12T01:47:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6248ca70f3e0e19d19170eeb5468435648d46875","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rthallisey/clapper/pulls/32/commits","review_comments_url":"https://api.github.com/repos/rthallisey/clapper/pulls/32/comments","review_comment_url":"https://api.github.com/repos/rthallisey/clapper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rthallisey/clapper/issues/32/comments","statuses_url":"https://api.github.com/repos/rthallisey/clapper/statuses/baae0496cfa908d88ff263a6958c853cf1b41433","head":{"label":"rthallisey:advanced-format","ref":"advanced-format","sha":"baae0496cfa908d88ff263a6958c853cf1b41433","user":{"login":"rthallisey","id":6795213,"avatar_url":"https://avatars.githubusercontent.com/u/6795213?v=3","gravatar_id":"","url":"https://api.github.com/users/rthallisey","html_url":"https://github.com/rthallisey","followers_url":"https://api.github.com/users/rthallisey/followers","following_url":"https://api.github.com/users/rthallisey/following{/other_user}","gists_url":"https://api.github.com/users/rthallisey/gists{/gist_id}","starred_url":"https://api.github.com/users/rthallisey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rthallisey/subscriptions","organizations_url":"https://api.github.com/users/rthallisey/orgs","repos_url":"https://api.github.com/users/rthallisey/repos","events_url":"https://api.github.com/users/rthallisey/events{/privacy}","received_events_url":"https://api.github.com/users/rthallisey/received_events","type":"User","site_admin":false},"repo":{"id":39218737,"name":"clapper","full_name":"rthallisey/clapper","owner":{"login":"rthallisey","id":6795213,"avatar_url":"https://avatars.githubusercontent.com/u/6795213?v=3","gravatar_id":"","url":"https://api.github.com/users/rthallisey","html_url":"https://github.com/rthallisey","followers_url":"https://api.github.com/users/rthallisey/followers","following_url":"https://api.github.com/users/rthallisey/following{/other_user}","gists_url":"https://api.github.com/users/rthallisey/gists{/gist_id}","starred_url":"https://api.github.com/users/rthallisey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rthallisey/subscriptions","organizations_url":"https://api.github.com/users/rthallisey/orgs","repos_url":"https://api.github.com/users/rthallisey/repos","events_url":"https://api.github.com/users/rthallisey/events{/privacy}","received_events_url":"https://api.github.com/users/rthallisey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rthallisey/clapper","description":"Synchronize setup and deployment for the Director.","fork":false,"url":"https://api.github.com/repos/rthallisey/clapper","forks_url":"https://api.github.com/repos/rthallisey/clapper/forks","keys_url":"https://api.github.com/repos/rthallisey/clapper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rthallisey/clapper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rthallisey/clapper/teams","hooks_url":"https://api.github.com/repos/rthallisey/clapper/hooks","issue_events_url":"https://api.github.com/repos/rthallisey/clapper/issues/events{/number}","events_url":"https://api.github.com/repos/rthallisey/clapper/events","assignees_url":"https://api.github.com/repos/rthallisey/clapper/assignees{/user}","branches_url":"https://api.github.com/repos/rthallisey/clapper/branches{/branch}","tags_url":"https://api.github.com/repos/rthallisey/clapper/tags","blobs_url":"https://api.github.com/repos/rthallisey/clapper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rthallisey/clapper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rthallisey/clapper/git/refs{/sha}","trees_url":"https://api.github.com/repos/rthallisey/clapper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rthallisey/clapper/statuses/{sha}","languages_url":"https://api.github.com/repos/rthallisey/clapper/languages","stargazers_url":"https://api.github.com/repos/rthallisey/clapper/stargazers","contributors_url":"https://api.github.com/repos/rthallisey/clapper/contributors","subscribers_url":"https://api.github.com/repos/rthallisey/clapper/subscribers","subscription_url":"https://api.github.com/repos/rthallisey/clapper/subscription","commits_url":"https://api.github.com/repos/rthallisey/clapper/commits{/sha}","git_commits_url":"https://api.github.com/repos/rthallisey/clapper/git/commits{/sha}","comments_url":"https://api.github.com/repos/rthallisey/clapper/comments{/number}","issue_comment_url":"https://api.github.com/repos/rthallisey/clapper/issues/comments{/number}","contents_url":"https://api.github.com/repos/rthallisey/clapper/contents/{+path}","compare_url":"https://api.github.com/repos/rthallisey/clapper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rthallisey/clapper/merges","archive_url":"https://api.github.com/repos/rthallisey/clapper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rthallisey/clapper/downloads","issues_url":"https://api.github.com/repos/rthallisey/clapper/issues{/number}","pulls_url":"https://api.github.com/repos/rthallisey/clapper/pulls{/number}","milestones_url":"https://api.github.com/repos/rthallisey/clapper/milestones{/number}","notifications_url":"https://api.github.com/repos/rthallisey/clapper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rthallisey/clapper/labels{/name}","releases_url":"https://api.github.com/repos/rthallisey/clapper/releases{/id}","created_at":"2015-07-16T20:24:08Z","updated_at":"2016-01-05T17:53:23Z","pushed_at":"2016-01-08T14:54:48Z","git_url":"git://github.com/rthallisey/clapper.git","ssh_url":"git@github.com:rthallisey/clapper.git","clone_url":"https://github.com/rthallisey/clapper.git","svn_url":"https://github.com/rthallisey/clapper","homepage":null,"size":151,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"rthallisey:master","ref":"master","sha":"6107c2339cbe358091f3ac0f36e1da966c6dac0f","user":{"login":"rthallisey","id":6795213,"avatar_url":"https://avatars.githubusercontent.com/u/6795213?v=3","gravatar_id":"","url":"https://api.github.com/users/rthallisey","html_url":"https://github.com/rthallisey","followers_url":"https://api.github.com/users/rthallisey/followers","following_url":"https://api.github.com/users/rthallisey/following{/other_user}","gists_url":"https://api.github.com/users/rthallisey/gists{/gist_id}","starred_url":"https://api.github.com/users/rthallisey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rthallisey/subscriptions","organizations_url":"https://api.github.com/users/rthallisey/orgs","repos_url":"https://api.github.com/users/rthallisey/repos","events_url":"https://api.github.com/users/rthallisey/events{/privacy}","received_events_url":"https://api.github.com/users/rthallisey/received_events","type":"User","site_admin":false},"repo":{"id":39218737,"name":"clapper","full_name":"rthallisey/clapper","owner":{"login":"rthallisey","id":6795213,"avatar_url":"https://avatars.githubusercontent.com/u/6795213?v=3","gravatar_id":"","url":"https://api.github.com/users/rthallisey","html_url":"https://github.com/rthallisey","followers_url":"https://api.github.com/users/rthallisey/followers","following_url":"https://api.github.com/users/rthallisey/following{/other_user}","gists_url":"https://api.github.com/users/rthallisey/gists{/gist_id}","starred_url":"https://api.github.com/users/rthallisey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rthallisey/subscriptions","organizations_url":"https://api.github.com/users/rthallisey/orgs","repos_url":"https://api.github.com/users/rthallisey/repos","events_url":"https://api.github.com/users/rthallisey/events{/privacy}","received_events_url":"https://api.github.com/users/rthallisey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rthallisey/clapper","description":"Synchronize setup and deployment for the Director.","fork":false,"url":"https://api.github.com/repos/rthallisey/clapper","forks_url":"https://api.github.com/repos/rthallisey/clapper/forks","keys_url":"https://api.github.com/repos/rthallisey/clapper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rthallisey/clapper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rthallisey/clapper/teams","hooks_url":"https://api.github.com/repos/rthallisey/clapper/hooks","issue_events_url":"https://api.github.com/repos/rthallisey/clapper/issues/events{/number}","events_url":"https://api.github.com/repos/rthallisey/clapper/events","assignees_url":"https://api.github.com/repos/rthallisey/clapper/assignees{/user}","branches_url":"https://api.github.com/repos/rthallisey/clapper/branches{/branch}","tags_url":"https://api.github.com/repos/rthallisey/clapper/tags","blobs_url":"https://api.github.com/repos/rthallisey/clapper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rthallisey/clapper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rthallisey/clapper/git/refs{/sha}","trees_url":"https://api.github.com/repos/rthallisey/clapper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rthallisey/clapper/statuses/{sha}","languages_url":"https://api.github.com/repos/rthallisey/clapper/languages","stargazers_url":"https://api.github.com/repos/rthallisey/clapper/stargazers","contributors_url":"https://api.github.com/repos/rthallisey/clapper/contributors","subscribers_url":"https://api.github.com/repos/rthallisey/clapper/subscribers","subscription_url":"https://api.github.com/repos/rthallisey/clapper/subscription","commits_url":"https://api.github.com/repos/rthallisey/clapper/commits{/sha}","git_commits_url":"https://api.github.com/repos/rthallisey/clapper/git/commits{/sha}","comments_url":"https://api.github.com/repos/rthallisey/clapper/comments{/number}","issue_comment_url":"https://api.github.com/repos/rthallisey/clapper/issues/comments{/number}","contents_url":"https://api.github.com/repos/rthallisey/clapper/contents/{+path}","compare_url":"https://api.github.com/repos/rthallisey/clapper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rthallisey/clapper/merges","archive_url":"https://api.github.com/repos/rthallisey/clapper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rthallisey/clapper/downloads","issues_url":"https://api.github.com/repos/rthallisey/clapper/issues{/number}","pulls_url":"https://api.github.com/repos/rthallisey/clapper/pulls{/number}","milestones_url":"https://api.github.com/repos/rthallisey/clapper/milestones{/number}","notifications_url":"https://api.github.com/repos/rthallisey/clapper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rthallisey/clapper/labels{/name}","releases_url":"https://api.github.com/repos/rthallisey/clapper/releases{/id}","created_at":"2015-07-16T20:24:08Z","updated_at":"2016-01-05T17:53:23Z","pushed_at":"2016-01-08T14:54:48Z","git_url":"git://github.com/rthallisey/clapper.git","ssh_url":"git@github.com:rthallisey/clapper.git","clone_url":"https://github.com/rthallisey/clapper.git","svn_url":"https://github.com/rthallisey/clapper","homepage":null,"size":151,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rthallisey/clapper/pulls/32"},"html":{"href":"https://github.com/rthallisey/clapper/pull/32"},"issue":{"href":"https://api.github.com/repos/rthallisey/clapper/issues/32"},"comments":{"href":"https://api.github.com/repos/rthallisey/clapper/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/rthallisey/clapper/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/rthallisey/clapper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rthallisey/clapper/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/rthallisey/clapper/statuses/baae0496cfa908d88ff263a6958c853cf1b41433"}}}}