{"action":"created","comment":{"url":"https://api.github.com/repos/autotest/virt-test/pulls/comments/22989917","id":22989917,"diff_hunk":"@@ -915,71 +917,70 @@ def pre_pool(self, pool_name, pool_type, pool_target, emulated_image,\n                 extra = \"--source-host %s --source-path %s\" % (source_host,\n                                                                nfs_path)\n         elif pool_type == \"iscsi\":\n+            ip_protocal = kwargs.get('ip_protocal', \"ipv4\")\n             setup_or_cleanup_iscsi(is_setup=True,\n                                    emulated_image=emulated_image,\n                                    image_size=image_size)\n-            # Verify if expected iscsi device has been set\n             iscsi_sessions = iscsi.iscsi_get_sessions()\n-            iscsi_device = ()\n+            iscsi_target = None\n             for iscsi_node in iscsi_sessions:\n                 if iscsi_node[1].count(emulated_image):\n-                    # Remove port for pool operations\n-                    ip_addr = iscsi_node[0].split(\":3260\")[0]\n-                    iscsi_device = (ip_addr, iscsi_node[1])\n+                    iscsi_target = iscsi_node[1]\n                     break\n-            if iscsi_device == ():\n-                raise error.TestFail(\"No matched iscsi device.\")\n-            if \"::\" in iscsi_device[0]:\n-                iscsi_device = ('localhost', iscsi_device[1])\n-            extra = \" --source-host %s  --source-dev %s\" % iscsi_device\n+            iscsi.iscsi_logout(iscsi_target)\n+            if ip_protocal == \"ipv6\":\n+                ip_addr = \"::1\"\n+            else:\n+                ip_addr = \"127.0.0.1\"\n+            extra = \" --source-host %s  --source-dev %s\" % (ip_addr,\n+                                                            iscsi_target)\n         elif pool_type == \"scsi\":\n-            scsi_xml_file = self.params.get(\"scsi_xml_file\")\n+            scsi_xml_file = self.params.get(\"scsi_xml_file\", \"\")\n             if not os.path.exists(scsi_xml_file):\n-                scsi_xml_file = os.path.join(self.tmpdir, scsi_xml_file)\n-                logical_device = setup_or_cleanup_iscsi(is_setup=True,\n-                                                        emulated_image=emulated_image,\n-                                                        image_size=image_size)\n+                logical_device = setup_or_cleanup_iscsi(\n+                    is_setup=True,\n+                    emulated_image=emulated_image,\n+                    image_size=image_size)\n                 cmd = (\"iscsiadm -m session -P 3 |grep -B3 %s| grep Host|awk \"\n                        \"'{print $3}'\" % logical_device.split('/')[2])\n                 scsi_host = utils.system_output(cmd)\n-                scsi_xml = \"\"\"\n-<pool type='scsi'>\n-  <name>%s</name>\n-   <source>\n-    <adapter type='scsi_host' name='host%s'/>\n-  </source>\n-  <target>\n-    <path>/dev/disk/by-path</path>\n-  </target>\n-</pool>\n-\"\"\" % (pool_name, scsi_host)\n-                logging.debug(\"Prepare the scsi pool xml: %s\", scsi_xml)\n-                xml_object = open(scsi_xml_file, 'w')\n-                xml_object.write(scsi_xml)\n-                xml_object.close()\n+                scsi_pool_xml = pool_xml.PoolXML()\n+                scsi_pool_xml.name = pool_name\n+                scsi_pool_xml.pool_type = \"scsi\"\n+                scsi_pool_xml.target_path = pool_target\n+                scsi_pool_source_xml = pool_xml.SourceXML()\n+                scsi_pool_source_xml.adp_type = 'scsi_host'\n+                scsi_pool_source_xml.adp_name = \"host\" + scsi_host\n+                scsi_pool_xml.set_source(scsi_pool_source_xml)\n+                logging.debug(\"SCSI pool XML %s:\\n%s\", scsi_pool_xml.xml,\n+                              str(scsi_pool_xml))\n+                scsi_xml_file = scsi_pool_xml.xml\n+                self.params['scsi_xml_file'] = scsi_xml_file\n         elif pool_type == \"gluster\":\n-            # Prepare gluster service and create volume\n+            source_path = kwargs.get('source_path')\n             hostip = setup_or_cleanup_gluster(True, source_name,\n                                               pool_name=pool_name)\n-            logging.debug(\"hostip is %s\", hostip)\n+            logging.debug(\"Gluster host ip address: %s\", hostip)\n             extra = \"--source-host %s --source-path %s --source-name %s\" % \\\n                     (hostip, source_path, source_name)\n \n-        # Create pool\n+        func = virsh.pool_create_as\n         if pool_type == \"scsi\":\n-            re_v = virsh.pool_create(scsi_xml_file)\n-        else:\n-            re_v = virsh.pool_create_as(pool_name, pool_type,\n-                                        pool_target, extra, debug=True)\n+            func = virsh.pool_create\n+        if persistent:\n+            func = virsh.pool_define_as\n+            if pool_type == \"scsi\":\n+                func = virsh.pool_define\n \n+        # Create/define pool\n+        if pool_type == \"scsi\":\n+            re_v = func(scsi_xml_file, debug=True)\n+        else:\n+            re_v = func(pool_name, pool_type, pool_target, extra, debug=True)\n         if not re_v:\n-            raise error.TestFail(\"Create pool failed.\")\n-\n-        ret = virsh.pool_dumpxml(pool_name)","path":"virttest/utils_test/libvirt.py","position":219,"original_position":219,"commit_id":"d0112869ce338bc156943d4477219e9c73f55d02","original_commit_id":"d0112869ce338bc156943d4477219e9c73f55d02","user":{"login":"will-Do","id":1916899,"avatar_url":"https://avatars.githubusercontent.com/u/1916899?v=3","gravatar_id":"","url":"https://api.github.com/users/will-Do","html_url":"https://github.com/will-Do","followers_url":"https://api.github.com/users/will-Do/followers","following_url":"https://api.github.com/users/will-Do/following{/other_user}","gists_url":"https://api.github.com/users/will-Do/gists{/gist_id}","starred_url":"https://api.github.com/users/will-Do/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/will-Do/subscriptions","organizations_url":"https://api.github.com/users/will-Do/orgs","repos_url":"https://api.github.com/users/will-Do/repos","events_url":"https://api.github.com/users/will-Do/events{/privacy}","received_events_url":"https://api.github.com/users/will-Do/received_events","type":"User","site_admin":false},"body":"I'm not sure why the checking is necessary here. ```check_actived_pool``` just check if the given pool is running(pool in inactive status also raise TestFail), so it's not suit for the ```pre_pool``` func any more, or we can update that func to check both active or inactive pool, but it's not what I want to do here.\r\nAnd what I though the calling logical here is, cases call ```pre_pool``` to define/create a pool, if ```re_v == 1```, then we clean the env and raise TestFail, if ```re_v != 1```, then just let the cases deal with the next step result.","created_at":"2015-01-15T04:19:59Z","updated_at":"2015-01-15T04:19:59Z","html_url":"https://github.com/autotest/virt-test/pull/1939#discussion_r22989917","pull_request_url":"https://api.github.com/repos/autotest/virt-test/pulls/1939","_links":{"self":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/comments/22989917"},"html":{"href":"https://github.com/autotest/virt-test/pull/1939#discussion_r22989917"},"pull_request":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/1939"}}},"pull_request":{"url":"https://api.github.com/repos/autotest/virt-test/pulls/1939","id":26636700,"html_url":"https://github.com/autotest/virt-test/pull/1939","diff_url":"https://github.com/autotest/virt-test/pull/1939.diff","patch_url":"https://github.com/autotest/virt-test/pull/1939.patch","issue_url":"https://api.github.com/repos/autotest/virt-test/issues/1939","number":1939,"state":"open","locked":false,"title":"    utils_test.libvirt: Update prepare pool method","user":{"login":"will-Do","id":1916899,"avatar_url":"https://avatars.githubusercontent.com/u/1916899?v=3","gravatar_id":"","url":"https://api.github.com/users/will-Do","html_url":"https://github.com/will-Do","followers_url":"https://api.github.com/users/will-Do/followers","following_url":"https://api.github.com/users/will-Do/following{/other_user}","gists_url":"https://api.github.com/users/will-Do/gists{/gist_id}","starred_url":"https://api.github.com/users/will-Do/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/will-Do/subscriptions","organizations_url":"https://api.github.com/users/will-Do/orgs","repos_url":"https://api.github.com/users/will-Do/repos","events_url":"https://api.github.com/users/will-Do/events{/privacy}","received_events_url":"https://api.github.com/users/will-Do/received_events","type":"User","site_admin":false},"body":"\r\n    1. Use kwargs instead of optional parameters\r\n    2. Support 'source-format' when prepare pool\r\n    3. Support both ipv4 and ipv6 for iscsi pool\r\n    4. Support define persistent pool\r\n    5. Update SCSI pool XML create method\r\n\r\n\r\nSigned-off-by: Yanbing Du <ydu@redhat.com>","created_at":"2014-12-29T09:13:25Z","updated_at":"2015-01-15T04:19:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"75b85fff8b3109770fbe238db5a9ac16ab8fddcf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/autotest/virt-test/pulls/1939/commits","review_comments_url":"https://api.github.com/repos/autotest/virt-test/pulls/1939/comments","review_comment_url":"https://api.github.com/repos/autotest/virt-test/pulls/comments/{number}","comments_url":"https://api.github.com/repos/autotest/virt-test/issues/1939/comments","statuses_url":"https://api.github.com/repos/autotest/virt-test/statuses/d0112869ce338bc156943d4477219e9c73f55d02","head":{"label":"will-Do:libvirt_pre_pool","ref":"libvirt_pre_pool","sha":"d0112869ce338bc156943d4477219e9c73f55d02","user":{"login":"will-Do","id":1916899,"avatar_url":"https://avatars.githubusercontent.com/u/1916899?v=3","gravatar_id":"","url":"https://api.github.com/users/will-Do","html_url":"https://github.com/will-Do","followers_url":"https://api.github.com/users/will-Do/followers","following_url":"https://api.github.com/users/will-Do/following{/other_user}","gists_url":"https://api.github.com/users/will-Do/gists{/gist_id}","starred_url":"https://api.github.com/users/will-Do/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/will-Do/subscriptions","organizations_url":"https://api.github.com/users/will-Do/orgs","repos_url":"https://api.github.com/users/will-Do/repos","events_url":"https://api.github.com/users/will-Do/events{/privacy}","received_events_url":"https://api.github.com/users/will-Do/received_events","type":"User","site_admin":false},"repo":{"id":9469716,"name":"virt-test","full_name":"will-Do/virt-test","owner":{"login":"will-Do","id":1916899,"avatar_url":"https://avatars.githubusercontent.com/u/1916899?v=3","gravatar_id":"","url":"https://api.github.com/users/will-Do","html_url":"https://github.com/will-Do","followers_url":"https://api.github.com/users/will-Do/followers","following_url":"https://api.github.com/users/will-Do/following{/other_user}","gists_url":"https://api.github.com/users/will-Do/gists{/gist_id}","starred_url":"https://api.github.com/users/will-Do/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/will-Do/subscriptions","organizations_url":"https://api.github.com/users/will-Do/orgs","repos_url":"https://api.github.com/users/will-Do/repos","events_url":"https://api.github.com/users/will-Do/events{/privacy}","received_events_url":"https://api.github.com/users/will-Do/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/will-Do/virt-test","description":"Linux Virtualization Tests","fork":true,"url":"https://api.github.com/repos/will-Do/virt-test","forks_url":"https://api.github.com/repos/will-Do/virt-test/forks","keys_url":"https://api.github.com/repos/will-Do/virt-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/will-Do/virt-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/will-Do/virt-test/teams","hooks_url":"https://api.github.com/repos/will-Do/virt-test/hooks","issue_events_url":"https://api.github.com/repos/will-Do/virt-test/issues/events{/number}","events_url":"https://api.github.com/repos/will-Do/virt-test/events","assignees_url":"https://api.github.com/repos/will-Do/virt-test/assignees{/user}","branches_url":"https://api.github.com/repos/will-Do/virt-test/branches{/branch}","tags_url":"https://api.github.com/repos/will-Do/virt-test/tags","blobs_url":"https://api.github.com/repos/will-Do/virt-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/will-Do/virt-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/will-Do/virt-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/will-Do/virt-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/will-Do/virt-test/statuses/{sha}","languages_url":"https://api.github.com/repos/will-Do/virt-test/languages","stargazers_url":"https://api.github.com/repos/will-Do/virt-test/stargazers","contributors_url":"https://api.github.com/repos/will-Do/virt-test/contributors","subscribers_url":"https://api.github.com/repos/will-Do/virt-test/subscribers","subscription_url":"https://api.github.com/repos/will-Do/virt-test/subscription","commits_url":"https://api.github.com/repos/will-Do/virt-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/will-Do/virt-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/will-Do/virt-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/will-Do/virt-test/issues/comments/{number}","contents_url":"https://api.github.com/repos/will-Do/virt-test/contents/{+path}","compare_url":"https://api.github.com/repos/will-Do/virt-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/will-Do/virt-test/merges","archive_url":"https://api.github.com/repos/will-Do/virt-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/will-Do/virt-test/downloads","issues_url":"https://api.github.com/repos/will-Do/virt-test/issues{/number}","pulls_url":"https://api.github.com/repos/will-Do/virt-test/pulls{/number}","milestones_url":"https://api.github.com/repos/will-Do/virt-test/milestones{/number}","notifications_url":"https://api.github.com/repos/will-Do/virt-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/will-Do/virt-test/labels{/name}","releases_url":"https://api.github.com/repos/will-Do/virt-test/releases{/id}","created_at":"2013-04-16T10:11:30Z","updated_at":"2014-12-11T09:09:10Z","pushed_at":"2015-01-12T12:17:27Z","git_url":"git://github.com/will-Do/virt-test.git","ssh_url":"git@github.com:will-Do/virt-test.git","clone_url":"https://github.com/will-Do/virt-test.git","svn_url":"https://github.com/will-Do/virt-test","homepage":null,"size":18824,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"autotest:master","ref":"master","sha":"9f7959a72b90c774660daa8f02a85cb75f178cfd","user":{"login":"autotest","id":472856,"avatar_url":"https://avatars.githubusercontent.com/u/472856?v=3","gravatar_id":"","url":"https://api.github.com/users/autotest","html_url":"https://github.com/autotest","followers_url":"https://api.github.com/users/autotest/followers","following_url":"https://api.github.com/users/autotest/following{/other_user}","gists_url":"https://api.github.com/users/autotest/gists{/gist_id}","starred_url":"https://api.github.com/users/autotest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autotest/subscriptions","organizations_url":"https://api.github.com/users/autotest/orgs","repos_url":"https://api.github.com/users/autotest/repos","events_url":"https://api.github.com/users/autotest/events{/privacy}","received_events_url":"https://api.github.com/users/autotest/received_events","type":"Organization","site_admin":false},"repo":{"id":5952670,"name":"virt-test","full_name":"autotest/virt-test","owner":{"login":"autotest","id":472856,"avatar_url":"https://avatars.githubusercontent.com/u/472856?v=3","gravatar_id":"","url":"https://api.github.com/users/autotest","html_url":"https://github.com/autotest","followers_url":"https://api.github.com/users/autotest/followers","following_url":"https://api.github.com/users/autotest/following{/other_user}","gists_url":"https://api.github.com/users/autotest/gists{/gist_id}","starred_url":"https://api.github.com/users/autotest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autotest/subscriptions","organizations_url":"https://api.github.com/users/autotest/orgs","repos_url":"https://api.github.com/users/autotest/repos","events_url":"https://api.github.com/users/autotest/events{/privacy}","received_events_url":"https://api.github.com/users/autotest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/autotest/virt-test","description":"Linux Virtualization Tests","fork":false,"url":"https://api.github.com/repos/autotest/virt-test","forks_url":"https://api.github.com/repos/autotest/virt-test/forks","keys_url":"https://api.github.com/repos/autotest/virt-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/autotest/virt-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/autotest/virt-test/teams","hooks_url":"https://api.github.com/repos/autotest/virt-test/hooks","issue_events_url":"https://api.github.com/repos/autotest/virt-test/issues/events{/number}","events_url":"https://api.github.com/repos/autotest/virt-test/events","assignees_url":"https://api.github.com/repos/autotest/virt-test/assignees{/user}","branches_url":"https://api.github.com/repos/autotest/virt-test/branches{/branch}","tags_url":"https://api.github.com/repos/autotest/virt-test/tags","blobs_url":"https://api.github.com/repos/autotest/virt-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/autotest/virt-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/autotest/virt-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/autotest/virt-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/autotest/virt-test/statuses/{sha}","languages_url":"https://api.github.com/repos/autotest/virt-test/languages","stargazers_url":"https://api.github.com/repos/autotest/virt-test/stargazers","contributors_url":"https://api.github.com/repos/autotest/virt-test/contributors","subscribers_url":"https://api.github.com/repos/autotest/virt-test/subscribers","subscription_url":"https://api.github.com/repos/autotest/virt-test/subscription","commits_url":"https://api.github.com/repos/autotest/virt-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/autotest/virt-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/autotest/virt-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/autotest/virt-test/issues/comments/{number}","contents_url":"https://api.github.com/repos/autotest/virt-test/contents/{+path}","compare_url":"https://api.github.com/repos/autotest/virt-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/autotest/virt-test/merges","archive_url":"https://api.github.com/repos/autotest/virt-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/autotest/virt-test/downloads","issues_url":"https://api.github.com/repos/autotest/virt-test/issues{/number}","pulls_url":"https://api.github.com/repos/autotest/virt-test/pulls{/number}","milestones_url":"https://api.github.com/repos/autotest/virt-test/milestones{/number}","notifications_url":"https://api.github.com/repos/autotest/virt-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/autotest/virt-test/labels{/name}","releases_url":"https://api.github.com/repos/autotest/virt-test/releases{/id}","created_at":"2012-09-25T16:10:43Z","updated_at":"2015-01-15T03:34:08Z","pushed_at":"2015-01-14T05:56:21Z","git_url":"git://github.com/autotest/virt-test.git","ssh_url":"git@github.com:autotest/virt-test.git","clone_url":"https://github.com/autotest/virt-test.git","svn_url":"https://github.com/autotest/virt-test","homepage":"http://virt-test.readthedocs.org/en/latest/","size":40540,"stargazers_count":72,"watchers_count":72,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":116,"mirror_url":null,"open_issues_count":50,"forks":116,"open_issues":50,"watchers":72,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/1939"},"html":{"href":"https://github.com/autotest/virt-test/pull/1939"},"issue":{"href":"https://api.github.com/repos/autotest/virt-test/issues/1939"},"comments":{"href":"https://api.github.com/repos/autotest/virt-test/issues/1939/comments"},"review_comments":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/1939/comments"},"review_comment":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/1939/commits"},"statuses":{"href":"https://api.github.com/repos/autotest/virt-test/statuses/d0112869ce338bc156943d4477219e9c73f55d02"}}}}