{"action":"created","comment":{"url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/comments/35373970","id":35373970,"diff_hunk":"@@ -10,3 +27,43 @@ def generate_cali_interface_name(prefix, ep_id):\n     if len(prefix) > 4:\n         raise ValueError('Prefix must be 4 characters or less.')\n     return prefix + ep_id[:11]\n+\n+\n+def get_host_ips(version=4, exclude=[]):\n+    \"\"\"\n+    Gets all IP addresses assigned to this host.\n+\n+    Ignores Loopback Addresses\n+\n+    This function is fail-safe and will return an empty array instead of\n+    raising any exceptions.\n+\n+    :param version: Desired version of IP addresses. Can be 4 or 6. defaults to 4\n+    :param exclude: list of interfaces (strings) to ignore (ex. [\"lo\",\"docker0\"])\n+    :return: List of string representations of IP Addresses.\n+    \"\"\"\n+    ip_addrs = []\n+\n+    # Select Regex for IPv6 or IPv4.\n+    IP_RE = IPV4_RE if version is 4 else IPV6_RE\n+\n+    # Call `ip addr`.\n+    try:\n+        ip_addr_output = check_output([\"ip\", \"-%d\" % (version), \"addr\"])\n+    except CalledProcessError:\n+        print \"Call to 'ip addr' Failed\"\n+        sys.exit(1)\n+\n+    # Separate interface blocks from ip addr output and iterate.\n+    for iface_block in INTERFACE_SPLIT_RE.findall(ip_addr_output):\n+        # Exclude certain interfaces.\n+        match = IFACE_RE.match(iface_block)\n+        if match and (match.group(1) not in exclude):","path":"calico_containers/pycalico/util.py","position":56,"original_position":56,"commit_id":"a3868c134fc415afa322dfbff3a9953b6d705386","original_commit_id":"a3868c134fc415afa322dfbff3a9953b6d705386","user":{"login":"Symmetric","id":1524910,"avatar_url":"https://avatars.githubusercontent.com/u/1524910?v=3","gravatar_id":"","url":"https://api.github.com/users/Symmetric","html_url":"https://github.com/Symmetric","followers_url":"https://api.github.com/users/Symmetric/followers","following_url":"https://api.github.com/users/Symmetric/following{/other_user}","gists_url":"https://api.github.com/users/Symmetric/gists{/gist_id}","starred_url":"https://api.github.com/users/Symmetric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Symmetric/subscriptions","organizations_url":"https://api.github.com/users/Symmetric/orgs","repos_url":"https://api.github.com/users/Symmetric/repos","events_url":"https://api.github.com/users/Symmetric/events{/privacy}","received_events_url":"https://api.github.com/users/Symmetric/received_events","type":"User","site_admin":false},"body":"superfluous brackets?","created_at":"2015-07-23T21:31:38Z","updated_at":"2015-07-23T21:31:38Z","html_url":"https://github.com/Metaswitch/calico-docker/pull/364#discussion_r35373970","pull_request_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364","_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/comments/35373970"},"html":{"href":"https://github.com/Metaswitch/calico-docker/pull/364#discussion_r35373970"},"pull_request":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364"}}},"pull_request":{"url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364","id":40625555,"html_url":"https://github.com/Metaswitch/calico-docker/pull/364","diff_url":"https://github.com/Metaswitch/calico-docker/pull/364.diff","patch_url":"https://github.com/Metaswitch/calico-docker/pull/364.patch","issue_url":"https://api.github.com/repos/Metaswitch/calico-docker/issues/364","number":364,"state":"open","locked":false,"title":"Network independent IP retrieval","user":{"login":"alexhersh","id":3424115,"avatar_url":"https://avatars.githubusercontent.com/u/3424115?v=3","gravatar_id":"","url":"https://api.github.com/users/alexhersh","html_url":"https://github.com/alexhersh","followers_url":"https://api.github.com/users/alexhersh/followers","following_url":"https://api.github.com/users/alexhersh/following{/other_user}","gists_url":"https://api.github.com/users/alexhersh/gists{/gist_id}","starred_url":"https://api.github.com/users/alexhersh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexhersh/subscriptions","organizations_url":"https://api.github.com/users/alexhersh/orgs","repos_url":"https://api.github.com/users/alexhersh/repos","events_url":"https://api.github.com/users/alexhersh/events{/privacy}","received_events_url":"https://api.github.com/users/alexhersh/received_events","type":"User","site_admin":false},"body":"Previous implementation of IP retrieval pings Google's DNS Server, this uses legacy RegEx formulas to  parse `ip addr` output","created_at":"2015-07-23T00:09:50Z","updated_at":"2015-07-23T21:31:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7dfb435edef445163f2a20347f568740a9a2022","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364/commits","review_comments_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364/comments","review_comment_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Metaswitch/calico-docker/issues/364/comments","statuses_url":"https://api.github.com/repos/Metaswitch/calico-docker/statuses/a3868c134fc415afa322dfbff3a9953b6d705386","head":{"label":"alexhersh:plat-indep-ip","ref":"plat-indep-ip","sha":"a3868c134fc415afa322dfbff3a9953b6d705386","user":{"login":"alexhersh","id":3424115,"avatar_url":"https://avatars.githubusercontent.com/u/3424115?v=3","gravatar_id":"","url":"https://api.github.com/users/alexhersh","html_url":"https://github.com/alexhersh","followers_url":"https://api.github.com/users/alexhersh/followers","following_url":"https://api.github.com/users/alexhersh/following{/other_user}","gists_url":"https://api.github.com/users/alexhersh/gists{/gist_id}","starred_url":"https://api.github.com/users/alexhersh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexhersh/subscriptions","organizations_url":"https://api.github.com/users/alexhersh/orgs","repos_url":"https://api.github.com/users/alexhersh/repos","events_url":"https://api.github.com/users/alexhersh/events{/privacy}","received_events_url":"https://api.github.com/users/alexhersh/received_events","type":"User","site_admin":false},"repo":{"id":38707997,"name":"calico-docker","full_name":"alexhersh/calico-docker","owner":{"login":"alexhersh","id":3424115,"avatar_url":"https://avatars.githubusercontent.com/u/3424115?v=3","gravatar_id":"","url":"https://api.github.com/users/alexhersh","html_url":"https://github.com/alexhersh","followers_url":"https://api.github.com/users/alexhersh/followers","following_url":"https://api.github.com/users/alexhersh/following{/other_user}","gists_url":"https://api.github.com/users/alexhersh/gists{/gist_id}","starred_url":"https://api.github.com/users/alexhersh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexhersh/subscriptions","organizations_url":"https://api.github.com/users/alexhersh/orgs","repos_url":"https://api.github.com/users/alexhersh/repos","events_url":"https://api.github.com/users/alexhersh/events{/privacy}","received_events_url":"https://api.github.com/users/alexhersh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexhersh/calico-docker","description":"Docker version of Project Calico","fork":true,"url":"https://api.github.com/repos/alexhersh/calico-docker","forks_url":"https://api.github.com/repos/alexhersh/calico-docker/forks","keys_url":"https://api.github.com/repos/alexhersh/calico-docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexhersh/calico-docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexhersh/calico-docker/teams","hooks_url":"https://api.github.com/repos/alexhersh/calico-docker/hooks","issue_events_url":"https://api.github.com/repos/alexhersh/calico-docker/issues/events{/number}","events_url":"https://api.github.com/repos/alexhersh/calico-docker/events","assignees_url":"https://api.github.com/repos/alexhersh/calico-docker/assignees{/user}","branches_url":"https://api.github.com/repos/alexhersh/calico-docker/branches{/branch}","tags_url":"https://api.github.com/repos/alexhersh/calico-docker/tags","blobs_url":"https://api.github.com/repos/alexhersh/calico-docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexhersh/calico-docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexhersh/calico-docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexhersh/calico-docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexhersh/calico-docker/statuses/{sha}","languages_url":"https://api.github.com/repos/alexhersh/calico-docker/languages","stargazers_url":"https://api.github.com/repos/alexhersh/calico-docker/stargazers","contributors_url":"https://api.github.com/repos/alexhersh/calico-docker/contributors","subscribers_url":"https://api.github.com/repos/alexhersh/calico-docker/subscribers","subscription_url":"https://api.github.com/repos/alexhersh/calico-docker/subscription","commits_url":"https://api.github.com/repos/alexhersh/calico-docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexhersh/calico-docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexhersh/calico-docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexhersh/calico-docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexhersh/calico-docker/contents/{+path}","compare_url":"https://api.github.com/repos/alexhersh/calico-docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexhersh/calico-docker/merges","archive_url":"https://api.github.com/repos/alexhersh/calico-docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexhersh/calico-docker/downloads","issues_url":"https://api.github.com/repos/alexhersh/calico-docker/issues{/number}","pulls_url":"https://api.github.com/repos/alexhersh/calico-docker/pulls{/number}","milestones_url":"https://api.github.com/repos/alexhersh/calico-docker/milestones{/number}","notifications_url":"https://api.github.com/repos/alexhersh/calico-docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexhersh/calico-docker/labels{/name}","releases_url":"https://api.github.com/repos/alexhersh/calico-docker/releases{/id}","created_at":"2015-07-07T18:49:20Z","updated_at":"2015-07-07T18:49:20Z","pushed_at":"2015-07-23T21:19:40Z","git_url":"git://github.com/alexhersh/calico-docker.git","ssh_url":"git@github.com:alexhersh/calico-docker.git","clone_url":"https://github.com/alexhersh/calico-docker.git","svn_url":"https://github.com/alexhersh/calico-docker","homepage":"http://www.projectcalico.org","size":13228,"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":"Metaswitch:master","ref":"master","sha":"e8b9f845d81b94031e5c049d336a187e31b15324","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":29629333,"name":"calico-docker","full_name":"Metaswitch/calico-docker","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/calico-docker","description":"Docker version of Project Calico","fork":false,"url":"https://api.github.com/repos/Metaswitch/calico-docker","forks_url":"https://api.github.com/repos/Metaswitch/calico-docker/forks","keys_url":"https://api.github.com/repos/Metaswitch/calico-docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/calico-docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/calico-docker/teams","hooks_url":"https://api.github.com/repos/Metaswitch/calico-docker/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/calico-docker/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/calico-docker/events","assignees_url":"https://api.github.com/repos/Metaswitch/calico-docker/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/calico-docker/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/calico-docker/tags","blobs_url":"https://api.github.com/repos/Metaswitch/calico-docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/calico-docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/calico-docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/calico-docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/calico-docker/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/calico-docker/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/calico-docker/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/calico-docker/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/calico-docker/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/calico-docker/subscription","commits_url":"https://api.github.com/repos/Metaswitch/calico-docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/calico-docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/calico-docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/calico-docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/calico-docker/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/calico-docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/calico-docker/merges","archive_url":"https://api.github.com/repos/Metaswitch/calico-docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/calico-docker/downloads","issues_url":"https://api.github.com/repos/Metaswitch/calico-docker/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/calico-docker/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/calico-docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/calico-docker/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/calico-docker/releases{/id}","created_at":"2015-01-21T23:46:47Z","updated_at":"2015-07-23T00:13:43Z","pushed_at":"2015-07-23T21:25:47Z","git_url":"git://github.com/Metaswitch/calico-docker.git","ssh_url":"git@github.com:Metaswitch/calico-docker.git","clone_url":"https://github.com/Metaswitch/calico-docker.git","svn_url":"https://github.com/Metaswitch/calico-docker","homepage":"http://www.projectcalico.org","size":16752,"stargazers_count":102,"watchers_count":102,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":19,"forks":19,"open_issues":19,"watchers":102,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364"},"html":{"href":"https://github.com/Metaswitch/calico-docker/pull/364"},"issue":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/issues/364"},"comments":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/issues/364/comments"},"review_comments":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364/comments"},"review_comment":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/364/commits"},"statuses":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/statuses/a3868c134fc415afa322dfbff3a9953b6d705386"}}}}