establish a connection and have a hook back to the Cisco
Intersight platform. Three parameters need to be passed
in to instantiate the class:
host: This parameter specifies the Cisco Intersight REST API base
URI.
private_key: This parameter specifies the path to the file that
contains the keySecret of the Intersight account that will be used to sign
in.
api_key_id: This parameter contains the keyId of the same Intersight
account. As mentioned previously, both the keyId and keySecret are
generated in the Intersight web interface, under Settings > API keys.
Next, an instance of the
EquipmentDeviceSummaryApi class is created and
stored in the D_HANDLE variable. This Python class
maps into the
/api/v1/equipment/DeviceSummaries REST API
resource. The D_HANDLE variable contains the handle
to that REST API resource. The
equipment_device_summaries_get method that is
available with the EquipmentDeviceSummaryApi
class is invoked next, and the results are stored in the
DEVICES variable, which contains a complete list of all
the equipment that is being managed by Cisco Intersight
for the user account with the keyId and keySecret with
which the initial connection was established. The for
loop iterates over the devices in the list and extracts for
each one the distinguished name, model, serial number,
and object type and displays this information to the
console. The output of this Python script for a test user
account looks as shown in Figure 9-15.