mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
Support to duplicate an appliance.
This commit is contained in:
1 parent
9b83b087cb
commit
bd657c0167
3 files changed
+64
-1
No files matched your search
@@ -24,6 +24,7 @@ import shutil
|
||||
import asyncio
|
||||
import aiohttp
|
||||
import jsonschema
|
||||
import copy
|
||||
|
||||
from ..config import Config
|
||||
from .project import Project
|
||||
@@ -181,6 +182,20 @@ class Controller:
|
||||
self.save()
|
||||
self.notification.controller_emit("appliance.deleted", appliance.__json__())
|
||||
|
||||
def duplicate_appliance(self, appliance_id):
|
||||
"""
|
||||
Duplicates an appliance.
|
||||
|
||||
:param appliance_id: appliance identifier
|
||||
"""
|
||||
|
||||
appliance = self.get_appliance(appliance_id)
|
||||
if appliance.builtin:
|
||||
raise aiohttp.web.HTTPConflict(text="Appliance ID {} cannot be duplicated because it is a builtin".format(appliance_id))
|
||||
appliance_settings = copy.deepcopy(appliance.settings)
|
||||
del appliance_settings["appliance_id"]
|
||||
return self.add_appliance(appliance_settings)
|
||||
|
||||
def load_appliances(self):
|
||||
|
||||
#self._appliances = {}
|
||||
|
||||
Reference in new issue
Block a user