{"action":"created","comment":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/84092840","pull_request_review_id":4891912,"id":84092840,"diff_hunk":"@@ -0,0 +1,188 @@\n+# This program is free software; you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation; either version 2 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n+#\n+# See LICENSE for more details.\n+#\n+# Copyright: 2016 IBM\n+# Author: Narasimhan V <sim@linux.vnet.ibm.com>\n+\n+\"\"\"\n+Module with multipath related utility functions\n+\"\"\"\n+\n+import time\n+from . import distro\n+from . import process\n+\n+\n+class MultipathError(Exception):\n+    \"\"\"\n+    Multipath Error\n+    \"\"\"\n+\n+    def __init__(self, msg):\n+        self.msg = msg\n+\n+    def __str__(self):\n+        return self.msg\n+\n+\n+def form_conf_mpath_file(blacklist=\"\", defaults_extra=\"\"):\n+    \"\"\"\n+    Form a multipath configuration file, and restart multipath service.\n+\n+    :parm blacklist: Entry in conf file to indicate blacklist section.\n+    :parm defaults_extra: Extra entry in conf file in defaults section.\n+    \"\"\"\n+    mpath_fp = open(\"/etc/multipath.conf\", \"w\")\n+    mpath_fp.write(\"defaults {\\n\")\n+    mpath_fp.write(\"    find_multipaths yes\\n\")\n+    mpath_fp.write(\"    user_friendly_names yes\\n\")\n+    if defaults_extra:\n+        mpath_fp.write(\"    %s\\n\" % defaults_extra)\n+    mpath_fp.write(\"}\\n\")\n+    if blacklist:\n+        mpath_fp.write(\"blacklist {\\n\")\n+        mpath_fp.write(\"    %s\\n\" % blacklist)\n+        mpath_fp.write(\"}\\n\")\n+    mpath_fp.close()\n+    cmd = \"cat /etc/multipath.conf\"\n+    process.system(cmd, ignore_status=True)\n+    multipath_service(operation='restart')\n+\n+\n+def multipath_service(operation='restart'):\n+    \"\"\"\n+    Start, Stop, Restart multipath service.\n+\n+    :parm operation: multipath service operation to perform.\n+                     Can be one of start, stop, restart.\n+\n+    :raise: :class:`MultipathError`, if ``multipath is inactive``.\n+    \"\"\"\n+    if distro.detect().name == 'Ubuntu':\n+        service_name = \"multipath-tools\"\n+    else:\n+        service_name = \"multipathd\"\n+    cmd = \"service %s %s\" % (service_name, operation)\n+    time.sleep(5)\n+    process.system(cmd, ignore_status=True)\n+    if 'start' in operation and not multipath_isactive():\n+        cmd = \"cat /etc/multipath.conf\"\n+        process.system(cmd, ignore_status=True)\n+        raise MultipathError(\"Multipath service not active\")\n+\n+\n+def multipath_isactive():\n+    \"\"\"\n+    Checks if multipath service is active or not.\n+\n+    :return: True if service is active, False if inactive.\n+    \"\"\"\n+    if distro.detect().name == 'Ubuntu':\n+        service_name = \"multipath-tools\"\n+    else:\n+        service_name = \"multipathd\"\n+    cmd = \"service %s status\" % service_name\n+    out = process.system_output(cmd, ignore_status=True)\n+    for line in out.splitlines():\n+        if 'Active' in line:\n+            return line.split()[1] == 'active'","path":"avocado/utils/multipath.py","position":96,"original_position":96,"commit_id":"355ef28107bbabee846da6a9f8310fd5e911534a","original_commit_id":"355ef28107bbabee846da6a9f8310fd5e911534a","user":{"login":"narasimhan-v","id":16101053,"avatar_url":"https://avatars.githubusercontent.com/u/16101053?v=3","gravatar_id":"","url":"https://api.github.com/users/narasimhan-v","html_url":"https://github.com/narasimhan-v","followers_url":"https://api.github.com/users/narasimhan-v/followers","following_url":"https://api.github.com/users/narasimhan-v/following{/other_user}","gists_url":"https://api.github.com/users/narasimhan-v/gists{/gist_id}","starred_url":"https://api.github.com/users/narasimhan-v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narasimhan-v/subscriptions","organizations_url":"https://api.github.com/users/narasimhan-v/orgs","repos_url":"https://api.github.com/users/narasimhan-v/repos","events_url":"https://api.github.com/users/narasimhan-v/events{/privacy}","received_events_url":"https://api.github.com/users/narasimhan-v/received_events","type":"User","site_admin":false},"body":"@lmr @ldoktor Yes, `avocado.utils.service` solves this purpose","created_at":"2016-10-19T15:08:58Z","updated_at":"2016-10-19T15:08:59Z","html_url":"https://github.com/avocado-framework/avocado/pull/1547#discussion_r84092840","pull_request_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547","_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/84092840"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/1547#discussion_r84092840"},"pull_request":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547"}}},"pull_request":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547","id":89975417,"html_url":"https://github.com/avocado-framework/avocado/pull/1547","diff_url":"https://github.com/avocado-framework/avocado/pull/1547.diff","patch_url":"https://github.com/avocado-framework/avocado/pull/1547.patch","issue_url":"https://api.github.com/repos/avocado-framework/avocado/issues/1547","number":1547,"state":"open","locked":false,"title":"Adding Multipath Module","user":{"login":"narasimhan-v","id":16101053,"avatar_url":"https://avatars.githubusercontent.com/u/16101053?v=3","gravatar_id":"","url":"https://api.github.com/users/narasimhan-v","html_url":"https://github.com/narasimhan-v","followers_url":"https://api.github.com/users/narasimhan-v/followers","following_url":"https://api.github.com/users/narasimhan-v/following{/other_user}","gists_url":"https://api.github.com/users/narasimhan-v/gists{/gist_id}","starred_url":"https://api.github.com/users/narasimhan-v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narasimhan-v/subscriptions","organizations_url":"https://api.github.com/users/narasimhan-v/orgs","repos_url":"https://api.github.com/users/narasimhan-v/repos","events_url":"https://api.github.com/users/narasimhan-v/events{/privacy}","received_events_url":"https://api.github.com/users/narasimhan-v/received_events","type":"User","site_admin":false},"body":"avocado.utils.multipath: Adds multipath related modules.\r\n\r\nSigned-off-by: Narasimhan V <sim@linux.vnet.ibm.com>","created_at":"2016-10-19T09:49:25Z","updated_at":"2016-10-19T15:08:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"419326da9335b2fa11fc6f82d2dc3bb655eadfd9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547/commits","review_comments_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547/comments","review_comment_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/issues/1547/comments","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/355ef28107bbabee846da6a9f8310fd5e911534a","head":{"label":"narasimhan-v:multipath","ref":"multipath","sha":"355ef28107bbabee846da6a9f8310fd5e911534a","user":{"login":"narasimhan-v","id":16101053,"avatar_url":"https://avatars.githubusercontent.com/u/16101053?v=3","gravatar_id":"","url":"https://api.github.com/users/narasimhan-v","html_url":"https://github.com/narasimhan-v","followers_url":"https://api.github.com/users/narasimhan-v/followers","following_url":"https://api.github.com/users/narasimhan-v/following{/other_user}","gists_url":"https://api.github.com/users/narasimhan-v/gists{/gist_id}","starred_url":"https://api.github.com/users/narasimhan-v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narasimhan-v/subscriptions","organizations_url":"https://api.github.com/users/narasimhan-v/orgs","repos_url":"https://api.github.com/users/narasimhan-v/repos","events_url":"https://api.github.com/users/narasimhan-v/events{/privacy}","received_events_url":"https://api.github.com/users/narasimhan-v/received_events","type":"User","site_admin":false},"repo":{"id":57944657,"name":"avocado","full_name":"narasimhan-v/avocado","owner":{"login":"narasimhan-v","id":16101053,"avatar_url":"https://avatars.githubusercontent.com/u/16101053?v=3","gravatar_id":"","url":"https://api.github.com/users/narasimhan-v","html_url":"https://github.com/narasimhan-v","followers_url":"https://api.github.com/users/narasimhan-v/followers","following_url":"https://api.github.com/users/narasimhan-v/following{/other_user}","gists_url":"https://api.github.com/users/narasimhan-v/gists{/gist_id}","starred_url":"https://api.github.com/users/narasimhan-v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narasimhan-v/subscriptions","organizations_url":"https://api.github.com/users/narasimhan-v/orgs","repos_url":"https://api.github.com/users/narasimhan-v/repos","events_url":"https://api.github.com/users/narasimhan-v/events{/privacy}","received_events_url":"https://api.github.com/users/narasimhan-v/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/narasimhan-v/avocado","description":"Avocado Test Framework","fork":true,"url":"https://api.github.com/repos/narasimhan-v/avocado","forks_url":"https://api.github.com/repos/narasimhan-v/avocado/forks","keys_url":"https://api.github.com/repos/narasimhan-v/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/narasimhan-v/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/narasimhan-v/avocado/teams","hooks_url":"https://api.github.com/repos/narasimhan-v/avocado/hooks","issue_events_url":"https://api.github.com/repos/narasimhan-v/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/narasimhan-v/avocado/events","assignees_url":"https://api.github.com/repos/narasimhan-v/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/narasimhan-v/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/narasimhan-v/avocado/tags","blobs_url":"https://api.github.com/repos/narasimhan-v/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/narasimhan-v/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/narasimhan-v/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/narasimhan-v/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/narasimhan-v/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/narasimhan-v/avocado/languages","stargazers_url":"https://api.github.com/repos/narasimhan-v/avocado/stargazers","contributors_url":"https://api.github.com/repos/narasimhan-v/avocado/contributors","subscribers_url":"https://api.github.com/repos/narasimhan-v/avocado/subscribers","subscription_url":"https://api.github.com/repos/narasimhan-v/avocado/subscription","commits_url":"https://api.github.com/repos/narasimhan-v/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/narasimhan-v/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/narasimhan-v/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/narasimhan-v/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/narasimhan-v/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/narasimhan-v/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/narasimhan-v/avocado/merges","archive_url":"https://api.github.com/repos/narasimhan-v/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/narasimhan-v/avocado/downloads","issues_url":"https://api.github.com/repos/narasimhan-v/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/narasimhan-v/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/narasimhan-v/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/narasimhan-v/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/narasimhan-v/avocado/labels{/name}","releases_url":"https://api.github.com/repos/narasimhan-v/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/narasimhan-v/avocado/deployments","created_at":"2016-05-03T05:52:07Z","updated_at":"2016-05-03T05:52:08Z","pushed_at":"2016-10-19T09:49:12Z","git_url":"git://github.com/narasimhan-v/avocado.git","ssh_url":"git@github.com:narasimhan-v/avocado.git","clone_url":"https://github.com/narasimhan-v/avocado.git","svn_url":"https://github.com/narasimhan-v/avocado","homepage":"http://avocado-framework.github.io/","size":9388,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"avocado-framework:master","ref":"master","sha":"07cb6b49d8902b1d1e6bd6f9a0f51ce226f1cc82","user":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":17449498,"name":"avocado","full_name":"avocado-framework/avocado","owner":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avocado-framework/avocado","description":"Avocado Test Framework","fork":false,"url":"https://api.github.com/repos/avocado-framework/avocado","forks_url":"https://api.github.com/repos/avocado-framework/avocado/forks","keys_url":"https://api.github.com/repos/avocado-framework/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avocado-framework/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avocado-framework/avocado/teams","hooks_url":"https://api.github.com/repos/avocado-framework/avocado/hooks","issue_events_url":"https://api.github.com/repos/avocado-framework/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/avocado-framework/avocado/events","assignees_url":"https://api.github.com/repos/avocado-framework/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/avocado-framework/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/avocado-framework/avocado/tags","blobs_url":"https://api.github.com/repos/avocado-framework/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avocado-framework/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avocado-framework/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/avocado-framework/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/avocado-framework/avocado/languages","stargazers_url":"https://api.github.com/repos/avocado-framework/avocado/stargazers","contributors_url":"https://api.github.com/repos/avocado-framework/avocado/contributors","subscribers_url":"https://api.github.com/repos/avocado-framework/avocado/subscribers","subscription_url":"https://api.github.com/repos/avocado-framework/avocado/subscription","commits_url":"https://api.github.com/repos/avocado-framework/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/avocado-framework/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/avocado-framework/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/avocado-framework/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/avocado-framework/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avocado-framework/avocado/merges","archive_url":"https://api.github.com/repos/avocado-framework/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avocado-framework/avocado/downloads","issues_url":"https://api.github.com/repos/avocado-framework/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/avocado-framework/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/avocado-framework/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/avocado-framework/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avocado-framework/avocado/labels{/name}","releases_url":"https://api.github.com/repos/avocado-framework/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/avocado-framework/avocado/deployments","created_at":"2014-03-05T17:52:27Z","updated_at":"2016-10-01T06:51:02Z","pushed_at":"2016-10-19T15:00:25Z","git_url":"git://github.com/avocado-framework/avocado.git","ssh_url":"git@github.com:avocado-framework/avocado.git","clone_url":"https://github.com/avocado-framework/avocado.git","svn_url":"https://github.com/avocado-framework/avocado","homepage":"http://avocado-framework.github.io/","size":15050,"stargazers_count":62,"watchers_count":62,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":10,"forks":76,"open_issues":10,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/1547"},"issue":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/1547"},"comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/1547/comments"},"review_comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547/comments"},"review_comment":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1547/commits"},"statuses":{"href":"https://api.github.com/repos/avocado-framework/avocado/statuses/355ef28107bbabee846da6a9f8310fd5e911534a"}}}}
{"actor":{"display_login":"narasimhan-v"}}