Closed Krlosromero closed 2 years ago
All tests passed
Live tests:
In [12]: print(tabulate(links_summary, headers=["Node A", "Port A", "Node B", "Port B"])) Node A Port A Node B Port B ---------------- ----------- ---------------- ----------- PC-1 Ethernet0 Ethernetswitch-1 Ethernet0 Ethernetswitch-1 Ethernet1 PC-2 Ethernet0 Ethernetswitch-1 Ethernet5 vEOS-4.21.5F-2 Management IOU1 Ethernet0/0 Ethernetswitch-1 Ethernet2 inet0-VMNET1 eth0 Ethernetswitch-1 Ethernet3 switch2 Ethernet1 IOU2 Ethernet0/0 switch2 Ethernet0 Ethernetswitch-1 Ethernet4 In [13]: first_lab.delete_link('switch2','Ethernet0','Ethernetswitch-1','Ethernet4') Deleted Link-ID: d2ede188-693d-4e32-9a18-d6cd23d019d7 From node switch2, port: Ethernet0 <--> to node Ethernetswitch-1, port: Ethernet4 In [14]: first_lab.get() In [15]: links_summary = first_lab.links_summary(is_print=False) In [16]: print(tabulate(links_summary, headers=["Node A", "Port A", "Node B", "Port B"])) Node A Port A Node B Port B ---------------- ----------- ---------------- ----------- PC-1 Ethernet0 Ethernetswitch-1 Ethernet0 Ethernetswitch-1 Ethernet1 PC-2 Ethernet0 Ethernetswitch-1 Ethernet5 vEOS-4.21.5F-2 Management IOU1 Ethernet0/0 Ethernetswitch-1 Ethernet2 inet0-VMNET1 eth0 Ethernetswitch-1 Ethernet3 switch2 Ethernet1 IOU2 Ethernet0/0 switch2 Ethernet0 Ethernetswitch-1 Ethernet4 In [17]: first_lab.delete_link('Ethernetswitch-1','Ethernet4','switch2','Ethernet0') Deleted Link-ID: 694e6681-afb3-4bc0-9d8d-6c31bee570b8 From node Ethernetswitch-1, port: Ethernet4 <--> to node switch2, port: Ethernet0 In [18]: first_lab.get() In [19]: links_summary = first_lab.links_summary(is_print=False) In [20]: print(tabulate(links_summary, headers=["Node A", "Port A", "Node B", "Port B"])) Node A Port A Node B Port B ---------------- ----------- ---------------- ----------- PC-1 Ethernet0 Ethernetswitch-1 Ethernet0 Ethernetswitch-1 Ethernet1 PC-2 Ethernet0 Ethernetswitch-1 Ethernet5 vEOS-4.21.5F-2 Management IOU1 Ethernet0/0 Ethernetswitch-1 Ethernet2 inet0-VMNET1 eth0 Ethernetswitch-1 Ethernet3 switch2 Ethernet1 IOU2 Ethernet0/0 switch2 Ethernet0 Ethernetswitch-1 Ethernet4 In [21]: first_lab.delete_link('Ethernetswitch-8','Ethernet4','switch2','Ethernet0') --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-21-d854dc7da484> in <module> ----> 1 first_lab.delete_link('Ethernetswitch-8','Ethernet4','switch2','Ethernet0') ~/workspace/gns3fy/gns3fy/gns3fy.py in delete_link(self, node_a, port_a, node_b, port_b) 1797 _node_a = self.get_node(name=node_a) 1798 if not _node_a: -> 1799 raise ValueError(f"node_a: {node_a} not found") 1800 try: 1801 _port_a = [_p for _p in _node_a.ports if _p["name"] == port_a][0] ValueError: node_a: Ethernetswitch-8 not found In [22]: first_lab.delete_link('Ethernetswitch-1','Ethernet4','switch2','Ethernet8') --------------------------------------------------------------------------- IndexError Traceback (most recent call last) ~/workspace/gns3fy/gns3fy/gns3fy.py in delete_link(self, node_a, port_a, node_b, port_b) 1808 try: -> 1809 _port_b = [_p for _p in _node_b.ports if _p["name"] == port_b][0] 1810 except IndexError: IndexError: list index out of range During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) <ipython-input-22-c4366e719bef> in <module> ----> 1 first_lab.delete_link('Ethernetswitch-1','Ethernet4','switch2','Ethernet8') ~/workspace/gns3fy/gns3fy/gns3fy.py in delete_link(self, node_a, port_a, node_b, port_b) 1809 _port_b = [_p for _p in _node_b.ports if _p["name"] == port_b][0] 1810 except IndexError: -> 1811 raise ValueError(f"port_b: {port_b} not found") 1812 1813 _matches = [] ValueError: port_b: Ethernet8 not found
All tests passed
Live tests: