{"action":"created","comment":{"url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/comments/37825307","id":37825307,"diff_hunk":"@@ -1,138 +1,149 @@\n-#!/usr/bin/env python\n+# Copyright 2015 Metaswitch Networks\n+#\n+# Licensed under the Apache License, Version 2.0 (the 'License');\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an 'AS IS' BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n from __future__ import print_function\n import socket\n import functools\n+import logging\n import json\n import os\n import sys\n from subprocess import check_output, CalledProcessError, check_call\n-\n from netaddr import IPAddress, IPNetwork, AddrFormatError\n+\n+from logutils import configure_logger\n from pycalico import netns\n from pycalico.ipam import IPAMClient, SequentialAssignment\n from pycalico.netns import Namespace\n-from pycalico.datastore_datatypes import Rules\n+from pycalico.datastore_datatypes import Rules, IPPool\n from pycalico.datastore import IF_PREFIX, DatastoreClient\n from pycalico.datastore_errors import PoolNotFound\n \n-print_stderr = functools.partial(print, file=sys.stderr)\n+logger = logging.getLogger(__name__)\n \n-\n-input_ = ''.join(sys.stdin.readlines()).replace('\\n', '')\n-input_json = json.loads(input_)\n-\n-# Append to existing env, to avoid losing PATH etc.\n-# TODO-PAT: This shouldn't be hardcoded\n-env = os.environ.copy()\n ETCD_AUTHORITY_ENV = 'ETCD_AUTHORITY'\n-env[ETCD_AUTHORITY_ENV] = 'localhost:2379'\n \n-# PROFILE_LABEL = 'CALICO_PROFILE'\n-# ETCD_PROFILE_PATH = '/calico/'\n+env, INPUT_JSON = {}, {}\n \n ORCHESTRATOR_ID = \"rkt\"\n HOSTNAME = socket.gethostname()\n-NETNS_ROOT= '/var/lib/rkt/pods/run'\n+NETNS_ROOT = '/var/lib/rkt/pods/run'\n \n def main():\n     mode = env['CNI_COMMAND']\n \n     if mode == 'init':\n-        print_stderr('No initialization work to perform')\n+        logger.info('No initialization work to perform')\n     elif mode == 'ADD':\n-        print_stderr('Executing Calico pod-creation plugin')\n-        create(\n-            container_id=env['CNI_CONTAINERID']\n-            )\n+        logger.info('Executing Calico pod-creation plugin')","path":"calico_rkt/calico_rkt.py","position":69,"original_position":69,"commit_id":"8b7a2c413190761afbd44785d296c09971d28caf","original_commit_id":"8b7a2c413190761afbd44785d296c09971d28caf","user":{"login":"djosborne","id":3444362,"avatar_url":"https://avatars.githubusercontent.com/u/3444362?v=3","gravatar_id":"","url":"https://api.github.com/users/djosborne","html_url":"https://github.com/djosborne","followers_url":"https://api.github.com/users/djosborne/followers","following_url":"https://api.github.com/users/djosborne/following{/other_user}","gists_url":"https://api.github.com/users/djosborne/gists{/gist_id}","starred_url":"https://api.github.com/users/djosborne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djosborne/subscriptions","organizations_url":"https://api.github.com/users/djosborne/orgs","repos_url":"https://api.github.com/users/djosborne/repos","events_url":"https://api.github.com/users/djosborne/events{/privacy}","received_events_url":"https://api.github.com/users/djosborne/received_events","type":"User","site_admin":false},"body":"You've got a bit of a redundant logging message here, since you log a second message immediately in the `create` and `delete` functions. Though a lot of things can go wrong in python, we can assume that we'll make it to that next logger, so remove either this logging message or the one down there","created_at":"2015-08-25T01:44:26Z","updated_at":"2015-08-25T01:44:26Z","html_url":"https://github.com/projectcalico/calico-rkt/pull/2#discussion_r37825307","pull_request_url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/comments/37825307"},"html":{"href":"https://github.com/projectcalico/calico-rkt/pull/2#discussion_r37825307"},"pull_request":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2","id":42992286,"html_url":"https://github.com/projectcalico/calico-rkt/pull/2","diff_url":"https://github.com/projectcalico/calico-rkt/pull/2.diff","patch_url":"https://github.com/projectcalico/calico-rkt/pull/2.patch","issue_url":"https://api.github.com/repos/projectcalico/calico-rkt/issues/2","number":2,"state":"open","locked":false,"title":"Update #2: UTs, formatting/cleanup, requirements, logger and README","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":"Working PR to fix UTs and add features\r\n\r\nAlso added in a few changes as per Tim's [comments](https://github.com/projectcalico/calico-rkt/pull/1)","created_at":"2015-08-21T00:06:35Z","updated_at":"2015-08-25T01:44:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b1ab26572a6091755b5c17fb2fc43b08ac91458e","assignee":{"login":"caseydavenport","id":1944093,"avatar_url":"https://avatars.githubusercontent.com/u/1944093?v=3","gravatar_id":"","url":"https://api.github.com/users/caseydavenport","html_url":"https://github.com/caseydavenport","followers_url":"https://api.github.com/users/caseydavenport/followers","following_url":"https://api.github.com/users/caseydavenport/following{/other_user}","gists_url":"https://api.github.com/users/caseydavenport/gists{/gist_id}","starred_url":"https://api.github.com/users/caseydavenport/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseydavenport/subscriptions","organizations_url":"https://api.github.com/users/caseydavenport/orgs","repos_url":"https://api.github.com/users/caseydavenport/repos","events_url":"https://api.github.com/users/caseydavenport/events{/privacy}","received_events_url":"https://api.github.com/users/caseydavenport/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2/commits","review_comments_url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2/comments","review_comment_url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projectcalico/calico-rkt/issues/2/comments","statuses_url":"https://api.github.com/repos/projectcalico/calico-rkt/statuses/8b7a2c413190761afbd44785d296c09971d28caf","head":{"label":"alexhersh:fix-uts","ref":"fix-uts","sha":"8b7a2c413190761afbd44785d296c09971d28caf","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":41050089,"name":"calico-rkt","full_name":"alexhersh/calico-rkt","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-rkt","description":"Calico plugin for rkt deployments","fork":true,"url":"https://api.github.com/repos/alexhersh/calico-rkt","forks_url":"https://api.github.com/repos/alexhersh/calico-rkt/forks","keys_url":"https://api.github.com/repos/alexhersh/calico-rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexhersh/calico-rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexhersh/calico-rkt/teams","hooks_url":"https://api.github.com/repos/alexhersh/calico-rkt/hooks","issue_events_url":"https://api.github.com/repos/alexhersh/calico-rkt/issues/events{/number}","events_url":"https://api.github.com/repos/alexhersh/calico-rkt/events","assignees_url":"https://api.github.com/repos/alexhersh/calico-rkt/assignees{/user}","branches_url":"https://api.github.com/repos/alexhersh/calico-rkt/branches{/branch}","tags_url":"https://api.github.com/repos/alexhersh/calico-rkt/tags","blobs_url":"https://api.github.com/repos/alexhersh/calico-rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexhersh/calico-rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexhersh/calico-rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexhersh/calico-rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexhersh/calico-rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/alexhersh/calico-rkt/languages","stargazers_url":"https://api.github.com/repos/alexhersh/calico-rkt/stargazers","contributors_url":"https://api.github.com/repos/alexhersh/calico-rkt/contributors","subscribers_url":"https://api.github.com/repos/alexhersh/calico-rkt/subscribers","subscription_url":"https://api.github.com/repos/alexhersh/calico-rkt/subscription","commits_url":"https://api.github.com/repos/alexhersh/calico-rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexhersh/calico-rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexhersh/calico-rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexhersh/calico-rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexhersh/calico-rkt/contents/{+path}","compare_url":"https://api.github.com/repos/alexhersh/calico-rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexhersh/calico-rkt/merges","archive_url":"https://api.github.com/repos/alexhersh/calico-rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexhersh/calico-rkt/downloads","issues_url":"https://api.github.com/repos/alexhersh/calico-rkt/issues{/number}","pulls_url":"https://api.github.com/repos/alexhersh/calico-rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/alexhersh/calico-rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/alexhersh/calico-rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexhersh/calico-rkt/labels{/name}","releases_url":"https://api.github.com/repos/alexhersh/calico-rkt/releases{/id}","created_at":"2015-08-19T17:44:54Z","updated_at":"2015-08-19T17:44:55Z","pushed_at":"2015-08-25T00:04:45Z","git_url":"git://github.com/alexhersh/calico-rkt.git","ssh_url":"git@github.com:alexhersh/calico-rkt.git","clone_url":"https://github.com/alexhersh/calico-rkt.git","svn_url":"https://github.com/alexhersh/calico-rkt","homepage":"http://www.projectcalico.org/","size":86,"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":"projectcalico:master","ref":"master","sha":"7ac459b40a34830369cbaa97c0c6478f49298a43","user":{"login":"projectcalico","id":12304728,"avatar_url":"https://avatars.githubusercontent.com/u/12304728?v=3","gravatar_id":"","url":"https://api.github.com/users/projectcalico","html_url":"https://github.com/projectcalico","followers_url":"https://api.github.com/users/projectcalico/followers","following_url":"https://api.github.com/users/projectcalico/following{/other_user}","gists_url":"https://api.github.com/users/projectcalico/gists{/gist_id}","starred_url":"https://api.github.com/users/projectcalico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectcalico/subscriptions","organizations_url":"https://api.github.com/users/projectcalico/orgs","repos_url":"https://api.github.com/users/projectcalico/repos","events_url":"https://api.github.com/users/projectcalico/events{/privacy}","received_events_url":"https://api.github.com/users/projectcalico/received_events","type":"Organization","site_admin":false},"repo":{"id":39909298,"name":"calico-rkt","full_name":"projectcalico/calico-rkt","owner":{"login":"projectcalico","id":12304728,"avatar_url":"https://avatars.githubusercontent.com/u/12304728?v=3","gravatar_id":"","url":"https://api.github.com/users/projectcalico","html_url":"https://github.com/projectcalico","followers_url":"https://api.github.com/users/projectcalico/followers","following_url":"https://api.github.com/users/projectcalico/following{/other_user}","gists_url":"https://api.github.com/users/projectcalico/gists{/gist_id}","starred_url":"https://api.github.com/users/projectcalico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectcalico/subscriptions","organizations_url":"https://api.github.com/users/projectcalico/orgs","repos_url":"https://api.github.com/users/projectcalico/repos","events_url":"https://api.github.com/users/projectcalico/events{/privacy}","received_events_url":"https://api.github.com/users/projectcalico/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projectcalico/calico-rkt","description":"Calico plugin for rkt deployments","fork":false,"url":"https://api.github.com/repos/projectcalico/calico-rkt","forks_url":"https://api.github.com/repos/projectcalico/calico-rkt/forks","keys_url":"https://api.github.com/repos/projectcalico/calico-rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projectcalico/calico-rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projectcalico/calico-rkt/teams","hooks_url":"https://api.github.com/repos/projectcalico/calico-rkt/hooks","issue_events_url":"https://api.github.com/repos/projectcalico/calico-rkt/issues/events{/number}","events_url":"https://api.github.com/repos/projectcalico/calico-rkt/events","assignees_url":"https://api.github.com/repos/projectcalico/calico-rkt/assignees{/user}","branches_url":"https://api.github.com/repos/projectcalico/calico-rkt/branches{/branch}","tags_url":"https://api.github.com/repos/projectcalico/calico-rkt/tags","blobs_url":"https://api.github.com/repos/projectcalico/calico-rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projectcalico/calico-rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projectcalico/calico-rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/projectcalico/calico-rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projectcalico/calico-rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/projectcalico/calico-rkt/languages","stargazers_url":"https://api.github.com/repos/projectcalico/calico-rkt/stargazers","contributors_url":"https://api.github.com/repos/projectcalico/calico-rkt/contributors","subscribers_url":"https://api.github.com/repos/projectcalico/calico-rkt/subscribers","subscription_url":"https://api.github.com/repos/projectcalico/calico-rkt/subscription","commits_url":"https://api.github.com/repos/projectcalico/calico-rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/projectcalico/calico-rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/projectcalico/calico-rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/projectcalico/calico-rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/projectcalico/calico-rkt/contents/{+path}","compare_url":"https://api.github.com/repos/projectcalico/calico-rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projectcalico/calico-rkt/merges","archive_url":"https://api.github.com/repos/projectcalico/calico-rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projectcalico/calico-rkt/downloads","issues_url":"https://api.github.com/repos/projectcalico/calico-rkt/issues{/number}","pulls_url":"https://api.github.com/repos/projectcalico/calico-rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/projectcalico/calico-rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/projectcalico/calico-rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projectcalico/calico-rkt/labels{/name}","releases_url":"https://api.github.com/repos/projectcalico/calico-rkt/releases{/id}","created_at":"2015-07-29T18:23:48Z","updated_at":"2015-08-19T17:38:08Z","pushed_at":"2015-08-25T00:04:46Z","git_url":"git://github.com/projectcalico/calico-rkt.git","ssh_url":"git@github.com:projectcalico/calico-rkt.git","clone_url":"https://github.com/projectcalico/calico-rkt.git","svn_url":"https://github.com/projectcalico/calico-rkt","homepage":"http://www.projectcalico.org/","size":86,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2"},"html":{"href":"https://github.com/projectcalico/calico-rkt/pull/2"},"issue":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/issues/2"},"comments":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/projectcalico/calico-rkt/statuses/8b7a2c413190761afbd44785d296c09971d28caf"}}}}