SD-WAN

 View Only
last person joined: yesterday 

Forum to discuss HPE Aruba EdgeConnect SD-WAN and SD-Branch solutions. This includes SD-WAN Orchestration WAN edge network functions - routing, security, zone-based firewall, segmentation and WAN optimization, micro-branch solutions, best practics, and third-party integrations. All things SD-WAN!
Expand all | Collapse all

Python language bindings for the REST API - hp-sdn-client

This thread has been viewed 1 times
  • 1.  Python language bindings for the REST API - hp-sdn-client

    Posted Feb 16, 2014 10:24 AM

    hp-sdn-client

    A Python library that makes interaction with the HP SDN Controller REST API easy

     

    This is a free open-source (Apache 2.0) library, that you can use to develop your own applications in Python.

    It tries to abstract the complexity of dealing wth the REST API (JSON, Token Management etc..) and allows you to focus on your application logic.

     

    You can install it from PyPi by using  pip:

     

        pip install hp-sdn-client

     

    If you find this library useful, please star the repo on GitHub and if you'd like to contribute please fork it, make your changes and send me a pull request!


    Code:

    https://github.com/dave-tucker/hp-sdn-client

     

    Docs:

    https://hp-sdn-client.readthedocs.org/en/latest/index.html

     

    Example:

     

    import hpsdnclient as hp
    
    controller = '10.44.254.129'
    # Set up Authentication
    auth = hp.XAuthToken(user='sdn',password='skyline', server=controller)
    # Create an API object
    api = hp.Api(controller=controller, auth=auth)
    
    #API calls are then just a method call using "natural language"
    datapaths = api.get_datapaths()
    for datapath in datapaths:
        flows = api.get_flows(datapath.dpid)
        for flow in flows:
            print "This is a flow from {} to {} on DPID: {}".format(flow.eth_src, 
                                                                                           flow.eth_dst, 
                                                                                           datapath.dpid)

     

     


    #Python


  • 2.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 16, 2014 03:06 PM

    Hi Dave,

     

    just starting with the sdn controller and a couple of hp 5900 switches.

    want to use python to create some apps, so found your information and tried to install...but failed...

     

    I installed the sdn-controller on a virtual ubuntu server and tested it with my 5900 switches...succes!

    Now i installed pip on this same server: "sudo apt-get install python-pip"

    after this i tried to start "pip install hp-sdn-client", but failed.

     

    can you help me with this?

     

     

    root@ubuntu-server-12:/# pip install hp-sdn-client
    Downloading/unpacking hp-sdn-client
      Downloading hp-sdn-client-1.0.2.tar.gz (633Kb): 633Kb downloaded
      Running setup.py egg_info for package hp-sdn-client
        Traceback (most recent call last):
          File "<string>", line 14, in <module>
          File "/build/hp-sdn-client/setup.py", line 18, in <module>
            from hpsdnclient import __version__
          File "hpsdnclient/__init__.py", line 17, in <module>
            from hpsdnclient.api import __version__, Api
          File "hpsdnclient/api.py", line 23, in <module>
            from hpsdnclient.core import CoreMixin
          File "hpsdnclient/core.py", line 28, in <module>
            import requests
        ImportError: No module named requests
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):

      File "<string>", line 14, in <module>

      File "/build/hp-sdn-client/setup.py", line 18, in <module>

        from hpsdnclient import __version__

      File "hpsdnclient/__init__.py", line 17, in <module>

        from hpsdnclient.api import __version__, Api

      File "hpsdnclient/api.py", line 23, in <module>

        from hpsdnclient.core import CoreMixin

      File "hpsdnclient/core.py", line 28, in <module>

        import requests

    ImportError: No module named requests

    ----------------------------------------
    Command python setup.py egg_info failed with error code 1
    Storing complete log in /root/.pip/pip.log



  • 3.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 16, 2014 03:09 PM

    Yes I can...

     

        pip install requests

     

    ... then you can try

     

        pip install hp-sdn-client

     

     

    For some reason this dependency isn't being installed automatically. I'm looking in to it, but for now the workaround above should get you started!

     

    -- Dave



  • 4.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 16, 2014 03:14 PM

    PERFECT!

     

    Thank you Dave!

     

    root@ubuntu-server-12:/# pip install requests
    Downloading/unpacking requests
      Downloading requests-2.2.1.tar.gz (421Kb): 421Kb downloaded
      Running setup.py egg_info for package requests

    Installing collected packages: requests
      Running setup.py install for requests

    Successfully installed requests
    Cleaning up...
    root@ubuntu-server-12:/# pip install hp-sdn-client
    Downloading/unpacking hp-sdn-client
      Downloading hp-sdn-client-1.0.2.tar.gz (633Kb): 633Kb downloaded
      Running setup.py egg_info for package hp-sdn-client

    Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/dist-packages (from hp-sdn-client)
    Requirement already satisfied (use --upgrade to upgrade): distribute in /usr/lib/python2.7/dist-packages (from hp-sdn-client)
    Installing collected packages: hp-sdn-client
      Running setup.py install for hp-sdn-client

    Successfully installed hp-sdn-client
    Cleaning up...
    root@ubuntu-server-12:/#



  • 5.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 18, 2014 08:39 AM

    Thank you Dave it's done ;)



  • 6.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 25, 2014 03:19 AM

    Hi Dave,

     

    Thanks for the code. I was able to execute the same on Ubuntu.

     

    However the same does not work on Windows machine. Can you guide in this case?

     

    Regards


    Atul



  • 7.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 25, 2014 11:19 AM

    Windows is a little more tricky.

    I'll try and put together some comprehensive instructions for windows in the next few days...

     

    -- Dave



  • 8.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Feb 25, 2014 11:20 AM

    v1.0.3 is now released which fixes the dependency errors mentioned in this thread



  • 9.  RE: Python language bindings for the REST API - hp-sdn-client

    EMPLOYEE
    Posted Feb 27, 2014 01:43 PM

    I'm using this python library to make some end to end tests on mininet. It's awesome and very helpfully because mininet is written in python too. I expect to send some pull requests soon.

     

    Thanks.



  • 10.  RE: Python language bindings for the REST API - hp-sdn-client

    Posted Mar 02, 2014 06:16 AM

    If you want some help with installation and first steps or you would like some demos and code walkthroughs of example applications please check out these videos on YouTube

     

    http://www.youtube.com/playlist?list=PLhpgNkL46_235AgToyrhEMykVLaBTt6Bw

     

    This also covers installation on Windows as requested.

     

    @dave_tucker



  • 11.  RE: Python language bindings for the REST API - hp-sdn-client

    EMPLOYEE
    Posted May 21, 2014 02:09 PM

    Nice work Dave.

     

    Thank you for the details. It makes getting up & running as faster as it could get.

     

    Appreciate it.

     

    Thanks

    Pradeep