diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index e638eb50..d8fb2899 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -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 """ @@ -459,7 +459,7 @@ class IOUVM(BaseNode): 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). """ @@ -569,14 +569,13 @@ class IOUVM(BaseNode): raise IOUError(f"Could not rename nvram files: {e}") iourc_path = None - if self._is_iou_licence_check_enabled(): + if self._is_iou_license_check_enabled(): iourc_path = self.iourc_path if not iourc_path: raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license") if not os.path.isfile(iourc_path): raise IOUError(f"The iourc path '{iourc_path}' is not a regular file") - - await self._check_iou_licence() + await self._check_iou_license() await self._start_ubridge() self._create_netmap_config() diff --git a/tests/compute/iou/test_iou_vm.py b/tests/compute/iou/test_iou_vm.py index 7a4c816e..211b8e3c 100644 --- a/tests/compute/iou/test_iou_vm.py +++ b/tests/compute/iou/test_iou_vm.py @@ -92,7 +92,7 @@ async def test_start(vm): mock_process = MagicMock() 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._ubridge_send = AsyncioMagicMock() @@ -104,7 +104,7 @@ async def test_start(vm): assert vm.command_line == ' '.join(mock_exec.call_args[0]) assert vm._check_requirements.called - assert vm._check_iou_licence.called + assert vm._check_iou_license.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 create IOL-BRIDGE-513 513") @@ -120,8 +120,8 @@ async def test_start_with_iourc(vm, tmpdir, config): mock_process = MagicMock() vm._check_requirements = AsyncioMagicMock(return_value=True) - vm._is_iou_licence_check_enabled = AsyncioMagicMock(return_value=True) - vm._check_iou_licence = AsyncioMagicMock(return_value=True) + vm._is_iou_license_check_enabled = AsyncioMagicMock(return_value=True) + vm._check_iou_license = AsyncioMagicMock(return_value=True) vm._start_ioucon = AsyncioMagicMock(return_value=True) vm._start_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -158,7 +158,7 @@ async def test_stop(vm): process = MagicMock() 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_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -184,7 +184,7 @@ async def test_reload(vm, fake_iou_bin): process = MagicMock() 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_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -384,42 +384,42 @@ def test_get_legacy_vm_workdir(): async def test_invalid_iou_file(vm, iourc_file): hostname = socket.gethostname() - await vm._check_iou_licence() + await vm._check_iou_license() # Missing ; with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[license]\n{} = aaaaaaaaaaaaaaaa".format(hostname)) - await vm._check_iou_licence() + await vm._check_iou_license() # Key too short with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[license]\n{} = aaaaaaaaaaaaaa;".format(hostname)) - await vm._check_iou_licence() + await vm._check_iou_license() # Invalid hostname with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[license]\nbla = aaaaaaaaaaaaaa;") - await vm._check_iou_licence() + await vm._check_iou_license() # Missing licence section with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[licensetest]\n{} = aaaaaaaaaaaaaaaa;") - await vm._check_iou_licence() + await vm._check_iou_license() # Broken config file with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[") - await vm._check_iou_licence() + await vm._check_iou_license() # Missing file with pytest.raises(IOUError): os.remove(iourc_file) - await vm._check_iou_licence() + await vm._check_iou_license() def test_iourc_content(vm):