vmware / ansible-collection-alb

VMware Advanced Load Balancer (formerly Avi) Ansible Collection
Other
20 stars 13 forks source link

avi_api_session does not handle forcedelete paths (i.e. /api/serviceengine/<se_uuid>/forcedelete #154

Open joeycoakleyavi opened 1 year ago

joeycoakleyavi commented 1 year ago

Describe the bug

  - name: Force Delete a Service Engine
      vmware.alb.avi_api_session:
        avi_credentials: "{{ AVI_CREDENTIALS }}"
        data:
          name: foo
        http_method: post
        timeout: 30
        path: "serviceengine/{{ se_uuid }}/forcedelete"

Results in: vmware.alb.plugins.module_utils.avi_api.APIError: ('HTTP Error: 405 Error Msg {\"detail\": \"Method \\'GET\\' not allowed.\"}', <Response [405]>)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

It looks like we are hitting this conditional

https://github.com/vmware/ansible-collection-alb/blob/eng/plugins/modules/avi_api_session.py#L199

which should be avoided if we add 'forcedelete' to api_get_not_allowed and sub_api_get_not_allowed on lines 181 and 182, respectively.

I added the above to my local ansible collection and it allowed the post to proceed correctly.

Reproduction steps

  1. Attempt to use avi_api_session module to POST to an endpoint which includes /forcedelete

Expected behavior

Post is expected to go through unless there is an issue with se_uuid or permissions.

Additional context

No response