datacenter / acitoolkit

A basic toolkit for accessing the Cisco APIC
Other
347 stars 266 forks source link

How to get encapsulation mode regular|trunk for each encapsulation in acitoolkit? #371

Open nohir0 opened 3 years ago

nohir0 commented 3 years ago

Hello,

since acitoolkit does not follow the ACI object hierachy exactly, e.g. it directly maps endpoints under the EPG class as child objects

    #data = []
    #endpoints = acitk.Endpoint.get(session)
    #for ep in endpoints:
    #    epg = ep.get_parent()
    #    app_profile = epg.get_parent()
    #    tenant = app_profile.get_parent()
    #    data.append((ep.mac, ep.ip, ep.if_name, ep.encap,
    #                 tenant.name, app_profile.name, epg.name))

I wonder how to map the encapsulation mode "regular|trunk" to the example above since EPG static paths are not accessible directly via acitoolkit? Neither the Endpoint class nor the EPG class has methods for fetching Static Paths from Fabric which includes this information...

I do this in my code as such:

        self.url = "https://{}/api/node/mo/uni/tn-{}/ap-{}/epg-{}.json?query-target=children&target-subtree-class=fvRsPathAtt&challenge={}".format(
            self.ip,
            self.tenant,
            self.ap,
            self.epg,
            self.token)

Which returns the Static Path objects and the relevant information if this EPG encapsulation is tagged or not (access|regular or trunk):

{'annotation': '', 'childAction': '', 'descr': '', 'dn': 'uni/tn-TENANTNAME/ap-APNAME/epg-EPGNAME/rspathAtt-[topology/pod-1/paths-1203/pathep-[eth1/13]]', 'encap': 'vlan-666', 'extMngdBy': '', 'forceResolve': 'yes', 'instrImedcy': 'lazy', 'lcC': '', 'lcOwn': 'local', 'modTs': '2021-02-19T05:37:48.487+01:00', **'mode': 'regular'**, 'monPolDn': 'uni/tn-common/monepg-default', 'primaryEncap': 'unknown', 'rType': 'mo', 'state': 'unformed', 'stateQual': 'none', 'status': '', 'tCl': 'fabricPathEp', 'tDn': 'topology/pod-1/paths-1203/pathep-[eth1/13]', 'tType': 'mo', 'uid': '15519'}

Any help appreciated