diff --git a/.travis.yml b/.travis.yml index 972b3545..2440f1dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: python python: - - "2.7" - "3.3" + - "3.4" install: - "pip install -r requirements.txt --use-mirrors" diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 2ef9c85a..0b4bd4d7 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -302,6 +302,7 @@ class Dynamips(IModule): else: if "project_name" in request: + # for remote server new_working_dir = os.path.join(self._projects_dir, request["project_name"]) if self._projects_dir != self._working_dir != new_working_dir: @@ -321,10 +322,11 @@ class Dynamips(IModule): return elif "working_dir" in request: + # for local server new_working_dir = request.pop("working_dir") - self._hypervisor_manager.working_dir = new_working_dir self._working_dir = new_working_dir + self._hypervisor_manager.working_dir = new_working_dir # apply settings to the hypervisor manager for name, value in request.items(): diff --git a/gns3server/server.py b/gns3server/server.py index 23985218..d468a931 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -160,7 +160,7 @@ class Server(object): except OSError as e: if e.errno == errno.EADDRINUSE: # socket already in use logging.critical("socket in use for {}:{}".format(self._host, self._port)) - self._cleanup() + self._cleanup(graceful=False) ioloop = tornado.ioloop.IOLoop.instance() self._stream = zmqstream.ZMQStream(router, ioloop) @@ -201,7 +201,7 @@ class Server(object): self._router.bind("ipc:///tmp/gns3.ipc") except zmq.error.ZMQError as e: log.critical("Could not start ZeroMQ server on ipc:///tmp/gns3.ipc, reason: {}".format(e)) - self._cleanup() + self._cleanup(graceful=False) raise SystemExit log.info("ZeroMQ server listening to ipc:///tmp/gns3.ipc") else: @@ -209,7 +209,7 @@ class Server(object): self._router.bind("tcp://127.0.0.1:{}".format(self._zmq_port)) except zmq.error.ZMQError as e: log.critical("Could not start ZeroMQ server on 127.0.0.1:{}, reason: {}".format(self._zmq_port, e)) - self._cleanup() + self._cleanup(graceful=False) raise SystemExit log.info("ZeroMQ server listening to 127.0.0.1:{}".format(self._zmq_port)) return self._router @@ -251,25 +251,26 @@ class Server(object): ioloop = tornado.ioloop.IOLoop.instance() ioloop.stop() - def _cleanup(self, signum=None): + def _cleanup(self, signum=None, graceful=True): """ Shutdowns any running module processes and adds a callback to stop the event loop & ZeroMQ :param signum: signal number (if called by a signal handler) + :param graceful: gracefully stop the modules """ # terminate all modules for module in self._modules: - if module.is_alive(): + if module.is_alive() and graceful: log.info("stopping {}".format(module.name)) self.stop_module(module.name) module.join(timeout=3) - if module.is_alive(): - # just kill the module if it is still alive. - log.info("terminating {}".format(module.name)) - module.terminate() - module.join(timeout=1) + if module.is_alive(): + # just kill the module if it is still alive. + log.info("terminating {}".format(module.name)) + module.terminate() + module.join(timeout=1) ioloop = tornado.ioloop.IOLoop.instance() if signum: