Derive parameters clean up

Removing derive parameters code.

Change-Id: I88fb7c66f75ae5571f69af1472bc6e173a4775e8
This commit is contained in:
Jaganathan Palanisamy 2022-07-27 13:50:59 +05:30
parent 0b83227bdb
commit f47a6ffca3
3 changed files with 0 additions and 100 deletions

View File

@ -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"""

View File

@ -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 <flavor instance>.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 <flavor instance>.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 = {

View File

@ -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.