Developer

 View Only
last person joined: 7 days ago 

Expand all | Collapse all

showcommand using API

This thread has been viewed 49 times
  • 1.  showcommand using API

    Posted Feb 14, 2023 09:21 AM

    Hello,

    The API is brilliant, what a joy compared to parsing SSH output!

    Anyway, having said that I do have a problem, I am running "show user mac <mac>" but all I get back is:

    {'_data': ['This operation can take a while depending on number of users. Please be patient ....']}

    So I suppose that warning is being taken as the CLI output before the actual output arrives.

    Is there a way around this?

    Thank you,

    Guy 



  • 2.  RE: showcommand using API

    Posted Feb 14, 2023 04:03 PM

    Hi @cauliflower ! Can you please share which product/platform/firmware you're using? As well as what you're using for automation (python, Ansible, other)?



    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 3.  RE: showcommand using API

    Posted Feb 15, 2023 09:52 AM
    Hello,

    We're running aos 8.10.0.5
    Cluster of 10 7240xm's (standby cluster of 4)
    Active and standby conductors (physical)

    I'm trying to do this using a Python script. Though I see the same response if I go to the /api gui on the controller and run the same command (using showcommand)

    Guy

    Guy Goodrick
    University of Cambridge
    UIS
    Wireless Team





  • 4.  RE: showcommand using API

    Posted Feb 16, 2023 03:50 AM

    Hi,

    I can see the problem... This is the output on the CLI before the actual table appears. 

    It is really just a workaround but you could get this output via SSH by using Netmiko for example.

    The Aruba vendor in Netmiko can be used for WLC.

    But then you are back to parsing output again...

    But Netmiko waits until the prompt for the next command is there so you get the whole SSH output and not just the first sentence.



    ------------------------------
    Thanks,
    Bjarne
    ------------------------------



  • 5.  RE: showcommand using API

    Posted Feb 16, 2023 09:26 AM

    If you go with the netmiko route, look at ntc-templates, https://github.com/networktocode/ntc-templates, for the cli parsing.  I wrote a few for Aruba before I moved to API calls for what I needed.

     

    --  

    Jeff Hagley

    Principal Consultant 

     

    PIER Group 

    Main: 812-650-7434 | Direct: 734-508-2060 

    Cell: 734-652-4687 | Email: jhagley@piergroup.com 






  • 6.  RE: showcommand using API

    Posted Feb 17, 2023 06:00 AM

    Ok thanks for this both. I'm pretty wedded to not having to parse SSH output! So I might explore using "show user-table ..." instead of "show user ...". The only issue with this is that there might be more than one entry so I guess I need to do some work to sort the results and pick the most recent entry. If I fall flat on my face then I'll go the SSH route! 

    Unless anyone knows of another command that will tell me the SSID to which an individual device MAC is currently connected?




  • 7.  RE: showcommand using API

    EMPLOYEE
    Posted Feb 17, 2023 06:06 AM

    If the following is the case: 'I can see the problem... This is the output on the CLI before the actual table appears.'; then if you can please open a TAC case. This seems like it's not behaving as it should and a bug may be filed for that.



    ------------------------------
    Herman Robers
    ------------------------
    If you have urgent issues, always contact your Aruba partner, distributor, or Aruba TAC Support. Check https://www.arubanetworks.com/support-services/contact-support/ for how to contact Aruba TAC. Any opinions expressed here are solely my own and not necessarily that of Hewlett Packard Enterprise or Aruba Networks.

    In case your problem is solved, please invest the time to post a follow-up with the information on how you solved it. Others can benefit from that.
    ------------------------------



  • 8.  RE: showcommand using API

    Posted Feb 17, 2023 06:10 AM

    Will do Herman




  • 9.  RE: showcommand using API

    Posted Feb 20, 2023 06:05 PM

    I opened a TAC case, but while that is moving along I thought I'd better work on an alternative for now.

    So I am using "show user-table mac <mac>". A MAC can have more than one entry in this table so I am using the "Age (d:h:m)" field to compare the entries for that MAC and find the most recent (which I hope will be an accurate way of telling me which SSID that client is actually connected to).

    But I hit another slight snag which is that usually the data returned from that command looks like:

    {'Users': [{'AP name': 'xx:xx:xx:xx:xx:xx', 'Age(d:h:m)': '00:03:34', 'Auth': '802.1x', 'Essid/Bssid/Phy': 'eduroam/xx:xx:xx:xx:xx:xx/5GHz-HE', 'Forward mode': 'tunnel', 'Host Name': None, 'IP': 'x.x.x.x', 'MAC': 'xx:xx:xx:xx:xx:xx', 'Name': 'user@something.com', 'Profile': 'someaaa', 'Roaming': 'Wireless', 'Role': 'somerole', 'Type': 'macOS', 'User Type': 'WIRELESS', 'VPN link': None}], '_meta': ['IP', 'MAC', 'Name', 'Role', 'Age(d:h:m)', 'Auth', 'VPN link', 'AP name', 'Roaming', 'Essid/Bssid/Phy', 'Profile', 'Forward mode', 'Type', 'Host Name', 'User Type']}

     

    But occasionally it is like:

    {'Station Entry': [{'AP name': 'xx:xx:xx:xx:xx:xx', 'Age(d:h:m)': '00:04:18', 'Auth': 'Yes', 'Essid': 'eduroam', 'MAC': 'xx:xx:xx:xx:xx:xx', 'Name': 'user@something.com', 'Phy': '5GHz-VHT', 'Profile': 'someaaa', 'Remote': 'No', 'Role': 'somerole', 'User Type': 'WIRELESS'}], '_meta': ['MAC', 'Name', 'Role', 'Age(d:h:m)', 'Auth', 'AP name', 'Essid', 'Phy', 'Remote', 'Profile', 'User Type']}

    Please can anyone explain why there is a difference, and what that means in terms of that client's status? I'm wondering if I should just ignore the Station entries or parse them and count them in the same way as I am doing for entries that come back as "Users". 

    To be clear - both of these are returned when I run the same command (show user-table mac <mac>). More often than not the first version is returned ("Users"), but occasionally it's "Station Entry".

    Note - the same happens if I run the command on the CLI - most of the time the output looks like:

    (controller) *#show user-table mac xx:xx:xx:xx:xx:xx

    Users
    -----
        IP               MAC            Name            Role               Age(d:h:m)  Auth    VPN link  AP name            Roaming   Essid/Bssid/Phy                     Profile      Forward mode  Type   Host Name  User Type

    But sometimes I get:

    (controller) *#show user-table mac xx:xx:xx:xx:xx:xx

    Station Entry
    -------------
         MAC            Name            Role               Age(d:h:m)  Auth  AP name            Essid    Phy       Remote  Profile      User Type
    ------------       ------           ----               ----------  ----  -------            -----    ---       ------  -------      ---------

    Guy




  • 10.  RE: showcommand using API

    EMPLOYEE
    Posted Feb 21, 2023 04:19 AM

    The difference between a station and user is that the station is L2 and user is L3 (IP); that is also reflected in the table... when you see stations there is no IP, the user entries have IP. Normally, I would not expect a station without IP in the show-user table, those I look up normally in the 'show ap association' command. It could be, but not easy for me to test right now, that the show user-table automatically reverts to show ap association when there is no user-table entry? It may make sense if you see that.. Update: it looks if you do the show user-table mac xx:xx:xx... if there is no user entry you see Station Entry; if there is a user it shows 'Users'. You may explore the show ap association if that gives possible better information for your use-case.



    ------------------------------
    Herman Robers
    ------------------------
    If you have urgent issues, always contact your Aruba partner, distributor, or Aruba TAC Support. Check https://www.arubanetworks.com/support-services/contact-support/ for how to contact Aruba TAC. Any opinions expressed here are solely my own and not necessarily that of Hewlett Packard Enterprise or Aruba Networks.

    In case your problem is solved, please invest the time to post a follow-up with the information on how you solved it. Others can benefit from that.
    ------------------------------



  • 11.  RE: showcommand using API

    Posted Feb 21, 2023 06:33 AM

    Thanks Herman,

    Yes I think I will try 'show ap association...' instead of 'show user-table...'. Thanks for the explanation.

    Guy