ansible-aci icon indicating copy to clipboard operation
ansible-aci copied to clipboard

Leaf Interface Profile for FEX

Open mkyrc opened this issue 2 years ago • 0 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I'd like to extend existing module plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py for FEX-type leafs. I do some code changes (see below), but I don't know to extended it with relevant objects for infraFexBndlGrp.

Module diffs:

102,105d101
<   fex_id:
<     description:
<     - Fex ID number.
<     type: str
338,339d333
<         fex_profile=dict(type='str'),  # new: fex profile
<         fex_id=dict(type='str'),  # new: fex ID
364,365d357
<     fex_profile = module.params.get('fex_profile')  # new: get fex profile
<     fex_id = module.params.get('fex_id')  # new: get fex_id
383c375
<     # Add infraRsAccBaseGrp only when policy_group was defined and type_profile is not 'fex'
---
>     # Add infraRsAccBaseGrp only when policy_group was defined
393,400d384
<     # new: create json object for fex type
<     if fex_profile is not None and fex_id is not None and policy_group is None:
<         child_configs.append(dict(
<             infraRsAccBaseGrp=dict(
<                 attributes=dict(
<                     fexId=fex_id,
<                     tDn=f'uni/infra/fexprof-{format(fex_profile)}/fexbundle-{format(fex_profile)}'  # new: dn correction
<                     # tDn=INTERFACE_TYPE_MAPPING[interface_type].format(interface_profile),
<                 ),
<             ),
<         ))
< 

JSON after change made by ansible (corrected module):

{
  "totalCount": "1",
  "imdata": [
    {
      "infraFexP": {
        "attributes": {
          "annotation": "",
          "descr": "",
          "dn": "uni/infra/fexprof-1109_fex199_iprf",
          "name": "1109_fex199_iprf",
          "nameAlias": "",
          "ownerKey": "",
          "ownerTag": "",
          "userdom": ":all:"
        },
        "children": [
          {
            "infraHPortS": {
              "attributes": {
                "annotation": "",
                "descr": "test fex downlink",
                "name": "fex199_1p01_isel",
                "nameAlias": "",
                "ownerKey": "",
                "ownerTag": "",
                "type": "range",
                "userdom": ":all:"
              },
              "children": [
                {
                  "infraRsAccBaseGrp": {
                    "attributes": {
                      "annotation": "",
                      "fexId": "101",
                      "tDn": "uni/infra/funcprof/accbundle-test_pcfex_dca_ipg",
                      "userdom": ":all:"
                    }
                  }
                },
                {
                  "infraPortBlk": {
                    "attributes": {
                      "annotation": "",
                      "descr": "test fex downlink",
                      "fromCard": "1",
                      "fromPort": "1",
                      "name": "block1_1",
                      "nameAlias": "",
                      "toCard": "1",
                      "toPort": "1",
                      "userdom": ":all:"
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}

JSON for change made by APIC:

{
  "totalCount": "1",
  "imdata": [
    {
      "infraFexP": {
        "attributes": {
          "annotation": "",
          "descr": "",
          "dn": "uni/infra/fexprof-1109_fex199_iprf",
          "name": "1109_fex199_iprf",
          "nameAlias": "",
          "ownerKey": "",
          "ownerTag": "",
          "userdom": ":all:"
        },
        "children": [
          {
            "infraHPortS": {
              "attributes": {
                "annotation": "",
                "descr": "",
                "name": "fex199_1p01_isel",
                "nameAlias": "",
                "ownerKey": "",
                "ownerTag": "",
                "type": "range",
                "userdom": ":all:"
              },
              "children": [
                {
                  "infraRsAccBaseGrp": {
                    "attributes": {
                      "annotation": "",
                      "fexId": "101",
                      "tDn": "uni/infra/funcprof/accbundle-test_pcfex_dca_ipg",
                      "userdom": ":all:"
                    }
                  }
                },
                {
                  "infraPortBlk": {
                    "attributes": {
                      "annotation": "",
                      "descr": "",
                      "fromCard": "1",
                      "fromPort": "1",
                      "name": "block2",
                      "nameAlias": "",
                      "toCard": "1",
                      "toPort": "1",
                      "userdom": ":all:"
                    }
                  }
                }
              ]
            }
          },
          {
            "infraFexBndlGrp": {
              "attributes": {
                "annotation": "",
                "descr": "",
                "name": "1109_fex199_iprf",
                "nameAlias": "",
                "ownerKey": "",
                "ownerTag": "",
                "userdom": ":all:"
              },
              "children": [
                {
                  "infraRsMonFexInfraPol": {
                    "attributes": {
                      "annotation": "",
                      "tnMonInfraPolName": "",
                      "userdom": "all"
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}

As you can see, infraFexBndlGrp part is missing. This one is mandatory, because:

  • leaf profile for FEX-type interface is created (I can see it in APIC GUI)
  • but it is not possible add this 'fex profile' to 'normal'-type interface

fex profile created by Ansible module (after modification): fex-profile

leaf profile (not fex) looks correct: 1109_iprf

but it is not applied correctly - it is not listed there (because part of json is missing.): isel_missing_profile

The question

I can use REST call module and do this - interface profile for fex leafs, with correct JSON payload. But I think it is better to modify/extend existing module for fex-type leafs. First part is done (see my changes), but second part (see above) is not. Can anybody help with fixing this second part? It could be interesting for a lot of people.

New or Affected Module(s):

APIC version and APIC Platform

  • V 5.2(2f) and on-prem

Collection versions

  • cisco.aci 2.1.0 (latest)

mkyrc avatar Dec 06 '21 12:12 mkyrc