Added a warning log to list the deprecated parameters in the plan
Execute a workflow to get the list of deprecated parameters in the plan. Add a warning log to the user just before the deployment to alert the user that a list of parameters are deprecated. And should be removed soon. Change-Id: If496795e44c5b36cb58fcc0221d99d94e098415c
This commit is contained in:
parent
82b501b322
commit
8f1e68d0ab
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Added a warning log with the list of deprecated parameters in the plan.
|
||||
|
@ -411,6 +411,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
clients.tripleoclient.object_store.put_object.assert_called()
|
||||
self.assertTrue(mock_invoke_plan_env_wf.called)
|
||||
|
||||
@mock.patch('tripleoclient.workflows.parameters.'
|
||||
'check_deprecated_parameters', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig', autospec=True)
|
||||
@ -445,7 +447,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
mock_create_tempest_deployer_input,
|
||||
mock_create_parameters_env, mock_validate_args,
|
||||
mock_breakpoints_cleanup, mock_tarball,
|
||||
mock_postconfig, mock_get_overcloud_endpoint):
|
||||
mock_postconfig, mock_get_overcloud_endpoint,
|
||||
mock_deprecated_params):
|
||||
|
||||
arglist = ['--templates', '--skip-deploy-identifier']
|
||||
verifylist = [
|
||||
@ -1286,6 +1289,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
|
||||
mock_validate_args.assert_called_once_with(parsed_args)
|
||||
|
||||
@mock.patch('tripleoclient.workflows.parameters.'
|
||||
'check_deprecated_parameters', autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.deploy_and_wait',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
@ -1302,7 +1307,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
mock_get_template_contents,
|
||||
mock_upload_missing_files,
|
||||
mock_process_and_upload_env,
|
||||
mock_deploy_and_wait):
|
||||
mock_deploy_and_wait,
|
||||
mock_deprecated_params):
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.orchestration
|
||||
mock_stack = fakes.create_tht_stack()
|
||||
@ -1324,6 +1330,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
|
||||
mock_get_template_contents.return_value = [{}, {}]
|
||||
|
||||
self.cmd.clients = {}
|
||||
|
||||
self.cmd._heat_deploy(mock_stack, 'mock_stack', '/tmp', {},
|
||||
{}, 1, '/tmp', {}, True, False, False, None)
|
||||
|
||||
|
@ -21,6 +21,17 @@ from tripleoclient import exceptions
|
||||
from tripleoclient.workflows import parameters
|
||||
|
||||
|
||||
class TestStringCapture(object):
|
||||
def __init__(self):
|
||||
self.capture_string = ''
|
||||
|
||||
def write(self, msg):
|
||||
self.capture_string = self.capture_string + msg
|
||||
|
||||
def getvalue(self):
|
||||
return self.capture_string
|
||||
|
||||
|
||||
class TestParameterWorkflows(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
@ -149,3 +160,63 @@ class TestParameterWorkflows(utils.TestCommand):
|
||||
'the-plan-environment.yaml')
|
||||
|
||||
self.workflow.executions.create.assert_not_called()
|
||||
|
||||
def test_check_deprecated_params_no_output(self):
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "SUCCESS",
|
||||
}])
|
||||
|
||||
parameters.check_deprecated_parameters(
|
||||
self.app.client_manager,
|
||||
container='container-name')
|
||||
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.get_deprecated_parameters',
|
||||
workflow_input={'queue_name': 'UUID4',
|
||||
'container': 'container-name'})
|
||||
|
||||
@mock.patch("sys.stdout", new_callable=TestStringCapture)
|
||||
def test_check_deprecated_params_user_defined(self, mock_print):
|
||||
deprecated_params = [{'parameter': 'TestParameter1',
|
||||
'deprecated': True,
|
||||
'user_defined': True}]
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "SUCCESS",
|
||||
"deprecated": deprecated_params
|
||||
}])
|
||||
|
||||
parameters.check_deprecated_parameters(
|
||||
self.app.client_manager,
|
||||
container='container-name')
|
||||
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.get_deprecated_parameters',
|
||||
workflow_input={'queue_name': 'UUID4',
|
||||
'container': 'container-name'})
|
||||
|
||||
std_output = mock_print.getvalue()
|
||||
self.assertIn('TestParameter1', std_output)
|
||||
|
||||
@mock.patch("sys.stdout", new_callable=TestStringCapture)
|
||||
def test_check_deprecated_params_user_not_defined(self, mock_print):
|
||||
deprecated_params = [{'parameter': 'TestParameter1',
|
||||
'deprecated': True}]
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "SUCCESS",
|
||||
"deprecated": deprecated_params
|
||||
}])
|
||||
|
||||
parameters.check_deprecated_parameters(
|
||||
self.app.client_manager,
|
||||
container='container-name')
|
||||
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.plan_management.v1.get_deprecated_parameters',
|
||||
workflow_input={'queue_name': 'UUID4',
|
||||
'container': 'container-name'})
|
||||
|
||||
std_output = mock_print.getvalue()
|
||||
self.assertNotIn('TestParameter1', std_output)
|
||||
|
@ -225,6 +225,9 @@ class DeployOvercloud(command.Command):
|
||||
workflow_params.invoke_plan_env_workflows(self.clients,
|
||||
stack_name,
|
||||
plan_env_file)
|
||||
|
||||
workflow_params.check_deprecated_parameters(self.clients, stack_name)
|
||||
|
||||
if not update_plan_only:
|
||||
print("Deploying templates in the directory {0}".format(
|
||||
os.path.abspath(tht_root)))
|
||||
|
@ -9,7 +9,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
import yaml
|
||||
|
||||
@ -100,3 +99,37 @@ def invoke_plan_env_workflows(clients, stack_name, plan_env_file):
|
||||
message = payload.get('message', '')
|
||||
msg = ('Workflow execution is failed: %s' % (message))
|
||||
raise exceptions.PlanEnvWorkflowError(msg)
|
||||
|
||||
|
||||
def check_deprecated_parameters(clients, container):
|
||||
"""Checks for deprecated parameters in plan and adds warning if present"""
|
||||
|
||||
workflow_client = clients.workflow_engine
|
||||
tripleoclients = clients.tripleoclient
|
||||
queue_name = str(uuid.uuid4())
|
||||
workflow_input = {
|
||||
'container': container,
|
||||
'queue_name': queue_name
|
||||
}
|
||||
|
||||
with tripleoclients.messaging_websocket(queue_name) as ws:
|
||||
execution = base.start_workflow(
|
||||
workflow_client,
|
||||
'tripleo.plan_management.v1.get_deprecated_parameters',
|
||||
workflow_input=workflow_input
|
||||
)
|
||||
|
||||
messages = base.wait_for_messages(workflow_client, ws, execution, 60)
|
||||
|
||||
deprecated_params = []
|
||||
for message in messages:
|
||||
if message['status'] == 'SUCCESS':
|
||||
for param in message.get('deprecated', []):
|
||||
if param.get('user_defined'):
|
||||
deprecated_params.append(param['parameter'])
|
||||
|
||||
if deprecated_params:
|
||||
print('WARNING: Following parameters are deprecated and still '
|
||||
'defined. Deprecated parameters will be removed soon!')
|
||||
print('\n'.join([' {}'.format(param)
|
||||
for param in deprecated_params]))
|
||||
|
Loading…
Reference in New Issue
Block a user