Add convert_docker_params function
This will be used in workflows to transition from the old Docker* parameters to the new Container* varients. Change-Id: I29d5791acaafa31de15bd58a79302a6b0cb0b7dd
This commit is contained in:
parent
3300af4827
commit
fbb87c541a
@ -187,3 +187,22 @@ class ParametersTest(base.TestCase):
|
||||
self.assertRaises(exception.DeriveParamsError,
|
||||
parameters.get_profile_of_flavor,
|
||||
'no_profile', compute_client)
|
||||
|
||||
def test_convert_docker_params(self):
|
||||
|
||||
env = {
|
||||
'parameter_defaults': {
|
||||
'DockerFooImage': 'bar',
|
||||
'DockerNoOverwriteImage': 'zzzz',
|
||||
'ContainerNoOverwriteImage': 'boom',
|
||||
'ContainerNoChangeImage': 'bar',
|
||||
'DockerNoChangeImage': 'bar',
|
||||
}
|
||||
}
|
||||
|
||||
parameters.convert_docker_params(env)
|
||||
pd = env.get('parameter_defaults', {})
|
||||
self.assertEqual(pd['ContainerFooImage'], 'bar')
|
||||
self.assertEqual(pd['ContainerNoOverwriteImage'], 'boom')
|
||||
self.assertEqual(pd['ContainerNoChangeImage'], 'bar')
|
||||
self.assertEqual(pd['DockerNoChangeImage'], 'bar')
|
||||
|
@ -123,3 +123,18 @@ def get_profile_of_flavor(flavor_name, compute_client):
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
if stack_env:
|
||||
pd = stack_env.get('parameter_defaults', {})
|
||||
for k, v in pd.copy().items():
|
||||
if k.startswith('Docker') and k.endswith('Image'):
|
||||
name = "Container%s" % k[6:]
|
||||
pd.setdefault(name, v)
|
||||
# TODO(dprince) add other Docker* conversions here once
|
||||
# this is wired in
|
||||
|
Loading…
Reference in New Issue
Block a user