Automation

last person joined: 5 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  XPath basics

    Posted 11-11-2018 07:22

    Hi

     

    Need some assistance here please:

    I am running an rpc against my qfx switch:

     

    results = dev.rpc.get_evpn_database_information(mac_address='18:66:da:94:ab:23',normalize=True)

    this is returning correctly.

    when there is no entry the results is None.

    But when there is an entry a etree.dump(results) gives me:

    <evpn-database-information>
    <evpn-database-instance style="normal">
    <instance-name>default-switch</instance-name>
    <mac-entry style="normal">
    <vni-id>96</vni-id>
    <mac-address>18:66:da:94:ab:23</mac-address>
    <active-source>172.16.111.3</active-source>
    <active-source-timestamp>Nov 02 13:37:51</active-source-timestamp>
    </mac-entry>
    </evpn-database-instance>
    </evpn-database-information>

     yet when I try to access an element by using a results.find() or results.findall() etc I always get back None??

     

    example I have tried so far:

    str1 = results.find("mac-entry")

    str1 = results.find("evpn-database-information/evpn-database-instance/mac-entry")

     

    I wish to access some elements of the response to use as input for further rpc calls.

     

    I have used an external XPath checker website to check the syntax and all looks ok.

     

    any comments please.


    #Python
    #xpath


  • 2.  RE: XPath basics
    Best Answer

    Posted 11-11-2018 09:01

    Hi

     

    I think it should be results.find("evpn-database-instance/mac-entry") as the result is parked at <evpn-database-information> element. Let me know if it works.