{"action":"created","comment":{"url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/comments/45178821","id":45178821,"diff_hunk":"@@ -0,0 +1,143 @@\n+# Copyright (c) 2015 OpenStack Foundation\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\n+# implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+from baremetal_network_provisioning.common import constants\n+\n+from ironic.common import exception\n+from oslo_log import log as logging\n+from pysnmp.entity.rfc3413.oneliner import cmdgen\n+from pysnmp import error as snmp_error\n+\n+LOG = logging.getLogger(__name__)\n+\n+\n+Auth_protocol = {None: cmdgen.usmNoAuthProtocol,\n+                 'md5': cmdgen.usmHMACMD5AuthProtocol,\n+                 'sha': cmdgen.usmHMACSHAAuthProtocol}\n+\n+Priv_protocol = {None: cmdgen.usmNoPrivProtocol,\n+                 'des': cmdgen.usmDESPrivProtocol,\n+                 'des56': cmdgen.usmDESPrivProtocol,\n+                 '3des': cmdgen.usm3DESEDEPrivProtocol,\n+                 'aes': cmdgen.usmAesCfb128Protocol,\n+                 'aes128': cmdgen.usmAesCfb128Protocol,\n+                 'aes192': cmdgen.usmAesCfb192Protocol,\n+                 'aes256': cmdgen.usmAesCfb256Protocol}\n+\n+\n+class SNMPClient(object):\n+\n+    \"\"\"SNMP client object.\n+\n+    \"\"\"\n+    def __init__(self, ip_address, access_protocol,\n+                 write_community=None, security_name=None,\n+                 auth_protocol=None, auth_key=None,\n+                 priv_protocol=None, priv_key=None):\n+        self.ip_address = ip_address\n+        self.access_protocol = access_protocol\n+        if self.access_protocol == constants.SNMP_V3:\n+            self.security_name = security_name\n+            if auth_protocol:\n+                self.auth_protocol = Auth_protocol[auth_protocol]\n+                self.auth_key = auth_key\n+            if priv_protocol:\n+                self.priv_protocol = Priv_protocol[priv_protocol]\n+                self.priv_key = priv_key\n+        else:\n+            self.write_community = write_community\n+        self.cmd_gen = cmdgen.CommandGenerator()\n+\n+    def _get_auth(self):\n+        \"\"\"Return the authorization data for an SNMP request.\n+\n+        \"\"\"\n+        if self.access_protocol == constants.SNMP_V3:\n+            return cmdgen.UsmUserData(self.security_name,\n+                                      authKey=self.auth_key,\n+                                      privKey=self.priv_key,\n+                                      authProtocol=self.auth_protocol,\n+                                      privProtocol=self.priv_protocol)\n+        else:\n+            mp_model = 1 if self.access_protocol == constants.SNMP_V2C else 0\n+            return cmdgen.CommunityData(self.write_community,\n+                                        mpModel=mp_model)\n+\n+    def _get_transport(self):\n+        \"\"\"Return the transport target for an SNMP request.\n+\n+        \"\"\"\n+        return cmdgen.UdpTransportTarget(\n+            (self.ip_address, constants.SNMP_PORT), timeout=1, retries=5)","path":"baremetal_network_provisioning/drivers/snmp_client.py","position":83,"original_position":83,"commit_id":"63b280ff601a46cfa9949eb397bed9560896e4a8","original_commit_id":"63b280ff601a46cfa9949eb397bed9560896e4a8","user":{"login":"selvakumarnms","id":5934573,"avatar_url":"https://avatars.githubusercontent.com/u/5934573?v=3","gravatar_id":"","url":"https://api.github.com/users/selvakumarnms","html_url":"https://github.com/selvakumarnms","followers_url":"https://api.github.com/users/selvakumarnms/followers","following_url":"https://api.github.com/users/selvakumarnms/following{/other_user}","gists_url":"https://api.github.com/users/selvakumarnms/gists{/gist_id}","starred_url":"https://api.github.com/users/selvakumarnms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selvakumarnms/subscriptions","organizations_url":"https://api.github.com/users/selvakumarnms/orgs","repos_url":"https://api.github.com/users/selvakumarnms/repos","events_url":"https://api.github.com/users/selvakumarnms/events{/privacy}","received_events_url":"https://api.github.com/users/selvakumarnms/received_events","type":"User","site_admin":false},"body":"need to see timeout & retries  should be configurable ..","created_at":"2015-11-18T09:50:17Z","updated_at":"2015-11-18T09:50:17Z","html_url":"https://github.com/hp-networking/baremetal-network-provisioning/pull/26#discussion_r45178821","pull_request_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/comments/45178821"},"html":{"href":"https://github.com/hp-networking/baremetal-network-provisioning/pull/26#discussion_r45178821"},"pull_request":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26","id":50911587,"html_url":"https://github.com/hp-networking/baremetal-network-provisioning/pull/26","diff_url":"https://github.com/hp-networking/baremetal-network-provisioning/pull/26.diff","patch_url":"https://github.com/hp-networking/baremetal-network-provisioning/pull/26.patch","issue_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues/26","number":26,"state":"open","locked":false,"title":"Extension driver along with Discovery driver","user":{"login":"phanipawan","id":15884134,"avatar_url":"https://avatars.githubusercontent.com/u/15884134?v=3","gravatar_id":"","url":"https://api.github.com/users/phanipawan","html_url":"https://github.com/phanipawan","followers_url":"https://api.github.com/users/phanipawan/followers","following_url":"https://api.github.com/users/phanipawan/following{/other_user}","gists_url":"https://api.github.com/users/phanipawan/gists{/gist_id}","starred_url":"https://api.github.com/users/phanipawan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phanipawan/subscriptions","organizations_url":"https://api.github.com/users/phanipawan/orgs","repos_url":"https://api.github.com/users/phanipawan/repos","events_url":"https://api.github.com/users/phanipawan/events{/privacy}","received_events_url":"https://api.github.com/users/phanipawan/received_events","type":"User","site_admin":false},"body":"This patchset contains the implementation of extension and the\r\nimplementation of the discovery of the switch.","created_at":"2015-11-17T07:09:08Z","updated_at":"2015-11-18T09:50:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"736b439c7b299e60b27ef58a0c2b8016812f16fd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26/commits","review_comments_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26/comments","review_comment_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues/26/comments","statuses_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/statuses/63b280ff601a46cfa9949eb397bed9560896e4a8","head":{"label":"phanipawan:master","ref":"master","sha":"63b280ff601a46cfa9949eb397bed9560896e4a8","user":{"login":"phanipawan","id":15884134,"avatar_url":"https://avatars.githubusercontent.com/u/15884134?v=3","gravatar_id":"","url":"https://api.github.com/users/phanipawan","html_url":"https://github.com/phanipawan","followers_url":"https://api.github.com/users/phanipawan/followers","following_url":"https://api.github.com/users/phanipawan/following{/other_user}","gists_url":"https://api.github.com/users/phanipawan/gists{/gist_id}","starred_url":"https://api.github.com/users/phanipawan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phanipawan/subscriptions","organizations_url":"https://api.github.com/users/phanipawan/orgs","repos_url":"https://api.github.com/users/phanipawan/repos","events_url":"https://api.github.com/users/phanipawan/events{/privacy}","received_events_url":"https://api.github.com/users/phanipawan/received_events","type":"User","site_admin":false},"repo":{"id":46327029,"name":"baremetal-network-provisioning","full_name":"phanipawan/baremetal-network-provisioning","owner":{"login":"phanipawan","id":15884134,"avatar_url":"https://avatars.githubusercontent.com/u/15884134?v=3","gravatar_id":"","url":"https://api.github.com/users/phanipawan","html_url":"https://github.com/phanipawan","followers_url":"https://api.github.com/users/phanipawan/followers","following_url":"https://api.github.com/users/phanipawan/following{/other_user}","gists_url":"https://api.github.com/users/phanipawan/gists{/gist_id}","starred_url":"https://api.github.com/users/phanipawan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phanipawan/subscriptions","organizations_url":"https://api.github.com/users/phanipawan/orgs","repos_url":"https://api.github.com/users/phanipawan/repos","events_url":"https://api.github.com/users/phanipawan/events{/privacy}","received_events_url":"https://api.github.com/users/phanipawan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/phanipawan/baremetal-network-provisioning","description":"This repository contains Openstack Neutron based ML2 drivers that will enable provisioning networks for Openstack Ironic managed baremetal servers.","fork":true,"url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning","forks_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/forks","keys_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/teams","hooks_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/hooks","issue_events_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/issues/events{/number}","events_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/events","assignees_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/assignees{/user}","branches_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/branches{/branch}","tags_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/tags","blobs_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/git/refs{/sha}","trees_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/statuses/{sha}","languages_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/languages","stargazers_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/stargazers","contributors_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/contributors","subscribers_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/subscribers","subscription_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/subscription","commits_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/commits{/sha}","git_commits_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/git/commits{/sha}","comments_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/comments{/number}","issue_comment_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/issues/comments{/number}","contents_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/contents/{+path}","compare_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/merges","archive_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/downloads","issues_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/issues{/number}","pulls_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/pulls{/number}","milestones_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/milestones{/number}","notifications_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/labels{/name}","releases_url":"https://api.github.com/repos/phanipawan/baremetal-network-provisioning/releases{/id}","created_at":"2015-11-17T06:13:15Z","updated_at":"2015-11-17T06:13:16Z","pushed_at":"2015-11-17T07:16:35Z","git_url":"git://github.com/phanipawan/baremetal-network-provisioning.git","ssh_url":"git@github.com:phanipawan/baremetal-network-provisioning.git","clone_url":"https://github.com/phanipawan/baremetal-network-provisioning.git","svn_url":"https://github.com/phanipawan/baremetal-network-provisioning","homepage":null,"size":119,"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":"hp-networking:master","ref":"master","sha":"04444c1dada50ae84408f05c506744057eb4f984","user":{"login":"hp-networking","id":10058468,"avatar_url":"https://avatars.githubusercontent.com/u/10058468?v=3","gravatar_id":"","url":"https://api.github.com/users/hp-networking","html_url":"https://github.com/hp-networking","followers_url":"https://api.github.com/users/hp-networking/followers","following_url":"https://api.github.com/users/hp-networking/following{/other_user}","gists_url":"https://api.github.com/users/hp-networking/gists{/gist_id}","starred_url":"https://api.github.com/users/hp-networking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hp-networking/subscriptions","organizations_url":"https://api.github.com/users/hp-networking/orgs","repos_url":"https://api.github.com/users/hp-networking/repos","events_url":"https://api.github.com/users/hp-networking/events{/privacy}","received_events_url":"https://api.github.com/users/hp-networking/received_events","type":"User","site_admin":false},"repo":{"id":38354313,"name":"baremetal-network-provisioning","full_name":"hp-networking/baremetal-network-provisioning","owner":{"login":"hp-networking","id":10058468,"avatar_url":"https://avatars.githubusercontent.com/u/10058468?v=3","gravatar_id":"","url":"https://api.github.com/users/hp-networking","html_url":"https://github.com/hp-networking","followers_url":"https://api.github.com/users/hp-networking/followers","following_url":"https://api.github.com/users/hp-networking/following{/other_user}","gists_url":"https://api.github.com/users/hp-networking/gists{/gist_id}","starred_url":"https://api.github.com/users/hp-networking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hp-networking/subscriptions","organizations_url":"https://api.github.com/users/hp-networking/orgs","repos_url":"https://api.github.com/users/hp-networking/repos","events_url":"https://api.github.com/users/hp-networking/events{/privacy}","received_events_url":"https://api.github.com/users/hp-networking/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hp-networking/baremetal-network-provisioning","description":"This repository contains Openstack Neutron based ML2 drivers that will enable provisioning networks for Openstack Ironic managed baremetal servers.","fork":false,"url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning","forks_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/forks","keys_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/teams","hooks_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/hooks","issue_events_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues/events{/number}","events_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/events","assignees_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/assignees{/user}","branches_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/branches{/branch}","tags_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/tags","blobs_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/git/refs{/sha}","trees_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/statuses/{sha}","languages_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/languages","stargazers_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/stargazers","contributors_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/contributors","subscribers_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/subscribers","subscription_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/subscription","commits_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/commits{/sha}","git_commits_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/git/commits{/sha}","comments_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/comments{/number}","issue_comment_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues/comments{/number}","contents_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/contents/{+path}","compare_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/merges","archive_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/downloads","issues_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues{/number}","pulls_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls{/number}","milestones_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/milestones{/number}","notifications_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/labels{/name}","releases_url":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/releases{/id}","created_at":"2015-07-01T06:39:03Z","updated_at":"2015-07-15T06:52:47Z","pushed_at":"2015-11-17T07:16:35Z","git_url":"git://github.com/hp-networking/baremetal-network-provisioning.git","ssh_url":"git@github.com:hp-networking/baremetal-network-provisioning.git","clone_url":"https://github.com/hp-networking/baremetal-network-provisioning.git","svn_url":"https://github.com/hp-networking/baremetal-network-provisioning","homepage":null,"size":349,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26"},"html":{"href":"https://github.com/hp-networking/baremetal-network-provisioning/pull/26"},"issue":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues/26"},"comments":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/hp-networking/baremetal-network-provisioning/statuses/63b280ff601a46cfa9949eb397bed9560896e4a8"}}}}