Skip to content

cisco.intersight.intersight_rest_api fails when output doesn't contain a 'Results' key. #204

@StephenEGibson

Description

@StephenEGibson

We’re looking to enable alarm suppression during builds and disable alarm suppression when the server is finally elevated to Production. Enabling the suppression works without a hitch. Disabling the suppression is a problem. The root of the problem is that /cond/AlarmSuppressions/{Moid} does not return a ‘Results’ key which is what the python code for Cisco.intersight.intersight_rest_api relies on for GET's and DELETE’s (specifics later). Here’s an example of the REST output of the call:

{ "AccountMoid": "<moid>", "Ancestors": [ { "ClassId": "mo.MoRef", "Moid": <moid>", "ObjectType": "compute.Blade", "link": "https://www.intersight.com/api/v1/compute/Blades/<moid>" } ], "ClassId": "cond.AlarmSuppression", "Classifications": [ { "ClassId": "mo.MoRef", "Moid": "<moid>", "ObjectType": "cond.AlarmClassification", "link": "https://www.intersight.com/api/v1/cond/AlarmClassifications/<moid>" } ], "CreateTime": "2025-02-14T17:28:25.772Z", "Description": "<description>", "DomainGroupMoid": "<moid>", "Entity": { "ClassId": "mo.MoRef", "Moid": "<moid>", "ObjectType": "compute.Blade", "link": "https://www.intersight.com/api/v1/compute/Blades/<moid>" }, "ModTime": "2025-05-30T02:57:52.492Z", "Moid": "<moid>", "Name": "compute.Blade-<moid>", "ObjectType": "cond.AlarmSuppression", "Owners": [ "<moid>", "<moid>", "<moid>" ], "Parent": { "ClassId": "mo.MoRef", "Moid": "<moid>", "ObjectType": "compute.Blade", "link": "https://www.intersight.com/api/v1/compute/Blades/<moid>" }, "PermissionResources": [ { "ClassId": "mo.MoRef", "Moid": "<moid>", "ObjectType": "organization.Organization", "link": "https://www.intersight.com/api/v1/organization/Organizations/<moid>" } ], "SharedScope": "", "Tags": [] }

Examples of problematic code is below. I would expect this code to get the information from the REST call above and remove it:

     - name: "Retrieve alarm suppression"
      cisco.intersight.intersight_rest_api:
        <<: *api_info
        resource_path: /cond/AlarmSuppressions/{{ alarm_moid }}
        state: present
      register: "alarm_sup_retrieval"

    - name: Debug Alarm Suppression Removal Results
      ansible.builtin.debug:
        msg: "{{ alarm_sup_retrieval }}"

    - name: "Removing alarm suppression"
      cisco.intersight.intersight_rest_api:
        <<: *api_info
        resource_path: /cond/AlarmSuppressions/{{ alarm_moid }}
        state: absent
      register: "alarm_sup_removal"

    - name: Debug Alarm Suppression Removal Results
      ansible.builtin.debug:
        msg: "{{ alarm_sup_removal }}"

However, what ends up happening is the module returns ok with no results for both calls.

The reason is that both a GET and DELETE will use the get_resource function from intersight.py: https://github.com/CiscoDevNet/intersight-ansible/blob/main/plugins/module_utils/intersight.py#L344

I believe the module is non-functioning for these calls because of line 362. There is no ‘Results’ key in the REST output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions