From bf401c7f7252994c61eaace005f71a850a680477 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Fri, 9 Aug 2024 18:24:01 +0200 Subject: [PATCH] Rename "opal_passphrase" to "opal_admin_passphrase" To make the naming consistent with the other projects. --- blivet/formats/luks.py | 16 ++++++++-------- tests/unit_tests/formats_tests/luks_test.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py index df8ef2bd9..01ff71355 100644 --- a/blivet/formats/luks.py +++ b/blivet/formats/luks.py @@ -102,8 +102,8 @@ def __init__(self, **kwargs): :type luks_sector_size: int :keyword subsystem: LUKS subsystem :type subsystem: str - :keyword opal_passphrase: OPAL admin passphrase - :type opal_passphrase: str + :keyword opal_admin_passphrase: OPAL admin passphrase + :type opal_admin_passphrase: str .. note:: @@ -185,7 +185,7 @@ def __init__(self, **kwargs): if self.luks_sector_size and self.luks_version != "luks2": raise ValueError("Sector size argument is valid only for LUKS version 2.") - self.__opal_passphrase = kwargs.get("opal_passphrase") + self.__opal_admin_passphrase = kwargs.get("opal_admin_passphrase") def __repr__(self): s = DeviceFormat.__repr__(self) @@ -229,11 +229,11 @@ def _set_passphrase(self, passphrase): passphrase = property(fset=_set_passphrase) - def _set_opal_passphrase(self, opal_passphrase): + def _set_opal_admin_passphrase(self, opal_admin_passphrase): """ Set the OPAL admin passphrase for this device. """ - self.__opal_passphrase = opal_passphrase + self.__opal_admin_passphrase = opal_admin_passphrase - opal_passphrase = property(fset=_set_opal_passphrase) + opal_admin_passphrase = property(fset=_set_opal_admin_passphrase) @property def has_key(self): @@ -390,9 +390,9 @@ def _create(self, **kwargs): raise LUKSError("Passphrase or key file must be set for LUKS create") if self.is_opal: - if not self.__opal_passphrase: + if not self.__opal_admin_passphrase: raise LUKSError("OPAL admin passphrase must be specified when creating LUKS HW-OPAL format") - opal_context = blockdev.CryptoKeyslotContext(passphrase=self.__opal_passphrase) + opal_context = blockdev.CryptoKeyslotContext(passphrase=self.__opal_admin_passphrase) try: if self.is_opal: diff --git a/tests/unit_tests/formats_tests/luks_test.py b/tests/unit_tests/formats_tests/luks_test.py index 086c246b2..c8f8dcfec 100644 --- a/tests/unit_tests/formats_tests/luks_test.py +++ b/tests/unit_tests/formats_tests/luks_test.py @@ -139,7 +139,7 @@ def test_luks_opal(self): self.assertTrue(fmt.is_opal) self.assertTrue(fmt.protected) - fmt = LUKS(luks_version="luks2-hw-opal", passphrase="passphrase", opal_passphrase="passphrase") + fmt = LUKS(luks_version="luks2-hw-opal", passphrase="passphrase", opal_admin_passphrase="passphrase") with patch("blivet.devicelibs.crypto.calculate_luks2_max_memory", return_value=None): with patch("blivet.devicelibs.crypto.get_optimal_luks_sector_size", return_value=512): with patch("blivet.devices.lvm.blockdev.crypto") as crypto: @@ -151,7 +151,7 @@ def test_luks_opal(self): self.assertEqual(crypto.opal_format.call_args[1]["cipher"], "aes-xts-plain64") self.assertEqual(crypto.opal_format.call_args[1]["key_size"], 512) - fmt = LUKS(luks_version="luks2-hw-opal-only", passphrase="passphrase", opal_passphrase="passphrase") + fmt = LUKS(luks_version="luks2-hw-opal-only", passphrase="passphrase", opal_admin_passphrase="passphrase") with patch("blivet.devicelibs.crypto.calculate_luks2_max_memory", return_value=None): with patch("blivet.devicelibs.crypto.get_optimal_luks_sector_size", return_value=512): with patch("blivet.devices.lvm.blockdev.crypto") as crypto: