{"action":"created","comment":{"url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/comments/50372385","id":50372385,"diff_hunk":"@@ -0,0 +1,101 @@\n+class Puppet::Provider::Gluster < Puppet::Provider\n+\n+  # NOTE: This assumes that child providers define a `gluster` command:\n+  #\n+  # has_command(:gluster, 'gluster') do\n+  #   environment :HOME => \"/tmp\"\n+  # end\n+\n+  # Peer information\n+\n+  def self.parse_peer_status(output)\n+    doc = REXML::Document.new(output)\n+    xpath_match(doc, \"/cliOutput/peerStatus/peer/hostname/text()\")\n+  end\n+\n+  def self.all_peers\n+    parse_peer_status(gluster(\"peer\", \"status\", \"--xml\"))\n+  end\n+\n+  def self.peers_present(required_peers)\n+    peers = all_peers\n+    missing_peers = required_peers - peers\n+    if (required_peers - all_peers).empty?\n+      true\n+    else\n+      debug(\"Missing required peers: #{missing_peers.join(', ')}\")\n+      false\n+    end\n+  end\n+\n+  # Volume information\n+\n+  def self.parse_volume_info(output)\n+    doc = REXML::Document.new(output)\n+    xpath_match(doc, \"/cliOutput/volInfo/volumes/volume\").map do |vol|\n+      extract_volume_info(vol)\n+    end\n+  end\n+\n+  def self.volume_status(status_str)\n+    case status_str\n+    when \"Created\"\n+      :stopped\n+    when \"Stopped\"\n+      :stopped\n+    when \"Started\"\n+      :started\n+    else\n+      alert(\"Unknown volume status: #{status_str}\")\n+      :unknown\n+    end\n+  end\n+\n+  def self.brick_peers(bricks)\n+    bricks.map { |brick| brick.split(\":\")[0] }.uniq\n+  end\n+\n+  def self.extract_volume_info(vol_xml)\n+    vol = {\n+      :name => xpath_first(vol_xml, \"name/text()\"),\n+      :status => volume_status(xpath_first(vol_xml, \"statusStr/text()\")),\n+    }\n+    vol[:bricks] = xpath_match(vol_xml, \"bricks/brick/name/text()\")\n+    vol[:peers] = brick_peers(vol[:bricks])\n+    if vol[:status] == :started\n+      vol[:ensure] = :present\n+    else\n+      vol[:ensure] = vol[:status]\n+    end\n+    vol\n+  end\n+\n+  def self.all_volumes\n+    output = gluster(\"volume\", \"info\", \"all\", \"--xml\")\n+    parse_volume_info(output)\n+  end\n+\n+  def get_volume_info(name)\n+    vols = self.class.all_volumes.select { |v| v[:name] == name }\n+    vols.first","path":"lib/puppet/provider/gluster.rb","position":80,"original_position":80,"commit_id":"19d26d9b3e62f4deef58a9e659400ffe6c1482bb","original_commit_id":"19d26d9b3e62f4deef58a9e659400ffe6c1482bb","user":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"body":"Actually, I can use the single-volume version of this in combination with `.first`. That's probably a better idea.","created_at":"2016-01-21T08:38:43Z","updated_at":"2016-01-21T08:38:43Z","html_url":"https://github.com/praekeltfoundation/puppet-gluster/pull/1#discussion_r50372385","pull_request_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/comments/50372385"},"html":{"href":"https://github.com/praekeltfoundation/puppet-gluster/pull/1#discussion_r50372385"},"pull_request":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1","id":56623242,"html_url":"https://github.com/praekeltfoundation/puppet-gluster/pull/1","diff_url":"https://github.com/praekeltfoundation/puppet-gluster/pull/1.diff","patch_url":"https://github.com/praekeltfoundation/puppet-gluster/pull/1.patch","issue_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/1","number":1,"state":"open","locked":false,"title":"Something from nothing","user":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"body":"First steps toward a usable gluster module.","created_at":"2016-01-20T15:33:05Z","updated_at":"2016-01-21T08:38:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba80240a9533701ad7b07d31f833d38444a4b286","assignee":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1/commits","review_comments_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1/comments","review_comment_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/1/comments","statuses_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/statuses/19d26d9b3e62f4deef58a9e659400ffe6c1482bb","head":{"label":"praekeltfoundation:feature/issue-1-something-from-nothing","ref":"feature/issue-1-something-from-nothing","sha":"19d26d9b3e62f4deef58a9e659400ffe6c1482bb","user":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":50038911,"name":"puppet-gluster","full_name":"praekeltfoundation/puppet-gluster","owner":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekeltfoundation/puppet-gluster","description":"Puppet module for managing glusterfs","fork":false,"url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster","forks_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/forks","keys_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/teams","hooks_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/hooks","issue_events_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/events{/number}","events_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/events","assignees_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/assignees{/user}","branches_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/branches{/branch}","tags_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/tags","blobs_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/statuses/{sha}","languages_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/languages","stargazers_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/stargazers","contributors_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/contributors","subscribers_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/subscribers","subscription_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/subscription","commits_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/contents/{+path}","compare_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/merges","archive_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/downloads","issues_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues{/number}","pulls_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls{/number}","milestones_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/milestones{/number}","notifications_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/labels{/name}","releases_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/releases{/id}","created_at":"2016-01-20T15:24:55Z","updated_at":"2016-01-20T15:24:55Z","pushed_at":"2016-01-20T16:31:19Z","git_url":"git://github.com/praekeltfoundation/puppet-gluster.git","ssh_url":"git@github.com:praekeltfoundation/puppet-gluster.git","clone_url":"https://github.com/praekeltfoundation/puppet-gluster.git","svn_url":"https://github.com/praekeltfoundation/puppet-gluster","homepage":null,"size":9,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"praekeltfoundation:develop","ref":"develop","sha":"c907835b74f75a0eaa5074dce9ad481d9c57b227","user":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":50038911,"name":"puppet-gluster","full_name":"praekeltfoundation/puppet-gluster","owner":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekeltfoundation/puppet-gluster","description":"Puppet module for managing glusterfs","fork":false,"url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster","forks_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/forks","keys_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/teams","hooks_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/hooks","issue_events_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/events{/number}","events_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/events","assignees_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/assignees{/user}","branches_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/branches{/branch}","tags_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/tags","blobs_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/statuses/{sha}","languages_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/languages","stargazers_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/stargazers","contributors_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/contributors","subscribers_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/subscribers","subscription_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/subscription","commits_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/contents/{+path}","compare_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/merges","archive_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/downloads","issues_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues{/number}","pulls_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls{/number}","milestones_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/milestones{/number}","notifications_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/labels{/name}","releases_url":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/releases{/id}","created_at":"2016-01-20T15:24:55Z","updated_at":"2016-01-20T15:24:55Z","pushed_at":"2016-01-20T16:31:19Z","git_url":"git://github.com/praekeltfoundation/puppet-gluster.git","ssh_url":"git@github.com:praekeltfoundation/puppet-gluster.git","clone_url":"https://github.com/praekeltfoundation/puppet-gluster.git","svn_url":"https://github.com/praekeltfoundation/puppet-gluster","homepage":null,"size":9,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1"},"html":{"href":"https://github.com/praekeltfoundation/puppet-gluster/pull/1"},"issue":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/1"},"comments":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/praekeltfoundation/puppet-gluster/statuses/19d26d9b3e62f4deef58a9e659400ffe6c1482bb"}}}}