Developer

last person joined: 2 days ago 

Expand all | Collapse all

MobilityMaster - show command API with JSON Filter

This thread has been viewed 29 times
  • 1.  MobilityMaster - show command API with JSON Filter

    Posted Jul 29, 2020 07:41 AM

    Hello community, I need to get the "show global-user-table list" response from a MobilityMaster via REST API.

    I can only find a way to get this information via the "show command API", hence with: 

     

    https://1.1.1.1:4343/v1/configuration/showcommandcommand=show+global-user-table+list&UIDARUBA=XYZ

     

    Attached is the output of the call, that I need to filter for only "IP" and "MAC". 

     

    "Users": [
    {
    "AP name": "C-Site-A-Building-2",
    "Age(d:h:m)": "00:00:24",
    "Auth": "802.1x",
    "Essid/Bssid/Phy": "C/ac:a3:1e:c4:eb:80/g-HT",
    "Forward mode": "tunnel",
    "Host Name": null,
    "IP": "192.168.123.157",
    "MAC": "c1:e4:34:ea:1d:d5",
    "Name": "radius1-at-domainA",
    "Profile": "C_aaa_prof",
    "Roaming": "Wireless",
    "Role": "guest",
    "Type": "Win 10",
    "User Type": "WIRELESS",
    "VPN link": null

     

    Can anyone advice me, how to use a Filter in this "show command API" call, or if there is another way to get this complete user-table i.e. by an API call to a container/object? In the swagger file I cannot determine, where to search for the complete user table.

    Thanks! Benny



  • 2.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 29, 2020 09:11 AM

    Hi,

     

    What language do you are using ?



  • 3.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 29, 2020 09:24 AM

    Hi alagoutte,

     

    I tried go use different filters in the GET request, but it seems to have no impact. I try to access the API with Pyton Requests and a function like:

     

    def send_show_command(ip,cookie,uidaruba,show_command,*args):
        url="https://{}:4343/v1/configuration/showcommand?command=          {}&UIDARUBA={}".format(ip,show_command,uidaruba)
     
    r = requests.get(url, verify=False, cookies=cookie)
     
    If I try to modify the URL with additonal filters from the API Guide, it has no impact. For instance, I tried to add:
     
    &filter=[{"Users.MAC":{"$eq":"aa:bb:cc:dd:ee:ff"}}]
     
    From the API Guide, I found this example:
    &filter=[{"OBJECT" : { "<oper>" : <list-of-parameters> } } ]
     
    So I'm not really sure if my syntax is correct, or if it is even impossible to filter the response from the "show command API".
     
    Additionally to "Python Requests", I tried to use the filters with "Postman" but also here without success.
     
    Is this what you meant with language or which information is needed?
     
    Thanks a lot!

     



  • 4.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 29, 2020 11:05 AM

    Hi,

     

    No sure it is possible to filter with show command API

     

    you can use PowerArubaMC module and after PowerShell for filter

     

    Connect-ArubaMC ....
    $user = Get-ArubaMCShowCmd "showglobal-user-table list"
    
    $user.users | Where-Object { $_.mac -eq "c1:xx:xx:xx:xx" }

     



  • 5.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 30, 2020 03:42 AM

    Wow, awesome work! I Wasn´t aware of this. Thanks a lot!

     

    I tested the Module with PowerShell and it would work this way. So thanks for that!

     

    My problem ist still related to performance/scalability concerns, as I need to request a "global-user-table" which can go up to about 50.000 entries. Hence, I would like to filter the MobilityMaster response before it is send out, to reduce amount of data transferred over network. So I need to continue to find a filter for the "show command API" call.

     

     



  • 6.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 30, 2020 09:42 AM

    Good question...

     

    the documentation is not clear about this, do you have try to ask SE or TAC ?



  • 7.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 30, 2020 10:57 AM

    Hi,

     

    Why don't you change the command from

    show global-user-table list

    to

    show global-user-table list mac-addr <MAC_OF_CLIENT > or

    use one of the below filters to filter based on your required match..

    ayman_mukaddam_0-1596120922920.png

     



  • 8.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jul 30, 2020 11:43 AM

    good idea but it will be better to have directly option for filter...



  • 9.  RE: MobilityMaster - show command API with JSON Filter

    Posted Dec 08, 2020 02:46 PM
    This post is a few months old, but in case you never got the answer, I figured out the syntax of the object filter recently.
    # Aruba OBJECT filter expressions
    # The following sample request shows how to return sub-objects of "ipaddress" and "mtu" value configured
    # for all interface VLAN (GET /object/int_vlan) at this particular node (or as derived from higher in the hierarchy)
    # [{"OBJECT":{ "$eq":["int_vlan.int_vlan_ip","int_vlan.int_vlan_mtu"]}}]
    # refer to ArubaOS API Guide under the section GET modifiers > Object Filter
    
    # filter example using GET /object/int_gig:
    # [{"OBJECT":{ "$eq":["int_gig.slot/module/port"]}}]
    # this returns 0/0/0, 0/0/1, etc​

    You can see in both of these examples that "OBJECT" is a literal string. The "filter" being used here is not a standard JSON filter expression; I'm guessing it's proprietary syntax.

    Here is my python using the int_gig filter above:
        myHeaders = {'Content-Type': 'application/json','Accept': 'application/json'}
    
        # UIDARUBA parameter is already stored in myUid
        myParams = {'config_path': '/md/00:0b:86:bc:0c:c7',
                    'UIDARUBA': myUid,
                    'filter': r'[{"OBJECT":{ "$eq":["int_gig.slot/module/port"]}}]'
                   }
        
        # the 'session' below <class requests.Session()> has already been declared and logged in
        response = session.get(url="https://mm.example.com/v1/configuration/object/int_gig",
                                    headers=myHeaders,
                                    params=myParams,
                                    cookies=session.cookies)
        print (response.text)​

    That produces this result:

    {
      "_data": {
        "int_gig": [
          {
            "slot/module/port": "0/0/0"
          }, 
          {
            "slot/module/port": "0/0/1"
          }, 
          <snip>
        ]
      }
    }


  • 10.  RE: MobilityMaster - show command API with JSON Filter

    Posted Jan 17, 2021 08:53 AM
    Thanks tim !

    ------------------------------
    PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...

    PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)

    PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..

    ACEP / ACMX #107 / ACDX #1281
    ------------------------------