mirror of
https://github.com/GNS3/gns3-server
synced 2025-01-13 09:30:54 +00:00
Merge branch '2.2' into 3.0
# Conflicts: # gns3server/compute/iou/iou_vm.py
This commit is contained in:
commit
5e1b8814b6
@ -436,9 +436,9 @@ class IOUVM(BaseNode):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _is_iou_licence_check_enabled(self):
|
def _is_iou_license_check_enabled(self):
|
||||||
"""
|
"""
|
||||||
Returns if IOU licence check is enabled.
|
Returns if IOU license check is enabled.
|
||||||
|
|
||||||
:return: boolean
|
:return: boolean
|
||||||
"""
|
"""
|
||||||
@ -459,7 +459,7 @@ class IOUVM(BaseNode):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def _check_iou_licence(self):
|
async def _check_iou_license(self):
|
||||||
"""
|
"""
|
||||||
Checks for a valid IOU key in the iourc file (paranoid mode).
|
Checks for a valid IOU key in the iourc file (paranoid mode).
|
||||||
"""
|
"""
|
||||||
@ -569,14 +569,13 @@ class IOUVM(BaseNode):
|
|||||||
raise IOUError(f"Could not rename nvram files: {e}")
|
raise IOUError(f"Could not rename nvram files: {e}")
|
||||||
|
|
||||||
iourc_path = None
|
iourc_path = None
|
||||||
if self._is_iou_licence_check_enabled():
|
if self._is_iou_license_check_enabled():
|
||||||
iourc_path = self.iourc_path
|
iourc_path = self.iourc_path
|
||||||
if not iourc_path:
|
if not iourc_path:
|
||||||
raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license")
|
raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license")
|
||||||
if not os.path.isfile(iourc_path):
|
if not os.path.isfile(iourc_path):
|
||||||
raise IOUError(f"The iourc path '{iourc_path}' is not a regular file")
|
raise IOUError(f"The iourc path '{iourc_path}' is not a regular file")
|
||||||
|
await self._check_iou_license()
|
||||||
await self._check_iou_licence()
|
|
||||||
|
|
||||||
await self._start_ubridge()
|
await self._start_ubridge()
|
||||||
self._create_netmap_config()
|
self._create_netmap_config()
|
||||||
|
@ -92,7 +92,7 @@ async def test_start(vm):
|
|||||||
|
|
||||||
mock_process = MagicMock()
|
mock_process = MagicMock()
|
||||||
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
||||||
vm._check_iou_licence = AsyncioMagicMock(return_value=True)
|
vm._check_iou_license = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
||||||
vm._ubridge_send = AsyncioMagicMock()
|
vm._ubridge_send = AsyncioMagicMock()
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ async def test_start(vm):
|
|||||||
assert vm.command_line == ' '.join(mock_exec.call_args[0])
|
assert vm.command_line == ' '.join(mock_exec.call_args[0])
|
||||||
|
|
||||||
assert vm._check_requirements.called
|
assert vm._check_requirements.called
|
||||||
assert vm._check_iou_licence.called
|
assert vm._check_iou_license.called
|
||||||
assert vm._start_ubridge.called
|
assert vm._start_ubridge.called
|
||||||
vm._ubridge_send.assert_any_call("iol_bridge delete IOL-BRIDGE-513")
|
vm._ubridge_send.assert_any_call("iol_bridge delete IOL-BRIDGE-513")
|
||||||
vm._ubridge_send.assert_any_call("iol_bridge create IOL-BRIDGE-513 513")
|
vm._ubridge_send.assert_any_call("iol_bridge create IOL-BRIDGE-513 513")
|
||||||
@ -120,8 +120,8 @@ async def test_start_with_iourc(vm, tmpdir, config):
|
|||||||
mock_process = MagicMock()
|
mock_process = MagicMock()
|
||||||
|
|
||||||
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
||||||
vm._is_iou_licence_check_enabled = AsyncioMagicMock(return_value=True)
|
vm._is_iou_license_check_enabled = AsyncioMagicMock(return_value=True)
|
||||||
vm._check_iou_licence = AsyncioMagicMock(return_value=True)
|
vm._check_iou_license = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ioucon = AsyncioMagicMock(return_value=True)
|
vm._start_ioucon = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
||||||
vm._ubridge_send = AsyncioMagicMock()
|
vm._ubridge_send = AsyncioMagicMock()
|
||||||
@ -158,7 +158,7 @@ async def test_stop(vm):
|
|||||||
|
|
||||||
process = MagicMock()
|
process = MagicMock()
|
||||||
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
||||||
vm._check_iou_licence = AsyncioMagicMock(return_value=True)
|
vm._check_iou_license = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ioucon = AsyncioMagicMock(return_value=True)
|
vm._start_ioucon = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
||||||
vm._ubridge_send = AsyncioMagicMock()
|
vm._ubridge_send = AsyncioMagicMock()
|
||||||
@ -184,7 +184,7 @@ async def test_reload(vm, fake_iou_bin):
|
|||||||
|
|
||||||
process = MagicMock()
|
process = MagicMock()
|
||||||
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
vm._check_requirements = AsyncioMagicMock(return_value=True)
|
||||||
vm._check_iou_licence = AsyncioMagicMock(return_value=True)
|
vm._check_iou_license = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ioucon = AsyncioMagicMock(return_value=True)
|
vm._start_ioucon = AsyncioMagicMock(return_value=True)
|
||||||
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
vm._start_ubridge = AsyncioMagicMock(return_value=True)
|
||||||
vm._ubridge_send = AsyncioMagicMock()
|
vm._ubridge_send = AsyncioMagicMock()
|
||||||
@ -384,42 +384,42 @@ def test_get_legacy_vm_workdir():
|
|||||||
async def test_invalid_iou_file(vm, iourc_file):
|
async def test_invalid_iou_file(vm, iourc_file):
|
||||||
|
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
# Missing ;
|
# Missing ;
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
with open(iourc_file, "w+") as f:
|
with open(iourc_file, "w+") as f:
|
||||||
f.write("[license]\n{} = aaaaaaaaaaaaaaaa".format(hostname))
|
f.write("[license]\n{} = aaaaaaaaaaaaaaaa".format(hostname))
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
# Key too short
|
# Key too short
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
with open(iourc_file, "w+") as f:
|
with open(iourc_file, "w+") as f:
|
||||||
f.write("[license]\n{} = aaaaaaaaaaaaaa;".format(hostname))
|
f.write("[license]\n{} = aaaaaaaaaaaaaa;".format(hostname))
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
# Invalid hostname
|
# Invalid hostname
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
with open(iourc_file, "w+") as f:
|
with open(iourc_file, "w+") as f:
|
||||||
f.write("[license]\nbla = aaaaaaaaaaaaaa;")
|
f.write("[license]\nbla = aaaaaaaaaaaaaa;")
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
# Missing licence section
|
# Missing licence section
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
with open(iourc_file, "w+") as f:
|
with open(iourc_file, "w+") as f:
|
||||||
f.write("[licensetest]\n{} = aaaaaaaaaaaaaaaa;")
|
f.write("[licensetest]\n{} = aaaaaaaaaaaaaaaa;")
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
# Broken config file
|
# Broken config file
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
with open(iourc_file, "w+") as f:
|
with open(iourc_file, "w+") as f:
|
||||||
f.write("[")
|
f.write("[")
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
# Missing file
|
# Missing file
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
os.remove(iourc_file)
|
os.remove(iourc_file)
|
||||||
await vm._check_iou_licence()
|
await vm._check_iou_license()
|
||||||
|
|
||||||
|
|
||||||
def test_iourc_content(vm):
|
def test_iourc_content(vm):
|
||||||
|
Loading…
Reference in New Issue
Block a user