mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 06:21:15 +02:00
iourc_path is set from server settings file
This commit is contained in:
1 parent
0e98497a99
commit
dd1833c4f0
5 files changed
+36
-40
No files matched your search
@@ -65,7 +65,6 @@ class IOUHandler:
|
||||
initial_config=request.json.get("initial_config")
|
||||
)
|
||||
vm.path = request.json.get("path", vm.path)
|
||||
vm.iourc_path = request.json.get("iourc_path", vm.iourc_path)
|
||||
response.set_status(201)
|
||||
response.json(vm)
|
||||
|
||||
@@ -112,7 +111,6 @@ class IOUHandler:
|
||||
vm.name = request.json.get("name", vm.name)
|
||||
vm.console = request.json.get("console", vm.console)
|
||||
vm.path = request.json.get("path", vm.path)
|
||||
vm.iourc_path = request.json.get("iourc_path", vm.iourc_path)
|
||||
vm.ethernet_adapters = request.json.get("ethernet_adapters", vm.ethernet_adapters)
|
||||
vm.serial_adapters = request.json.get("serial_adapters", vm.serial_adapters)
|
||||
vm.ram = request.json.get("ram", vm.ram)
|
||||
|
||||
@@ -86,12 +86,10 @@ class IOUVM(BaseVM):
|
||||
self._iou_stdout_file = ""
|
||||
self._started = False
|
||||
self._path = None
|
||||
self._iourc_path = None
|
||||
self._ioucon_thread = None
|
||||
self._console_host = console_host
|
||||
|
||||
# IOU settings
|
||||
self._iourc = None
|
||||
self._ethernet_adapters = []
|
||||
self._serial_adapters = []
|
||||
self.ethernet_adapters = 2 if ethernet_adapters is None else ethernet_adapters # one adapter = 4 interfaces
|
||||
@@ -154,26 +152,6 @@ class IOUVM(BaseVM):
|
||||
if not os.access(self._path, os.X_OK):
|
||||
raise IOUError("IOU image '{}' is not executable".format(self._path))
|
||||
|
||||
@property
|
||||
def iourc_path(self):
|
||||
"""
|
||||
Returns the path to the iourc file.
|
||||
:returns: path to the iourc file
|
||||
"""
|
||||
|
||||
return self._iourc_path
|
||||
|
||||
@iourc_path.setter
|
||||
def iourc_path(self, path):
|
||||
"""
|
||||
Set path to IOURC file
|
||||
"""
|
||||
|
||||
self._iourc_path = path
|
||||
log.info("IOU {name} [id={id}]: iourc file path set to {path}".format(name=self._name,
|
||||
id=self._id,
|
||||
path=self._iourc_path))
|
||||
|
||||
@property
|
||||
def use_default_iou_values(self):
|
||||
"""
|
||||
@@ -237,6 +215,16 @@ class IOUVM(BaseVM):
|
||||
path = shutil.which("iouyap")
|
||||
return path
|
||||
|
||||
@property
|
||||
def iourc_path(self):
|
||||
"""
|
||||
Returns the IOURC path.
|
||||
|
||||
:returns: path to IOURC
|
||||
"""
|
||||
|
||||
return self._manager.config.get_section_config("IOU").get("iourc_path")
|
||||
|
||||
@property
|
||||
def console(self):
|
||||
"""
|
||||
@@ -362,7 +350,8 @@ class IOUVM(BaseVM):
|
||||
|
||||
self._rename_nvram_file()
|
||||
|
||||
if self._iourc_path and not os.path.isfile(self._iourc_path):
|
||||
iourc_path = self.iourc_path
|
||||
if iourc_path and not os.path.isfile(iourc_path):
|
||||
raise IOUError("A valid iourc file is necessary to start IOU")
|
||||
|
||||
iouyap_path = self.iouyap_path
|
||||
@@ -372,8 +361,9 @@ class IOUVM(BaseVM):
|
||||
self._create_netmap_config()
|
||||
# created a environment variable pointing to the iourc file.
|
||||
env = os.environ.copy()
|
||||
if self._iourc_path:
|
||||
env["IOURC"] = self._iourc_path
|
||||
|
||||
if iourc_path:
|
||||
env["IOURC"] = iourc_path
|
||||
self._command = yield from self._build_command()
|
||||
try:
|
||||
log.info("Starting IOU: {}".format(self._command))
|
||||
@@ -832,7 +822,7 @@ class IOUVM(BaseVM):
|
||||
"""
|
||||
|
||||
env = os.environ.copy()
|
||||
env["IOURC"] = self._iourc
|
||||
env["IOURC"] = self.iourc_path
|
||||
try:
|
||||
output = yield from gns3server.utils.asyncio.subprocess_check_output(self._path, "-h", cwd=self.working_dir, env=env)
|
||||
if re.search("-l\s+Enable Layer 1 keepalive messages", output):
|
||||
|
||||
@@ -46,10 +46,6 @@ IOU_CREATE_SCHEMA = {
|
||||
"description": "Path of iou binary",
|
||||
"type": "string"
|
||||
},
|
||||
"iourc_path": {
|
||||
"description": "Path of iourc",
|
||||
"type": "string"
|
||||
},
|
||||
"serial_adapters": {
|
||||
"description": "How many serial adapters are connected to the IOU",
|
||||
"type": "integer"
|
||||
@@ -99,10 +95,6 @@ IOU_UPDATE_SCHEMA = {
|
||||
"description": "Path of iou binary",
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"iourc_path": {
|
||||
"description": "Path of iourc",
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"serial_adapters": {
|
||||
"description": "How many serial adapters are connected to the IOU",
|
||||
"type": ["integer", "null"]
|
||||
|
||||
Reference in new issue
Block a user