1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

IOUCON start when vm start

This commit is contained in:
Julien Duponchelle 2015-02-11 15:57:02 +01:00
parent 986c63f344
commit faa7472670
4 changed files with 17 additions and 9 deletions

View File

@ -46,10 +46,10 @@ class IOUHandler:
iou = IOU.instance() iou = IOU.instance()
vm = yield from iou.create_vm(request.json["name"], vm = yield from iou.create_vm(request.json["name"],
request.match_info["project_id"], request.match_info["project_id"],
request.json.get("vm_id"), request.json.get("vm_id"),
console=request.json.get("console"), console=request.json.get("console"),
) )
vm.iou_path = request.json.get("iou_path", vm.iou_path) vm.iou_path = request.json.get("iou_path", vm.iou_path)
vm.iourc_path = request.json.get("iourc_path", vm.iourc_path) vm.iourc_path = request.json.get("iourc_path", vm.iourc_path)
response.set_status(201) response.set_status(201)

View File

@ -27,12 +27,15 @@ import signal
import re import re
import asyncio import asyncio
import shutil import shutil
import argparse
import threading
from pkg_resources import parse_version from pkg_resources import parse_version
from .iou_error import IOUError from .iou_error import IOUError
from ..adapters.ethernet_adapter import EthernetAdapter from ..adapters.ethernet_adapter import EthernetAdapter
from ..adapters.serial_adapter import SerialAdapter from ..adapters.serial_adapter import SerialAdapter
from ..base_vm import BaseVM from ..base_vm import BaseVM
from .ioucon import start_ioucon
import logging import logging
@ -50,9 +53,12 @@ class IOUVM(BaseVM):
:param project: Project instance :param project: Project instance
:param manager: parent VM Manager :param manager: parent VM Manager
:param console: TCP console port :param console: TCP console port
:params console_host: TCP console host IP
""" """
def __init__(self, name, vm_id, project, manager, console=None): def __init__(self, name, vm_id, project, manager,
console=None,
console_host="0.0.0.0"):
super().__init__(name, vm_id, project, manager) super().__init__(name, vm_id, project, manager)
@ -65,6 +71,7 @@ class IOUVM(BaseVM):
self._iou_path = None self._iou_path = None
self._iourc_path = None self._iourc_path = None
self._ioucon_thread = None self._ioucon_thread = None
self._console_host = console_host
# IOU settings # IOU settings
self._ethernet_adapters = [EthernetAdapter(), EthernetAdapter()] # one adapter = 4 interfaces self._ethernet_adapters = [EthernetAdapter(), EthernetAdapter()] # one adapter = 4 interfaces
@ -292,7 +299,7 @@ class IOUVM(BaseVM):
raise IOUError("could not start IOU {}: {}\n{}".format(self._iou_path, e, iou_stdout)) raise IOUError("could not start IOU {}: {}\n{}".format(self._iou_path, e, iou_stdout))
# start console support # start console support
# self._start_ioucon() self._start_ioucon()
# connections support # connections support
# self._start_iouyap() # self._start_iouyap()

View File

@ -55,7 +55,7 @@ EXIT_ABORT = 2
# Mostly from: # Mostly from:
# https://code.google.com/p/miniboa/source/browse/trunk/miniboa/telnet.py # https://code.google.com/p/miniboa/source/browse/trunk/miniboa/telnet.py
#--[ Telnet Commands ]--------------------------------------------------------- # --[ Telnet Commands ]---------------------------------------------------------
SE = 240 # End of sub-negotiation parameters SE = 240 # End of sub-negotiation parameters
NOP = 241 # No operation NOP = 241 # No operation
DATMK = 242 # Data stream portion of a sync. DATMK = 242 # Data stream portion of a sync.
@ -74,7 +74,7 @@ DONT = 254 # Don't = Demand or confirm option halt
IAC = 255 # Interpret as Command IAC = 255 # Interpret as Command
SEND = 1 # Sub-process negotiation SEND command SEND = 1 # Sub-process negotiation SEND command
IS = 0 # Sub-process negotiation IS command IS = 0 # Sub-process negotiation IS command
#--[ Telnet Options ]---------------------------------------------------------- # --[ Telnet Options ]----------------------------------------------------------
BINARY = 0 # Transmit Binary BINARY = 0 # Transmit Binary
ECHO = 1 # Echo characters back to sender ECHO = 1 # Echo characters back to sender
RECON = 2 # Reconnection RECON = 2 # Reconnection

View File

@ -32,6 +32,7 @@ def fake_iou_bin(tmpdir):
os.chmod(path, stat.S_IREAD | stat.S_IEXEC) os.chmod(path, stat.S_IREAD | stat.S_IEXEC)
return path return path
@pytest.fixture @pytest.fixture
def base_params(tmpdir, fake_iou_bin): def base_params(tmpdir, fake_iou_bin):
"""Return standard parameters""" """Return standard parameters"""
@ -91,7 +92,7 @@ def test_iou_delete(server, vm):
def test_iou_update(server, vm, tmpdir, free_console_port): def test_iou_update(server, vm, tmpdir, free_console_port):
response = server.put("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test", response = server.put("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
"console": free_console_port}) "console": free_console_port})
assert response.status == 200 assert response.status == 200
assert response.json["name"] == "test" assert response.json["name"] == "test"
assert response.json["console"] == free_console_port assert response.json["console"] == free_console_port