Cloudify python script plugin - how to use packages?

185 Views Asked by At

I am trying to run a python script on cloudify and for that I am using the script plugin. Now I've managed to get the script running but it fails when importing the python packages it needs. Is there a way to install those packages in cloudify manager's python environment?. My blueprint looks like this:

tosca_definitions_version: cloudify_dsl_1_3

imports:
    - http://www.getcloudify.org/spec/cloudify/5.0.0/types.yaml

inputs:
    input1:
        description: description1
    input2:
        description: description2
        type: string

node_templates:
    node_name:
        type: cloudify.nodes.SoftwareComponent
        interfaces:
            cloudify.interfaces.lifecycle:
                start:
                    implementation: scripts/python_script.py
                    executor: central_deployment_agent
                    inputs:
                        input1: { get_input: input1 }
                        input2: { get_input: input2 }

the imports I need are at the beggining of python_script.py:

import ssh
import bottle
import paramiko

ssh is a file I wrote in the scripts folder I uploaded to cloudify as part of the blueprint package. Cloudify is not finding ssh and I don't know how to make sure that bottle and paramiko are installed on cloudify

1

There are 1 best solutions below

0
On

You do not need to install anything into the worker environment manually. I assume that you are trying to execute some SSH commands on a remote machine. I would propose the following... Option 1 Use the ready terminal plugin Terminal plugin Here is an example Terminal plugin example

Option 2 Build a wagon archive with all dependencies and upload it to Cloudify Manager as a plugin.

  1. you can use the template Plugin template
  2. populate the plugin code and dependencies in setup.py
  3. build wagon
  4. upload it to the manager

To build a wagon you need to have docker installed:

  1. Build docker from a ready Dockerfile Docker files for Wagon builder . You need to choose OS that matches the one that Cloudify is running. Cloudify 5.1 uses Python 3.6 so centos_7_py3 would be a default option. py2py3 builders will provide Python 2.7 and 3.6 compatible plugins that can work on new and old Cloudify versions.
  2. Run Docker and provide it a directory where the plugin source is - it will build a wgn file It is all described in the README.md Wagon builders readme