{"action":"created","comment":{"url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/comments/54980167","id":54980167,"diff_hunk":"@@ -0,0 +1,440 @@\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 oslo_log import log as logging\n+\n+from gbpservice.nfp._i18n import _\n+from gbpservice.nfp.lifecycle_manager.openstack import (\n+    openstack_driver\n+)\n+\n+LOG = logging.getLogger(__name__)\n+\n+\n+class LifeCycleDriverBase(object):\n+    \"\"\"Generic Driver class for Lifecycle handling of virtual appliances\n+\n+    Does not support sharing of virtual appliance for different chains\n+    Does not support hotplugging interface to devices\n+    Launches the VM with all the management and data ports and a new VM\n+    is launched for each Network Service Instance\n+    \"\"\"\n+    def __init__(self, supports_device_sharing=False, supports_hotplug=False,\n+                 max_interfaces=5):\n+        self.service_vendor = 'general'\n+        self.supports_device_sharing = supports_device_sharing\n+        self.supports_hotplug = supports_hotplug\n+        self.maximum_interfaces = max_interfaces\n+\n+        # TODO[Magesh]: Try to move the following handlers to\n+        # Device LCM manager rather than having here in the driver\n+        self.identity_handler = openstack_driver.KeystoneClient()\n+        self.compute_handler_nova = openstack_driver.NovaClient()\n+        self.network_handler_gbp = openstack_driver.GBPClient()\n+        self.network_handler_neutron = openstack_driver.NeutronClient()\n+\n+    def _is_device_sharing_supported(self):\n+        return self.supports_device_sharing and self.supports_hotplug\n+\n+    def _create_management_interface(self, device_data):\n+        token = (device_data['token']\n+                 if device_data.get('token')\n+                 else self.identity_handler.get_admin_token())\n+        name = 'mgmt_interface'  # TODO[RPM]: Use proper name\n+        if device_data['network_policy'].lower() == 'gbp':\n+            mgmt_ptg_id = device_data['management_network_info']['id']\n+            mgmt_interface = self.network_handler_gbp.create_policy_target(\n+                                token,\n+                                device_data['tenant_id'],\n+                                mgmt_ptg_id,\n+                                name)\n+        else:\n+            mgmt_net_id = device_data['management_network_info']['id']\n+            mgmt_interface = self.network_handler_neutron.create_port(\n+                                token,\n+                                device_data['tenant_id'],\n+                                mgmt_net_id)\n+\n+        return {'id': mgmt_interface['id'],\n+                'port_policy': device_data['network_policy'],\n+                'port_classification': 'mgmt',\n+                'port_type': 'NA'}\n+\n+    def _delete_management_interface(self, device_data, interface):\n+        token = (device_data['token']\n+                 if device_data.get('token')\n+                 else self.identity_handler.get_admin_token())\n+\n+        if interface['port_policy'].lower() == 'gbp':\n+            self.network_handler_gbp.delete_policy_target(token,\n+                                                          interface['id'])\n+        else:\n+            self.network_handler_neutron.delete_port(token, interface['id'])\n+\n+    def _get_interfaces_for_device_create(self, device_data):\n+        mgmt_interface = self._create_management_interface(device_data)\n+\n+        return [mgmt_interface]\n+\n+    def _delete_interfaces(self, device_data, interfaces):\n+        for interface in interfaces:\n+            if interface['port_classification'].lower() == 'mgmt':\n+                self._delete_management_interface(device_data, interface)\n+\n+    def _get_port_id(self, interface, token):\n+        if interface['port_policy'].lower() == 'gbp':\n+            pt = self.network_handler_gbp.get_policy_target(\n+                                token,\n+                                interface['id'])\n+            return pt['port_id']\n+        else:\n+            return interface['id']\n+\n+    def _get_port_details(self, token, port_id):\n+        port = self.network_handler_neutron.get_port(token, port_id)\n+        ip = port['port']['fixed_ips'][0]['ip_address']\n+        mac = port['port']['mac_address']\n+        subnet_id = port['port']['fixed_ips'][0]['subnet_id']\n+        subnet = self.network_handler_neutron.get_subnet(token, subnet_id)\n+        cidr = subnet['subnet']['cidr']\n+        gateway_ip = subnet['subnet']['gateway_ip']\n+\n+        return (ip, mac, cidr, gateway_ip)\n+\n+    def get_network_function_device_sharing_info(self, device_data):\n+        if not self._is_device_sharing_supported():","path":"gbpservice/nfp/lifecycle_manager/drivers/lifecycle_driver_base.py","position":114,"original_position":114,"commit_id":"e2b988dcf3b3f50f7fb7268b6564f082c2806bb9","original_commit_id":"e2b988dcf3b3f50f7fb7268b6564f082c2806bb9","user":{"login":"hemanthravi","id":1445038,"avatar_url":"https://avatars.githubusercontent.com/u/1445038?v=3","gravatar_id":"","url":"https://api.github.com/users/hemanthravi","html_url":"https://github.com/hemanthravi","followers_url":"https://api.github.com/users/hemanthravi/followers","following_url":"https://api.github.com/users/hemanthravi/following{/other_user}","gists_url":"https://api.github.com/users/hemanthravi/gists{/gist_id}","starred_url":"https://api.github.com/users/hemanthravi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hemanthravi/subscriptions","organizations_url":"https://api.github.com/users/hemanthravi/orgs","repos_url":"https://api.github.com/users/hemanthravi/repos","events_url":"https://api.github.com/users/hemanthravi/events{/privacy}","received_events_url":"https://api.github.com/users/hemanthravi/received_events","type":"User","site_admin":false},"body":"Why raise an exception if sharing is not supported?","created_at":"2016-03-04T01:46:28Z","updated_at":"2016-03-04T01:46:28Z","html_url":"https://github.com/oneconvergence/group-based-policy/pull/76#discussion_r54980167","pull_request_url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/comments/54980167"},"html":{"href":"https://github.com/oneconvergence/group-based-policy/pull/76#discussion_r54980167"},"pull_request":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76","id":61199004,"html_url":"https://github.com/oneconvergence/group-based-policy/pull/76","diff_url":"https://github.com/oneconvergence/group-based-policy/pull/76.diff","patch_url":"https://github.com/oneconvergence/group-based-policy/pull/76.patch","issue_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/76","number":76,"state":"open","locked":false,"title":"Rebase orchestrator","user":{"login":"mageshgv-oc","id":10354859,"avatar_url":"https://avatars.githubusercontent.com/u/10354859?v=3","gravatar_id":"","url":"https://api.github.com/users/mageshgv-oc","html_url":"https://github.com/mageshgv-oc","followers_url":"https://api.github.com/users/mageshgv-oc/followers","following_url":"https://api.github.com/users/mageshgv-oc/following{/other_user}","gists_url":"https://api.github.com/users/mageshgv-oc/gists{/gist_id}","starred_url":"https://api.github.com/users/mageshgv-oc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mageshgv-oc/subscriptions","organizations_url":"https://api.github.com/users/mageshgv-oc/orgs","repos_url":"https://api.github.com/users/mageshgv-oc/repos","events_url":"https://api.github.com/users/mageshgv-oc/events{/privacy}","received_events_url":"https://api.github.com/users/mageshgv-oc/received_events","type":"User","site_admin":false},"body":"Orchestrator code (includes framework commits)","created_at":"2016-03-01T06:26:48Z","updated_at":"2016-03-04T01:46:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8609036ab017d574c68d0e9b3cd2dde0e696b745","assignee":{"login":"hemanthravi","id":1445038,"avatar_url":"https://avatars.githubusercontent.com/u/1445038?v=3","gravatar_id":"","url":"https://api.github.com/users/hemanthravi","html_url":"https://github.com/hemanthravi","followers_url":"https://api.github.com/users/hemanthravi/followers","following_url":"https://api.github.com/users/hemanthravi/following{/other_user}","gists_url":"https://api.github.com/users/hemanthravi/gists{/gist_id}","starred_url":"https://api.github.com/users/hemanthravi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hemanthravi/subscriptions","organizations_url":"https://api.github.com/users/hemanthravi/orgs","repos_url":"https://api.github.com/users/hemanthravi/repos","events_url":"https://api.github.com/users/hemanthravi/events{/privacy}","received_events_url":"https://api.github.com/users/hemanthravi/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76/commits","review_comments_url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76/comments","review_comment_url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/76/comments","statuses_url":"https://api.github.com/repos/oneconvergence/group-based-policy/statuses/e2b988dcf3b3f50f7fb7268b6564f082c2806bb9","head":{"label":"oneconvergence:rebase_orchestrator","ref":"rebase_orchestrator","sha":"e2b988dcf3b3f50f7fb7268b6564f082c2806bb9","user":{"login":"oneconvergence","id":8160602,"avatar_url":"https://avatars.githubusercontent.com/u/8160602?v=3","gravatar_id":"","url":"https://api.github.com/users/oneconvergence","html_url":"https://github.com/oneconvergence","followers_url":"https://api.github.com/users/oneconvergence/followers","following_url":"https://api.github.com/users/oneconvergence/following{/other_user}","gists_url":"https://api.github.com/users/oneconvergence/gists{/gist_id}","starred_url":"https://api.github.com/users/oneconvergence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oneconvergence/subscriptions","organizations_url":"https://api.github.com/users/oneconvergence/orgs","repos_url":"https://api.github.com/users/oneconvergence/repos","events_url":"https://api.github.com/users/oneconvergence/events{/privacy}","received_events_url":"https://api.github.com/users/oneconvergence/received_events","type":"Organization","site_admin":false},"repo":{"id":34099604,"name":"group-based-policy","full_name":"oneconvergence/group-based-policy","owner":{"login":"oneconvergence","id":8160602,"avatar_url":"https://avatars.githubusercontent.com/u/8160602?v=3","gravatar_id":"","url":"https://api.github.com/users/oneconvergence","html_url":"https://github.com/oneconvergence","followers_url":"https://api.github.com/users/oneconvergence/followers","following_url":"https://api.github.com/users/oneconvergence/following{/other_user}","gists_url":"https://api.github.com/users/oneconvergence/gists{/gist_id}","starred_url":"https://api.github.com/users/oneconvergence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oneconvergence/subscriptions","organizations_url":"https://api.github.com/users/oneconvergence/orgs","repos_url":"https://api.github.com/users/oneconvergence/repos","events_url":"https://api.github.com/users/oneconvergence/events{/privacy}","received_events_url":"https://api.github.com/users/oneconvergence/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oneconvergence/group-based-policy","description":"Group Based Policy","fork":true,"url":"https://api.github.com/repos/oneconvergence/group-based-policy","forks_url":"https://api.github.com/repos/oneconvergence/group-based-policy/forks","keys_url":"https://api.github.com/repos/oneconvergence/group-based-policy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oneconvergence/group-based-policy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oneconvergence/group-based-policy/teams","hooks_url":"https://api.github.com/repos/oneconvergence/group-based-policy/hooks","issue_events_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/events{/number}","events_url":"https://api.github.com/repos/oneconvergence/group-based-policy/events","assignees_url":"https://api.github.com/repos/oneconvergence/group-based-policy/assignees{/user}","branches_url":"https://api.github.com/repos/oneconvergence/group-based-policy/branches{/branch}","tags_url":"https://api.github.com/repos/oneconvergence/group-based-policy/tags","blobs_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/refs{/sha}","trees_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oneconvergence/group-based-policy/statuses/{sha}","languages_url":"https://api.github.com/repos/oneconvergence/group-based-policy/languages","stargazers_url":"https://api.github.com/repos/oneconvergence/group-based-policy/stargazers","contributors_url":"https://api.github.com/repos/oneconvergence/group-based-policy/contributors","subscribers_url":"https://api.github.com/repos/oneconvergence/group-based-policy/subscribers","subscription_url":"https://api.github.com/repos/oneconvergence/group-based-policy/subscription","commits_url":"https://api.github.com/repos/oneconvergence/group-based-policy/commits{/sha}","git_commits_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/commits{/sha}","comments_url":"https://api.github.com/repos/oneconvergence/group-based-policy/comments{/number}","issue_comment_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/comments{/number}","contents_url":"https://api.github.com/repos/oneconvergence/group-based-policy/contents/{+path}","compare_url":"https://api.github.com/repos/oneconvergence/group-based-policy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oneconvergence/group-based-policy/merges","archive_url":"https://api.github.com/repos/oneconvergence/group-based-policy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oneconvergence/group-based-policy/downloads","issues_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues{/number}","pulls_url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls{/number}","milestones_url":"https://api.github.com/repos/oneconvergence/group-based-policy/milestones{/number}","notifications_url":"https://api.github.com/repos/oneconvergence/group-based-policy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oneconvergence/group-based-policy/labels{/name}","releases_url":"https://api.github.com/repos/oneconvergence/group-based-policy/releases{/id}","deployments_url":"https://api.github.com/repos/oneconvergence/group-based-policy/deployments","created_at":"2015-04-17T06:06:34Z","updated_at":"2016-02-19T14:46:42Z","pushed_at":"2016-03-03T18:07:12Z","git_url":"git://github.com/oneconvergence/group-based-policy.git","ssh_url":"git@github.com:oneconvergence/group-based-policy.git","clone_url":"https://github.com/oneconvergence/group-based-policy.git","svn_url":"https://github.com/oneconvergence/group-based-policy","homepage":"http://openstack.org","size":5080,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":14,"forks":3,"open_issues":14,"watchers":0,"default_branch":"oneconvergence_service_node_driver"}},"base":{"label":"oneconvergence:sc_opensource_integration","ref":"sc_opensource_integration","sha":"c806a88f3fa172e5fa94f3e58fb074a83e6ad966","user":{"login":"oneconvergence","id":8160602,"avatar_url":"https://avatars.githubusercontent.com/u/8160602?v=3","gravatar_id":"","url":"https://api.github.com/users/oneconvergence","html_url":"https://github.com/oneconvergence","followers_url":"https://api.github.com/users/oneconvergence/followers","following_url":"https://api.github.com/users/oneconvergence/following{/other_user}","gists_url":"https://api.github.com/users/oneconvergence/gists{/gist_id}","starred_url":"https://api.github.com/users/oneconvergence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oneconvergence/subscriptions","organizations_url":"https://api.github.com/users/oneconvergence/orgs","repos_url":"https://api.github.com/users/oneconvergence/repos","events_url":"https://api.github.com/users/oneconvergence/events{/privacy}","received_events_url":"https://api.github.com/users/oneconvergence/received_events","type":"Organization","site_admin":false},"repo":{"id":34099604,"name":"group-based-policy","full_name":"oneconvergence/group-based-policy","owner":{"login":"oneconvergence","id":8160602,"avatar_url":"https://avatars.githubusercontent.com/u/8160602?v=3","gravatar_id":"","url":"https://api.github.com/users/oneconvergence","html_url":"https://github.com/oneconvergence","followers_url":"https://api.github.com/users/oneconvergence/followers","following_url":"https://api.github.com/users/oneconvergence/following{/other_user}","gists_url":"https://api.github.com/users/oneconvergence/gists{/gist_id}","starred_url":"https://api.github.com/users/oneconvergence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oneconvergence/subscriptions","organizations_url":"https://api.github.com/users/oneconvergence/orgs","repos_url":"https://api.github.com/users/oneconvergence/repos","events_url":"https://api.github.com/users/oneconvergence/events{/privacy}","received_events_url":"https://api.github.com/users/oneconvergence/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oneconvergence/group-based-policy","description":"Group Based Policy","fork":true,"url":"https://api.github.com/repos/oneconvergence/group-based-policy","forks_url":"https://api.github.com/repos/oneconvergence/group-based-policy/forks","keys_url":"https://api.github.com/repos/oneconvergence/group-based-policy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oneconvergence/group-based-policy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oneconvergence/group-based-policy/teams","hooks_url":"https://api.github.com/repos/oneconvergence/group-based-policy/hooks","issue_events_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/events{/number}","events_url":"https://api.github.com/repos/oneconvergence/group-based-policy/events","assignees_url":"https://api.github.com/repos/oneconvergence/group-based-policy/assignees{/user}","branches_url":"https://api.github.com/repos/oneconvergence/group-based-policy/branches{/branch}","tags_url":"https://api.github.com/repos/oneconvergence/group-based-policy/tags","blobs_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/refs{/sha}","trees_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oneconvergence/group-based-policy/statuses/{sha}","languages_url":"https://api.github.com/repos/oneconvergence/group-based-policy/languages","stargazers_url":"https://api.github.com/repos/oneconvergence/group-based-policy/stargazers","contributors_url":"https://api.github.com/repos/oneconvergence/group-based-policy/contributors","subscribers_url":"https://api.github.com/repos/oneconvergence/group-based-policy/subscribers","subscription_url":"https://api.github.com/repos/oneconvergence/group-based-policy/subscription","commits_url":"https://api.github.com/repos/oneconvergence/group-based-policy/commits{/sha}","git_commits_url":"https://api.github.com/repos/oneconvergence/group-based-policy/git/commits{/sha}","comments_url":"https://api.github.com/repos/oneconvergence/group-based-policy/comments{/number}","issue_comment_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/comments{/number}","contents_url":"https://api.github.com/repos/oneconvergence/group-based-policy/contents/{+path}","compare_url":"https://api.github.com/repos/oneconvergence/group-based-policy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oneconvergence/group-based-policy/merges","archive_url":"https://api.github.com/repos/oneconvergence/group-based-policy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oneconvergence/group-based-policy/downloads","issues_url":"https://api.github.com/repos/oneconvergence/group-based-policy/issues{/number}","pulls_url":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls{/number}","milestones_url":"https://api.github.com/repos/oneconvergence/group-based-policy/milestones{/number}","notifications_url":"https://api.github.com/repos/oneconvergence/group-based-policy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oneconvergence/group-based-policy/labels{/name}","releases_url":"https://api.github.com/repos/oneconvergence/group-based-policy/releases{/id}","deployments_url":"https://api.github.com/repos/oneconvergence/group-based-policy/deployments","created_at":"2015-04-17T06:06:34Z","updated_at":"2016-02-19T14:46:42Z","pushed_at":"2016-03-03T18:07:12Z","git_url":"git://github.com/oneconvergence/group-based-policy.git","ssh_url":"git@github.com:oneconvergence/group-based-policy.git","clone_url":"https://github.com/oneconvergence/group-based-policy.git","svn_url":"https://github.com/oneconvergence/group-based-policy","homepage":"http://openstack.org","size":5080,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":14,"forks":3,"open_issues":14,"watchers":0,"default_branch":"oneconvergence_service_node_driver"}},"_links":{"self":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76"},"html":{"href":"https://github.com/oneconvergence/group-based-policy/pull/76"},"issue":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/76"},"comments":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/oneconvergence/group-based-policy/statuses/e2b988dcf3b3f50f7fb7268b6564f082c2806bb9"}}}}