{ "info": { "author": "Jathan McCollum", "author_email": "jathan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: Science/Research", "Intended Audience :: System Administrators", "Intended Audience :: Telecommunications Industry", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Education :: Testing", "Topic :: Internet", "Topic :: Security", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Networking", "Topic :: System :: Networking :: Monitoring", "Topic :: System :: Operating System", "Topic :: System :: Systems Administration", "Topic :: Utilities" ], "description": "=============\nNetScaler API\n=============\n\nSummary\n=======\n\nNetScaler API is a Python interface for interacting with Citrix NetScaler\napplication delivery controllers, utilizing the SOAP API to execute commands.\n\nDependencies\n============\n\n:`python-suds `_: Lightweight SOAP client\n\nExample\n=======\n\nPass any kwargs to init that you would to the ``suds.client.Client``\nconstructor. A little bit of magic is performed with the ``ImportDoctor`` to cover\nmissing types used in the WSDL.\n\n+ If you ``specify wsdl``, this file will be pulled from the default http URL\n+ If you ``specify wsdl_url``, it will override the wsdl file. Local\n+ ``file://`` URLs work just fine.\n\nTo save time for re-usable code, it is a good idea subclassing this to\ncreate methods for commonly used commands in your application::\n\n class MyAPI(API):\n def change_password(self, username, newpass):\n return self.run(\"setsystemuser_password\", username=username,\n password=newpass)\n\nIn a script::\n\n import netscaler\n\n if __name__ == '__main__':\n netscaler.DEBUG = True\n wsdl_url = 'file:///home/j/jathan/sandbox/NSUserAdmin.wsdl'\n client = netscaler.API('nos', username='nsroot', password='nsroot', wsdl_url=wsdl_url)\n print client.logged_in\n\nPerformance\n===========\n\nThe default NetScaler WSDL is massive and is undoubtedly the most comprehensive\nSOAP API I have ever worked with. It is 2.5M as of this writing. It describes\nservices everything the NetScaler can do, which is overkill for most tools.\nFetching the default ``NSConfig.wsdl`` will cause ``netscaler.py`` to compile\nthem all.\n\nThis can take a long time::\n\n % time ./nstest.py\n WSDL: file:///home/j/jathan/sandbox/NSConfig.wsdl\n Starting client...\n Done.\n ./netscaler.py 12.23s user 0.37s system 99% cpu 12.613 total\n\nIt will take even longer if you have to download the WSDL every time you start\nup your program. So you definitely want to filter your WSDL and the NetScaler\nhas a CLI tool called ``filterwsdl`` that does just that.\n\nIf you want more details on why to do it, please read http://bit.ly/aX57SS.\n\nSo let's say we just want to interact with user administration operations. How\nabout ``login``, ``logout``, ``savensconfig`` (of course), and anything with\n``systemuser`` in it. It goes like this (run from CLI shell on NetScaler)::\n\n # filterwsdl /netscaler/api/NSConfig.wsdl +\"log*\" +\"*systemuser*\" +\"savensconfig\" > /netscaler/api/NSUserAdmin.wsdl\n\nThen ``scp`` the file to localhost from the device. Now let's compare::\n\n -rw-r--r-- 1 jathan jathan 2.6M 2009-08-19 00:40 NSConfig.wsdl\n -rw-r--r-- 1 jathan jathan 14K 2010-03-02 16:36 NSUserAdmin.wsdl\n\nBig difference. Observe how fast does subset WSDL compiles::\n\n % time ./nstest.py\n WSDL: file:///home/j/jathan/sandbox/NSUserAdmin.wsdl\n Starting client...\n Done.\n ./netscaler.py 0.36s user 0.03s system 100% cpu 0.392 total\n\nHUGE difference.\n\nSuds WSDL caching\n=================\n\nBefore we play with it there is one thing to keep in mind about\n``suds.client``. It will cache the WSDL by default, which is helpful for\nproduction but can be confusing while testing and debugging, especially if\nyou're tweaking your filtered WSDL. So whenever testing, always pass\n``cache=None`` to the constructor to avoid this confusion.\n\nCommand-line example\n=====================\n\nOk now let's play with it::\n\n >>> import netscaler\n >>> wsdl_url = 'file:///Users/jathan/sandbox/netscaler-api/NSUserAdmin.wsdl'\n >>> api = netscaler.API('netscaler', username='nsroot', password='nsroot', wsdl_url=wsdl_url, cache=None)\n setting username to nsroot\n setting cache to None\n setting password to nsroot\n wsdl_url: file:///Users/jathan/sandbox/netscaler-api/NSUserAdmin.wsdl\n soap_url: http://netscaler/soap/\n\nNow if you print the api object, it acts just like a ``suds.client.Client``\nobject. Notice this subset of methods is way lower than the 2800+ methods from\nthe master WSDL::\n\n >>> print api\n\n Suds ( https://fedorahosted.org/suds/ ) version: 0.3.9 GA build: R659-20100219\n\n Service ( NSConfigService ) tns=\"urn:NSConfig\"\n Prefixes (2)\n ns0 = \"http://schemas.xmlsoap.org/soap/encoding/\"\n ns1 = \"urn:NSConfig\"\n Ports (1):\n (NSConfigPort)\n Methods (10):\n addsystemuser(xs:string username, xs:string password, )\n bindsystemuser_policy(xs:string username, xs:string policyname, xs:unsignedInt priority, )\n getsystemuser(xs:string username, )\n login(xs:string username, xs:string password, )\n loginchallengeresponse(xs:string response, )\n logout()\n rmsystemuser(xs:string username, )\n savensconfig()\n setsystemuser_password(xs:string username, xs:string password, )\n unbindsystemuser_policy(xs:string username, xs:string policyname, )\n Types (54):\n ns0:Array\n ns0:ENTITIES\n ns0:ENTITY\n ns0:ID\n ns0:IDREF\n ns0:IDREFS\n ns0:NCName\n ns0:NMTOKEN\n ns0:NMTOKENS\n ns0:NOTATION\n ns0:Name\n ns0:QName\n ns0:Struct\n ns0:anyURI\n ns0:arrayCoordinate\n ns0:base64\n ns0:base64Binary\n ns0:boolean\n ns0:byte\n ns0:date\n ns0:dateTime\n ns0:decimal\n ns0:double\n ns0:duration\n ns0:float\n ns0:gDay\n ns0:gMonth\n ns0:gMonthDay\n ns0:gYear\n ns0:gYearMonth\n getsystemuserResult\n ns0:hexBinary\n ns0:int\n ns0:integer\n ns0:language\n ns0:long\n ns0:negativeInteger\n ns0:nonNegativeInteger\n ns0:nonPositiveInteger\n ns0:normalizedString\n ns0:positiveInteger\n ns0:short\n simpleResult\n ns0:string\n stringList\n systemuser\n systemuserList\n ns0:time\n ns0:token\n ns0:unsignedByte\n ns0:unsignedInt\n unsignedIntList\n ns0:unsignedLong\n ns0:unsignedShort\n\nNow we can run a command::\n\n >>> api.run(\"addsystemuser\", username='jathan', password='jathan')\n config changed, autosaving.\n Done\n (simpleResult){\n rc = 0\n message = \"Done\"\n }\n\nAutosave\n========\n\nConfig changed, autosaving!\n\nYou might as yourself why not just directly invoke\n``api.client.service.addsystemuser()``. That's a good question. It depends on\nwhether you want to take advantage of the little perks I added like automatic\nlogin and automatic saving of the configuration on volatile operations. Some\npeople might like these ideas, others might not. Autosave is enabled by\ndefault, but you can disabled it by passing ``autosave=False`` to the\nconstructor.\n\nCurrently any command that does not start with ``login``, ``logout``, ``get``,\nor ``save`` is considered volatile, and will trigger an autosave.\n\n\nUserAdmin - A subclassing example\n=================================\n\nIn the examples directory is ``nsuser.py``, which is an example of how one might\nutilize subclassing to wrap some business logic around certain commands. Here\nit is::\n\n class IllegalName(netscaler.InteractionError): pass\n\n class UserAdmin(netscaler.API):\n def is_safe(self, username):\n \"\"\"Returns False for names containing 'root' or starting with 'ns'.\"\"\"\n if 'root' in username or username.startswith('ns'):\n return False\n return True\n\n def add_user(self, username, password):\n \"\"\"Custom user adder that won't allow unsafe names\"\"\"\n if not self.is_safe(username):\n raise IllegalName(username)\n\n try:\n resp = self.run(\"addsystemuser\", username=username, password=password)\n return True\n except netscaler.InteractionError, err:\n return False\n\n def del_user(self, username):\n \"\"\"Custom user remover that protects usernames\"\"\"\n if not self.is_safe(username):\n raise IllegalName(username)\n\n try:\n resp = self.run(\"rmsystemuser\", username=username)\n return True\n except netscaler.InteractionError, err:\n return False\n\n def user_exists(self, username):\n \"\"\"Returns True if user exists.\"\"\"\n try:\n resp = self.run(\"getsystemuser\", username=username)\n return True\n except netscaler.InteractionError, err:\n return False\n\nI used the example of blacklisting the creation or removal of any user that has\n\"root\" in the name or begins with \"ns\". So if you try any volatile operations\non this user using this module, this is what happens::\n\n >>> import nsuser\n >>> wsdl_url = 'file:///Users/jathan/sandbox/netscaler-api/examples/NSUserAdmin.wsdl'\n >>> api = nsuser.UserAdmin('netscaler', username='nsroot', password='nsroot',wsdl_url=wsdl_url, cache=None)\n >>> api.del_user('nsroot')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"nsuser.py\", line 29, in del_user\n raise IllegalName(username)\n nsuser.IllegalName: nsroot\n\nIf you run nsuser it does a little addition of missing users or removal of\nexisting ones with some dummy accounts just to show how it works::\n\n % py nsuser.py\n setting username to nsroot\n setting cache to None\n setting password to nsroot\n wsdl_url: file:///Users/jathan/sandbox/netscaler-api/examples/NSUserAdmin.wsdl\n soap_url: http://netscaler/soap/\n Done\n logged in: True\n autosave? True\n\n checking jathan\n config changed; consider saving!\n config changed; autosaving.\n Done\n jathan added!\n\n checking dynasty\n config changed; consider saving!\n config changed; autosaving.\n Done\n dynasty added!\n\n checking john\n config changed; consider saving!\n config changed; autosaving.\n Done\n john added!\n\nAnd the other way::\n\n % py nsuser.py\n setting username to nsroot\n setting cache to None\n setting password to nsroot\n wsdl_url: file:///Users/jathan/sandbox/netscaler-api/examples/NSUserAdmin.wsdl\n soap_url: http://netscaler/soap/\n Done\n logged in: True\n autosave? True\n\n checking jathan\n jathan exists.\n deleting\n config changed; consider saving!\n config changed; autosaving.\n Done\n\n checking dynasty\n config changed; autosaving.\n Done\n dynasty exists.\n deleting\n config changed; consider saving!\n config changed; autosaving.\n Done\n\n checking john\n config changed; autosaving.\n Done\n john exists.\n deleting\n config changed; consider saving!\n config changed; autosaving.\n Done\n\nEND TRANSMISSION\n", "description_content_type": null, "docs_url": "https://pythonhosted.org/netscaler-api/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jathanism/netscaler-api/", "keywords": "Networking,Automation,library,Security,NetScaler,API,SOAP", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "netscaler-api", "package_url": "https://pypi.org/project/netscaler-api/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/netscaler-api/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/jathanism/netscaler-api/" }, "release_url": "https://pypi.org/project/netscaler-api/0.2.3/", "requires_dist": null, "requires_python": null, "summary": "NetScaler API is a Python interface for interacting with Citrix NetScaler application delivery controllers, utilizing the SOAP API to execute commands.", "version": "0.2.3" }, "last_serial": 446151, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "bb1e3bbd09990086800c70cb24d75ca6", "sha256": "9aac4817407f5c4e4bbe04cee056168e7ac6ae90add31fd283f2453b34f1ba48" }, "downloads": -1, "filename": "netscaler-api-0.2.tar.gz", "has_sig": false, "md5_digest": "bb1e3bbd09990086800c70cb24d75ca6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22458, "upload_time": "2010-03-03T08:21:43", "url": "https://files.pythonhosted.org/packages/59/70/f5c8ba9c79394db92d505322fb2455cce1e2f085a15d547d9f2b8c21f2c3/netscaler-api-0.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "ccf044829c30e7a3952a6c672c2287e2", "sha256": "394baa086d6cc2302ff3fc60f21be3aeb99e223dcac48f68af82e7235c001c32" }, "downloads": -1, "filename": "netscaler-api-0.2.3.tar.gz", "has_sig": false, "md5_digest": "ccf044829c30e7a3952a6c672c2287e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29633, "upload_time": "2012-07-11T18:03:42", "url": "https://files.pythonhosted.org/packages/2c/97/c69a2edc8911810489cdfe43f70bb8d7492cf414027295e2ee095c138bd9/netscaler-api-0.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ccf044829c30e7a3952a6c672c2287e2", "sha256": "394baa086d6cc2302ff3fc60f21be3aeb99e223dcac48f68af82e7235c001c32" }, "downloads": -1, "filename": "netscaler-api-0.2.3.tar.gz", "has_sig": false, "md5_digest": "ccf044829c30e7a3952a6c672c2287e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29633, "upload_time": "2012-07-11T18:03:42", "url": "https://files.pythonhosted.org/packages/2c/97/c69a2edc8911810489cdfe43f70bb8d7492cf414027295e2ee095c138bd9/netscaler-api-0.2.3.tar.gz" } ] }