Open fatpelt opened 2 years ago
I have no idea about gns3fy or pydantic, but I bodged in a fix and it seems to work, I would assume that pydantic change from using initialised to __pydantic_initialised__ recently, and gns3fy needed to be updated
https://github.com/isostatic/gns3fy/commit/7862e1991e9625623ab3d02d0fbcde03a509a87a
Thanks for the description of the problem, downgrading helps indeed. I went ahead and pinned the pydantic
version in my requirements.txt
:
# pydantic is pinned to avoid this issue:
# https://github.com/davidban77/gns3fy/issues/107
pydantic==1.9.2
gns3fy==0.8.0
I have no idea about gns3fy or pydantic, but I bodged in a fix and it seems to work, I would assume that pydantic change from using initialised to pydantic_initialised recently, and gns3fy needed to be updated
Would you do a pull request for the fix ? If not I would do one from Domoninc@ab800ee which is the same fix you came up with first.
@Domoninic I have opened a pull request for this issue.
@Domoninic I have opened a pull request for this issue.
Your fix misses one occurrence, I open a pull request to included all occurrences.
@Domoninic Just added the missing part, before I saw your comment.
downgrading pydantic to 1.9.x works fine. it appears that pydantic is adding a field (
__pydantic_initialised__
) to dicts that are subsequently serialized to json and sent to the gns3 server which errors on the additional unexpected fields.a sample of the error message thrown:
TASK [davidban77.gns3.create_lab : Create Project] ** task path: /Users/pfelt/Projects/gns3_labs/ansible_collections/davidban77/gns3/roles/create_lab/tasks/main.yml:2 The full traceback is: Traceback (most recent call last): File "/Users/pfelt/Library/Python/3.8/lib/python/site-packages/gns3fy/gns3fy.py", line 141, in http_call _response.raise_for_status() File "/Users/pfelt/Library/Python/3.8/lib/python/site-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://192.168.122.89:80/v2/projects
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/pfelt/.ansible/tmp/ansible-tmp-1662489418.9695628-94710-141604783353771/AnsiballZ_gns3_project.py", line 100, in
_ansiballz_main()
File "/Users/pfelt/.ansible/tmp/ansible-tmp-1662489418.9695628-94710-141604783353771/AnsiballZ_gns3_project.py", line 92, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/pfelt/.ansible/tmp/ansible-tmp-1662489418.9695628-94710-141604783353771/AnsiballZ_gns3_project.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.davidban77.gns3.plugins.modules.gns3_project', init_globals=dict(_module_fqn='ansible_collections.davidban77.gns3.plugins.modules.gns3_project', _modlib_path=modlib_path),
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/var/folders/l5/vx4f7wdn73ng3kv4k_4k6l900000gq/T/ansible_gns3_project_payload_krb97usq/ansible_gns3_project_payload.zip/ansible_collections/davidban77/gns3/plugins/modules/gns3_project.py", line 437, in
File "/var/folders/l5/vx4f7wdn73ng3kv4k_4k6l900000gq/T/ansible_gns3_project_payload_krb97usq/ansible_gns3_project_payload.zip/ansible_collections/davidban77/gns3/plugins/modules/gns3_project.py", line 409, in main
File "/Users/pfelt/Library/Python/3.8/lib/python/site-packages/gns3fy/gns3fy.py", line 1264, in create
_response = self.connector.http_call("post", _url, json_data=data)
File "/Users/pfelt/Library/Python/3.8/lib/python/site-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': 'pgf2RockiesLab-ceos', 'pydantic_initialised': True}': Additional properties are not allowed ('pydantic_initialised' was unexpected)
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/Users/pfelt/Library/Python/3.8/lib/python/site-packages/gns3fy/gns3fy.py\", line 141, in http_call\n _response.raise_for_status()\n File \"/Users/pfelt/Library/Python/3.8/lib/python/site-packages/requests/models.py\", line 943, in raise_for_status\n raise HTTPError(http_error_msg, response=self)\nrequests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://192.168.122.89:80/v2/projects\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/Users/pfelt/.ansible/tmp/ansible-tmp-1662489418.9695628-94710-141604783353771/AnsiballZ_gns3_project.py\", line 100, in \n _ansiballz_main()\n File \"/Users/pfelt/.ansible/tmp/ansible-tmp-1662489418.9695628-94710-141604783353771/AnsiballZ_gns3_project.py\", line 92, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/pfelt/.ansible/tmp/ansible-tmp-1662489418.9695628-94710-141604783353771/AnsiballZ_gns3_project.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.davidban77.gns3.plugins.modules.gns3_project', init_globals=dict(_module_fqn='ansible_collections.davidban77.gns3.plugins.modules.gns3_project', _modlib_path=modlib_path),\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/var/folders/l5/vx4f7wdn73ng3kv4k_4k6l900000gq/T/ansible_gns3_project_payload_krb97usq/ansible_gns3_project_payload.zip/ansible_collections/davidban77/gns3/plugins/modules/gns3_project.py\", line 437, in \n File \"/var/folders/l5/vx4f7wdn73ng3kv4k_4k6l900000gq/T/ansible_gns3_project_payload_krb97usq/ansible_gns3_project_payload.zip/ansible_collections/davidban77/gns3/plugins/modules/gns3_project.py\", line 409, in main\n File \"/Users/pfelt/Library/Python/3.8/lib/python/site-packages/gns3fy/gns3fy.py\", line 1264, in create\n _response = self.connector.http_call(\"post\", _url, json_data=data)\n File \"/Users/pfelt/Library/Python/3.8/lib/python/site-packages/gns3fy/gns3fy.py\", line 143, in http_call\n raise HTTPError(\nrequests.exceptions.HTTPError: 400: JSON schema error with API request '/v2/projects' and JSON data '{'name': 'pgf2RockiesLab-ceos', 'pydantic_initialised': True}': Additional properties are not allowed ('pydantic_initialised' was unexpected)\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
PLAY RECAP ** localhost : ok=5 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
bash-3.2$