CiscoDevNet / ansible-aci

Cisco ACI Ansible Collection
https://galaxy.ansible.com/cisco/aci
GNU General Public License v3.0
143 stars 97 forks source link

cisco.aci.aci_vmm_controller "Query all VMware VMM controller" return APIC API error #521

Closed mdessamb closed 11 months ago

mdessamb commented 1 year ago

Community Note

Description

cisco.aci.aci_vmm_controller - Query all VMware VMM controller returns APIC API error 400 "Request failed, rsp-subtree option is not supported for class 'vmmProvP'"

  ...
  tasks:
    - name: Query VMware VMM domain
      cisco.aci.aci_vmm_controller:
        <<: *aci_login
        # domain: POD13-DVS
        # name: bdsol-aci13-vc
        vm_provider: vmware
        state: query
      register: query_result
      delegate_to: localhost

    - debug: msg="{{ query_result }}"   
TASK [Query VMware VMM domain] *************************************************************************************************************************************************************
fatal: [bdsol-aci13-apic1 -> localhost]: FAILED! => {"changed": false, "error": {"code": "400", "text": "Request failed, rsp-subtree option is not supported for class 'vmmProvP'"}, "msg": "APIC Error 400: Request failed, rsp-subtree option is not supported for class 'vmmProvP'"}

HTTP APIC API call return similar error

/api/class/vmmProvP.json?rsp-subtree=full&rsp-subtree-class=vmmDom
---
{
    "totalCount": "1",
    "imdata": [
        {
            "error": {
                "attributes": {
                    "code": "400",
                    "text": "Request failed, rsp-subtree option is not supported for class 'vmmProvP'"
                }
            }
        }
    ]
}  

Alternative is to query the children of the VMware vmmPropP

/api/uni/mo/uni/vmmp-VMware.json?query-target=children
---
{
    "totalCount": "1",
    "imdata": [
        {
            "vmmDomP": {
                "attributes": {
                    …
                    "dn": "uni/vmmp-VMware/dom-POD13-DVS",
                    "enableAVE": "no",
          ...
}

Affected Module Name(s):

APIC version and APIC Platform

Collection versions

Output/ Error message

ansible-playbook -i inventory.yml k8s-nested-deploy.yml

PLAY [Gather APIC information] *************************************************************************************************************************************************************

TASK [Query VMware VMM domain] *************************************************************************************************************************************************************
fatal: [bdsol-aci13-apic1 -> localhost]: FAILED! => {"changed": false, "error": {"code": "400", "text": "Request failed, rsp-subtree option is not supported for class 'vmmProvP'"}, "msg": "APIC Error 400: Request failed, rsp-subtree option is not supported for class 'vmmProvP'"}

PLAY RECAP *********************************************************************************************************************************************************************************
bdsol-aci13-apic1          : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Expected Behavior

Actual Behavior

Playbook tasks to Reproduce

 tasks:
    - name: Query VMware VMM domain
      cisco.aci.aci_vmm_controller:
        <<: *aci_login
        vm_provider: vmware
        state: query
      register: query_result
      delegate_to: localhost
    - debug: msg="{{ query_result }}"   

Important Factoids

N/A

References

ACI module example: https://docs.ansible.com/ansible/latest/collections/cisco/aci/aci_vmm_controller_module.html#examples

akinross commented 1 year ago

HI @mdessamb,

I notice that you have vm_provider: vmware set.

Could you try again to query all without vm_provider specified:

    - name: Query all controllers
      cisco.aci.aci_vmm_controller:
        <<: *aci_info
        state: query
      register: query_controller

In case you would like to query the vmware providers you could also leverage the aci_rest module:


    - name: Class Q vmmProvP
      cisco.aci.aci_rest:
        <<: *aci_info
        path: /api/class/vmmProvP.json?query-target-filter=eq(vmmProvP.dn,"uni/vmmp-VMware")
        method: get
mdessamb commented 1 year ago

Hi @akinross,

Thanks for looking into it,

It works, however this doesn't return me anything

---
- name: Gather APIC information
  hosts: apic
  gather_facts: false
  vars:
    aci_creds: &aci_login
      <ommited>

  tasks:
    - name: Query all controllers
      cisco.aci.aci_vmm_controller:
        <<: *aci_login
        state: query
      register: query_result
      delegate_to: localhost

    - debug: msg="{{ query_result }}"
PLAY [Gather APIC information] *******************************************************************************************************************************************

TASK [Query all controllers] *********************************************************************************************************************************************
ok: [bdsol-aci13-apic1 -> localhost]

TASK [debug] *************************************************************************************************************************************************************
ok: [bdsol-aci13-apic1] => {
    "msg": {
        "changed": false,
        "current": [],
        "failed": false
    }
}

PLAY RECAP ***************************************************************************************************************************************************************
bdsol-aci13-apic1          : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
mdessamb commented 1 year ago

This works great, thanks !

  • name: Class Q vmmProvP cisco.aci.aci_rest: <<: *aci_info path: /api/class/vmmProvP.json?query-target-filter=eq(vmmProvP.dn,"uni/vmmp-VMware") method: get
mdessamb commented 1 year ago

I'll have a look and work on it (no ETA)