{"action":"created","comment":{"url":"https://api.github.com/repos/autotest/virt-test/pulls/comments/22995910","id":22995910,"diff_hunk":"@@ -802,15 +802,35 @@ def __call__(self, value):\n                                                 index,\n                                                 str(item)))\n                     raise xcepts.LibvirtXMLAccessorError(msg)\n+\n+                # Handle element text values in element_tuple[1].\n                 text = None\n-                # To support text in element, marshal_from may return\n-                # an additional text value, check the length of element tuple\n+                new_dict = element_tuple[1].copy()\n+                if 'text' in element_tuple[1].keys():\n+                    del new_dict['text']\n+\n+                # To support text in element, marshal_from may return an\n+                # additional text value, check the length of element tuple\n                 if len(element_tuple) == 3:\n                     text = element_tuple[2]\n-                xml_utils.ElementTree.SubElement(parent,\n-                                                 element_tuple[0],\n-                                                 element_tuple[1],\n-                                                 text)\n+                parent_element = xml_utils.ElementTree.SubElement(\n+                    parent,\n+                    element_tuple[0],\n+                    new_dict,\n+                    text)\n+\n+                # To support child element contains text, create sub element\n+                # with text under new created parent element.\n+                if 'text' in element_tuple[1].keys():\n+                    text_dict = element_tuple[1]['text']\n+                    attr_dict = {}\n+                    for text_key, text_val in text_dict.items():\n+                        child_element = xml_utils.ElementTree.SubElement(","path":"virttest/libvirt_xml/accessors.py","position":33,"original_position":33,"commit_id":"70aacf3c05a457ca203a2cc5f393809a8caedb3d","original_commit_id":"70aacf3c05a457ca203a2cc5f393809a8caedb3d","user":{"login":"waynesun09","id":1912684,"avatar_url":"https://avatars.githubusercontent.com/u/1912684?v=3","gravatar_id":"","url":"https://api.github.com/users/waynesun09","html_url":"https://github.com/waynesun09","followers_url":"https://api.github.com/users/waynesun09/followers","following_url":"https://api.github.com/users/waynesun09/following{/other_user}","gists_url":"https://api.github.com/users/waynesun09/gists{/gist_id}","starred_url":"https://api.github.com/users/waynesun09/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waynesun09/subscriptions","organizations_url":"https://api.github.com/users/waynesun09/orgs","repos_url":"https://api.github.com/users/waynesun09/repos","events_url":"https://api.github.com/users/waynesun09/events{/privacy}","received_events_url":"https://api.github.com/users/waynesun09/received_events","type":"User","site_admin":false},"body":"@yumingfei yes, updating.","created_at":"2015-01-15T08:31:19Z","updated_at":"2015-01-15T08:31:19Z","html_url":"https://github.com/autotest/virt-test/pull/1943#discussion_r22995910","pull_request_url":"https://api.github.com/repos/autotest/virt-test/pulls/1943","_links":{"self":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/comments/22995910"},"html":{"href":"https://github.com/autotest/virt-test/pull/1943#discussion_r22995910"},"pull_request":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/1943"}}},"pull_request":{"url":"https://api.github.com/repos/autotest/virt-test/pulls/1943","id":26813671,"html_url":"https://github.com/autotest/virt-test/pull/1943","diff_url":"https://github.com/autotest/virt-test/pull/1943.diff","patch_url":"https://github.com/autotest/virt-test/pull/1943.patch","issue_url":"https://api.github.com/repos/autotest/virt-test/issues/1943","number":1943,"state":"open","locked":false,"title":"Add per-disk seclabel support","user":{"login":"waynesun09","id":1912684,"avatar_url":"https://avatars.githubusercontent.com/u/1912684?v=3","gravatar_id":"","url":"https://api.github.com/users/waynesun09","html_url":"https://github.com/waynesun09","followers_url":"https://api.github.com/users/waynesun09/followers","following_url":"https://api.github.com/users/waynesun09/following{/other_user}","gists_url":"https://api.github.com/users/waynesun09/gists{/gist_id}","starred_url":"https://api.github.com/users/waynesun09/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waynesun09/subscriptions","organizations_url":"https://api.github.com/users/waynesun09/orgs","repos_url":"https://api.github.com/users/waynesun09/repos","events_url":"https://api.github.com/users/waynesun09/events{/privacy}","received_events_url":"https://api.github.com/users/waynesun09/received_events","type":"User","site_admin":false},"body":"As libvirt xml support per-disk seclabel setting, implement seclabel class which include multiple element texts and attributes.\r\nHandle the element texts in marshal_from_seclabel and XMLElementList, update both to handle extra dict under key 'text'.\r\ne.g.\r\nThere are text element 'label' and 'baselabel' in seclabel:\r\n```\r\n      <source path='/tmp/file'>\r\n        <seclabel model='dac' relabel='no'>\r\n          <label>0:0</label>\r\n          <baselabel>0:0</baselabel>\r\n        </seclabel>\r\n      </source>\r\n```\r\nboth text element under parent tag 'seclabel' and with text value.\r\nthe return tuple of marshal_from_seclabel will be:\r\n```\r\n('seclabel', {'text': {'label': '0:0', 'baselabel': '0:0'}, 'model': 'dac', 'relabel': 'yes'})\r\n```\r\nand XMLElementList will create child element text after create seclabel element with attribute.\r\n\r\n\r\nThis update is different to PR:\r\nhttps://github.com/autotest/virt-test/pull/1902\r\n\r\nwhich handle only one text element just under the parent tag. \r\n\r\ne.g.\r\nthe text element hostname with only one value, and multiple hostname elements.\r\n```\r\n          <host ip='192.168.122.2'>\r\n            <hostname>myhost</hostname>\r\n            <hostname>myhostalias</hostname>\r\n          </host>\r\n```\r\n\r\nthe 2 return tuple of marshal_from_hostname will be\r\n```\r\n(\"hostname\", {}, 'myhost')\r\n```\r\nand \r\n```\r\n(\"hostname\", {}, 'myhostalias')\r\n```\r\nthen handle by XMLElementList to create element without attribute but with text under tag hostname.","created_at":"2015-01-05T09:37:16Z","updated_at":"2015-01-15T08:31:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5a82a96cec4d58515ad04264624672adf6de6fda","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/autotest/virt-test/pulls/1943/commits","review_comments_url":"https://api.github.com/repos/autotest/virt-test/pulls/1943/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/1943/comments","statuses_url":"https://api.github.com/repos/autotest/virt-test/statuses/70aacf3c05a457ca203a2cc5f393809a8caedb3d","head":{"label":"waynesun09:per_disk_seclabel","ref":"per_disk_seclabel","sha":"70aacf3c05a457ca203a2cc5f393809a8caedb3d","user":{"login":"waynesun09","id":1912684,"avatar_url":"https://avatars.githubusercontent.com/u/1912684?v=3","gravatar_id":"","url":"https://api.github.com/users/waynesun09","html_url":"https://github.com/waynesun09","followers_url":"https://api.github.com/users/waynesun09/followers","following_url":"https://api.github.com/users/waynesun09/following{/other_user}","gists_url":"https://api.github.com/users/waynesun09/gists{/gist_id}","starred_url":"https://api.github.com/users/waynesun09/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waynesun09/subscriptions","organizations_url":"https://api.github.com/users/waynesun09/orgs","repos_url":"https://api.github.com/users/waynesun09/repos","events_url":"https://api.github.com/users/waynesun09/events{/privacy}","received_events_url":"https://api.github.com/users/waynesun09/received_events","type":"User","site_admin":false},"repo":{"id":7234416,"name":"virt-test","full_name":"waynesun09/virt-test","owner":{"login":"waynesun09","id":1912684,"avatar_url":"https://avatars.githubusercontent.com/u/1912684?v=3","gravatar_id":"","url":"https://api.github.com/users/waynesun09","html_url":"https://github.com/waynesun09","followers_url":"https://api.github.com/users/waynesun09/followers","following_url":"https://api.github.com/users/waynesun09/following{/other_user}","gists_url":"https://api.github.com/users/waynesun09/gists{/gist_id}","starred_url":"https://api.github.com/users/waynesun09/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waynesun09/subscriptions","organizations_url":"https://api.github.com/users/waynesun09/orgs","repos_url":"https://api.github.com/users/waynesun09/repos","events_url":"https://api.github.com/users/waynesun09/events{/privacy}","received_events_url":"https://api.github.com/users/waynesun09/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/waynesun09/virt-test","description":"Linux Virtualization Tests","fork":true,"url":"https://api.github.com/repos/waynesun09/virt-test","forks_url":"https://api.github.com/repos/waynesun09/virt-test/forks","keys_url":"https://api.github.com/repos/waynesun09/virt-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/waynesun09/virt-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/waynesun09/virt-test/teams","hooks_url":"https://api.github.com/repos/waynesun09/virt-test/hooks","issue_events_url":"https://api.github.com/repos/waynesun09/virt-test/issues/events{/number}","events_url":"https://api.github.com/repos/waynesun09/virt-test/events","assignees_url":"https://api.github.com/repos/waynesun09/virt-test/assignees{/user}","branches_url":"https://api.github.com/repos/waynesun09/virt-test/branches{/branch}","tags_url":"https://api.github.com/repos/waynesun09/virt-test/tags","blobs_url":"https://api.github.com/repos/waynesun09/virt-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/waynesun09/virt-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/waynesun09/virt-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/waynesun09/virt-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/waynesun09/virt-test/statuses/{sha}","languages_url":"https://api.github.com/repos/waynesun09/virt-test/languages","stargazers_url":"https://api.github.com/repos/waynesun09/virt-test/stargazers","contributors_url":"https://api.github.com/repos/waynesun09/virt-test/contributors","subscribers_url":"https://api.github.com/repos/waynesun09/virt-test/subscribers","subscription_url":"https://api.github.com/repos/waynesun09/virt-test/subscription","commits_url":"https://api.github.com/repos/waynesun09/virt-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/waynesun09/virt-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/waynesun09/virt-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/waynesun09/virt-test/issues/comments/{number}","contents_url":"https://api.github.com/repos/waynesun09/virt-test/contents/{+path}","compare_url":"https://api.github.com/repos/waynesun09/virt-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/waynesun09/virt-test/merges","archive_url":"https://api.github.com/repos/waynesun09/virt-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/waynesun09/virt-test/downloads","issues_url":"https://api.github.com/repos/waynesun09/virt-test/issues{/number}","pulls_url":"https://api.github.com/repos/waynesun09/virt-test/pulls{/number}","milestones_url":"https://api.github.com/repos/waynesun09/virt-test/milestones{/number}","notifications_url":"https://api.github.com/repos/waynesun09/virt-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/waynesun09/virt-test/labels{/name}","releases_url":"https://api.github.com/repos/waynesun09/virt-test/releases{/id}","created_at":"2012-12-19T03:27:21Z","updated_at":"2014-07-08T05:50:04Z","pushed_at":"2015-01-15T07:15:28Z","git_url":"git://github.com/waynesun09/virt-test.git","ssh_url":"git@github.com:waynesun09/virt-test.git","clone_url":"https://github.com/waynesun09/virt-test.git","svn_url":"https://github.com/waynesun09/virt-test","homepage":null,"size":18009,"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":"53c789f4704a8d41a711dfe042f6465992a0c129","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-15T08:15:22Z","pushed_at":"2015-01-15T08:15:22Z","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/1943"},"html":{"href":"https://github.com/autotest/virt-test/pull/1943"},"issue":{"href":"https://api.github.com/repos/autotest/virt-test/issues/1943"},"comments":{"href":"https://api.github.com/repos/autotest/virt-test/issues/1943/comments"},"review_comments":{"href":"https://api.github.com/repos/autotest/virt-test/pulls/1943/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/1943/commits"},"statuses":{"href":"https://api.github.com/repos/autotest/virt-test/statuses/70aacf3c05a457ca203a2cc5f393809a8caedb3d"}}}}