mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Implement special request to stop a module.
This commit is contained in:
1 parent
0b47b5b41e
commit
0d944d39ef
4 files changed
+36
-18
No files matched your search
@@ -159,7 +159,7 @@ class IModule(multiprocessing.Process):
|
||||
if signum:
|
||||
self._ioloop.add_callback_from_signal(self._shutdown)
|
||||
else:
|
||||
self._shutdown()
|
||||
self._ioloop.add_callback(self._shutdown)
|
||||
|
||||
def send_response(self, results):
|
||||
"""
|
||||
@@ -240,6 +240,13 @@ class IModule(multiprocessing.Process):
|
||||
if self._stopping:
|
||||
return
|
||||
|
||||
# handle special request to stop the module
|
||||
# e.g. useful on Windows where the
|
||||
# SIGBREAK signal cound't be propagated
|
||||
if request[0] == b"stop":
|
||||
self.stop()
|
||||
return
|
||||
|
||||
try:
|
||||
request = zmq.utils.jsonapi.loads(request[0])
|
||||
except ValueError:
|
||||
|
||||
@@ -132,9 +132,8 @@ class Dynamips(IModule):
|
||||
|
||||
if not sys.platform.startswith("win32"):
|
||||
self._callback.stop()
|
||||
if self._hypervisor_manager:
|
||||
self._hypervisor_manager.stop_all_hypervisors()
|
||||
|
||||
self.reset()
|
||||
IModule.stop(self, signum) # this will stop the I/O loop
|
||||
|
||||
def _check_hypervisors(self):
|
||||
@@ -175,11 +174,11 @@ class Dynamips(IModule):
|
||||
return instance_dict[device_id]
|
||||
|
||||
@IModule.route("dynamips.reset")
|
||||
def reset(self, request):
|
||||
def reset(self, request=None):
|
||||
"""
|
||||
Resets the module.
|
||||
Resets the module (JSON-RPC notification).
|
||||
|
||||
:param request: JSON request
|
||||
:param request: JSON request (not used)
|
||||
"""
|
||||
|
||||
# stop all Dynamips hypervisors
|
||||
|
||||
@@ -112,11 +112,7 @@ class IOU(IModule):
|
||||
"""
|
||||
|
||||
self._iou_callback.stop()
|
||||
# delete all IOU instances
|
||||
for iou_id in self._iou_instances:
|
||||
iou_instance = self._iou_instances[iou_id]
|
||||
iou_instance.delete()
|
||||
|
||||
self.reset()
|
||||
IModule.stop(self, signum) # this will stop the I/O loop
|
||||
|
||||
def _check_iou_is_alive(self):
|
||||
@@ -161,11 +157,11 @@ class IOU(IModule):
|
||||
return self._iou_instances[iou_id]
|
||||
|
||||
@IModule.route("iou.reset")
|
||||
def reset(self, request):
|
||||
def reset(self, request=None):
|
||||
"""
|
||||
Resets the module.
|
||||
Resets the module (JSON-RPC notification).
|
||||
|
||||
:param request: JSON request
|
||||
:param request: JSON request (not used)
|
||||
"""
|
||||
|
||||
# delete all IOU instances
|
||||
|
||||
Reference in new issue
Block a user