HomeGuidesAPI ReferenceGuidesMRT APIConfiguration API
GitHubAirheads Developer Community
Guides

Querying GLP Device Inventory

📘

Source Code

You can find these playbooks in the collection repository: examples/glp_api.yml and examples/glp_devices_info.yml

These playbooks retrieve device inventory data from GLP with glp_devices_info — from a simple "get everything" query to filtered, field-selected lookups by serial number, filter expression, or device ID.

Prerequisites

  • A GLP workspace with API access enabled
  • A client_id and client_secret for GLP

Installation

  1. Install the collection from Ansible Galaxy:
ansible-galaxy collection install arubanetworks.hpeanw_central
  1. Install the pycentral v2 SDK, which the collection depends on:
pip3 install --pre pycentral

This workflow is tested on collection version 2.1.1-beta. Please check compatibility before executing on older/newer versions as there may be changes.

Configuration

Credentials Configuration (inventory.yml)

all:
  hosts:
    localhost:
      ansible_connection: local # Do not change
      glp_client_id: <glp-client-id>
      glp_client_secret: <glp-client-secret>
📘

Important Links

Execution

Quick Start

Generate a token and retrieve the full device inventory:

- name: Demo HPE GreenLake Platform Devices Info
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Generate Token for Session
      arubanetworks.hpeanw_central.glp_token:
        client_id: "{{ glp_client_id }}"
        client_secret: "{{ glp_client_secret }}"
      register: token_result
      no_log: true

    - name: Retrieve Devices from GLP
      arubanetworks.hpeanw_central.glp_devices_info:
        access_token: "{{ token_result['access_token'] }}"
      register: glp_device_inventory

    - debug:
        var: glp_device_inventory
ansible-playbook -i inventory.yml glp_api.yml

Filtering and Selecting Fields

glp_devices_info supports four subset modes and an optional select field list, all using the same generated token:

- name: Get SERIAL in GLP with Token
  arubanetworks.hpeanw_central.glp_devices_info:
    access_token: "{{ token_result['access_token'] }}"
    subset: device_by_serial
    serial_number: "ABC123456"
  register: devices_result

- name: Get Select MAC from All Devices in GLP with Token
  arubanetworks.hpeanw_central.glp_devices_info:
    access_token: "{{ token_result['access_token'] }}"
    select: "macAddress"
  register: devices_result

- name: Get device by filter
  arubanetworks.hpeanw_central.glp_devices_info:
    access_token: "{{ token_result['access_token'] }}"
    subset: device_by_filter
    device_filter: "serialNumber eq 'ABC123456'"
  register: devices_result

- name: Get device by ID
  arubanetworks.hpeanw_central.glp_devices_info:
    access_token: "{{ token_result['access_token'] }}"
    subset: device_by_id
    device_id: 111222333-444555-666777888-999000
  register: devices_result
ansible-playbook -i inventory.yml glp_devices_info.yml

Module Parameters

ParameterTypeRequiredDescription
subsetstrNoall_devices (default), device_by_filter, device_by_id, or device_by_serial
device_filterstrWith device_by_filterFilter expression, e.g. serialNumber eq 'ABC123456'
device_idstrWith device_by_idDevice ID to retrieve
serial_numberstrWith device_by_serialDevice serial number to look up
selectstrNoComma-separated list of fields to return, e.g. id,serialNumber,model,macAddress

Output

Each task registers a result containing devices (a list of device dictionaries scoped to the requested subset/select), the HTTP code, and a msg.

Troubleshooting

ProblemFix
Empty devices listVerify the device_filter/serial_number/device_id matches an existing device
Filter syntax errorsdevice_filter uses OData-style expressions, e.g. field eq 'value'
Missing fields in responseConfirm select includes the field names you expect, exactly as GLP returns them

Support


Did this page help you?