CiscoDevNet / ansible-mso

Cisco MSO Ansible Collection
https://galaxy.ansible.com/cisco/mso
GNU General Public License v3.0
26 stars 32 forks source link

cisco.mso.mso_rest returns unhelpful error response (DCNE-49) #423

Open phil-dotchon opened 5 months ago

phil-dotchon commented 5 months ago

Community Note

Description

Affected Module Name(s):

MSO version and MSO Platform

APIC version and APIC Platform for Site Level Resources

Collection versions

Output/ Error message

Expected Behavior

Actual Behavior

Playbook tasks to Reproduce

    - name: Add service graph to template contract
      ignore_errors: true
      cisco.mso.mso_rest:
        host: "{{ ansible_host | mandatory }}"
        username: "{{ ansible_user | mandatory }}"
        password: "{{ ansible_password | mandatory }}"
        validate_certs: "{{ ansible_httpapi_validate_certs }}"
        use_ssl: "{{ ansible_httpapi_use_ssl }}"
        use_proxy: false
        timeout: "{{ mso_timeout | default(omit) }}"
        path: "/mso/api/v1/schemas/663a169d216a38e187135157"
        method: patch
        output_level: debug
        content:
          - op: add
            path: "/templates/CommonTemplate_001/contracts/CI9380650/serviceGraphRelationship"
            value:
              serviceGraphRef:
                templateName: CommonTemplate_001
                serviceGraphName: PA-5250-PBR_non-production
                schemaId: 663a169d216a38e187135157
              serviceGraphContractRelationRef:
                templateName: CommonTemplate_001
                serviceGraphName: PA-5250-PBR_non-production
                contractName: CI9380650
                schemaId: 663a169d216a38e187135157
              serviceNodesRelationship:
                - serviceNodeRef:
                    templateName: CommonTemplate_001
                    serviceGraphName: PA-5250-PBR_non-production
                    schemaId: 663a169d216a38e187135157
                    serviceNodeName: node1
                  consumerConnector:
                    bdRef:
                      templateName: Infrastructure_e-us1
                      bdName: ips-pbr-transit_non-production_e-us1
                      schemaId: 663529ef216a38e187132625
                    connectorType: general
                  providerConnector:
                    bdRef:
                      templateName: Infrastructure_e-us1
                      bdName: ips-pbr-transit_non-production_e-us1
                      schemaId: 663529ef216a38e187132625
                    connectorType: general

Postman call:

https://x.x.x.x/mso/api/v1/schemas/663a169d216a38e187135157

[
    {
        "op": "add",
        "path": "/templates/CommonTemplate_001/contracts/CI9380650/serviceGraphRelationship",
        "value": {
            "serviceGraphRef": {
                "templateName": "CommonTemplate_001",
                "serviceGraphName": "PA-5250-PBR_non-production",
                "schemaId": "663a169d216a38e187135157"
            },
            "serviceGraphContractRelationRef": {
                "templateName": "CommonTemplate_001",
                "serviceGraphName": "PA-5250-PBR_non-production",
                "contractName": "CI9380650",
                "schemaId": "663a169d216a38e187135157"
            },
            "serviceNodesRelationship": [
                {
                    "serviceNodeRef": {
                        "templateName": "CommonTemplate_001",
                        "serviceGraphName": "PA-5250-PBR_non-production",
                        "schemaId": "663a169d216a38e187135157",
                        "serviceNodeName": "node1"
                    },
                    "consumerConnector": {
                        "bdRef": {
                            "templateName": "Infrastructure_e-us1",
                            "bdName": "ips-pbr-transit_non-production_e-us1",
                            "schemaId": "663529ef216a38e187132625"
                        },
                        "connectorType": "general"
                    },
                    "providerConnector": {
                        "bdRef": {
                            "templateName": "Infrastructure_e-us1",
                            "bdName": "ips-pbr-transit_non-production_e-us1",
                            "schemaId": "663529ef216a38e187132625"
                        },
                        "connectorType": "general"
                    }
                }
            ]
        }
    }
]

Important Factoids

The reason for the failure is that NDO now requires the template and site level contract service graph structures to be provided at the same time, in the same API call, whereas in previous versions this could be delivered as two separate calls.

References

akinross commented 5 months ago

Hi @phil-dotchon, I have added it to the todo for further investigation by the team. Thank you for making us aware.

anvitha-jain commented 2 months ago

Hi @phil-dotchon, I am unable to reproduce this error (tested on MSO collection v2.6 and v2.9), does this error occor on v2.9 as well? Will it be possible to attach the complete playbook that generated this error?

I wanted to bring to your attention that modules are available for template and site-level Service graphs (mso_schema_template_service_graph, mso_schema_site_service_graph).

anvitha-jain commented 2 months ago

Hi @phil-dotchon, just following up on this issue. Are there any additional updates?

phil-dotchon commented 2 months ago

Hi Anvitha, sorry for being slow. I can't really attach the whole playbook because it is very large and would have all kinds of dependencies, but I'll try to recreate a scenario using an empty schema when I can find some time.

I did look at the service graph modules some time ago, but there were still some parts missing then. In the meantime I have written a custom module that generates schema patches for multiple contracts in one pass; speed/performance has increasing become an issue for us, as some of our plays can take 40/50 minutes+ where we are deploying app environments with a lot of contracts, so removing Ansible loops where possible has helped speed things up