{"action":"created","issue":{"url":"https://api.github.com/repos/napalm-automation/napalm-base/issues/296","repository_url":"https://api.github.com/repos/napalm-automation/napalm-base","labels_url":"https://api.github.com/repos/napalm-automation/napalm-base/issues/296/labels{/name}","comments_url":"https://api.github.com/repos/napalm-automation/napalm-base/issues/296/comments","events_url":"https://api.github.com/repos/napalm-automation/napalm-base/issues/296/events","html_url":"https://github.com/napalm-automation/napalm-base/pull/296","id":248551031,"number":296,"title":"Added recorder and an example (to be removed)","user":{"login":"dbarrosop","id":6246622,"avatar_url":"https://avatars3.githubusercontent.com/u/6246622?v=4","gravatar_id":"","url":"https://api.github.com/users/dbarrosop","html_url":"https://github.com/dbarrosop","followers_url":"https://api.github.com/users/dbarrosop/followers","following_url":"https://api.github.com/users/dbarrosop/following{/other_user}","gists_url":"https://api.github.com/users/dbarrosop/gists{/gist_id}","starred_url":"https://api.github.com/users/dbarrosop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbarrosop/subscriptions","organizations_url":"https://api.github.com/users/dbarrosop/orgs","repos_url":"https://api.github.com/users/dbarrosop/repos","events_url":"https://api.github.com/users/dbarrosop/events{/privacy}","received_events_url":"https://api.github.com/users/dbarrosop/received_events","type":"User","site_admin":false},"labels":[{"id":444708509,"url":"https://api.github.com/repos/napalm-automation/napalm-base/labels/enhancement","name":"enhancement","color":"424242","default":true}],"state":"open","locked":false,"assignee":{"login":"dbarrosop","id":6246622,"avatar_url":"https://avatars3.githubusercontent.com/u/6246622?v=4","gravatar_id":"","url":"https://api.github.com/users/dbarrosop","html_url":"https://github.com/dbarrosop","followers_url":"https://api.github.com/users/dbarrosop/followers","following_url":"https://api.github.com/users/dbarrosop/following{/other_user}","gists_url":"https://api.github.com/users/dbarrosop/gists{/gist_id}","starred_url":"https://api.github.com/users/dbarrosop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbarrosop/subscriptions","organizations_url":"https://api.github.com/users/dbarrosop/orgs","repos_url":"https://api.github.com/users/dbarrosop/repos","events_url":"https://api.github.com/users/dbarrosop/events{/privacy}","received_events_url":"https://api.github.com/users/dbarrosop/received_events","type":"User","site_admin":false},"assignees":[{"login":"dbarrosop","id":6246622,"avatar_url":"https://avatars3.githubusercontent.com/u/6246622?v=4","gravatar_id":"","url":"https://api.github.com/users/dbarrosop","html_url":"https://github.com/dbarrosop","followers_url":"https://api.github.com/users/dbarrosop/followers","following_url":"https://api.github.com/users/dbarrosop/following{/other_user}","gists_url":"https://api.github.com/users/dbarrosop/gists{/gist_id}","starred_url":"https://api.github.com/users/dbarrosop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbarrosop/subscriptions","organizations_url":"https://api.github.com/users/dbarrosop/orgs","repos_url":"https://api.github.com/users/dbarrosop/repos","events_url":"https://api.github.com/users/dbarrosop/events{/privacy}","received_events_url":"https://api.github.com/users/dbarrosop/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/napalm-automation/napalm-base/milestones/13","html_url":"https://github.com/napalm-automation/napalm-base/milestone/13","labels_url":"https://api.github.com/repos/napalm-automation/napalm-base/milestones/13/labels","id":2092762,"number":13,"title":"DISCUSSION","description":"","creator":{"login":"mirceaulinic","id":16694679,"avatar_url":"https://avatars1.githubusercontent.com/u/16694679?v=4","gravatar_id":"","url":"https://api.github.com/users/mirceaulinic","html_url":"https://github.com/mirceaulinic","followers_url":"https://api.github.com/users/mirceaulinic/followers","following_url":"https://api.github.com/users/mirceaulinic/following{/other_user}","gists_url":"https://api.github.com/users/mirceaulinic/gists{/gist_id}","starred_url":"https://api.github.com/users/mirceaulinic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirceaulinic/subscriptions","organizations_url":"https://api.github.com/users/mirceaulinic/orgs","repos_url":"https://api.github.com/users/mirceaulinic/repos","events_url":"https://api.github.com/users/mirceaulinic/events{/privacy}","received_events_url":"https://api.github.com/users/mirceaulinic/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":8,"state":"open","created_at":"2016-10-25T16:43:18Z","updated_at":"2017-08-08T09:17:32Z","due_on":null,"closed_at":null},"comments":15,"created_at":"2017-08-07T22:39:21Z","updated_at":"2017-08-17T11:16:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/napalm-automation/napalm-base/pulls/296","html_url":"https://github.com/napalm-automation/napalm-base/pull/296","diff_url":"https://github.com/napalm-automation/napalm-base/pull/296.diff","patch_url":"https://github.com/napalm-automation/napalm-base/pull/296.patch"},"body":"This PR introduces a class that can sit between the driver and the underlying library (pyeapi, netmiko, pyez, etc. see napalm-automation/napalm-eos/pull/173).\r\n\r\nThe \"middleware\" has three modes:\r\n\r\n1. `pass`. Does nothing. The `Recorder` will just proxy the calls to the underlying library.\r\n2. `record`. The interactions between the driver and the underlying library are proxied and recorded.\r\n3. `replay`. The interactions between the driver and the underlying library are interrupted. Instead, the `Recorder` will pickle a previous recording and replay it.\r\n\r\n\r\nExample, in the following snippet we are running the same code three times testing all modes. Note that in the \"replay\" mode at the end I set wrong data to prove that there is no connection with the real device.\r\n\r\n```\r\n(napalm) ➜  napalm-base git:(recorder) ✗ python test.py\r\n{u'fqdn': u'localhost',\r\n u'hostname': u'localhost',\r\n u'interface_list': [u'Ethernet1', u'Ethernet2', u'Management1'],\r\n u'model': u'vEOS',\r\n u'os_version': u'4.15.2.1F-2759627.41521F',\r\n u'serial_number': u'',\r\n u'uptime': 4147,\r\n u'vendor': u'Arista'}\r\n{u'Ethernet1': {u'description': u'',\r\n                u'is_enabled': True,\r\n                u'is_up': True,\r\n                u'last_flapped': 1502141344.0919724,\r\n                u'mac_address': u'08:00:27:34:90:5B',\r\n                u'speed': 0},\r\n u'Ethernet2': {u'description': u'',\r\n                u'is_enabled': True,\r\n                u'is_up': True,\r\n                u'last_flapped': 1502141344.0921075,\r\n                u'mac_address': u'08:00:27:07:C3:F0',\r\n                u'speed': 0},\r\n u'Management1': {u'description': u'',\r\n                  u'is_enabled': True,\r\n                  u'is_up': True,\r\n                  u'last_flapped': 1502141358.069374,\r\n                  u'mac_address': u'08:00:27:7D:44:C1',\r\n                  u'speed': 1000}}\r\nnapalm-base - DEBUG - Recording run_commands\r\nnapalm-base - DEBUG - Recording run_commands\r\n{u'fqdn': u'localhost',\r\n u'hostname': u'localhost',\r\n u'interface_list': [u'Ethernet1', u'Ethernet2', u'Management1'],\r\n u'model': u'vEOS',\r\n u'os_version': u'4.15.2.1F-2759627.41521F',\r\n u'serial_number': u'',\r\n u'uptime': 4147,\r\n u'vendor': u'Arista'}\r\nnapalm-base - DEBUG - Recording run_commands\r\n{u'Ethernet1': {u'description': u'',\r\n                u'is_enabled': True,\r\n                u'is_up': True,\r\n                u'last_flapped': 1502141344.0919635,\r\n                u'mac_address': u'08:00:27:34:90:5B',\r\n                u'speed': 0},\r\n u'Ethernet2': {u'description': u'',\r\n                u'is_enabled': True,\r\n                u'is_up': True,\r\n                u'last_flapped': 1502141344.0921032,\r\n                u'mac_address': u'08:00:27:07:C3:F0',\r\n                u'speed': 0},\r\n u'Management1': {u'description': u'',\r\n                  u'is_enabled': True,\r\n                  u'is_up': True,\r\n                  u'last_flapped': 1502141358.0693803,\r\n                  u'mac_address': u'08:00:27:7D:44:C1',\r\n                  u'speed': 1000}}\r\nnapalm-base - DEBUG - Replaying run_commands\r\nnapalm-base - DEBUG - Replaying run_commands\r\n{u'fqdn': u'localhost',\r\n u'hostname': u'localhost',\r\n u'interface_list': [u'Ethernet1', u'Ethernet2', u'Management1'],\r\n u'model': u'vEOS',\r\n u'os_version': u'4.15.2.1F-2759627.41521F',\r\n u'serial_number': u'',\r\n u'uptime': 4147,\r\n u'vendor': u'Arista'}\r\nnapalm-base - DEBUG - Replaying run_commands\r\n{u'Ethernet1': {u'description': u'',\r\n                u'is_enabled': True,\r\n                u'is_up': True,\r\n                u'last_flapped': 1502141344.0919635,\r\n                u'mac_address': u'08:00:27:34:90:5B',\r\n                u'speed': 0},\r\n u'Ethernet2': {u'description': u'',\r\n                u'is_enabled': True,\r\n                u'is_up': True,\r\n                u'last_flapped': 1502141344.0921032,\r\n                u'mac_address': u'08:00:27:07:C3:F0',\r\n                u'speed': 0},\r\n u'Management1': {u'description': u'',\r\n                  u'is_enabled': True,\r\n                  u'is_up': True,\r\n                  u'last_flapped': 1502141358.0693803,\r\n                  u'mac_address': u'08:00:27:7D:44:C1',\r\n                  u'speed': 1000}}\r\n```\r\n\r\nTODO:\r\n1. Make sure we can capture exceptions as well\r\n2. Decide if we want to use pickle or serialize/deserialize objects. 99% of the interactions are going to be via dicts, json or xml so it should be doable. Exceptions might be trickier with doable as well."},"comment":{"url":"https://api.github.com/repos/napalm-automation/napalm-base/issues/comments/323041107","html_url":"https://github.com/napalm-automation/napalm-base/pull/296#issuecomment-323041107","issue_url":"https://api.github.com/repos/napalm-automation/napalm-base/issues/296","id":323041107,"user":{"login":"mirceaulinic","id":16694679,"avatar_url":"https://avatars1.githubusercontent.com/u/16694679?v=4","gravatar_id":"","url":"https://api.github.com/users/mirceaulinic","html_url":"https://github.com/mirceaulinic","followers_url":"https://api.github.com/users/mirceaulinic/followers","following_url":"https://api.github.com/users/mirceaulinic/following{/other_user}","gists_url":"https://api.github.com/users/mirceaulinic/gists{/gist_id}","starred_url":"https://api.github.com/users/mirceaulinic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirceaulinic/subscriptions","organizations_url":"https://api.github.com/users/mirceaulinic/orgs","repos_url":"https://api.github.com/users/mirceaulinic/repos","events_url":"https://api.github.com/users/mirceaulinic/events{/privacy}","received_events_url":"https://api.github.com/users/mirceaulinic/received_events","type":"User","site_admin":false},"created_at":"2017-08-17T11:16:36Z","updated_at":"2017-08-17T11:16:36Z","body":"@dbarrosop - you may have missed my review.\r\n\r\nI disagree on using an obscure library that gained less interest than naplam (i.e. https://github.com/eevee/camel has exactly 7 followers), rather than a very well known and widely adopted msgpack (also very well know for its speed).\r\n\r\nAlso, it's very bizzare that the sole resource I was able to find about this camel is the blog post you pointed out... written by its maintainer and one of the **4** contributors.\r\n"}}
{"actor":{"display_login":"mirceaulinic"}}