Add a way to update ContainerImagePrepare params
Closes-Bug: #1807154 Change-Id: I1e1cd3c2756c1cafe8096dd19cd572887917b853
This commit is contained in:
parent
d6404dd372
commit
0923fca806
|
@ -85,6 +85,7 @@ mistral.actions =
|
||||||
tripleo.config.get_overcloud_config = tripleo_common.actions.config:GetOvercloudConfig
|
tripleo.config.get_overcloud_config = tripleo_common.actions.config:GetOvercloudConfig
|
||||||
tripleo.container_images.prepare = tripleo_common.actions.container_images:PrepareContainerImageEnv
|
tripleo.container_images.prepare = tripleo_common.actions.container_images:PrepareContainerImageEnv
|
||||||
tripleo.container_images.prepare_params = tripleo_common.actions.container_images:PrepareContainerImageParameters
|
tripleo.container_images.prepare_params = tripleo_common.actions.container_images:PrepareContainerImageParameters
|
||||||
|
tripleo.container_images.container_image_prepare_defaults = tripleo_common.actions.container_images:ContainerImagePrepareDefault
|
||||||
tripleo.deployment.config = tripleo_common.actions.deployment:OrchestrationDeployAction
|
tripleo.deployment.config = tripleo_common.actions.deployment:OrchestrationDeployAction
|
||||||
tripleo.deployment.deploy = tripleo_common.actions.deployment:DeployStackAction
|
tripleo.deployment.deploy = tripleo_common.actions.deployment:DeployStackAction
|
||||||
tripleo.deployment.get_deployment_failures = tripleo_common.actions.deployment:DeploymentFailuresAction
|
tripleo.deployment.get_deployment_failures = tripleo_common.actions.deployment:DeploymentFailuresAction
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -165,3 +166,40 @@ class PrepareContainerImageParameters(base.TripleOAction):
|
||||||
update_action = heat_capabilities.UpdateCapabilitiesAction(
|
update_action = heat_capabilities.UpdateCapabilitiesAction(
|
||||||
environments, container=self.container)
|
environments, container=self.container)
|
||||||
return update_action.run(context)
|
return update_action.run(context)
|
||||||
|
|
||||||
|
|
||||||
|
class ContainerImagePrepareDefault(base.TripleOAction):
|
||||||
|
"""ContainerImagePrepare default parameters
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, values):
|
||||||
|
|
||||||
|
super(ContainerImagePrepareDefault, self).__init__()
|
||||||
|
self.values = values
|
||||||
|
|
||||||
|
def run(self, context):
|
||||||
|
cip = copy.deepcopy(kolla_builder.CONTAINER_IMAGE_PREPARE_PARAM)
|
||||||
|
|
||||||
|
for entry in cip:
|
||||||
|
if 'push_destination' in self.values:
|
||||||
|
entry['push_destination'] = self.values['push_destination']
|
||||||
|
|
||||||
|
if 'tag_from_label' in self.values:
|
||||||
|
entry['tag_from_label'] = self.values['tag_from_label']
|
||||||
|
|
||||||
|
if 'namespace' in self.values:
|
||||||
|
entry['set']['namespace'] = self.values['namespace']
|
||||||
|
|
||||||
|
if 'name_prefix' in self.values:
|
||||||
|
entry['set']['name_prefix'] = self.values['name_prefix']
|
||||||
|
|
||||||
|
if 'name_suffix' in self.values:
|
||||||
|
entry['set']['name_suffix'] = self.values['name_suffix']
|
||||||
|
|
||||||
|
if 'tag' in self.values:
|
||||||
|
entry['set']['tag'] = self.values['tag']
|
||||||
|
|
||||||
|
return {
|
||||||
|
'ContainerImagePrepare': cip
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import yaml
|
||||||
|
|
||||||
from mistral_lib import actions
|
from mistral_lib import actions
|
||||||
from tripleo_common.actions import container_images
|
from tripleo_common.actions import container_images
|
||||||
|
from tripleo_common.image import kolla_builder
|
||||||
from tripleo_common.tests import base
|
from tripleo_common.tests import base
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,3 +178,60 @@ class PrepareContainerImageParametersTest(base.TestCase):
|
||||||
'environments/containers-default-parameters.yaml',
|
'environments/containers-default-parameters.yaml',
|
||||||
image_env_contents
|
image_env_contents
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ContainerImagePrepareDefaultTest(base.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ContainerImagePrepareDefaultTest, self).setUp()
|
||||||
|
self.ctx = mock.MagicMock()
|
||||||
|
|
||||||
|
def test_empty(self):
|
||||||
|
action = container_images.ContainerImagePrepareDefault({})
|
||||||
|
result = action.run(self.ctx)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
result['ContainerImagePrepare'],
|
||||||
|
kolla_builder.CONTAINER_IMAGE_PREPARE_PARAM
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_some_values(self):
|
||||||
|
values = {
|
||||||
|
'tag_from_label': 'tag label',
|
||||||
|
'push_destination': True,
|
||||||
|
'namespace': 'namespace',
|
||||||
|
'name_prefix': 'prefix-',
|
||||||
|
'name_suffix': '-suffix',
|
||||||
|
'tag': 'tag'
|
||||||
|
}
|
||||||
|
action = container_images.ContainerImagePrepareDefault(values)
|
||||||
|
result = action.run(self.ctx)
|
||||||
|
|
||||||
|
self.assertTrue('ContainerImagePrepare' in result)
|
||||||
|
self.assertEqual(1, len(result['ContainerImagePrepare']))
|
||||||
|
|
||||||
|
self.assertTrue('tag_from_label' in result['ContainerImagePrepare'][0])
|
||||||
|
self.assertEqual(
|
||||||
|
'tag label',
|
||||||
|
result['ContainerImagePrepare'][0]['tag_from_label']
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'push_destination' in result['ContainerImagePrepare'][0]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
True,
|
||||||
|
result['ContainerImagePrepare'][0]['push_destination']
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue('set' in result['ContainerImagePrepare'][0])
|
||||||
|
self.assertTrue(
|
||||||
|
isinstance(result['ContainerImagePrepare'][0]['set'], dict)
|
||||||
|
)
|
||||||
|
|
||||||
|
s = result['ContainerImagePrepare'][0]['set']
|
||||||
|
|
||||||
|
self.assertEqual(s['namespace'], 'namespace')
|
||||||
|
self.assertEqual(s['name_prefix'], 'prefix-')
|
||||||
|
self.assertEqual(s['name_suffix'], '-suffix')
|
||||||
|
self.assertEqual(s['tag'], 'tag')
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
---
|
||||||
|
version: '2.0'
|
||||||
|
name: tripleo.container_images.v1
|
||||||
|
description: TripleO Container Images Workflows v1
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
container_image_prepare_default:
|
||||||
|
description: >
|
||||||
|
Populate the ContainerImagePrepare parameter
|
||||||
|
|
||||||
|
tags:
|
||||||
|
- tripleo-common-managed
|
||||||
|
|
||||||
|
input:
|
||||||
|
- container
|
||||||
|
- container_image_values: {}
|
||||||
|
- update_parameters: true
|
||||||
|
- queue_name: tripleo
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
format_data:
|
||||||
|
action: tripleo.container_images.container_image_prepare_defaults values=<% $.container_image_values %>
|
||||||
|
publish:
|
||||||
|
status: SUCCESS
|
||||||
|
params: <% task().result %>
|
||||||
|
publish-on-error:
|
||||||
|
status: FAILED
|
||||||
|
message: <% task().result %>
|
||||||
|
on-error: send_message
|
||||||
|
on-success:
|
||||||
|
- update_parameters: <% $.update_parameters %>
|
||||||
|
- send_message: <% not $.update_parameters %>
|
||||||
|
|
||||||
|
update_parameters:
|
||||||
|
action: tripleo.parameters.update
|
||||||
|
input:
|
||||||
|
container: <% $.container %>
|
||||||
|
parameters: <% $.params %>
|
||||||
|
publish-on-error:
|
||||||
|
status: FAILED
|
||||||
|
message: <% task().result %>
|
||||||
|
on-complete: send_message
|
||||||
|
|
||||||
|
send_message:
|
||||||
|
workflow: tripleo.messaging.v1.send
|
||||||
|
input:
|
||||||
|
queue_name: <% $.queue_name %>
|
||||||
|
type: <% execution().name %>
|
||||||
|
status: <% $.status %>
|
||||||
|
execution: <% execution() %>
|
||||||
|
message: <% $.get('message', '') %>
|
Loading…
Reference in New Issue