Coverage for plugin/workflows.py : 41%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# ============LICENSE_START==========================================
2# ===================================================================
3# Copyright (c) 2018-2020 AT&T
4# Copyright (c) 2020 Pantheon.tech. All rights reserved.
5#
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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============================================
19from cloudify.decorators import workflow
20from cloudify.workflows import ctx
21from cloudify.exceptions import NonRecoverableError
22import json
23import yaml
24import base64
27@workflow
28def 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(
35 node_instance_id))
37 kwargs = {}
38 kwargs['config'] = ''
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)
52@workflow
53def 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(
59 node_instance_id))
61 kwargs = {}
62 kwargs['revision'] = str(revision)
63 operation_args = {'operation': 'rollback', }
64 operation_args['kwargs'] = kwargs
65 node_instance.execute_operation(**operation_args)
67@workflow
68def status(**kwargs):
70 for node in ctx.nodes:
71 for node_instance in node.instances:
72 kwargs = {}
73 operation_args = {'operation': 'status', }
74 operation_args['kwargs'] = kwargs
75 node_instance.execute_operation(**operation_args)