datacenter / acitoolkit

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

Attaching an EPG to a PortChannel instance retrieved from the fabric via .get(), fails. #60

Open luismartingarcia opened 9 years ago

luismartingarcia commented 9 years ago

Hi,

I'm trying to associate an EPG with an existing PortChannel/VPC. My use case is creating an EPG and creating a path to a VPC that already exists on the fabric. Basically I'm calling PortChannel.get(session) to retrieve the existing port channels and VPCs, and then attaching the relevant object to a L2interface and then to an EPG.

Here's a snipped to reproduce the problem:

tenant = Tenant('IT-Dept')
app = AppProfile('IT-App01-AP', tenant)
epg = EPG('IT-App01-EPG', app)
pcs = PortChannel.get(session)
l2if = L2Interface("encap-0001", "vlan", 100)
l2if.attach(pcs[0]) # first element, for example, happens with any
epg.attach(l2if)
resp = session.push_to_apic(tenant.get_url(), data=tenant.get_json())

And this is the result:

Traceback (most recent call last):
  File "C:\code\deploy.py", line 933, in <module>
    main()
  File "C:\code\deploy.py", line 922, in main
    fabric.push_configuration()
  File "C:\code\deploy.py", line 867, in push_configuration
    resp = self.session.push_to_apic(tenant.get_url(), data=tenant.get_json())
  File "build\bdist.win32\egg\acitoolkit\acitoolkit.py", line 103, in get_json
  File "build\bdist.win32\egg\acitoolkit\acibaseobject.py", line 720, in get_json
  File "build\bdist.win32\egg\acitoolkit\acitoolkit.py", line 257, in get_json
  File "build\bdist.win32\egg\acitoolkit\acibaseobject.py", line 720, in get_json
  File "build\bdist.win32\egg\acitoolkit\acitoolkit.py", line 673, in get_json
  File "build\bdist.win32\egg\acitoolkit\acitoolkit.py", line 333, in _get_path
  File "build\bdist.win32\egg\acitoolkit\acitoolkit.py", line 2093, in _get_path
AssertionError

The assertion failure happens here:

    def _get_path(self):
        """Get the path of this interface used when communicating with
           the APIC object model.
        """
        assert len(self._interfaces)
        pod = self._interfaces[0].pod
        if self.is_vpc():
            (node1, node2) = self._get_nodes()
            path = 'topology/pod-%s/protpaths-%s-%s/pathep-[%s]' % (pod,
                                                                    node1,
                                                                    node2,
                                                                    self.name)
        else:
            node = self._interfaces[0].node
            path = 'topology/pod-%s/paths-%s/pathep-%s' % (pod,
                                                           node,
                                                           self.name)

        return path

Is there any way to fix this? It looks like PortChannel.get() didn't retrieve the actual interface objects that belong to the PC. Do I have to attach them manually? In that case, how do I figure out which ones I need to retrieve and attach?

Thanks a lot for your help. BR,

Luis.

michsmit99 commented 9 years ago

This has been on the To Do list for quite some time. There is an old issue labeled "Add backend support for getting all Port Channels" which I think I'll close since this is a better description. The issue is that we added get_deep() for Tenants and the physical infrastructure but we haven't added it for the PortChannel class yet.

ricky-andre commented 5 years ago

any news on this issue ? I doubt about it, since 4 years has passed by and the problem is still there. I wonder how you can automate things (ACI's leit motiv) if there are such problems on the tool ...

thetechguy-it commented 2 years ago

Hi, I'm facing the same issue, even if I tried to define the vPC name manually, Do you have any idea? Thanks and best regards