{ "info": { "author": "Nathan Catania", "author_email": "nathan@nathancatania.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "============\nryurest\n============\nA Python module to interact with the REST API of the Ryu SDN controller.\n\n***************\nABOUT\n***************\nThese are two Python modules that individually provide either a functional or object-orientated approach to using the Ryu REST API.\n\nThe modules make use of the Requests framework to interact with the RYU REST API.\n\n***************\nMODULES\n***************\nBoth the modules contain identical functions/methods. Which one you should use depends entirely on how comfortable you are with Python (although it is generally seen as better practice in the community to use OO approaches where possible)\n\nryuswitch\n==========\nObject-orientated approach.\n\nProvides the `RyuSwitch` class to instantiate the physical switches connected to the controller as objects.\n\nryufunc\n=======\nFunctional approach.\n\nAllows you to call the RyuSwitch methods directly (although a switch Datapath ID (DPID) must be passed as an argument in most cases).\n\n************\nREQUIREMENTS\n************\nRun the Ryu controller with REST API enabled.::\n\n$ sudo ryu-manager ryu.app.simple_switch_13 ryu.app.ofctl_rest\n\n************\nINSTALLATION\n************\nPyPi\n====\n.. code-block::\n\n $ pip install ryurest\n\nYou may wish to use ``sudo`` with this command.\n\nFrom source\n===========\nAlternatively you can either download or clone this repository, place the required `ryufunc.py` and/or `ryuswitch.py` modules into your project directory, and import them as per normal.\n\n.. code-block::\n\n $ git clone https://github.com/nathancatania/ryurest\n\n.. code-block:: python\n\n # imports the functional module\n import ryufunc\n\n # imports the object-orientated module\n from ryuswitch import RySwitch\n\n\nYou may also need to install the `requests `_ library if it is not already on your machine:\n\n.. code-block::\n\n $ pip install requests\n\n=====\nUSAGE\n=====\n***************************************\nryuswitch.py (Object-Orientated module)\n***************************************\n1. Import the `ryurest` module and the `RyuSwitch` class into your script\n=========================================================================\n\n.. code-block::\n\n from ryurest import RyuSwitch\n\n\n2. Create one or more RyuSwitch objects\n=======================================\n\n.. code-block::\n\n switch1 = RyuSwitch( DPID )\n\nIf you do not know any of the DPIDs of the connected switches, you can initialize with no arguments and call the `.get_switches()` method to return an array of DPIDs.\n\nBe sure to assign any object created in this way a DPID manually:\n\n.. code-block::\n\n # Create a switch\n switch0 = RyuSwitch()\n\n # Get an array of Datapath IDs (DPIDs) for all connected switches\n DPID_list = switch0.get_switches()\n\n # Assign a DPID manually to the switch created\n switch0.DPID = DPID_list[0]\n\n\n3. [OPTIONAL] Change the REST API URI\n=====================================\n* The default location for the Ryu REST API is: `http://localhost:8080`\n* If Ryu is running on the same PC as the module (localhost), then there is no need to change anything.\n* If the Ryu controller is running on a different machine and/or port, you MUST set the API path within each `RyuSwitch` object created.\n\n.. code-block::\n\n switch1 = RyuSwitch( DPID_list[0] )\n switch1.API = \"http://192.168.1.30:8080\"\n\n switch2 = RyuSwitch( DPID_list[1] )\n switch2.API = \"http://192.168.1.30:8080\"\n\n**Warning!** If altering the API path, DO NOT add a trailing '/' at the end or the API call will fail!\n\n4. Execute the class methods as required\n========================================\n.. code-block::\n\n # Gets all flows in flowtable\n flows = switch1.get_flows()\n\n* Some methods have optional filters as well.\n* Consult the `ryuswitch.py` module or the `Ryu REST API documentation `_ for more info.\n\n******************************\nryufunc.py (functional module)\n******************************\n1. From the `ryurest` module, import `ryufunc` into your script\n===============================================================\n.. code-block::\n\n from ryurest import ryufunc\n\n2. [OPTIONAL] Change the REST API URI\n=====================================\n* The default location for the Ryu REST API is: `http://localhost:8080`\n* If Ryu is running on the same PC as the module (localhost), then there is no need to change anything.\n* If the Ryu controller is running on a different machine and/or port, you MUST set the API path. This is global for the entire ryufunc namespace.\n\n.. code-block::\n\n print ryufunc.API\n # prints: http://localhost:8080\n\n # Change the default IP and Port\n ryufunc.API = \"http://192.168.0.30:8080\"\n\n**Warning!** If altering the API path, DO NOT add a trailing '/' at the end or the API call will fail!\n\n3. [OPTIONAL] Obtain a list of Datapath IDs (DPIDs)\n===================================================\n* If you know the DPID(s) of the switch(es) you wish to interact with, you can skip this step.\n* To return an array containing all of the DPIDs (switches) connected to the Ryu controller, use the get_switches() function:\n\n.. code-block::\n\n DPID_list = ryufunc.get_switches()\n\n # Prints a list of all DPIDs\n for DPID in DPID_list:\n print DPID\n\n # Access how you would any other array\n switch1_dpid = DPID_list[0]\n switch2_dpid = DPID_list[1]\n # etc...\n\n\n4. Execute the functions as required\n====================================\n* Once you know the DPID(s) of the connected switch(es), you can start to execute function calls.\n\n.. code-block::\n\n # Gets all flows in flowtable\n flows = ryufunc.get_flows( switch1_dpid ) # returns JSON\n\n* Some methods have optional filters.\n* Consult the `ryufunc.py` module or the `Ryu REST API documentation `_ for more info.\n\n\n**************\nRETURN FORMATS\n**************\n* If API call was **successful**...\n * All the .get_x() methods will return **JSON formatted data**; EXCEPT .get_switches() which will return an array of DPIDs.\n * All the .set_x(), .delete_x(), .modify_X() methods will return boolean **True**.\n* If the API call **fails**...\n * ALL methods/functions will return boolean **False**.\n\nThis means that you can use `if` statements to check for and handle errors accordingly.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nathancatania/ryurest", "keywords": "ryu sdn rest api controller python", "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "ryurest", "package_url": "https://pypi.org/project/ryurest/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ryurest/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/nathancatania/ryurest" }, "release_url": "https://pypi.org/project/ryurest/0.1/", "requires_dist": null, "requires_python": null, "summary": "An unofficial Python library to interact with the REST API of the Ryu SDN Controller.", "version": "0.1" }, "last_serial": 2830535, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "f0701a4fe01108000ca71b5e702b6ef2", "sha256": "7587d2a734896392470981aa24ccc907caf569004cd3c7e5820fcd70db1e68eb" }, "downloads": -1, "filename": "ryurest-0.1.tar.gz", "has_sig": false, "md5_digest": "f0701a4fe01108000ca71b5e702b6ef2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15645, "upload_time": "2017-04-26T02:48:10", "url": "https://files.pythonhosted.org/packages/3e/cf/5f7ffad4ed3b595c89226c59d9d35a58390bca5fb9eaf7c93e0123d292c1/ryurest-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f0701a4fe01108000ca71b5e702b6ef2", "sha256": "7587d2a734896392470981aa24ccc907caf569004cd3c7e5820fcd70db1e68eb" }, "downloads": -1, "filename": "ryurest-0.1.tar.gz", "has_sig": false, "md5_digest": "f0701a4fe01108000ca71b5e702b6ef2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15645, "upload_time": "2017-04-26T02:48:10", "url": "https://files.pythonhosted.org/packages/3e/cf/5f7ffad4ed3b595c89226c59d9d35a58390bca5fb9eaf7c93e0123d292c1/ryurest-0.1.tar.gz" } ] }