{"action":"created","comment":{"url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/comments/366155927","pull_request_review_id":342295301,"id":366155927,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM2NjE1NTkyNw==","diff_hunk":"@@ -1166,74 +1166,123 @@ def get_context_test_ifs(vm_ref):\n     return [test_if for test_if in get_context_vm_ifs(vm_ref) if test_if[0] != mdevice]\n \n \n-def wait_for_ip(session, vm_ref, device, timeout=300):\n-    \"\"\"Wait for an IP address to be returned (until a given timeout)\"\"\"\n+def get_management_vif(session, vm_ref):\n+    networks = get_management_network(session)\n+    for vif in session.xenapi.VM.get_VIFs(vm_ref):\n+        if session.xenapi.VIF.get_network(vif) in networks:\n+            return vif\n+    return None\n \n-    # Check to see if a static IP has been configured\n-    xs_data = session.xenapi.VM.get_xenstore_data(vm_ref)\n-    log.debug(\"xenstore data: %s\" % xs_data)\n-    key = 'vm-data/control/%s/ip' % device\n-    if key in xs_data.keys():\n-        log.debug(\"Static IP %s found for VM %s\" % (xs_data[key], vm_ref))\n-        return xs_data[key]\n \n-    if session.xenapi.VM.get_is_control_domain(vm_ref):\n-        ipaddr = _get_control_domain_ip(session, vm_ref, device)\n-        log.debug(\"Control domain %s has IP %s on device %s\" %\n-                  (vm_ref, ipaddr, device))\n-        return ipaddr\n+def init_vms_first_run(session, vm_refs):\n+    for vm_ref in vm_refs:\n+        mip = get_context_vm_mip(vm_ref)\n+        # Install SSH Keys for Plugin operations\n+        call_ack_plugin(session, 'inject_ssh_key',\n+                        {'vm_ref': vm_ref, 'mip': mip, 'username': 'root',\n+                         'password': DEFAULT_PASSWORD})\n+        # Ensure that we make sure the switch accesses IP addresses by\n+        # their own interfaces (avoid interface forwarding).\n+        call_ack_plugin(session, 'reset_arp', {'vm_ref': vm_ref, 'mip': mip})\n \n-    if not device.startswith('eth'):\n-        raise Exception(\n-            \"Invalid device specified, it should be in the format 'ethX'\")\n \n-    start = time.time()\n+def disable_vm_static_ip_service(session, mip):\n+    cmd = \"\"\"systemctl stop static-ip; systemctl disable static-ip; systemctl status static-ip; \"\"\" \\\n+          \"\"\"rm -f /etc/sysconfig/network-scripts/ifcfg-eth*; \"\"\"\n+    ssh_command(mip, 'root', DEFAULT_PASSWORD, cmd, attempts=1, timeout=60)\n \n-    def should_timeout(start, timeout):\n-        \"\"\"Method for evaluating whether a time limit has been met\"\"\"\n-        return time.time() - start > float(timeout)\n \n-    i = 0\n-    while not should_timeout(start, timeout):\n-        log.debug(\"Trying to retrieve VM IP address - Attempt %d\" % i)\n-        ips = get_vm_ips(session, vm_ref)\n-        log.debug(\"VM %s has these %s IPs\" % (vm_ref, ips))\n+def get_vm_vif_ifs(session, vm_ref):\n+    \"\"\"Get vm interfaces information (vif, mac, ip) from xenstore vif records\"\"\"\n+    ifs = {}\n+    dom_root = \"/local/domain/%s\" % str(session.xenapi.VM.get_domid(vm_ref))\n \n-        for k, v in ips.iteritems():\n-            if k == device:\n-                return v\n+    cmd = b'''xenstore-ls -f %s | grep -E \"%s/device/vif/[0-9]+/mac|%s/attr/vif/[0-9]+/ipv4/[0-9]+\"''' % (dom_root, dom_root, dom_root)","path":"autocertkit/utils.py","position":null,"original_position":64,"commit_id":"0d2a37d0f2edee0c9279329d41835727ebdcb7f1","original_commit_id":"bd8bd98d9384a8290acbd7d28b08dbbb3e8f1628","user":{"login":"DeliZhangX","id":26405345,"node_id":"MDQ6VXNlcjI2NDA1MzQ1","avatar_url":"https://avatars1.githubusercontent.com/u/26405345?v=4","gravatar_id":"","url":"https://api.github.com/users/DeliZhangX","html_url":"https://github.com/DeliZhangX","followers_url":"https://api.github.com/users/DeliZhangX/followers","following_url":"https://api.github.com/users/DeliZhangX/following{/other_user}","gists_url":"https://api.github.com/users/DeliZhangX/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliZhangX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliZhangX/subscriptions","organizations_url":"https://api.github.com/users/DeliZhangX/orgs","repos_url":"https://api.github.com/users/DeliZhangX/repos","events_url":"https://api.github.com/users/DeliZhangX/events{/privacy}","received_events_url":"https://api.github.com/users/DeliZhangX/received_events","type":"User","site_admin":false},"body":"I won't break the style, you can see in all sources, format() is not used.","created_at":"2020-01-14T05:16:10Z","updated_at":"2020-01-14T05:16:10Z","html_url":"https://github.com/xenserver/auto-cert-kit/pull/178#discussion_r366155927","pull_request_url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/comments/366155927"},"html":{"href":"https://github.com/xenserver/auto-cert-kit/pull/178#discussion_r366155927"},"pull_request":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178"}},"in_reply_to_id":366111587},"pull_request":{"url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178","id":360918739,"node_id":"MDExOlB1bGxSZXF1ZXN0MzYwOTE4NzM5","html_url":"https://github.com/xenserver/auto-cert-kit/pull/178","diff_url":"https://github.com/xenserver/auto-cert-kit/pull/178.diff","patch_url":"https://github.com/xenserver/auto-cert-kit/pull/178.patch","issue_url":"https://api.github.com/repos/xenserver/auto-cert-kit/issues/178","number":178,"state":"open","locked":false,"title":"Private/deliz/ca 332753","user":{"login":"DeliZhangX","id":26405345,"node_id":"MDQ6VXNlcjI2NDA1MzQ1","avatar_url":"https://avatars1.githubusercontent.com/u/26405345?v=4","gravatar_id":"","url":"https://api.github.com/users/DeliZhangX","html_url":"https://github.com/DeliZhangX","followers_url":"https://api.github.com/users/DeliZhangX/followers","following_url":"https://api.github.com/users/DeliZhangX/following{/other_user}","gists_url":"https://api.github.com/users/DeliZhangX/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliZhangX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliZhangX/subscriptions","organizations_url":"https://api.github.com/users/DeliZhangX/orgs","repos_url":"https://api.github.com/users/DeliZhangX/repos","events_url":"https://api.github.com/users/DeliZhangX/events{/privacy}","received_events_url":"https://api.github.com/users/DeliZhangX/received_events","type":"User","site_admin":false},"body":"","created_at":"2020-01-09T11:46:34Z","updated_at":"2020-01-14T05:16:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"37c7f7e0f7a072c98a25b022a94367e657ab21a8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178/commits","review_comments_url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178/comments","review_comment_url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xenserver/auto-cert-kit/issues/178/comments","statuses_url":"https://api.github.com/repos/xenserver/auto-cert-kit/statuses/0d2a37d0f2edee0c9279329d41835727ebdcb7f1","head":{"label":"DeliZhangX:private/deliz/CA-332753","ref":"private/deliz/CA-332753","sha":"0d2a37d0f2edee0c9279329d41835727ebdcb7f1","user":{"login":"DeliZhangX","id":26405345,"node_id":"MDQ6VXNlcjI2NDA1MzQ1","avatar_url":"https://avatars1.githubusercontent.com/u/26405345?v=4","gravatar_id":"","url":"https://api.github.com/users/DeliZhangX","html_url":"https://github.com/DeliZhangX","followers_url":"https://api.github.com/users/DeliZhangX/followers","following_url":"https://api.github.com/users/DeliZhangX/following{/other_user}","gists_url":"https://api.github.com/users/DeliZhangX/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliZhangX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliZhangX/subscriptions","organizations_url":"https://api.github.com/users/DeliZhangX/orgs","repos_url":"https://api.github.com/users/DeliZhangX/repos","events_url":"https://api.github.com/users/DeliZhangX/events{/privacy}","received_events_url":"https://api.github.com/users/DeliZhangX/received_events","type":"User","site_admin":false},"repo":{"id":229191574,"node_id":"MDEwOlJlcG9zaXRvcnkyMjkxOTE1NzQ=","name":"auto-cert-kit","full_name":"DeliZhangX/auto-cert-kit","private":false,"owner":{"login":"DeliZhangX","id":26405345,"node_id":"MDQ6VXNlcjI2NDA1MzQ1","avatar_url":"https://avatars1.githubusercontent.com/u/26405345?v=4","gravatar_id":"","url":"https://api.github.com/users/DeliZhangX","html_url":"https://github.com/DeliZhangX","followers_url":"https://api.github.com/users/DeliZhangX/followers","following_url":"https://api.github.com/users/DeliZhangX/following{/other_user}","gists_url":"https://api.github.com/users/DeliZhangX/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliZhangX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliZhangX/subscriptions","organizations_url":"https://api.github.com/users/DeliZhangX/orgs","repos_url":"https://api.github.com/users/DeliZhangX/repos","events_url":"https://api.github.com/users/DeliZhangX/events{/privacy}","received_events_url":"https://api.github.com/users/DeliZhangX/received_events","type":"User","site_admin":false},"html_url":"https://github.com/DeliZhangX/auto-cert-kit","description":"Suite of automated tests for XenServer hardware certification","fork":true,"url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit","forks_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/forks","keys_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/teams","hooks_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/hooks","issue_events_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/issues/events{/number}","events_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/events","assignees_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/assignees{/user}","branches_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/branches{/branch}","tags_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/tags","blobs_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/languages","stargazers_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/stargazers","contributors_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/contributors","subscribers_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/subscribers","subscription_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/subscription","commits_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/contents/{+path}","compare_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/merges","archive_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/downloads","issues_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/issues{/number}","pulls_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/labels{/name}","releases_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/releases{/id}","deployments_url":"https://api.github.com/repos/DeliZhangX/auto-cert-kit/deployments","created_at":"2019-12-20T04:44:39Z","updated_at":"2019-12-20T04:44:40Z","pushed_at":"2020-01-09T12:26:31Z","git_url":"git://github.com/DeliZhangX/auto-cert-kit.git","ssh_url":"git@github.com:DeliZhangX/auto-cert-kit.git","clone_url":"https://github.com/DeliZhangX/auto-cert-kit.git","svn_url":"https://github.com/DeliZhangX/auto-cert-kit","homepage":null,"size":909,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"bsd-2-clause","name":"BSD 2-Clause \"Simplified\" License","spdx_id":"BSD-2-Clause","url":"https://api.github.com/licenses/bsd-2-clause","node_id":"MDc6TGljZW5zZTQ="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"xenserver:develop","ref":"develop","sha":"ec49357873e57fb8c7acc4ef8d3dcd16137188e6","user":{"login":"xenserver","id":4669806,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2Njk4MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/4669806?v=4","gravatar_id":"","url":"https://api.github.com/users/xenserver","html_url":"https://github.com/xenserver","followers_url":"https://api.github.com/users/xenserver/followers","following_url":"https://api.github.com/users/xenserver/following{/other_user}","gists_url":"https://api.github.com/users/xenserver/gists{/gist_id}","starred_url":"https://api.github.com/users/xenserver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xenserver/subscriptions","organizations_url":"https://api.github.com/users/xenserver/orgs","repos_url":"https://api.github.com/users/xenserver/repos","events_url":"https://api.github.com/users/xenserver/events{/privacy}","received_events_url":"https://api.github.com/users/xenserver/received_events","type":"Organization","site_admin":false},"repo":{"id":8431355,"node_id":"MDEwOlJlcG9zaXRvcnk4NDMxMzU1","name":"auto-cert-kit","full_name":"xenserver/auto-cert-kit","private":false,"owner":{"login":"xenserver","id":4669806,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2Njk4MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/4669806?v=4","gravatar_id":"","url":"https://api.github.com/users/xenserver","html_url":"https://github.com/xenserver","followers_url":"https://api.github.com/users/xenserver/followers","following_url":"https://api.github.com/users/xenserver/following{/other_user}","gists_url":"https://api.github.com/users/xenserver/gists{/gist_id}","starred_url":"https://api.github.com/users/xenserver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xenserver/subscriptions","organizations_url":"https://api.github.com/users/xenserver/orgs","repos_url":"https://api.github.com/users/xenserver/repos","events_url":"https://api.github.com/users/xenserver/events{/privacy}","received_events_url":"https://api.github.com/users/xenserver/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/xenserver/auto-cert-kit","description":"Suite of automated tests for XenServer hardware certification","fork":false,"url":"https://api.github.com/repos/xenserver/auto-cert-kit","forks_url":"https://api.github.com/repos/xenserver/auto-cert-kit/forks","keys_url":"https://api.github.com/repos/xenserver/auto-cert-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xenserver/auto-cert-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xenserver/auto-cert-kit/teams","hooks_url":"https://api.github.com/repos/xenserver/auto-cert-kit/hooks","issue_events_url":"https://api.github.com/repos/xenserver/auto-cert-kit/issues/events{/number}","events_url":"https://api.github.com/repos/xenserver/auto-cert-kit/events","assignees_url":"https://api.github.com/repos/xenserver/auto-cert-kit/assignees{/user}","branches_url":"https://api.github.com/repos/xenserver/auto-cert-kit/branches{/branch}","tags_url":"https://api.github.com/repos/xenserver/auto-cert-kit/tags","blobs_url":"https://api.github.com/repos/xenserver/auto-cert-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xenserver/auto-cert-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xenserver/auto-cert-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/xenserver/auto-cert-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xenserver/auto-cert-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/xenserver/auto-cert-kit/languages","stargazers_url":"https://api.github.com/repos/xenserver/auto-cert-kit/stargazers","contributors_url":"https://api.github.com/repos/xenserver/auto-cert-kit/contributors","subscribers_url":"https://api.github.com/repos/xenserver/auto-cert-kit/subscribers","subscription_url":"https://api.github.com/repos/xenserver/auto-cert-kit/subscription","commits_url":"https://api.github.com/repos/xenserver/auto-cert-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/xenserver/auto-cert-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/xenserver/auto-cert-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/xenserver/auto-cert-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/xenserver/auto-cert-kit/contents/{+path}","compare_url":"https://api.github.com/repos/xenserver/auto-cert-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xenserver/auto-cert-kit/merges","archive_url":"https://api.github.com/repos/xenserver/auto-cert-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xenserver/auto-cert-kit/downloads","issues_url":"https://api.github.com/repos/xenserver/auto-cert-kit/issues{/number}","pulls_url":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/xenserver/auto-cert-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/xenserver/auto-cert-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xenserver/auto-cert-kit/labels{/name}","releases_url":"https://api.github.com/repos/xenserver/auto-cert-kit/releases{/id}","deployments_url":"https://api.github.com/repos/xenserver/auto-cert-kit/deployments","created_at":"2013-02-26T11:44:51Z","updated_at":"2019-07-30T02:52:19Z","pushed_at":"2020-01-09T12:26:33Z","git_url":"git://github.com/xenserver/auto-cert-kit.git","ssh_url":"git@github.com:xenserver/auto-cert-kit.git","clone_url":"https://github.com/xenserver/auto-cert-kit.git","svn_url":"https://github.com/xenserver/auto-cert-kit","homepage":null,"size":667,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"bsd-2-clause","name":"BSD 2-Clause \"Simplified\" License","spdx_id":"BSD-2-Clause","url":"https://api.github.com/licenses/bsd-2-clause","node_id":"MDc6TGljZW5zZTQ="},"forks":15,"open_issues":2,"watchers":5,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178"},"html":{"href":"https://github.com/xenserver/auto-cert-kit/pull/178"},"issue":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/issues/178"},"comments":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/xenserver/auto-cert-kit/statuses/0d2a37d0f2edee0c9279329d41835727ebdcb7f1"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"DeliZhangX"}}