mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 16:28:11 +00:00
Clean delete for IOU & VPCS devices.
This commit is contained in:
parent
6c0918312c
commit
7182e59892
@ -373,7 +373,7 @@ class IOU(IModule):
|
||||
return
|
||||
|
||||
try:
|
||||
iou_instance.delete()
|
||||
iou_instance.clean_delete()
|
||||
del self._iou_instances[request["id"]]
|
||||
except IOUError as e:
|
||||
self.send_custom_error(str(e))
|
||||
|
@ -27,6 +27,8 @@ import subprocess
|
||||
import argparse
|
||||
import threading
|
||||
import configparser
|
||||
import shutil
|
||||
|
||||
from .ioucon import start_ioucon
|
||||
from .iou_error import IOUError
|
||||
from .adapters.ethernet_adapter import EthernetAdapter
|
||||
@ -332,6 +334,28 @@ class IOUDevice(object):
|
||||
log.info("IOU device {name} [id={id}] has been deleted".format(name=self._name,
|
||||
id=self._id))
|
||||
|
||||
def clean_delete(self):
|
||||
"""
|
||||
Deletes this IOU device & all files (nvram, startup-config etc.)
|
||||
"""
|
||||
|
||||
self.stop()
|
||||
self._instances.remove(self._id)
|
||||
|
||||
if self.console:
|
||||
self._allocated_console_ports.remove(self.console)
|
||||
|
||||
try:
|
||||
shutil.rmtree(self._working_dir)
|
||||
except OSError as e:
|
||||
log.error("could not delete IOU device {name} [id={id}]: {error}".format(name=self._name,
|
||||
id=self._id,
|
||||
error=e))
|
||||
return
|
||||
|
||||
log.info("IOU device {name} [id={id}] has been deleted (including associated files)".format(name=self._name,
|
||||
id=self._id))
|
||||
|
||||
@property
|
||||
def started(self):
|
||||
"""
|
||||
|
@ -284,7 +284,7 @@ class VPCS(IModule):
|
||||
return
|
||||
|
||||
try:
|
||||
vpcs_instance.delete()
|
||||
vpcs_instance.clean_delete()
|
||||
del self._vpcs_instances[request["id"]]
|
||||
except VPCSError as e:
|
||||
self.send_custom_error(str(e))
|
||||
|
@ -23,6 +23,8 @@ order to run an VPCS instance.
|
||||
import os
|
||||
import subprocess
|
||||
import signal
|
||||
import shutil
|
||||
|
||||
from .vpcs_error import VPCSError
|
||||
from .adapters.ethernet_adapter import EthernetAdapter
|
||||
from .nios.nio_udp import NIO_UDP
|
||||
@ -267,6 +269,28 @@ class VPCSDevice(object):
|
||||
log.info("VPCS device {name} [id={id}] has been deleted".format(name=self._name,
|
||||
id=self._id))
|
||||
|
||||
def clean_delete(self):
|
||||
"""
|
||||
Deletes this VPCS device & all files (configs, logs etc.)
|
||||
"""
|
||||
|
||||
self.stop()
|
||||
self._instances.remove(self._id)
|
||||
|
||||
if self.console:
|
||||
self._allocated_console_ports.remove(self.console)
|
||||
|
||||
try:
|
||||
shutil.rmtree(self._working_dir)
|
||||
except OSError as e:
|
||||
log.error("could not delete VPCS device {name} [id={id}]: {error}".format(name=self._name,
|
||||
id=self._id,
|
||||
error=e))
|
||||
return
|
||||
|
||||
log.info("VPCS device {name} [id={id}] has been deleted".format(name=self._name,
|
||||
id=self._id))
|
||||
|
||||
@property
|
||||
def started(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user