mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Raise an error if server flagged as local but should not
If the controller is not started with --local but the server ID is local it's raise an error.
This commit is contained in:
5 files changed
+68
-13
No files matched your search
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2016 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class ControllerError(Exception):
|
||||
def __init__(self, message):
|
||||
super().__init__(message)
|
||||
self._message = message
|
||||
|
||||
def __repr__(self):
|
||||
return self._message
|
||||
|
||||
def __str__(self):
|
||||
return self._message
|
||||
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from ..controller.controller_error import ControllerError
|
||||
from ..config import Config
|
||||
|
||||
|
||||
class ServerError(ControllerError):
|
||||
pass
|
||||
|
||||
|
||||
class Server:
|
||||
"""
|
||||
A GNS3 server.
|
||||
@@ -32,6 +40,11 @@ class Server:
|
||||
# The remote server version
|
||||
self._version = None
|
||||
|
||||
# If the server is local but the server id is local
|
||||
# it's a configuration issue
|
||||
if server_id == "local" and Config.instance().get_section_config("Server")["local"] is False:
|
||||
raise ServerError("The local server is started without --local")
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
@@ -57,7 +70,4 @@ class Server:
|
||||
"version": self._version
|
||||
}
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Server):
|
||||
return False
|
||||
return other._id == self._id
|
||||
|
||||
Reference in new issue
Block a user