mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Rename /controller/servers to /controller/hypervisors
This commit is contained in:
9 files changed
+80
-80
No files matched your search
@@ -20,10 +20,10 @@ from ..config import Config
|
||||
|
||||
|
||||
class Controller:
|
||||
"""The controller manage multiple gns3 servers"""
|
||||
"""The controller manage multiple gns3 hypervisors"""
|
||||
|
||||
def __init__(self):
|
||||
self._servers = {}
|
||||
self._hypervisors = {}
|
||||
|
||||
def isEnabled(self):
|
||||
"""
|
||||
@@ -32,18 +32,18 @@ class Controller:
|
||||
"""
|
||||
return Config.instance().get_section_config("Server").getboolean("controller")
|
||||
|
||||
def addServer(self, server):
|
||||
def addHypervisor(self, hypervisor):
|
||||
"""
|
||||
Add a server to the dictionnary of servers controlled by GNS3
|
||||
Add a server to the dictionnary of hypervisors controlled by GNS3
|
||||
"""
|
||||
self._servers[server.id] = server
|
||||
self._hypervisors[hypervisor.id] = hypervisor
|
||||
|
||||
@property
|
||||
def servers(self):
|
||||
def hypervisors(self):
|
||||
"""
|
||||
:returns: The dictionnary of servers managed by GNS3
|
||||
:returns: The dictionnary of hypervisors managed by GNS3
|
||||
"""
|
||||
return self._servers
|
||||
return self._hypervisors
|
||||
|
||||
@staticmethod
|
||||
def instance():
|
||||
|
||||
@@ -25,50 +25,50 @@ import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ServerError(ControllerError):
|
||||
class HypervisorError(ControllerError):
|
||||
pass
|
||||
|
||||
|
||||
class Server:
|
||||
class Hypervisor:
|
||||
"""
|
||||
A GNS3 server.
|
||||
A GNS3 hypervisor.
|
||||
"""
|
||||
|
||||
def __init__(self, server_id, protocol="http", host="localhost", port=8000, user=None, password=None):
|
||||
log.info("Create server %s", server_id)
|
||||
self._id = server_id
|
||||
def __init__(self, hypervisor_id, protocol="http", host="localhost", port=8000, user=None, password=None):
|
||||
log.info("Create hypervisor %s", hypervisor_id)
|
||||
self._id = hypervisor_id
|
||||
self._protocol = protocol
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._user = user
|
||||
self._password = password
|
||||
self._connected = False
|
||||
# The remote server version
|
||||
# The remote hypervisor version
|
||||
# TODO: For the moment it's fake we return the controller version
|
||||
self._version = __version__
|
||||
|
||||
# If the server is local but the server id is local
|
||||
# If the hypervisor is local but the hypervisor 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")
|
||||
if hypervisor_id == "local" and Config.instance().get_section_config("Hypervisor")["local"] is False:
|
||||
raise HypervisorError("The local hypervisor is started without --local")
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
:returns: Server identifier (string)
|
||||
:returns: Hypervisor identifier (string)
|
||||
"""
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
"""
|
||||
:returns: Server host (string)
|
||||
:returns: Hypervisor host (string)
|
||||
"""
|
||||
return self._host
|
||||
|
||||
def __json__(self):
|
||||
return {
|
||||
"server_id": self._id,
|
||||
"hypervisor_id": self._id,
|
||||
"protocol": self._protocol,
|
||||
"host": self._host,
|
||||
"port": self._port,
|
||||
Reference in new issue
Block a user