<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: acibaseobject issue in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903967#M3178</link>
    <description>&lt;P&gt;sorry for adding it few times... not sure what happened.&lt;/P&gt;</description>
    <pubDate>Sat, 12 Aug 2023 11:41:29 GMT</pubDate>
    <dc:creator>JamesDean87</dc:creator>
    <dc:date>2023-08-12T11:41:29Z</dc:date>
    <item>
      <title>acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903627#M3167</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I 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&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;self._parent.get_children(Node)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;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?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Below part of code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt; def get_node1(self):

        """Returns the Node object that corresponds to the first

        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 first end of link

        """

        return self._get_node(1)

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_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)`&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 08:56:48 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903627#M3167</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-11T08:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903720#M3168</link>
      <description>&lt;P&gt;Hi you should get the node ID's by calling get_node(), try this for your "matching_nodes":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;matching_nodes = (node.get_node() for node in self._parent.get_children(Node) if node.get_node() == target_node)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following works for me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from acitoolkit.acitoolkit import Session
from acitoolkit.aciphysobject import Pod, Node

url = "xxx"
login = "admin"
password = "xxx"

session = Session(url, login, password)
session.login()

pods = Pod.get(session)
for pod in pods:
    pod.populate_children(deep=False)
    node_generator = (node.get_node() for node in pod.get_children(Node))
    for x in node_generator:
        print(x)

""" OUTPUT:
101
201
1
102
"""&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 14:10:17 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903720#M3168</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-08-11T14:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903944#M3169</link>
      <description>&lt;P&gt;Hi Marcel,&lt;/P&gt;
&lt;P&gt;thank you very much for yours help, indeed it started working after one amendment added &lt;STRONG&gt;get_node()&lt;/STRONG&gt; to if - &lt;STRONG&gt;node.get_node()&lt;/STRONG&gt;&amp;nbsp; as yours first response (seems right now you also added it).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that I am struggle next problem related with&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class="ui-provider eo bdo bdp bdq bdr bds bdt bdu bdv bdw bdx bdy bdz bea beb bec bed bee bef beg beh bei bej bek bel bem ben beo bep beq ber bes bet beu bev"&gt;getFabricSt,&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="ui-provider eo bdo bdp bdq bdr bds bdt bdu bdv bdw bdx bdy bdz bea beb bec bed bee bef beg beh bei bej bek bel bem ben beo bep beq ber bes bet beu bev"&gt;wondering how to call it to get proper data, anyway i am also nto sure what this returns ? State of what ? Any ideas ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="ui-provider eo bdo bdp bdq bdr bds bdt bdu bdv bdw bdx bdy bdz bea beb bec bed bee bef beg beh bei bej bek bel bem ben beo bep beq ber bes bet beu bev"&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'getFabricSt'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;def _build_apic(self, pod):

        """This will build the cable plan using the configuration of the pod.

 

        :param pod: Pod

 

        :returns: None

        """

        nodes = pod.get_children(ACI.Node)

        for node in nodes:

            if node.getFabricSt() == 'active':

                if node.get_role() == 'spine':

                    self.add_switch(CpSwitch(node.get_name(), node.get_chassis_type(), spine=True))

                if node.get_role() == 'leaf':

                    self.add_switch(CpSwitch(node.get_name(), node.get_chassis_type()))

        links = pod.get_children(ACI.Link)

        for link in links:

            # node1_id = ACI.Link._get_target_node(link, 1)

            # print(node1_id)

            switch1 = link.get_node1()

            switch2 = link.get_node2()

            if switch1 and switch2:

                if link.get_node1().getFabricSt() == 'active' and link.get_node2().getFabricSt() == 'active':
                    if link.get_node1().get_role() != 'controller' and link.get_node2().get_role() != 'controller':

                        source_chassis = self._get_switch_from_apic_link(link, 1)

                        dest_chassis = self._get_switch_from_apic_link(link, 2)

                        source_interface = link.get_port1()

                        dest_interface = link.get_port2()

                        source_port = '{0:s}{1:s}/{2:s}'.format(source_interface.interface_type,

                                                                source_interface.module, source_interface.port)

                        dest_port = '{0:s}{1:s}/{2:s}'.format(dest_interface.interface_type,

                                                              dest_interface.module,

                                                              dest_interface.port)

 

                        self.add_link(

                            CpLink(source_chassis=source_chassis, source_port=source_port, dest_chassis=dest_chassis,

                                   dest_port=dest_port))

 &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 07:32:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903944#M3169</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T07:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903947#M3170</link>
      <description>&lt;P&gt;I think I found the problem it is triggered now by node name not number, will try to fix it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 08:24:54 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903947#M3170</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T08:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903957#M3171</link>
      <description>&lt;P&gt;Good to hear, if you stuck again, let me know.&lt;BR /&gt;&lt;BR /&gt;Regarding the other question: getFabricSt() returns the state of the node in question (active,&amp;nbsp;&lt;SPAN&gt;i&lt;/SPAN&gt;&lt;SPAN&gt;n&lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;c&lt;/SPAN&gt;&lt;SPAN&gt;t&lt;/SPAN&gt;&lt;SPAN&gt;i&lt;/SPAN&gt;&lt;SPAN&gt;v&lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;,&amp;nbsp;&lt;SPAN&gt;d&lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;&lt;SPAN&gt;c&lt;/SPAN&gt;&lt;SPAN&gt;o&lt;/SPAN&gt;&lt;SPAN&gt;m&lt;/SPAN&gt;&lt;SPAN&gt;m&lt;/SPAN&gt;&lt;SPAN&gt;i&lt;/SPAN&gt;&lt;SPAN&gt;s&lt;/SPAN&gt;&lt;SPAN&gt;s&lt;/SPAN&gt;&lt;SPAN&gt;i&lt;/SPAN&gt;&lt;SPAN&gt;o&lt;/SPAN&gt;&lt;SPAN&gt;n&lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;&lt;SPAN&gt;d&lt;/SPAN&gt;, disabled, discovering...etc) - it's the same state as you see in the UI under&amp;nbsp;&lt;EM&gt;Fabric &amp;gt; Inventory &amp;gt; Fabric Membership&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 09:12:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903957#M3171</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-08-12T09:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903958#M3172</link>
      <description>&lt;P&gt;For sure will do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;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.get_node() == target_node

    )


    return next(matching_nodes, None)`&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Generally easiest way in my case was replacing&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt; if node == target_node  to  if node.get_node() == target_node&lt;/LI-CODE&gt;
