davidban77 / gns3fy

Python library wrapper around GNS3 Server REST API
https://davidban77.github.io/gns3fy/
57 stars 28 forks source link

Incorrect Label on newly created link #70

Closed ollieyoung closed 4 years ago

ollieyoung commented 4 years ago

When I create a new link through gns3fy, lets say: lab.create_link("Switch", "Ethernet0", "Ubuntu18.04", "eth0")

it adds the label name of "0/0" for all connections rather than the appropriate names Ethernet0 & eth0. Is it possible that this can be revised or is this a issue with the API limitations? Thanks.

Krlosromero commented 4 years ago

Hi Ollie, I'll have a look to it

Krlosromero commented 4 years ago

Hello Ollie,

I had created a lab with only 2 nodes and cretaed the link between them, I don't see any issues.

In [41]: issue70.nodes_summary()                                                                                                                                                                                   
switch1: started -- Console: 5000 -- ID: 38542f12-8050-4d3a-aa51-98f89375366f
Router1: stopped -- Console: 5001 -- ID: 546a8d2c-900a-4e8a-bade-cb32ccbaca1a

In [42]: issue70.create_link("switch1", "Ethernet0", "Router1", "Ethernet1/1")                                                                                                                                     
Created Link-ID: 6cc76ac4-38ef-4af5-966d-57020e984934 -- Type: ethernet

In [43]: issue70.links_summary()                                                                                                                                                                                   
switch1: Ethernet0 ---- Router1: Ethernet1/1

Can you test again and show me your error?

Also, can you let me know:

Cheers

ollieyoung commented 4 years ago

Ok thanks for checking, much appreciated, let me look again today and grab the versions.

ollieyoung commented 4 years ago

Gns3fy version - 0.6.0 (install with 'pip3 install gns3fy' on Ubuntu 18.04 server - separate to GNS3VM) Gns3Server version - was 2.2.5, but have upgraded to 2.2.7 - same issue Python - 3.6.9 64-bit

Example - connection of 2 standard ethernet switches, but effects all devices (Cisco, Arista, Docker)

Python Code:

!/usr/bin/env python

from gns3fy import Gns3Connector, Project, Node, Link from tabulate import tabulate import csv import time

server = Gns3Connector("http://gnsvm:3080")

lab = Project(name="test-lab", connector=server) lab.get()

def main(): lab.create_link("Switch", "Ethernet7", "Switch2", "Ethernet7") print(lab.links)

if name == "main": main()

Terminal Output: Created Link-ID: 737095ac-7736-40eb-858d-c78bf798b603 -- Type: ethernet [Link(link_id='737095ac-7736-40eb-858d-c78bf798b603', link_type='ethernet', project_id='bacf8773-f1cf-42a7-b8a7-544c7e65fc6d', suspend=False, nodes=[{'adapter_number': 0, 'label': {'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;', 'text': '0/7'}, 'node_id': 'da83323c-6eb4-43f8-b667-4fd01da60c9a', 'port_number': 7}, {'adapter_number': 0, 'label': {'style': 'font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;', 'text': '0/7'}, 'node_id': '6bb614e5-4853-476e-9681-76db5aad3061', 'port_number': 7}], filters={}, capturing=False, capture_file_path=None, capture_file_name=None, capture_compute_id=None)]

issue

agroveandtrie commented 4 years ago

I was able to reproduce the same issue as Ollie with these versions. Gns3fy version - 0.7.0 Gns3Server version - was 2.2.8 Python 3.7.5

The create_link() method is not setting the label when defining the Link object. When the label is not set by the client the server sets it to adapter_number/port_number.

Link to relevant server code. https://github.com/GNS3/gns3-server/blob/16ca0fd91535ea0b0ed812f7d721c0d445844fa5/gns3server/controller/link.py#L249

davidban77 commented 4 years ago

Fixed #83