mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: dedupe and report automatic template creation from images
install_appliances_from_image relied on the name+version pair check in TemplatesService, so the same appliance reached through a second image (the CSR1000v case) created a second template sharing the name. The auto path now skips when any template with the same name exists, whatever the version, and returns a manifest of created and skipped candidates; POST /images/install replies 200 with that manifest instead of an empty 204, and the image_install MCP tool surfaces it.
This commit is contained in:
7 files changed
+154
-11
No files matched your search
@@ -71,6 +71,17 @@ class TemplatesRepository(BaseRepository):
|
||||
result = await self._db_session.execute(query)
|
||||
return result.scalars().first()
|
||||
|
||||
async def get_template_by_name(self, name: str) -> Union[None, models.Template]:
|
||||
"""
|
||||
Return the first template with this name, regardless of version.
|
||||
"""
|
||||
|
||||
query = select(models.Template).\
|
||||
options(selectinload(models.Template.images)).\
|
||||
where(models.Template.name == name)
|
||||
result = await self._db_session.execute(query)
|
||||
return result.scalars().first()
|
||||
|
||||
async def get_templates(self) -> List[models.Template]:
|
||||
|
||||
query = select(models.Template).options(selectinload(models.Template.images))
|
||||
|
||||
Reference in new issue
Block a user