mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-23 23:38:21 +00:00
Save IOS router configs when saving the project (done right this time).
This commit is contained in:
parent
f6b122cdfa
commit
8415117d2d
@ -15,10 +15,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import os
|
||||
import base64
|
||||
import asyncio
|
||||
|
||||
from ...web.route import Route
|
||||
from ...schemas.dynamips_vm import VM_CREATE_SCHEMA
|
||||
@ -341,7 +339,7 @@ class DynamipsVMHandler:
|
||||
},
|
||||
output=VM_CONFIGS_SCHEMA,
|
||||
description="Retrieve the startup and private configs content")
|
||||
def show_initial_config(request, response):
|
||||
def get_configs(request, response):
|
||||
|
||||
dynamips_manager = Dynamips.instance()
|
||||
vm = dynamips_manager.get_vm(request.match_info["vm_id"],
|
||||
@ -355,6 +353,23 @@ class DynamipsVMHandler:
|
||||
response.json({"startup_config_content": startup_config_content,
|
||||
"private_config_content": private_config_content})
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/dynamips/vms/{vm_id}/configs/save",
|
||||
status_codes={
|
||||
200: "Configs saved",
|
||||
400: "Invalid request",
|
||||
404: "Instance doesn't exist"
|
||||
},
|
||||
description="Save the startup and private configs content")
|
||||
def save_configs(request, response):
|
||||
|
||||
dynamips_manager = Dynamips.instance()
|
||||
vm = dynamips_manager.get_vm(request.match_info["vm_id"],
|
||||
project_id=request.match_info["project_id"])
|
||||
|
||||
yield from vm.save_configs()
|
||||
response.set_status(200)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/dynamips/vms/{vm_id}/idlepc_proposals",
|
||||
status_codes={
|
||||
|
@ -282,16 +282,6 @@ class BaseManager:
|
||||
|
||||
pass
|
||||
|
||||
@asyncio.coroutine
|
||||
def project_committed(self, project):
|
||||
"""
|
||||
Called when a project is committed.
|
||||
|
||||
:param project: Project instance
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete_vm(self, vm_id):
|
||||
"""
|
||||
|
@ -115,7 +115,6 @@ class Dynamips(BaseManager):
|
||||
self._devices = {}
|
||||
self._ghost_files = set()
|
||||
self._dynamips_path = None
|
||||
self._project_lock = asyncio.Lock()
|
||||
|
||||
@asyncio.coroutine
|
||||
def unload(self):
|
||||
@ -192,28 +191,13 @@ class Dynamips(BaseManager):
|
||||
:param project: Project instance
|
||||
"""
|
||||
|
||||
with (yield from self._project_lock):
|
||||
for vm in self._vms.values():
|
||||
if vm.project.id == project.id:
|
||||
yield from vm.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower()))
|
||||
for vm in self._vms.values():
|
||||
if vm.project.id == project.id:
|
||||
yield from vm.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower()))
|
||||
|
||||
for device in self._devices.values():
|
||||
if device.project.id == project.id:
|
||||
yield from device.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower()))
|
||||
|
||||
@asyncio.coroutine
|
||||
def project_committed(self, project):
|
||||
"""
|
||||
Called when a project has been committed.
|
||||
|
||||
:param project: Project instance
|
||||
"""
|
||||
|
||||
# save the configs when the project is committed
|
||||
with (yield from self._project_lock):
|
||||
for vm in self._vms.values():
|
||||
if vm.project.id == project.id:
|
||||
yield from vm.save_configs()
|
||||
for device in self._devices.values():
|
||||
if device.project.id == project.id:
|
||||
yield from device.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower()))
|
||||
|
||||
@property
|
||||
def dynamips_path(self):
|
||||
|
@ -324,8 +324,6 @@ class Project:
|
||||
vm = self._vms_to_destroy.pop()
|
||||
yield from vm.delete()
|
||||
self.remove_vm(vm)
|
||||
for module in self.modules():
|
||||
yield from module.instance().project_committed(self)
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete(self):
|
||||
|
Loading…
Reference in New Issue
Block a user