3 from cloudify import ctx
4 from cloudify.exceptions import NonRecoverableError
7 SERVICES_FILE_PARTS_SEPARATOR = '---'
10 def _import_or_install():
14 pip.main(["install", "pyaml"])
17 import cloudify_kubernetes.tasks as kubernetes_plugin
21 "https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/archive/1.2.1rc1.zip"
25 import cloudify_kubernetes.tasks as kubernetes_plugin
27 return yaml, kubernetes_plugin
31 return ctx.node.properties.get('init_pod', None)
34 def _set_deployment_result(key):
35 result = ctx.instance.runtime_properties.pop(key)
36 ctx.instance.runtime_properties['kubernetes'] = result
39 def _do_delete_init_pod(kubernetes_plugin, yaml):
40 ctx.logger.info('Deleting init pod')
41 init_pod_file_path = _retrieve_path()
43 if not init_pod_file_path:
44 raise NonRecoverableError('Init pod file is not defined.')
46 temp_file_path = ctx.download_resource_and_render(
50 with open(temp_file_path) as temp_file:
51 init_pod_file_content = temp_file.read()
52 init_pod_yaml_content = yaml.load(init_pod_file_content)
54 _set_deployment_result('init_pod')
55 kubernetes_plugin.resource_delete(definition=init_pod_yaml_content)
57 ctx.logger.info('Init pod deleted successfully')
60 if __name__ == '__main__':
61 yaml, kubernetes_plugin = _import_or_install()
63 _do_delete_init_pod(kubernetes_plugin, yaml)