davidban77 / gns3fy

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

Erro lab.create() #117

Open nguyentheanhhnd opened 7 months ago

nguyentheanhhnd commented 7 months ago

I try run script:


server = Gns3Connector(url="http://localhost:3080")
lab = Project(name="check", connector=server)
try:
    lab.create()
    print("Project created successfully")
except ValueError as e:
    print(f"Error creating project: {e}")
print(server.projects_summary())
print(lab.status)

this is erro : python3 vidu2.py Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/gns3fy/gns3fy.py", line 141, in http_call _response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:3080/v2/projects

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "vidu2.py", line 12, in lab.create() File "/usr/local/lib/python3.8/dist-packages/gns3fy/gns3fy.py", line 1264, in create _response = self.connector.http_call("post", _url, json_data=data) File "/usr/local/lib/python3.8/dist-packages/gns3fy/gns3fy.py", line 143, in http_call raise HTTPError( requests.exceptions.HTTPError: 400: JSON schema error with API request '/v2/projects' and JSON data '{'name': 'demo2', 'pydantic_initialised': True}': Additional properties are not allowed ('pydantic_initialised' was unexpected)

davidban77 commented 7 months ago

Can you post the version of GNS3 you are using and the version of pydantic as well?

nguyentheanhhnd commented 7 months ago

I am currently using GNS3 version 2.2.44.1, Python 3.8.10, and Ubuntu 20.04.6 LTS.

nguyentheanhhnd commented 7 months ago

I'm also having difficulty with node creation and link creation. Do you have any examples for this? thank you

davidban77 commented 7 months ago

Here is a link to the documentation for node creation: https://davidban77.github.io/gns3fy/user-guide/#node-creation

Link creation is just after it.

kuuse commented 5 months ago

I had the same error, using 'pip install gns3fy' on Ubuntu 20.04. A dirty hack is to get the newest version of 'gns3fy.py' from GitHub (either clone the repos or make a raw copy of the file).
Then overwrite the existing file (which seems to be /usr/local/lib/python3.8/dist-packages/gns3fy/gns3fy.py in your case).

This fixes the 'pydantic_initialised was unexpected' error.

The "proper" solution (according to the documentation) to install the cloned GitHub version is using 'poetry', but this doesn't seem to work with Python 3.8.