Exemplo n.º 1
0
    def test_link_get_for_node(self):
        session = self.login_to_apic()
        pod = Pod.get(session)[0]
        links = Link.get(session)
        total_links = len(links)
        self.assertTrue(total_links > 0)
        self.assertRaises(TypeError, links[0].get_node1)
        self.assertRaises(TypeError, links[0].get_node2)
        self.assertRaises(TypeError, links[0].get_slot1)
        self.assertRaises(TypeError, links[0].get_slot2)
        self.assertRaises(TypeError, links[0].get_port1)
        self.assertRaises(TypeError, links[0].get_port2)
        links = Link.get(session, pod)
        self.assertEqual(len(links), total_links)
        switches = []
        for link in links:
            self.assertEqual(link.get_node1(), None)
            self.assertEqual(link.get_slot1(), None)
            self.assertEqual(link.get_port1(), None)
            self.assertEqual(link.get_node2(), None)
            self.assertEqual(link.get_slot2(), None)
            self.assertEqual(link.get_port2(), None)
            if link.node1 not in switches:
                switches.append(link.node1)
        self.assertTrue(len(switches) > 1)
        nodes = Node.get(session)
        spine = None
        for node in nodes:
            if node.get_role() == 'spine' and node.fabricSt == 'active':
                spine = node
                break
        if spine:
            links = Link.get(session, pod, spine.node)
            spine_links = len(links)
            self.assertTrue(spine_links > 0)
            self.assertTrue(spine_links < total_links)
            for link in links:
                self.assertEqual(link.node1, spine.node)
                self.assertIsInstance(str(link), str)
            links = Link.get(session, '1', spine.node)
            self.assertEqual(len(links), spine_links)

            self.assertNotEqual(links[0], links[1])
Exemplo n.º 2
0
    def test_link_get_for_node(self):
        session = self.login_to_apic()
        pod = Pod.get(session)[0]
        links = Link.get(session)
        total_links = len(links)
        self.assertTrue(total_links > 0)
        self.assertRaises(TypeError, links[0].get_node1)
        self.assertRaises(TypeError, links[0].get_node2)
        self.assertRaises(TypeError, links[0].get_slot1)
        self.assertRaises(TypeError, links[0].get_slot2)
        self.assertRaises(TypeError, links[0].get_port1)
        self.assertRaises(TypeError, links[0].get_port2)
        links = Link.get(session, pod)
        self.assertEqual(len(links), total_links)
        switches = []
        for link in links:
            self.assertEqual(link.get_node1(), None)
            self.assertEqual(link.get_slot1(), None)
            self.assertEqual(link.get_port1(), None)
            self.assertEqual(link.get_node2(), None)
            self.assertEqual(link.get_slot2(), None)
            self.assertEqual(link.get_port2(), None)
            if link.node1 not in switches:
                switches.append(link.node1)
        self.assertTrue(len(switches) > 1)
        nodes = Node.get(session)
        spine = None
        for node in nodes:
            if node.get_role() == 'spine' and node.fabricSt == 'active':
                spine = node
                break
        if spine:
            links = Link.get(session, pod, spine.node)
            spine_links = len(links)
            self.assertTrue(spine_links > 0)
            self.assertTrue(spine_links < total_links)
            for link in links:
                self.assertEqual(link.node1, spine.node)
                self.assertIsInstance(str(link), str)
            links = Link.get(session, '1', spine.node)
            self.assertEqual(len(links), spine_links)

            self.assertNotEqual(links[0], links[1])
Exemplo n.º 3
0
    def test_get_endpoint_objects(self):
        pod_id = '1'
        node1_id = '2'
        node2_id = '3'
        slot1_id = '4'
        slot2_id = '5'
        port1_id = '6'
        port2_id = '7'
        link_id = '101'

        pod = Pod(pod_id)
        node1 = Node(pod_id, node1_id, 'Spine', 'spine', pod)
        node2 = Node(pod_id, node2_id, 'Leaf', 'leaf', pod)
        linecard1 = Linecard(slot1_id, node1)
        linecard2 = Linecard(slot2_id, node2)
        interface1 = Interface(interface_type='eth',
                               pod=pod_id,
                               node=node1_id,
                               module=slot1_id,
                               port=port1_id,
                               parent=linecard1)
        interface2 = Interface(interface_type='eth',
                               pod=pod_id,
                               node=node2_id,
                               module=slot2_id,
                               port=port2_id,
                               parent=linecard2)
        link1 = Link(pod)
        link1.pod = pod_id
        link1.link = link_id
        link1.node1 = node1_id
        link1.slot1 = slot1_id
        link1.port1 = port1_id
        link1.node2 = node2_id
        link1.slot2 = slot2_id
        link1.port2 = port2_id

        self.assertEqual(node1, link1.get_node1())
        self.assertEqual(node2, link1.get_node2())
        self.assertEqual(linecard1, link1.get_slot1())
        self.assertEqual(linecard2, link1.get_slot2())
        self.assertEqual(interface1, link1.get_port1())
        self.assertEqual(interface2, link1.get_port2())
Exemplo n.º 4
0
    def test_parameters(self):
        pod = Pod('1')
        node1 = '2'
        node2 = '3'
        slot1 = '4'
        slot2 = '5'
        port1 = '6'
        port2 = '7'
        link = '101'

        link1 = Link(pod)
        link1.pod = pod.pod
        link1.link = link
        link1.node1 = node1
        link1.slot1 = slot1
        link1.port1 = port1
        link1.node2 = node2
        link1.slot2 = slot2
        link1.port2 = port2
        self.assertEqual(link1.pod, pod.pod)
        self.assertEqual(link1.link, link)
        self.assertEqual(link1.node1, node1)
        self.assertEqual(link1.slot1, slot1)
        self.assertEqual(link1.port1, port1)
        self.assertEqual(link1.node2, node2)
        self.assertEqual(link1.slot2, slot2)
        self.assertEqual(link1.port2, port2)
        self.assertEqual(link1.get_parent(), pod)

        self.assertEqual(link1.get_port_id1(), '1/2/4/6')
        self.assertEqual(link1.get_port_id2(), '1/3/5/7')
