1 # ============LICENSE_START==========================================
2 # ===================================================================
3 # Copyright (c) 2018-2020 AT&T
4 # Copyright (c) 2020 Pantheon.tech. All rights reserved.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END============================================
19 from cloudify.decorators import workflow
20 from cloudify.workflows import ctx
21 from cloudify.exceptions import NonRecoverableError
28 def upgrade(node_instance_id, config_set, config, config_url, config_format,
29 chart_version, chart_repo_url, repo_user, repo_user_password, **kwargs):
30 node_instance = ctx.get_node_instance(node_instance_id)
32 if not node_instance_id:
33 raise NonRecoverableError(
34 'No such node_instance_id in deployment: {0}.'.format(
39 kwargs['chart_version'] = str(chart_version)
40 kwargs['chart_repo'] = str(chart_repo_url)
41 kwargs['config_set'] = str(config_set)
42 kwargs['config_json'] = str(config)
43 kwargs['config_url'] = str(config_url)
44 kwargs['config_format'] = str(config_format)
45 kwargs['repo_user'] = str(repo_user)
46 kwargs['repo_user_passwd'] = str(repo_user_password)
47 operation_args = {'operation': 'upgrade', }
48 operation_args['kwargs'] = kwargs
49 node_instance.execute_operation(**operation_args)
53 def rollback(node_instance_id, revision, **kwargs):
54 node_instance = ctx.get_node_instance(node_instance_id)
56 if not node_instance_id:
57 raise NonRecoverableError(
58 'No such node_instance_id in deployment: {0}.'.format(
62 kwargs['revision'] = str(revision)
63 operation_args = {'operation': 'rollback', }
64 operation_args['kwargs'] = kwargs
65 node_instance.execute_operation(**operation_args)
70 for node in ctx.nodes:
71 for node_instance in node.instances:
73 operation_args = {'operation': 'status', }
74 operation_args['kwargs'] = kwargs
75 node_instance.execute_operation(**operation_args)