{"action":"created","comment":{"url":"https://api.github.com/repos/romana/core/pulls/comments/61178471","id":61178471,"diff_hunk":"@@ -0,0 +1,469 @@\n+#!/usr/bin/env python\n+# Copyright (c) 2016 Pani Networks\n+# All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+# not use this file except in compliance with the License. You may obtain\n+# 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, WITHOUT\n+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+# License for the specific language governing permissions and limitations\n+# under the License.\n+\n+from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer\n+from optparse import OptionParser\n+import subprocess\n+import logging\n+import simplejson\n+from mimetools import Message\n+from StringIO import StringIO\n+HTTP_Unprocessable_Entity = 422\n+\n+logging.basicConfig(level=logging.DEBUG,\n+                    format='%(asctime)s %(levelname)-8s %(message)s',\n+                    datefmt='%a, %d %b %Y %H:%M:%S')\n+\n+# TODO should probably discover this from romana root\n+addr_scheme = {\n+    \"network_width\" : 8,\n+    \"host_width\" : 8,\n+    \"tenant_width\" : 4,\n+    \"segment_width\" : 4,\n+    \"endpoint_width\" : 8,\n+\n+    \"network_value\" : 10,\n+}\n+\n+parser = OptionParser(usage=\"%prog --port\")\n+parser.add_option('--port', default=9630, dest=\"port\", type=\"int\",\n+                  help=\"Port number to listen for incoming requests\")\n+(options, args) = parser.parse_args()\n+\n+def filter_rules_idx(rules):\n+    \"\"\"\n+    Returns 'sweet spot' in iptables rules, index in *filter table where chain\n+    definition ends and rules definition begins.\n+    \"\"\"\n+    filter_idx = rules.index('*filter')\n+    for rule in rules[filter_idx + 1:]:\n+        if not rule.startswith(\":\"):\n+            return rules.index(rule) + 1\n+\n+# We want to receive json object as a POST.\n+class AgentHandler(BaseHTTPRequestHandler):\n+    def do_GET(self):\n+        self.send_response(200)\n+        self.send_header('Content-type','text/html')","path":"pkg/util/policy/agent/agent.py","position":60,"original_position":60,"commit_id":"d0c6d26b4e5ed6c1f2c433af8131d2ef964dd04b","original_commit_id":"d0c6d26b4e5ed6c1f2c433af8131d2ef964dd04b","user":{"login":"opendsp2","id":8846577,"avatar_url":"https://avatars.githubusercontent.com/u/8846577?v=3","gravatar_id":"","url":"https://api.github.com/users/opendsp2","html_url":"https://github.com/opendsp2","followers_url":"https://api.github.com/users/opendsp2/followers","following_url":"https://api.github.com/users/opendsp2/following{/other_user}","gists_url":"https://api.github.com/users/opendsp2/gists{/gist_id}","starred_url":"https://api.github.com/users/opendsp2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendsp2/subscriptions","organizations_url":"https://api.github.com/users/opendsp2/orgs","repos_url":"https://api.github.com/users/opendsp2/repos","events_url":"https://api.github.com/users/opendsp2/events{/privacy}","received_events_url":"https://api.github.com/users/opendsp2/received_events","type":"User","site_admin":false},"body":"I know it doesn't matter much but can we use JSON?","created_at":"2016-04-26T22:53:10Z","updated_at":"2016-04-26T22:53:10Z","html_url":"https://github.com/romana/core/pull/69#discussion_r61178471","pull_request_url":"https://api.github.com/repos/romana/core/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/romana/core/pulls/comments/61178471"},"html":{"href":"https://github.com/romana/core/pull/69#discussion_r61178471"},"pull_request":{"href":"https://api.github.com/repos/romana/core/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/romana/core/pulls/69","id":66406868,"html_url":"https://github.com/romana/core/pull/69","diff_url":"https://github.com/romana/core/pull/69.diff","patch_url":"https://github.com/romana/core/pull/69.patch","issue_url":"https://api.github.com/repos/romana/core/issues/69","number":69,"state":"closed","locked":false,"title":"Feature/policy vectors","user":{"login":"flashvoid","id":446328,"avatar_url":"https://avatars.githubusercontent.com/u/446328?v=3","gravatar_id":"","url":"https://api.github.com/users/flashvoid","html_url":"https://github.com/flashvoid","followers_url":"https://api.github.com/users/flashvoid/followers","following_url":"https://api.github.com/users/flashvoid/following{/other_user}","gists_url":"https://api.github.com/users/flashvoid/gists{/gist_id}","starred_url":"https://api.github.com/users/flashvoid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flashvoid/subscriptions","organizations_url":"https://api.github.com/users/flashvoid/orgs","repos_url":"https://api.github.com/users/flashvoid/repos","events_url":"https://api.github.com/users/flashvoid/events{/privacy}","received_events_url":"https://api.github.com/users/flashvoid/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-13T23:13:43Z","updated_at":"2016-04-26T22:53:11Z","closed_at":"2016-04-25T23:33:07Z","merged_at":"2016-04-25T23:33:07Z","merge_commit_sha":"ce42a0dbb787f7940d5fd408a981407e5f2797d5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/romana/core/pulls/69/commits","review_comments_url":"https://api.github.com/repos/romana/core/pulls/69/comments","review_comment_url":"https://api.github.com/repos/romana/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/romana/core/issues/69/comments","statuses_url":"https://api.github.com/repos/romana/core/statuses/d0c6d26b4e5ed6c1f2c433af8131d2ef964dd04b","head":{"label":"romana:feature/policy-vectors","ref":"feature/policy-vectors","sha":"d0c6d26b4e5ed6c1f2c433af8131d2ef964dd04b","user":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"repo":{"id":43855674,"name":"core","full_name":"romana/core","owner":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/romana/core","description":"Romana core components - Micro services written in Go.","fork":false,"url":"https://api.github.com/repos/romana/core","forks_url":"https://api.github.com/repos/romana/core/forks","keys_url":"https://api.github.com/repos/romana/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romana/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romana/core/teams","hooks_url":"https://api.github.com/repos/romana/core/hooks","issue_events_url":"https://api.github.com/repos/romana/core/issues/events{/number}","events_url":"https://api.github.com/repos/romana/core/events","assignees_url":"https://api.github.com/repos/romana/core/assignees{/user}","branches_url":"https://api.github.com/repos/romana/core/branches{/branch}","tags_url":"https://api.github.com/repos/romana/core/tags","blobs_url":"https://api.github.com/repos/romana/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romana/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romana/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/romana/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romana/core/statuses/{sha}","languages_url":"https://api.github.com/repos/romana/core/languages","stargazers_url":"https://api.github.com/repos/romana/core/stargazers","contributors_url":"https://api.github.com/repos/romana/core/contributors","subscribers_url":"https://api.github.com/repos/romana/core/subscribers","subscription_url":"https://api.github.com/repos/romana/core/subscription","commits_url":"https://api.github.com/repos/romana/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/romana/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/romana/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/romana/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/romana/core/contents/{+path}","compare_url":"https://api.github.com/repos/romana/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romana/core/merges","archive_url":"https://api.github.com/repos/romana/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romana/core/downloads","issues_url":"https://api.github.com/repos/romana/core/issues{/number}","pulls_url":"https://api.github.com/repos/romana/core/pulls{/number}","milestones_url":"https://api.github.com/repos/romana/core/milestones{/number}","notifications_url":"https://api.github.com/repos/romana/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romana/core/labels{/name}","releases_url":"https://api.github.com/repos/romana/core/releases{/id}","deployments_url":"https://api.github.com/repos/romana/core/deployments","created_at":"2015-10-08T01:45:35Z","updated_at":"2016-04-13T22:10:15Z","pushed_at":"2016-04-26T22:51:35Z","git_url":"git://github.com/romana/core.git","ssh_url":"git@github.com:romana/core.git","clone_url":"https://github.com/romana/core.git","svn_url":"https://github.com/romana/core","homepage":"","size":604,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":10,"default_branch":"master"}},"base":{"label":"romana:project/policy-vectors","ref":"project/policy-vectors","sha":"89ad640f889cdfb01d669b56dfdda189de1d900a","user":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"repo":{"id":43855674,"name":"core","full_name":"romana/core","owner":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/romana/core","description":"Romana core components - Micro services written in Go.","fork":false,"url":"https://api.github.com/repos/romana/core","forks_url":"https://api.github.com/repos/romana/core/forks","keys_url":"https://api.github.com/repos/romana/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romana/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romana/core/teams","hooks_url":"https://api.github.com/repos/romana/core/hooks","issue_events_url":"https://api.github.com/repos/romana/core/issues/events{/number}","events_url":"https://api.github.com/repos/romana/core/events","assignees_url":"https://api.github.com/repos/romana/core/assignees{/user}","branches_url":"https://api.github.com/repos/romana/core/branches{/branch}","tags_url":"https://api.github.com/repos/romana/core/tags","blobs_url":"https://api.github.com/repos/romana/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romana/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romana/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/romana/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romana/core/statuses/{sha}","languages_url":"https://api.github.com/repos/romana/core/languages","stargazers_url":"https://api.github.com/repos/romana/core/stargazers","contributors_url":"https://api.github.com/repos/romana/core/contributors","subscribers_url":"https://api.github.com/repos/romana/core/subscribers","subscription_url":"https://api.github.com/repos/romana/core/subscription","commits_url":"https://api.github.com/repos/romana/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/romana/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/romana/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/romana/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/romana/core/contents/{+path}","compare_url":"https://api.github.com/repos/romana/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romana/core/merges","archive_url":"https://api.github.com/repos/romana/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romana/core/downloads","issues_url":"https://api.github.com/repos/romana/core/issues{/number}","pulls_url":"https://api.github.com/repos/romana/core/pulls{/number}","milestones_url":"https://api.github.com/repos/romana/core/milestones{/number}","notifications_url":"https://api.github.com/repos/romana/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romana/core/labels{/name}","releases_url":"https://api.github.com/repos/romana/core/releases{/id}","deployments_url":"https://api.github.com/repos/romana/core/deployments","created_at":"2015-10-08T01:45:35Z","updated_at":"2016-04-13T22:10:15Z","pushed_at":"2016-04-26T22:51:35Z","git_url":"git://github.com/romana/core.git","ssh_url":"git@github.com:romana/core.git","clone_url":"https://github.com/romana/core.git","svn_url":"https://github.com/romana/core","homepage":"","size":604,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/romana/core/pulls/69"},"html":{"href":"https://github.com/romana/core/pull/69"},"issue":{"href":"https://api.github.com/repos/romana/core/issues/69"},"comments":{"href":"https://api.github.com/repos/romana/core/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/romana/core/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/romana/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/romana/core/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/romana/core/statuses/d0c6d26b4e5ed6c1f2c433af8131d2ef964dd04b"}}}}