From f47a6ffca38b22e55c786ce6df8eff25ab073cfd Mon Sep 17 00:00:00 2001 From: Jaganathan Palanisamy Date: Wed, 27 Jul 2022 13:50:59 +0530 Subject: [PATCH] Derive parameters clean up Removing derive parameters code. Change-Id: I88fb7c66f75ae5571f69af1472bc6e173a4775e8 --- tripleo_common/exception.py | 4 -- tripleo_common/tests/utils/test_parameters.py | 66 ------------------- tripleo_common/utils/parameters.py | 30 --------- 3 files changed, 100 deletions(-) diff --git a/tripleo_common/exception.py b/tripleo_common/exception.py index a86a39c69..f5d392b74 100644 --- a/tripleo_common/exception.py +++ b/tripleo_common/exception.py @@ -101,10 +101,6 @@ class RootDeviceDetectionError(Exception): """Failed to detect the root device""" -class DeriveParamsError(Exception): - """Error while performing a derive parameters operation""" - - class NotFound(Exception): """Resource not found""" diff --git a/tripleo_common/tests/utils/test_parameters.py b/tripleo_common/tests/utils/test_parameters.py index e65aa7a87..488ae0830 100644 --- a/tripleo_common/tests/utils/test_parameters.py +++ b/tripleo_common/tests/utils/test_parameters.py @@ -13,7 +13,6 @@ from unittest import mock -from tripleo_common import exception from tripleo_common.tests import base from tripleo_common.utils import parameters @@ -123,71 +122,6 @@ class ParametersTest(base.TestCase): self.assertEqual(parameters.get_flavor('compute', compute_client), 'compute') - def test_profile_flavor_found(self): - compute_client = mock.MagicMock() - - # Mock for a compute_client.flavors.find result item - flavor = mock.MagicMock() - flavor.id = 1 - flavor.name = 'oooq_compute' - - # Mock result of .get_keys() - flavor_keys = mock.MagicMock() - flavor_keys.get.side_effect = ('compute', ) - - # Connecting the mock instances... - flavor.get_keys.side_effect = (flavor_keys, ) - compute_client.flavors.find.side_effect = (flavor, ) - - # Calling `get_profile_of_flavor` with a 'oooq_compute' flavor - # should return profile 'compute'. - profile = parameters.get_profile_of_flavor('oooq_compute', - compute_client) - self.assertEqual(profile, 'compute') - - def test_profile_flavor_not_found_exception(self): - compute_client = mock.MagicMock() - flavor = (Exception, ) - compute_client.flavors.find.side_effect = flavor - - # Calling `get_profile_of_flavor` with a 'oooq_compute' flavor - # should raises DeriveParamsError exception - self.assertRaises(exception.DeriveParamsError, - parameters.get_profile_of_flavor, - 'oooq_compute', compute_client) - - def test_profile_flavor_not_found(self): - compute_client = mock.MagicMock() - compute_client.flavors.find.return_value = None - - # Calling `get_profile_of_flavor` with a 'oooq_compute' flavor - # should raises DeriveParamsError exception - self.assertRaises(exception.DeriveParamsError, - parameters.get_profile_of_flavor, - 'oooq_compute', compute_client) - - def test_profile_not_found_flavor_found(self): - compute_client = mock.MagicMock() - - # Mock for a compute_client.flavors.find result item - flavor = mock.MagicMock() - flavor.id = 1 - flavor.name = 'oooq_compute' - - # Mock result of .get_keys() - flavor_keys = mock.MagicMock() - flavor_keys.get.side_effect = (exception.DeriveParamsError, ) - - # Connecting the mock instances... - flavor.get_keys.side_effect = (flavor_keys, ) - compute_client.flavors.find.side_effect = (flavor, ) - - # Calling `get_profile_of_flavor` with a 'no_profile' flavor - # should raises DeriveParamsError exception - self.assertRaises(exception.DeriveParamsError, - parameters.get_profile_of_flavor, - 'no_profile', compute_client) - def test_convert_docker_params(self): env = { diff --git a/tripleo_common/utils/parameters.py b/tripleo_common/utils/parameters.py index 4a6cd2182..056d0213e 100644 --- a/tripleo_common/utils/parameters.py +++ b/tripleo_common/utils/parameters.py @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tripleo_common import exception from tripleo_common.utils import nodes @@ -94,35 +93,6 @@ def set_count_and_flavor_params(role, baremetal_client, compute_client): } -def get_profile_of_flavor(flavor_name, compute_client): - """Returns profile name for a given flavor name. - - :param flavor_name: Flavor name - :param compute_client: Compute client object - :raises: exception.DeriveParamsError: Derive parameters error - - :return: profile name - """ - - try: - flavor = compute_client.flavors.find(name=flavor_name) - except Exception as err: - raise exception.DeriveParamsError( - 'Unable to determine flavor for flavor name: ' - '%(flavor_name)s. Error:%(err)s' % {'flavor_name': flavor_name, - 'err': err}) - if flavor: - profile = flavor.get_keys().get('capabilities:profile', '') - if profile: - return profile - raise exception.DeriveParamsError( - 'Unable to determine profile for flavor (flavor name: ' - '%s)' % flavor_name) - raise exception.DeriveParamsError( - 'Unable to determine flavor for flavor name: ' - '%s' % flavor_name) - - def convert_docker_params(stack_env=None): """Convert Docker* params to "Container" varients for compatibility.