mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Return a compute name it could be different of compute id
This commit is contained in:
6 files changed
+48
-5
No files matched your search
@@ -38,7 +38,7 @@ class Compute:
|
||||
A GNS3 compute.
|
||||
"""
|
||||
|
||||
def __init__(self, compute_id, controller=None, protocol="http", host="localhost", port=8000, user=None, password=None):
|
||||
def __init__(self, compute_id, controller=None, protocol="http", host="localhost", port=8000, user=None, password=None, name=None):
|
||||
assert controller is not None
|
||||
log.info("Create compute %s", compute_id)
|
||||
self._id = compute_id
|
||||
@@ -52,6 +52,7 @@ class Compute:
|
||||
self._set_auth(user, password)
|
||||
self._session = aiohttp.ClientSession()
|
||||
self._version = None
|
||||
self.name = name
|
||||
|
||||
# If the compute is local but the compute id is local
|
||||
# it's a configuration issue
|
||||
@@ -79,6 +80,22 @@ class Compute:
|
||||
"""
|
||||
return self._version
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
:returns: Compute name
|
||||
"""
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
if name is not None:
|
||||
self._name = name
|
||||
elif self._id == "local":
|
||||
self._name = "local"
|
||||
else:
|
||||
self._name = "{}://{}:{}".format(self._protocol, self._host, self._port)
|
||||
|
||||
@property
|
||||
def connected(self):
|
||||
"""
|
||||
@@ -133,6 +150,7 @@ class Compute:
|
||||
def __json__(self):
|
||||
return {
|
||||
"compute_id": self._id,
|
||||
"name": self._name,
|
||||
"protocol": self._protocol,
|
||||
"host": self._host,
|
||||
"port": self._port,
|
||||
|
||||
@@ -25,6 +25,10 @@ COMPUTE_CREATE_SCHEMA = {
|
||||
"description": "Server identifier",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "Server name",
|
||||
"type": "string"
|
||||
},
|
||||
"protocol": {
|
||||
"description": "Server protocol",
|
||||
"enum": ["http", "https"]
|
||||
@@ -59,6 +63,10 @@ COMPUTE_OBJECT_SCHEMA = {
|
||||
"description": "Server identifier",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "Server name",
|
||||
"type": "string"
|
||||
},
|
||||
"protocol": {
|
||||
"description": "Server protocol",
|
||||
"enum": ["http", "https"]
|
||||
@@ -85,5 +93,5 @@ COMPUTE_OBJECT_SCHEMA = {
|
||||
}
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"required": ["compute_id", "protocol", "host", "port"]
|
||||
"required": ["compute_id", "protocol", "host", "port", "name"]
|
||||
}
|
||||
@@ -29,6 +29,7 @@ in futur GNS3 versions.
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
<th>Connected</th>
|
||||
<th>Protocol</th>
|
||||
@@ -38,6 +39,7 @@ in futur GNS3 versions.
|
||||
{% for compute in controller.computes.values() %}
|
||||
<tr>
|
||||
<td>{{compute.id}}</td>
|
||||
<td>{{compute.name}}</td>
|
||||
<td>{{compute.version}}</td>
|
||||
<td>{{compute.connected}}</td>
|
||||
<td>{{compute.protocol}}</td>
|
||||
|
||||
Reference in new issue
Block a user