{"action":"created","comment":{"url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/comments/28467594","id":28467594,"diff_hunk":"@@ -314,14 +293,87 @@ def del_ip_pool(self, version, pool):\n         assert version in (\"v4\", \"v6\")\n         assert isinstance(pool, IPNetwork)\n \n-        pools = self._get_ip_pools_with_keys(version)\n+        pool_path = IP_POOL_PATH % {\"version\": version}\n+        pools = self._get_path_with_keys(pool_path)\n         try:\n-            key = pools[pool.cidr]\n+            key = pools[str(pool.cidr)]\n             self.etcd_client.delete(key)\n         except KeyError:\n             # Re-raise with a better error message.\n             raise KeyError(\"%s is not a configured IP pool.\" % pool)\n \n+    def get_bgp_peer(self, version):\n+        \"\"\"\n+        Get the configured BGP Peers\n+\n+        :param version: \"v4\" for IPv4, \"v6\" for IPv6\n+        :return: List of netaddr.IPAddress IP addresses.\n+        \"\"\"\n+        assert version in (\"v4\", \"v6\")\n+        bgp_peer_path = BGP_PEER_PATH % {\"version\": version}\n+        return map(IPAddress, self._get_path_with_keys(bgp_peer_path).keys())\n+\n+\n+    def _get_path_with_keys(self, path):\n+        \"\"\"\n+        Retrieve all the keys in a path and create a reverse dict\n+        values -> keys\n+\n+        :param path: The path the the keys from.\n+        :return: dict of {<values>: <etcd key>} for the peers.\n+        \"\"\"\n+\n+        try:\n+            nodes = self.etcd_client.read(path).children\n+        except KeyError:\n+            # Path doesn't exist.  Interpret as no configured pools.","path":"node/adapter/datastore.py","position":89,"original_position":89,"commit_id":"1b71e1da3a9153ad750140541e9d5527ff9055ab","original_commit_id":"9addb0b76dfafbab20c456c03d9a404ee62f7930","user":{"login":"spikecurtis","id":5375600,"avatar_url":"https://avatars.githubusercontent.com/u/5375600?v=3","gravatar_id":"","url":"https://api.github.com/users/spikecurtis","html_url":"https://github.com/spikecurtis","followers_url":"https://api.github.com/users/spikecurtis/followers","following_url":"https://api.github.com/users/spikecurtis/following{/other_user}","gists_url":"https://api.github.com/users/spikecurtis/gists{/gist_id}","starred_url":"https://api.github.com/users/spikecurtis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spikecurtis/subscriptions","organizations_url":"https://api.github.com/users/spikecurtis/orgs","repos_url":"https://api.github.com/users/spikecurtis/repos","events_url":"https://api.github.com/users/spikecurtis/events{/privacy}","received_events_url":"https://api.github.com/users/spikecurtis/received_events","type":"User","site_admin":false},"body":"Comment outdated, refers to \"pools\"","created_at":"2015-04-15T22:01:24Z","updated_at":"2015-04-15T22:01:24Z","html_url":"https://github.com/Metaswitch/calico-docker/pull/67#discussion_r28467594","pull_request_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/comments/28467594"},"html":{"href":"https://github.com/Metaswitch/calico-docker/pull/67#discussion_r28467594"},"pull_request":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67","id":33397609,"html_url":"https://github.com/Metaswitch/calico-docker/pull/67","diff_url":"https://github.com/Metaswitch/calico-docker/pull/67.diff","patch_url":"https://github.com/Metaswitch/calico-docker/pull/67.patch","issue_url":"https://api.github.com/repos/Metaswitch/calico-docker/issues/67","number":67,"state":"open","locked":false,"title":"Add calicoctl commands for BGP Peers (and configurable AS)","user":{"login":"tomdee","id":6635,"avatar_url":"https://avatars.githubusercontent.com/u/6635?v=3","gravatar_id":"","url":"https://api.github.com/users/tomdee","html_url":"https://github.com/tomdee","followers_url":"https://api.github.com/users/tomdee/followers","following_url":"https://api.github.com/users/tomdee/following{/other_user}","gists_url":"https://api.github.com/users/tomdee/gists{/gist_id}","starred_url":"https://api.github.com/users/tomdee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomdee/subscriptions","organizations_url":"https://api.github.com/users/tomdee/orgs","repos_url":"https://api.github.com/users/tomdee/repos","events_url":"https://api.github.com/users/tomdee/events{/privacy}","received_events_url":"https://api.github.com/users/tomdee/received_events","type":"User","site_admin":false},"body":"Configure AS using \r\n- etcdctl set /calico/config/bgp_as 64512\r\n\r\n","created_at":"2015-04-15T21:19:25Z","updated_at":"2015-04-15T22:01:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a2bfeed5e28e36f06f9d5dfd727431e242e57f0","assignee":{"login":"spikecurtis","id":5375600,"avatar_url":"https://avatars.githubusercontent.com/u/5375600?v=3","gravatar_id":"","url":"https://api.github.com/users/spikecurtis","html_url":"https://github.com/spikecurtis","followers_url":"https://api.github.com/users/spikecurtis/followers","following_url":"https://api.github.com/users/spikecurtis/following{/other_user}","gists_url":"https://api.github.com/users/spikecurtis/gists{/gist_id}","starred_url":"https://api.github.com/users/spikecurtis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spikecurtis/subscriptions","organizations_url":"https://api.github.com/users/spikecurtis/orgs","repos_url":"https://api.github.com/users/spikecurtis/repos","events_url":"https://api.github.com/users/spikecurtis/events{/privacy}","received_events_url":"https://api.github.com/users/spikecurtis/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67/commits","review_comments_url":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67/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/67/comments","statuses_url":"https://api.github.com/repos/Metaswitch/calico-docker/statuses/1b71e1da3a9153ad750140541e9d5527ff9055ab","head":{"label":"Metaswitch:bgp_peer_calicoctl","ref":"bgp_peer_calicoctl","sha":"1b71e1da3a9153ad750140541e9d5527ff9055ab","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-04-15T01:24:43Z","pushed_at":"2015-04-15T21:57:41Z","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":13329,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":28,"default_branch":"master"}},"base":{"label":"Metaswitch:master","ref":"master","sha":"65fd6c02f8c708c560da5460a1d32a1fbddd94fd","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-04-15T01:24:43Z","pushed_at":"2015-04-15T21:57:41Z","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":13329,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67"},"html":{"href":"https://github.com/Metaswitch/calico-docker/pull/67"},"issue":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/issues/67"},"comments":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/pulls/67/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/67/commits"},"statuses":{"href":"https://api.github.com/repos/Metaswitch/calico-docker/statuses/1b71e1da3a9153ad750140541e9d5527ff9055ab"}}}}