GithubHelp home page GithubHelp logo

cloudify-bash-plugin's Introduction

Cloudify Bash Plugin

This plugin allows the execution of bash scripts as part of a node interface opeations.

Usage

built-in bash types

Cloudify offers some built in types, who's lifecycle interface (see Lifecycle Interface) is mapped to execute bash scripts by default. When using these types, a property by the name of 'scrtips' should be part of the node properties, which mapps each interface operation to a sepcific script.

for example:

-   name: http_web_server
    type: cloudify.types.bash.web_server
    properties:
      scripts:            
        configure: scripts/configure.sh
        start: scripts/start.sh
        stop: scripts/stop.sh

This means that the 'configure', 'start' and 'stop' operations will be executed by the 'configure.sh', 'start.sh' and 'stop.sh' scripts. You can of course create you own interface and map any operation to any script.

for a complete example of the usage see Cloudify Hello World

direct operation mapping

You can also specify a script for execution on a specific operation by mapping it directly inside the intefrace declaration.

for example:

types:
  my_new_type:
    derived_from: cloudify.types.base
    interfaces:
        my_new_interface:
            - my_new_operation:
                  mapping: 'bash_runner.tasks.run'
                  properties:
                      script_path: 'scripts/my-new-script.sh'

This means the operation 'my_new_operation' of inteface 'my_new_inteface' for the type 'my_new_type' is mapped to the Bash plugin, with the 'my-new-script.sh' set for execution.

API

Cloudify offers some extra API available to use inside your scripts.

blueprint resource access

You can access blueprint resource inside your script using the function 'download_resource <relative_path_to_resource>', to enable this function add the following line at the beginning of your script:

. ${CLOUDIFY_FILE_SERVER}

for example:

. ${CLOUDIFY_FILE_SERVER}
cfy_download_resource index.html

index.html in this example should be placed in the root of the blueprint folder.

NOTE: This function is implemented using bash 'wget' function. That means you can pass any wget flags as well.

logging

You can log messages from the script by using the 'info <message>' and 'error <message>' functions. to enable these function add the following line at the beginning of your script:

. ${CLOUDIFY_LOGGING}

for example:

cfy_info THIS IS AN INFO PRINT
cfy_error THIS IS AN ERROR PRINT

This messages will be stored in Cloudify's logging mechanism and be viewed as regular logs. As such, they will be displayed in the CLI, as well as the Web interface.

By default, Cloudify will not log the script's system out stream. to enable this type of logging, pass the 'log_all' property as part of the node properties, or in the direct mapping approach. (see above)

cloudify-bash-plugin's People

Contributors

idanmo avatar iliapolo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.