{ "info": { "author": "Mike Timm", "author_email": "mtimm@cisco.com", "bugtrack_url": null, "classifiers": [], "description": "====================\nSimpleAciUiLogServer\n====================\n\n.. image:: https://landscape.io/github/datacenter/SimpleAciUiLogServer/master/landscape.svg?style=flat\n :target: https://landscape.io/github/datacenter/SimpleAciUiLogServer/master\n :alt: Code Health\n\n.. image:: https://pypip.in/version/SimpleAciUiLogServer/badge.svg\n :target: https://pypi.python.org/pypi/SimpleAciUiLogServer/\n :alt: Latest Version\n\n.. image:: https://pypip.in/wheel/SimpleAciUiLogServer/badge.svg\n :target: https://pypi.python.org/pypi/SimpleAciUiLogServer/\n :alt: Wheel Status\n\n.. image:: https://pypip.in/egg/SimpleAciUiLogServer/badge.svg\n :target: https://pypi.python.org/pypi/SimpleAciUiLogServer/\n :alt: Egg Status\n\nA Simple HTTP/HTTPS server that accepts POSTs from the APIC UI as a remote API\nInspector.\n\nThe simplest method to use this module is to execute it as a standalone script,\nhowever it is designed to allow it to be imported as a module as well.\n\n\n\n-----------------\nStandalone Script\n-----------------\n\n.. code-block:: bash\n\n $ SimpleAci\n SimpleAciUiLogServer SimpleAciUiLogServer.py\n $ SimpleAciUiLogServer\n serving at:\n http://10.10.10.107:8987/apiinspector\n https://10.10.10.107:8443/apiinspector\n\n 2015-01-25 05:07:11,040 DEBUG - \n\n method: GET\n url: http://172.1.1.176/api/node/class/fabricTopology.json?subscription=yes\n payload: None\n # objs: 1\n response: {\"totalCount\":\"1\",\"subscriptionId\":\"72057761559216131\",\"imdata\":\n [{\"fabricTopology\":{\"attributes\":{\"childAction\":\"\",\"dn\":\"topology\",\n \"lcOwn\":\"local\",\"modTs\":\"2015-01-08T02:10:36.147+04:00\",\"monPolDn\":\n \"uni/fabric/monfab-default\",\"status\":\"\"}}}]}\n\nThe standalone script can be invoked using any of these commands:\n\n* SimpleAciUiLogServer\n* SimpleAciUiLogServer.py\n* acilogserv\n\nThe standalone script also allows you to set several options:\n\n* -a or --apicip: The IP address of an APIC or an IP address on the same subnet\n as the APIC. This allows the standalone server to be able to print the\n correct IP address when it announces what IP address, port and location\n it is listening on if the server is multi-homed.\n* -p or --port: The http port the server should listen on.\n* -s or --sslport: The https port the server should listen on.\n* -c or --cert: The server certificate for HTTPS connections.\n* -l or --location: The local path that the server should look for, anything\n sent to the server outside of this location will result in the server\n returning a 404. The default is /apiinspector\n* -r or --logrequests: This will cause the server to log a message about the\n POST request to sys.stderr, the default is False, possible values are True\n and False.\n* -d or --delete-imdata: Strip out the im_data and other info at the im_data\n level from the payloads and responses.\n* -n or --nice-output: Pretty print the payloads and responses.\n* -i or --indent: Number of spaces to indent when pretty printing.\n\nWhen the module is run as a standalone script it simply logs the messages\nto sys.stdout using the standard logging module.\n\n------------------\nAPIC Configuration\n------------------\n\nOnce the server is running, you can start remote logging from the APIC UI by\nselecting \"Start Remote Logging\" from the 'welcome, username' menu in the top\nright corner of the APIC UI.\n\n.. image:: https://raw.githubusercontent.com/datacenter/SimpleAciUiLogServer/master/start_remote_logging.png\n\nThen enter the URL the server is listening on:\n\n.. image:: https://raw.githubusercontent.com/datacenter/SimpleAciUiLogServer/master/enter_remote_logging_info.png\n\nIf you need to disable the remote logging from the APIC, you can do so from\nthe same menu and selecting 'Stop Remote Logging.'\n\n.. image:: https://raw.githubusercontent.com/datacenter/SimpleAciUiLogServer/master/stop_remote_logging.png\n\nNote: If https is used to connect to the APIC, the server that is\ninstantiated will also need to be able to accept https connections.\n\n-----------\nServer Test\n-----------\n\nBy convention the APIC does not use the GET method when communicating with the\nlogging server. The APIC only uses POST to POST the log messages to the server.\nHowever, the servers provided by this module do offer a GET method to provide\na means of testing them. For example it is possible to open a web browser and\nbrowse to the server that has been started. If the server is working a small\nmessage is provided about pointing the APIC to that server.\n\n---------\nDebugging\n---------\n\nIf things do not seem to be working, the first step should be to open the\ndeveloper tools/javascript console for the browser and see if there are\nany errors being printed as you click on various items in the APIC GUI.\n\n---------------------\nImporting as a module\n---------------------\n\nYou can also import the module and use it as a server as part of another\napplication. This provides you with flexibility as it allows the registration\nof callback functions for each HTTP method (GET, POST, DELETE, etc) found in the\nlog message. From this, it is possible to do things like use the data from the\nlog message for other purposes or filter out specific logs messages based on\nthe HTTP method. The methods that the APIC uses are:\n\n* GET\n* POST\n* EventChannelMessage\n* undefined - NOTE: This is an APIC bug that is fixed in versions after 1.0(2*)\n\nExample:\n\n.. code-block:: python\n\n >>> from SimpleAciUiLogServer.SimpleAciUiLogServer import \\\n ... SimpleAciUiLogServer\n >>> import logging\n >>> \n >>> logging.basicConfig(level=logging.DEBUG)\n >>> def GET(**kwargs):\n ... logging.debug(\"Got a GET\")\n ... \n >>> def POST(**kwargs):\n ... logging.debug(\"Kwargs/params: {0}\".format(kwargs))\n ... \n >>> server = SimpleAciUiLogServer((\"\", 8987), location='/apiinspector')\n >>> server.register_function(GET)\n >>> server.register_function(POST)\n >>> server.serve_forever()\n DEBUG:root:Got a GET\n DEBUG:root:\n method: Event Channel Message\n url: N/A\n payload: N/A\n # objs: 0\n response: {\"subscriptionId\":[\"72057611234639895\",\"72057611234640073\"],\n \"imdata\":[{\"fvTenant\":{\"attributes\":{\"childAction\":\"\",\"dn\":\n \"uni/tn-mtimm-simple\",\"modTs\":\"2015-01-23T23:04:28.838+00:00\",\"rn\":\"\",\n \"status\":\"deleted\"}}}]}\n \n DEBUG:root:Kwargs/params: {'data': {'url':\n 'http://172.1.1.5/api/node/mo/uni.json', 'response': '{\"imdata\":[]}', \n 'preamble': '18:00:12 DEBUG - ', 'method': 'POST', 'payload': '{\"polUni\":{\n \"attributes\":{\"dn\":\"uni\",\"status\":\"modified\"},\"children\":[{\"fvTenant\":{\n \"attributes\":{\"dn\":\"uni/tn-mtimm-simple\",\"status\":\"deleted\"},\"children\":[]}\n }]}}'}, 'layout': 'PatternLayout'}\n\nNote: since there were no functions registered for the EventChannelMessage\nmethod, SimpleAciUiLogServer sent that data to the default dispatch method\nwhich logs a formatted message. However, both GET and POST have registered\nfunctions and they do different things than the default dispatch method.\n\nIt is also possible to override the \\_dispatch method to create your own\ndispatch logic, for example rather than dispatch based on method maybe you\nwould like to dispatch based on subscription id.\n\n++++++++++++++++++++++\nMulti-threaded Servers\n++++++++++++++++++++++\n\nThe SimpleAciUiLogServer class is single threaded. If many APIC's are going\nto be reporting into the same server, one transaction may block another until\nthe first is complete. This scenario can be avoided using the\nThreadingSimpleAciUiLogServer class. The ThreadingSimpleAciUiLogServer class\nprovides a threaded server that can accept multiple connections at the same\ntime. When using the ThreadingSimpleAciUiLogServer it is best to use the\nlogging functionality from the Python standard library rather than print\nstatements because the logging module is thread safe.\n\nIf you need to listen on multiple ports you will need to instantiate multiple,\nSimpleAciUiLogServer or ThreadingSimpleAciUiLogServers. This might be done\nto start up both a http and https server. The module provides its own\nserve_forever() method that dispatches to multiple server instances. Otherwise\nthe servers own serve_forever() method is appropriate. The standalone script\noffers an example of doing this.\n\n+++++++++++++++++++++\nHTTPS TLS/SSL Support\n+++++++++++++++++++++\n\nTo accept HTTPS connections the SimpleAciUiLogServer or the\nThreadingSimpleAciUiLogServer classes can be instantiated with the cert\nparameter pointed at a file that contains the servers certificate. The module\ncomes with an embedded self-signed certificate but use of this should be avoided\nin long-term production scenarios. A self-signed certificate can be created\nusing openssl:\n\n.. code-block:: bash\n\n openssl req -new -x509 -keyout server.pem -out server.pem -days 36500 -nodes\n\nWhen the cert parameter is passed to the class initializer and is not None, the\nsocket is wrapped in ssl allowing the APIC to send https POST's to the server.\n\nIf you are using self-signed certificates, you will most likely need to accept\nthe certificate as a security exception in your browser before the APIC can send\ndata to it. This is usually a one-time configuration step and can most easily\nbe accomplished by using your browser to browse to the server.\n\n+++++++++++++++++++++++++\nAvailable Class Variables\n+++++++++++++++++++++++++\n\nThe servers provided inherit from a log dispatch class that offers some class\nvariables to control how the server formats the log messages. Those variables\nare:\n\n* prettyprint - Format the payload and responses so they are easier to read. The\n default is False.\n* indent - When using prettyprint, how much indent should be used. The default\n is 4.\n* strip_imdata - When printing responses, do not print the whole response, only\n print the contents of the im_data field. The default is False.\n\nAll three of these variables are booleans and should be set to True or False.\n\n---------------------------\nAuthor and Acknowledgements\n---------------------------\n\nWritten by Mike Timm (mtimm@cisco.com)\nBased on code written by Fredrik Lundh & Brian Quinlan.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/datacenter/SimpleAciUiLogServer/releases/tag/1.1.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/datacenter/SimpleAciUiLogServer", "keywords": null, "license": "SimpleAciUiLogServer\n\nMike Timm - mtimm@cisco.com\n\nCopyright (C) 2014 Cisco Systems Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.", "maintainer": null, "maintainer_email": null, "name": "SimpleAciUiLogServer", "package_url": "https://pypi.org/project/SimpleAciUiLogServer/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/SimpleAciUiLogServer/", "project_urls": { "Download": "https://github.com/datacenter/SimpleAciUiLogServer/releases/tag/1.1.3", "Homepage": "https://github.com/datacenter/SimpleAciUiLogServer" }, "release_url": "https://pypi.org/project/SimpleAciUiLogServer/1.1.3/", "requires_dist": null, "requires_python": null, "summary": "A remote API Inspector written in Python", "version": "1.1.3" }, "last_serial": 1679758, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "1b38ca08b14463cf2e3c4f36edb1e5a9", "sha256": "d826865b6be9cae8713fbf74b5979c5f680a0ed3617c71e9e28c3560cbaa569a" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.0.1.tar.gz", "has_sig": false, "md5_digest": "1b38ca08b14463cf2e3c4f36edb1e5a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8918, "upload_time": "2014-11-24T21:02:05", "url": "https://files.pythonhosted.org/packages/d0/d5/80542a3285d123fde6629f910448a15e582510742b4c80b385de86b62b2c/SimpleAciUiLogServer-1.0.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "f0a02c81644497b7ff7c466b3cd35244", "sha256": "50ffad5b37b49a0787a1e5a61b08334249a5ab7d5c43e14c0c26744d6752d237" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f0a02c81644497b7ff7c466b3cd35244", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 27834, "upload_time": "2015-02-04T03:11:04", "url": "https://files.pythonhosted.org/packages/13/5d/8834184ef60b384788eba820e9cb3f8dc3bf07221e639c23efc9ef18dc59/SimpleAciUiLogServer-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dfe8a813c3c6ff2913a3a769ffae41ef", "sha256": "a659302a2011fcb754745b13510e191329d0d0a66677df7b837803b966b5b714" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.1.tar.gz", "has_sig": false, "md5_digest": "dfe8a813c3c6ff2913a3a769ffae41ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18309, "upload_time": "2015-02-04T03:04:45", "url": "https://files.pythonhosted.org/packages/48/e1/45c776c21f717e10261742026e2f3f50534d0d715e21775783ef0ce7d49a/SimpleAciUiLogServer-1.1.1.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "f3b60e9ad615d1236939d893ce38a846", "sha256": "f45006848ded46f773a711b193970eca39be33b1bd471fd90ec1427e4bbbdd91" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.3-py2.7.egg", "has_sig": false, "md5_digest": "f3b60e9ad615d1236939d893ce38a846", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 35635, "upload_time": "2015-08-16T22:33:37", "url": "https://files.pythonhosted.org/packages/39/2d/80092cfb3664ae526ab400b05c21be518909419063938e0adae8841dc10f/SimpleAciUiLogServer-1.1.3-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "9ad5d1fb4a940666747b8390513a8a6f", "sha256": "dd78ccf5310ab76d7c54df123971a9b16acc2cf299843690841fadb301ec9465" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9ad5d1fb4a940666747b8390513a8a6f", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 30136, "upload_time": "2015-08-16T22:33:42", "url": "https://files.pythonhosted.org/packages/eb/30/6db66c0c83b7389da3cbb52f86fdc2f4dbed338e542bdd80e98215ea4f15/SimpleAciUiLogServer-1.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "34c1ef96485e414874e62e6c7ab0229f", "sha256": "caaccdd3ffea68c13df7cb9c3d37983c5f66c1ea51f43cfe9baf2abc00b11a05" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.3.tar.gz", "has_sig": false, "md5_digest": "34c1ef96485e414874e62e6c7ab0229f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20206, "upload_time": "2015-08-16T22:33:32", "url": "https://files.pythonhosted.org/packages/09/26/357621dc546b03e49206f8974bf3bc53e79b463892944c44b4c1a0a02b33/SimpleAciUiLogServer-1.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f3b60e9ad615d1236939d893ce38a846", "sha256": "f45006848ded46f773a711b193970eca39be33b1bd471fd90ec1427e4bbbdd91" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.3-py2.7.egg", "has_sig": false, "md5_digest": "f3b60e9ad615d1236939d893ce38a846", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 35635, "upload_time": "2015-08-16T22:33:37", "url": "https://files.pythonhosted.org/packages/39/2d/80092cfb3664ae526ab400b05c21be518909419063938e0adae8841dc10f/SimpleAciUiLogServer-1.1.3-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "9ad5d1fb4a940666747b8390513a8a6f", "sha256": "dd78ccf5310ab76d7c54df123971a9b16acc2cf299843690841fadb301ec9465" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9ad5d1fb4a940666747b8390513a8a6f", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 30136, "upload_time": "2015-08-16T22:33:42", "url": "https://files.pythonhosted.org/packages/eb/30/6db66c0c83b7389da3cbb52f86fdc2f4dbed338e542bdd80e98215ea4f15/SimpleAciUiLogServer-1.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "34c1ef96485e414874e62e6c7ab0229f", "sha256": "caaccdd3ffea68c13df7cb9c3d37983c5f66c1ea51f43cfe9baf2abc00b11a05" }, "downloads": -1, "filename": "SimpleAciUiLogServer-1.1.3.tar.gz", "has_sig": false, "md5_digest": "34c1ef96485e414874e62e6c7ab0229f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20206, "upload_time": "2015-08-16T22:33:32", "url": "https://files.pythonhosted.org/packages/09/26/357621dc546b03e49206f8974bf3bc53e79b463892944c44b4c1a0a02b33/SimpleAciUiLogServer-1.1.3.tar.gz" } ] }