Brocade Automation Community

Expand all | Collapse all

Pyfos list of objects

  • 1.  Pyfos list of objects

    Posted 09-11-2019 07:44 AM
    Hello.

    Maybe some can give me hint how to proceed with Pyfos.
    I`m able to connect to my devices and gather some information but as result of get() I`m getting list of objects not expected list of dictionaries.
    And is impossible to iterate over it. 
    Maybe do you know any way how I can convert it to normal list of dictionaries?

    Thank you!


  • 2.  RE: Pyfos list of objects

    Posted 09-11-2019 09:18 AM
    For people who do not want to work with the custom objects in PyFOS, I put together a more traditional interface. If you want to stick with PyFOS, I suggest you take the documentation (look for brcdapi_brcddb_guide in api_direct). There are some throttling scenarios, 0 length array issues, and data correlation that PyFOS does not resolve that are explained in the documentation.

    https://github.com/jconsoli

    The key difference between my libraries and PyFOS is that PyFOS has several stand-alone packages while, with few exceptions, my libraries are intended as examples for programmers. If you are using my libraries, you will be writing your own code.

    brcdapi

    • Converts JSON to standard Python dictionary
      • These will match the URIs as documented in the Rest API Guide
    • Handles all throttling and retries
    • Has a debug mode with limited capabilities that allows you to develop scripts without needing a switch
    • Single interface to the FOS RESTConf API
    • Converts 0 length lists to 0 length lists
      • 0 length lists are returned as an error by FOS

    api_direct

    •  Documentation
      • If you take nothing else, take  brcdapi_brcddb_guide. It explains throttling, how to correlate resources from different requests, and a few nuances
    • An example on how to issue every GET URI supported by 8.2.1c
    • An example on how to configure zoning, create logical switches, add/remove ports from a logical switch, configure switch and port parameters

    27_scripts

    Combines brcdapi & api_direct to provide some examples in Python 2.7. You should only be scripting in 2.7 if maintaining existing scripts.

    brcddb

    Brocade FOS API container with hierarchical relational database and built in common applications.

    This might be a little more than what you are looking for. These are custom objects with standard Python dictionaries of data as returned from the FOS API. The primary purpose of these libraries is to correlate data and provide simple searches. For example:

    • Return a list of all zones a WWN participates in
    • Return a list of all ports in a switch
    • Return the port where a WWN is connected
    • And much more
    aaplications

    Yes, I spelled applications wrong when I created the folder. Contains examples to use the brcddb libraries:

    • Generate an Excel report
    • Several examples to search the database
    • Zoning
      • A key difference between zoning direct or using PyFOS is that since zoning information is in a database, some error checking is done. You can't add an alias to a zone if the alias doesn't exist, you can't add an invalid WWN, etc.
    • Collect port statistics
    • And more.


    ------------------------------
    Field Applications Engineer
    Broadcom
    ------------------------------



  • 3.  RE: Pyfos list of objects

    Posted 09-11-2019 09:33 AM
    Thank you Jack.

    This looks like something what I would need ;)