Creating a snapshot with an underscore in the name (e.g. test_snapshot) results in an error when trying to load the snapshot after the server has restarted:
Traceback (most recent call last):
File "/home/gns3/.venv/gns3server-venv/lib/python3.8/site-packages/gns3server/web/route.py", line 202, in control_schema
func(request, response)
File "/home/gns3/.venv/gns3server-venv/lib/python3.8/site-packages/gns3server/handlers/api/controller/snapshot_handler.py", line 67, in list
response.json(sorted(snapshots, key=lambda s: (s.created_at, s.name)))
File "/home/gns3/.venv/gns3server-venv/lib/python3.8/site-packages/gns3server/handlers/api/controller/snapshot_handler.py", line 67, in <lambda>
response.json(sorted(snapshots, key=lambda s: (s.created_at, s.name)))
File "/home/gns3/.venv/gns3server-venv/lib/python3.8/site-packages/gns3server/controller/snapshot.py", line 80, in created_at
return int(self._created_at)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'
Creating a snapshot with an underscore in the name (e.g.
test_snapshot
) results in an error when trying to load the snapshot after the server has restarted:This is because the snapshot name is parsed by assuming that everything following the first underscore is the date: https://github.com/GNS3/gns3-server/blob/35f94b0c736ff9b30b9cc37b93ffff7c28e9636b/gns3server/controller/snapshot.py#L58-L59
A more robust solution might be to simply work backwards from the end of the filename instead using negative indexing: