{"action":"created","comment":{"url":"https://api.github.com/repos/projectcalico/calico/pulls/comments/43099876","id":43099876,"diff_hunk":"@@ -0,0 +1,113 @@\n+# Copyright (c) 2015 Cisco Systems.  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 neutron.db import l3_db\n+from neutron.plugins.ml2 import managers\n+from neutron.plugins.ml2.plugin import Ml2Plugin\n+from oslo_utils import importutils\n+\n+try:\n+    # Icehouse, Juno\n+    from neutron.openstack.common import log\n+except ImportError:\n+    # Kilo\n+    from oslo_log import log\n+\n+try:\n+    # Icehouse, Juno\n+    from oslo.config import cfg\n+except ImportError:\n+    # Kilo\n+    from oslo_config import cfg\n+\n+LOG = log.getLogger(__name__)\n+\n+\n+# Extend the MechanismManager class so that we have a way to pass floating\n+# IP update messages into the mechanism driver.\n+class CalicoMechanismManager(managers.MechanismManager):\n+    def __init__(self, *args, **kw):\n+        # Force the ML2 driver to use only the calico mechanism driver.  This\n+        # just makes it so less things need to be configured in neutron.conf.\n+        cfg.CONF.ml2.mechanism_drivers = ['calico']\n+        super(CalicoMechanismManager, self).__init__(*args, **kw)\n+\n+    def update_floatingip(self, context):\n+        \"\"\"Notify the mechanism driver of a floating IP update.\"\"\"\n+        self._call_on_drivers(\"update_floatingip\", context)\n+\n+\n+# Since we have to do all the work to overwrite MechanismManager, it's fairly\n+# cheap for us to remove the necessity for the user to configure the\n+# type_managers and tenant_network_types in neutron.conf.  This basically\n+# means the user shouldn't need to configure anything in the [ml2] config\n+# section.\n+class CalicoTypeManager(managers.TypeManager):\n+    def __init__(self, *args, **kw):\n+        cfg.CONF.ml2.type_drivers = ['local', 'flat']\n+        cfg.CONF.ml2.tenant_network_types = ['local']\n+        super(CalicoTypeManager, self).__init__(*args, **kw)\n+\n+\n+class CalicoCorePlugin(Ml2Plugin, l3_db.L3_NAT_dbonly_mixin):\n+    def __init__(self):\n+        # Add the ability to handle floating IPs.\n+        self._supported_extension_aliases.extend([\"router\"])\n+\n+        # The following is an annoying duplication from Ml2Plugin.__init__\n+        # just so that we can use our own MechanismManager class.\n+\n+        self.type_manager = CalicoTypeManager()\n+        self.extension_manager = managers.ExtensionManager()\n+        self.mechanism_manager = CalicoMechanismManager()\n+\n+        # Ml2Plugin.__init__ calls super on itself, but we can't do that\n+        # because it would overwrite self.mechanism_manager with a non-Calico\n+        # MechanismManager.  So we do a bit of a manual super implementation\n+        # that just makes sure to skip running __init__ in Ml2Plugin.\n+        for c in CalicoCorePlugin.__mro__:\n+            if not c in [CalicoCorePlugin, Ml2Plugin]:\n+                if getattr(c, '__init__', None):\n+                    c.__init__(self)\n+\n+        self.type_manager.initialize()\n+        self.extension_manager.initialize()\n+        self.mechanism_manager.initialize()\n+        self._setup_rpc()\n+        self.network_scheduler = importutils.import_object(\n+            cfg.CONF.network_scheduler_driver\n+        )\n+\n+        # Added to Ml2Plugin.__init__ in Kilo.\n+        if getattr(self, 'start_periodic_dhcp_agent_status_check', None):\n+            self.start_periodic_dhcp_agent_status_check()\n+\n+        LOG.info(\"Calico Core Plugin initialization complete\")\n+\n+","path":"calico/openstack/core_calico.py","position":98,"original_position":98,"commit_id":"bb4a41320430e78a33ec420a5bc6457c7d45d177","original_commit_id":"bb4a41320430e78a33ec420a5bc6457c7d45d177","user":{"login":"fasaxc","id":469264,"avatar_url":"https://avatars.githubusercontent.com/u/469264?v=3","gravatar_id":"","url":"https://api.github.com/users/fasaxc","html_url":"https://github.com/fasaxc","followers_url":"https://api.github.com/users/fasaxc/followers","following_url":"https://api.github.com/users/fasaxc/following{/other_user}","gists_url":"https://api.github.com/users/fasaxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fasaxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fasaxc/subscriptions","organizations_url":"https://api.github.com/users/fasaxc/orgs","repos_url":"https://api.github.com/users/fasaxc/repos","events_url":"https://api.github.com/users/fasaxc/events{/privacy}","received_events_url":"https://api.github.com/users/fasaxc/received_events","type":"User","site_admin":false},"body":"Nitpick: extra blank line.","created_at":"2015-10-27T09:44:13Z","updated_at":"2015-10-27T09:44:13Z","html_url":"https://github.com/projectcalico/calico/pull/848#discussion_r43099876","pull_request_url":"https://api.github.com/repos/projectcalico/calico/pulls/848","_links":{"self":{"href":"https://api.github.com/repos/projectcalico/calico/pulls/comments/43099876"},"html":{"href":"https://github.com/projectcalico/calico/pull/848#discussion_r43099876"},"pull_request":{"href":"https://api.github.com/repos/projectcalico/calico/pulls/848"}}},"pull_request":{"url":"https://api.github.com/repos/projectcalico/calico/pulls/848","id":48095866,"html_url":"https://github.com/projectcalico/calico/pull/848","diff_url":"https://github.com/projectcalico/calico/pull/848.diff","patch_url":"https://github.com/projectcalico/calico/pull/848.patch","issue_url":"https://api.github.com/repos/projectcalico/calico/issues/848","number":848,"state":"open","locked":false,"title":"Support floating IPs via NAT.","user":{"login":"nbartos","id":923926,"avatar_url":"https://avatars.githubusercontent.com/u/923926?v=3","gravatar_id":"","url":"https://api.github.com/users/nbartos","html_url":"https://github.com/nbartos","followers_url":"https://api.github.com/users/nbartos/followers","following_url":"https://api.github.com/users/nbartos/following{/other_user}","gists_url":"https://api.github.com/users/nbartos/gists{/gist_id}","starred_url":"https://api.github.com/users/nbartos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbartos/subscriptions","organizations_url":"https://api.github.com/users/nbartos/orgs","repos_url":"https://api.github.com/users/nbartos/repos","events_url":"https://api.github.com/users/nbartos/events{/privacy}","received_events_url":"https://api.github.com/users/nbartos/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-19T16:39:32Z","updated_at":"2015-10-27T09:44:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5be4b978cd6e551484a1269dbe6927599efdc44c","assignee":{"login":"fasaxc","id":469264,"avatar_url":"https://avatars.githubusercontent.com/u/469264?v=3","gravatar_id":"","url":"https://api.github.com/users/fasaxc","html_url":"https://github.com/fasaxc","followers_url":"https://api.github.com/users/fasaxc/followers","following_url":"https://api.github.com/users/fasaxc/following{/other_user}","gists_url":"https://api.github.com/users/fasaxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fasaxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fasaxc/subscriptions","organizations_url":"https://api.github.com/users/fasaxc/orgs","repos_url":"https://api.github.com/users/fasaxc/repos","events_url":"https://api.github.com/users/fasaxc/events{/privacy}","received_events_url":"https://api.github.com/users/fasaxc/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/projectcalico/calico/milestones/19","html_url":"https://github.com/projectcalico/calico/milestones/1.3.0","labels_url":"https://api.github.com/repos/projectcalico/calico/milestones/19/labels","id":1359060,"number":19,"title":"1.3.0","description":"","creator":{"login":"fasaxc","id":469264,"avatar_url":"https://avatars.githubusercontent.com/u/469264?v=3","gravatar_id":"","url":"https://api.github.com/users/fasaxc","html_url":"https://github.com/fasaxc","followers_url":"https://api.github.com/users/fasaxc/followers","following_url":"https://api.github.com/users/fasaxc/following{/other_user}","gists_url":"https://api.github.com/users/fasaxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fasaxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fasaxc/subscriptions","organizations_url":"https://api.github.com/users/fasaxc/orgs","repos_url":"https://api.github.com/users/fasaxc/repos","events_url":"https://api.github.com/users/fasaxc/events{/privacy}","received_events_url":"https://api.github.com/users/fasaxc/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":1,"state":"open","created_at":"2015-10-16T09:23:50Z","updated_at":"2015-10-26T17:41:08Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/projectcalico/calico/pulls/848/commits","review_comments_url":"https://api.github.com/repos/projectcalico/calico/pulls/848/comments","review_comment_url":"https://api.github.com/repos/projectcalico/calico/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projectcalico/calico/issues/848/comments","statuses_url":"https://api.github.com/repos/projectcalico/calico/statuses/bb4a41320430e78a33ec420a5bc6457c7d45d177","head":{"label":"nbartos:fip","ref":"fip","sha":"bb4a41320430e78a33ec420a5bc6457c7d45d177","user":{"login":"nbartos","id":923926,"avatar_url":"https://avatars.githubusercontent.com/u/923926?v=3","gravatar_id":"","url":"https://api.github.com/users/nbartos","html_url":"https://github.com/nbartos","followers_url":"https://api.github.com/users/nbartos/followers","following_url":"https://api.github.com/users/nbartos/following{/other_user}","gists_url":"https://api.github.com/users/nbartos/gists{/gist_id}","starred_url":"https://api.github.com/users/nbartos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbartos/subscriptions","organizations_url":"https://api.github.com/users/nbartos/orgs","repos_url":"https://api.github.com/users/nbartos/repos","events_url":"https://api.github.com/users/nbartos/events{/privacy}","received_events_url":"https://api.github.com/users/nbartos/received_events","type":"User","site_admin":false},"repo":{"id":34280764,"name":"calico","full_name":"nbartos/calico","owner":{"login":"nbartos","id":923926,"avatar_url":"https://avatars.githubusercontent.com/u/923926?v=3","gravatar_id":"","url":"https://api.github.com/users/nbartos","html_url":"https://github.com/nbartos","followers_url":"https://api.github.com/users/nbartos/followers","following_url":"https://api.github.com/users/nbartos/following{/other_user}","gists_url":"https://api.github.com/users/nbartos/gists{/gist_id}","starred_url":"https://api.github.com/users/nbartos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbartos/subscriptions","organizations_url":"https://api.github.com/users/nbartos/orgs","repos_url":"https://api.github.com/users/nbartos/repos","events_url":"https://api.github.com/users/nbartos/events{/privacy}","received_events_url":"https://api.github.com/users/nbartos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nbartos/calico","description":"Project Calico core repository.","fork":true,"url":"https://api.github.com/repos/nbartos/calico","forks_url":"https://api.github.com/repos/nbartos/calico/forks","keys_url":"https://api.github.com/repos/nbartos/calico/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nbartos/calico/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nbartos/calico/teams","hooks_url":"https://api.github.com/repos/nbartos/calico/hooks","issue_events_url":"https://api.github.com/repos/nbartos/calico/issues/events{/number}","events_url":"https://api.github.com/repos/nbartos/calico/events","assignees_url":"https://api.github.com/repos/nbartos/calico/assignees{/user}","branches_url":"https://api.github.com/repos/nbartos/calico/branches{/branch}","tags_url":"https://api.github.com/repos/nbartos/calico/tags","blobs_url":"https://api.github.com/repos/nbartos/calico/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nbartos/calico/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nbartos/calico/git/refs{/sha}","trees_url":"https://api.github.com/repos/nbartos/calico/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nbartos/calico/statuses/{sha}","languages_url":"https://api.github.com/repos/nbartos/calico/languages","stargazers_url":"https://api.github.com/repos/nbartos/calico/stargazers","contributors_url":"https://api.github.com/repos/nbartos/calico/contributors","subscribers_url":"https://api.github.com/repos/nbartos/calico/subscribers","subscription_url":"https://api.github.com/repos/nbartos/calico/subscription","commits_url":"https://api.github.com/repos/nbartos/calico/commits{/sha}","git_commits_url":"https://api.github.com/repos/nbartos/calico/git/commits{/sha}","comments_url":"https://api.github.com/repos/nbartos/calico/comments{/number}","issue_comment_url":"https://api.github.com/repos/nbartos/calico/issues/comments{/number}","contents_url":"https://api.github.com/repos/nbartos/calico/contents/{+path}","compare_url":"https://api.github.com/repos/nbartos/calico/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nbartos/calico/merges","archive_url":"https://api.github.com/repos/nbartos/calico/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nbartos/calico/downloads","issues_url":"https://api.github.com/repos/nbartos/calico/issues{/number}","pulls_url":"https://api.github.com/repos/nbartos/calico/pulls{/number}","milestones_url":"https://api.github.com/repos/nbartos/calico/milestones{/number}","notifications_url":"https://api.github.com/repos/nbartos/calico/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nbartos/calico/labels{/name}","releases_url":"https://api.github.com/repos/nbartos/calico/releases{/id}","created_at":"2015-04-20T19:10:57Z","updated_at":"2015-04-20T19:10:57Z","pushed_at":"2015-10-26T22:10:41Z","git_url":"git://github.com/nbartos/calico.git","ssh_url":"git@github.com:nbartos/calico.git","clone_url":"https://github.com/nbartos/calico.git","svn_url":"https://github.com/nbartos/calico","homepage":"http://projectcalico.org/","size":5017,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"f588892156a9324483db9e79188ba0cf17ce9df5","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":21242831,"name":"calico","full_name":"projectcalico/calico","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","description":"Project Calico core repository.","fork":false,"url":"https://api.github.com/repos/projectcalico/calico","forks_url":"https://api.github.com/repos/projectcalico/calico/forks","keys_url":"https://api.github.com/repos/projectcalico/calico/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projectcalico/calico/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projectcalico/calico/teams","hooks_url":"https://api.github.com/repos/projectcalico/calico/hooks","issue_events_url":"https://api.github.com/repos/projectcalico/calico/issues/events{/number}","events_url":"https://api.github.com/repos/projectcalico/calico/events","assignees_url":"https://api.github.com/repos/projectcalico/calico/assignees{/user}","branches_url":"https://api.github.com/repos/projectcalico/calico/branches{/branch}","tags_url":"https://api.github.com/repos/projectcalico/calico/tags","blobs_url":"https://api.github.com/repos/projectcalico/calico/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projectcalico/calico/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projectcalico/calico/git/refs{/sha}","trees_url":"https://api.github.com/repos/projectcalico/calico/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projectcalico/calico/statuses/{sha}","languages_url":"https://api.github.com/repos/projectcalico/calico/languages","stargazers_url":"https://api.github.com/repos/projectcalico/calico/stargazers","contributors_url":"https://api.github.com/repos/projectcalico/calico/contributors","subscribers_url":"https://api.github.com/repos/projectcalico/calico/subscribers","subscription_url":"https://api.github.com/repos/projectcalico/calico/subscription","commits_url":"https://api.github.com/repos/projectcalico/calico/commits{/sha}","git_commits_url":"https://api.github.com/repos/projectcalico/calico/git/commits{/sha}","comments_url":"https://api.github.com/repos/projectcalico/calico/comments{/number}","issue_comment_url":"https://api.github.com/repos/projectcalico/calico/issues/comments{/number}","contents_url":"https://api.github.com/repos/projectcalico/calico/contents/{+path}","compare_url":"https://api.github.com/repos/projectcalico/calico/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projectcalico/calico/merges","archive_url":"https://api.github.com/repos/projectcalico/calico/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projectcalico/calico/downloads","issues_url":"https://api.github.com/repos/projectcalico/calico/issues{/number}","pulls_url":"https://api.github.com/repos/projectcalico/calico/pulls{/number}","milestones_url":"https://api.github.com/repos/projectcalico/calico/milestones{/number}","notifications_url":"https://api.github.com/repos/projectcalico/calico/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projectcalico/calico/labels{/name}","releases_url":"https://api.github.com/repos/projectcalico/calico/releases{/id}","created_at":"2014-06-26T14:08:43Z","updated_at":"2015-10-27T07:08:10Z","pushed_at":"2015-10-27T09:18:53Z","git_url":"git://github.com/projectcalico/calico.git","ssh_url":"git@github.com:projectcalico/calico.git","clone_url":"https://github.com/projectcalico/calico.git","svn_url":"https://github.com/projectcalico/calico","homepage":"http://projectcalico.org/","size":11456,"stargazers_count":240,"watchers_count":240,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":42,"forks":36,"open_issues":42,"watchers":240,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projectcalico/calico/pulls/848"},"html":{"href":"https://github.com/projectcalico/calico/pull/848"},"issue":{"href":"https://api.github.com/repos/projectcalico/calico/issues/848"},"comments":{"href":"https://api.github.com/repos/projectcalico/calico/issues/848/comments"},"review_comments":{"href":"https://api.github.com/repos/projectcalico/calico/pulls/848/comments"},"review_comment":{"href":"https://api.github.com/repos/projectcalico/calico/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projectcalico/calico/pulls/848/commits"},"statuses":{"href":"https://api.github.com/repos/projectcalico/calico/statuses/bb4a41320430e78a33ec420a5bc6457c7d45d177"}}}}