datacenter / acitoolkit

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

acibaseobject issue #396

Open lukaszszopa opened 11 months ago

lukaszszopa commented 11 months ago

Hi, Ii found one problem in acitoolkit acibaseobject currently working on cable plan application, and noticed that target node is not same format as node in for loop. List self._parent.get_children(Node) have nodes names rather then nodes numbers so each time it throws None and nothing appears not sure how to change this list to include list o nodes number, will you be so kind and help me to change list to be nodes number representation? Below part of code:

def get_node2(self):

    """Returns the Node object that corresponds to the

    second node of the link.  The Node must be a child of

    the Pod that this link is a member of, i.e. it must

    already have been read from the APIC.  This can

    most easily be done by populating the entire physical

    heirarchy from the Pod down.

    :returns: Node object at second end of link

    """

    return self._get_node(2)

def _get_target_node(self, node_number):

    """Common implementation of get_node1() and get_node2()"""

    if not self._parent:

        raise TypeError("Parent pod must be specified in order to get node")

    target_node = {1: self.node1, 2: self.node2}[node_number]

    return target_node

def _get_node(self, node_number):

    """Common implementation of get_node1() and get_node2()"""

    if not self._parent:

        raise TypeError("Parent pod must be specified in order to get node")

    target_node = {1: self.node1, 2: self.node2}[node_number]

    matching_nodes = (

        node for node in self._parent.get_children(Node)

        if node == target_node

    )

    return next(matching_nodes, None)`