Exemplo n.º 5
0
    def test_get_endpoint_objects(self):
        pod_id = '1'
        node1_id = '2'
        node2_id = '3'
        slot1_id = '4'
        slot2_id = '5'
        port1_id = '6'
        port2_id = '7'
        link_id = '101'

        pod = Pod(pod_id)
        node1 = Node(pod_id, node1_id, 'Spine', 'spine', pod)
        node2 = Node(pod_id, node2_id, 'Leaf', 'leaf', pod)
        linecard1 = Linecard(slot1_id, node1)
        linecard2 = Linecard(slot2_id, node2)
        interface1 = Interface(interface_type='eth', pod=pod_id,
                               node=node1_id, module=slot1_id,
                               port=port1_id, parent=linecard1)
        interface2 = Interface(interface_type='eth', pod=pod_id,
                               node=node2_id, module=slot2_id,
                               port=port2_id, parent=linecard2)
        link1 = Link(pod)
        link1.pod = pod_id
        link1.link = link_id
        link1.node1 = node1_id
        link1.slot1 = slot1_id
        link1.port1 = port1_id
        link1.node2 = node2_id
        link1.slot2 = slot2_id
        link1.port2 = port2_id

        self.assertEqual(node1, link1.get_node1())
        self.assertEqual(node2, link1.get_node2())
        self.assertEqual(linecard1, link1.get_slot1())
        self.assertEqual(linecard2, link1.get_slot2())
        self.assertEqual(interface1, link1.get_port1())
        self.assertEqual(interface2, link1.get_port2())
Exemplo n.º 6
0
    def test_parameters(self):
        pod = Pod('1')
        node1 = '2'
        node2 = '3'
        slot1 = '4'
        slot2 = '5'
        port1 = '6'
        port2 = '7'
        link = '101'

        link1 = Link(pod)
        link1.pod = pod.pod
        link1.link = link
        link1.node1 = node1
        link1.slot1 = slot1
        link1.port1 = port1
        link1.node2 = node2
        link1.slot2 = slot2
        link1.port2 = port2
        self.assertEqual(link1.pod, pod.pod)
        self.assertEqual(link1.link, link)
        self.assertEqual(link1.node1, node1)
        self.assertEqual(link1.slot1, slot1)
        self.assertEqual(link1.port1, port1)
        self.assertEqual(link1.node2, node2)
        self.assertEqual(link1.slot2, slot2)
        self.assertEqual(link1.port2, port2)
        self.assertEqual(link1.get_parent(), pod)

        self.assertEqual(link1.get_port_id1(), '1/2/4/6')
        self.assertEqual(link1.get_port_id2(), '1/3/5/7')
Exemplo n.º 7
0
    def test_get_endpoint_objects(self):
        pod_id = "1"
        node1_id = "2"
        node2_id = "3"
        slot1_id = "4"
        slot2_id = "5"
        port1_id = "6"
        port2_id = "7"
        link_id = "101"

        pod = Pod(pod_id)
        node1 = Node(pod_id, node1_id, "Spine", "spine", pod)
        node2 = Node(pod_id, node2_id, "Leaf", "leaf", pod)
        linecard1 = Linecard(slot1_id, node1)
        linecard2 = Linecard(slot2_id, node2)
        interface1 = Interface(
            interface_type="eth", pod=pod_id, node=node1_id, module=slot1_id, port=port1_id, parent=linecard1
        )
        interface2 = Interface(
            interface_type="eth", pod=pod_id, node=node2_id, module=slot2_id, port=port2_id, parent=linecard2
        )
        link1 = Link(pod)
        link1.pod = pod_id
        link1.link = link_id
        link1.node1 = node1_id
        link1.slot1 = slot1_id
        link1.port1 = port1_id
        link1.node2 = node2_id
        link1.slot2 = slot2_id
        link1.port2 = port2_id

        self.assertEqual(node1, link1.get_node1())
        self.assertEqual(node2, link1.get_node2())
        self.assertEqual(linecard1, link1.get_slot1())
        self.assertEqual(linecard2, link1.get_slot2())
        self.assertEqual(interface1, link1.get_port1())
        self.assertEqual(interface2, link1.get_port2())
Exemplo n.º 8
0
    def test_parameters(self):
        pod = Pod("1")
        node1 = "2"
        node2 = "3"
        slot1 = "4"
        slot2 = "5"
        port1 = "6"
        port2 = "7"
        link = "101"

        link1 = Link(pod)
        link1.pod = pod.pod
        link1.link = link
        link1.node1 = node1
        link1.slot1 = slot1
        link1.port1 = port1
        link1.node2 = node2
        link1.slot2 = slot2
        link1.port2 = port2
        self.assertEqual(link1.pod, pod.pod)
        self.assertEqual(link1.link, link)
        self.assertEqual(link1.node1, node1)
        self.assertEqual(link1.slot1, slot1)
        self.assertEqual(link1.port1, port1)
        self.assertEqual(link1.node2, node2)
        self.assertEqual(link1.slot2, slot2)
        self.assertEqual(link1.port2, port2)
        self.assertEqual(link1.get_parent(), pod)

        self.assertEqual(link1.get_port_id1(), "1/2/4/6")
        self.assertEqual(link1.get_port_id2(), "1/3/5/7")