Support node without console

Fix #532
This commit is contained in:
Julien Duponchelle 2016-05-18 11:59:25 +02:00
parent d5895c3a47
commit d86cefaaeb
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
5 changed files with 4 additions and 17 deletions

View File

@ -23,7 +23,7 @@ import uuid
class Node:
def __init__(self, project, compute, node_id=None, node_type=None, name=None, console=None, console_type="telnet", properties={}):
def __init__(self, project, compute, node_id=None, node_type=None, name=None, console=None, console_type=None, properties={}):
"""
:param project: Project of the node
:param compute: Compute server where the server will run
@ -155,6 +155,7 @@ class Node:
if self._console:
# console is optional for builtin nodes
data["console"] = self._console
if self._console_type:
data["console_type"] = self._console_type
# None properties are not be send. Because it can mean the emulator doesn't support it

View File

@ -275,11 +275,7 @@ class ProjectHandler:
path = request.match_info["path"]
path = os.path.normpath(path)
<< << << < HEAD: gns3server / handlers / api / compute / project_handler.py
# Raise an error if user try to escape
== == == =
# Raise error if user try to escape
>>>>>> > 1.5: gns3server / handlers / api / project_handler.py
if path[0] == ".":
raise aiohttp.web.HTTPForbidden
path = os.path.join(project.path, path)
@ -432,17 +428,9 @@ class ProjectHandler:
project_id = request.match_info["project_id"]
project = pm.create_project(project_id=project_id)
<<<<<<< HEAD:gns3server/handlers/api/compute/project_handler.py
# We write the content to a temporary location and after we extract it all.
# It could be more optimal to stream this but it is not implemented in Python.
# Spooled means the file is temporary kept in memory until max_size is reached
=======
# We write the content to a temporary location
# and after extract all. It could be more optimal to stream
# this but it's not implemented in Python.
#
# Spooled mean the file is temporary keep in ram until max_size
>>>>>>> 1.5:gns3server/handlers/api/project_handler.py
try:
with tempfile.SpooledTemporaryFile(max_size=10000) as temp:
while True:

View File

@ -111,7 +111,7 @@ NODE_OBJECT_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["serial", "vnc", "telnet"]
"enum": ["serial", "vnc", "telnet", None]
},
"properties": {
"description": "Properties specific to an emulator",

View File

@ -148,7 +148,7 @@ class Documentation(object):
if "enum" in prop:
field_type = "enum"
prop['description'] = "Possible values: {}".format(', '.join(prop['enum']))
prop['description'] = "Possible values: {}".format(', '.join(map(lambda a: a or "null", prop['enum'])))
else:
field_type = prop.get("type", "")

View File

@ -99,7 +99,6 @@ def test_add_node_local(async_run):
})
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id,
'console_type': 'telnet',
'startup_config': 'test.cfg',
'name': 'test'})
assert compute in project._project_created_on_compute
@ -126,7 +125,6 @@ def test_add_node_non_local(async_run):
})
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id,
'console_type': 'telnet',
'startup_config': 'test.cfg',
'name': 'test'})
assert compute in project._project_created_on_compute