&lt;P&gt;rather rewriting whole functions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 09:22:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903958#M3172</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T09:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903959#M3173</link>
      <description>&lt;P&gt;Seems have next one, &lt;STRONG&gt;self.other&lt;/STRONG&gt;&amp;nbsp;in cableplan it is getting None and it is crashing here again, generally it seems it prompt switches names, but why i gets None ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="ui-provider en bdp bdq bdr bds bdt bdu bdv bdw bdx bdy bdz bea beb bec bed bee bef beg beh bei bej bek bel bem ben beo bep beq ber bes bet beu bev bew"&gt;return self.name == other.name&lt;BR /&gt;AttributeError: 'NoneType' object has no attribute 'name'&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;def __eq__(self, other):

        print(other)

        return self.name == other.name&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 09:39:12 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903959#M3173</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T09:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903963#M3174</link>
      <description>&lt;P&gt;Fixed, finally program started working &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;def __eq__(self, other):

        print(other)

        return self.name == other&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 09:53:05 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903963#M3174</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T09:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903964#M3175</link>
      <description>&lt;P&gt;Can you post the complete script?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 10:05:48 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903964#M3175</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-08-12T10:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903965#M3176</link>
      <description>&lt;P&gt;Never mind, I did not see your last post. Happy it works now.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 10:09:24 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903965#M3176</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-08-12T10:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903966#M3177</link>
      <description>&lt;P&gt;same problem here&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 11:42:16 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903966#M3177</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T11:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903967#M3178</link>
      <description>&lt;P&gt;sorry for adding it few times... not sure what happened.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 11:41:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903967#M3178</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T11:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: acibaseobject issue</title>
      <link>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903986#M3179</link>
      <description>&lt;P&gt;sure attached below, also acibaseobject you need to amend as below:&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-python"&gt;&lt;CODE&gt; if node == target_node  to  if node.get_node() == target_node&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Aug 2023 11:39:03 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/acibaseobject-issue/m-p/4903986#M3179</guid>
      <dc:creator>JamesDean87</dc:creator>
      <dc:date>2023-08-12T11:39:03Z</dc:date>
    </item>
  </channel>
</rss>

