Virtualization Plugins

Expand all | Collapse all

SDK Implement script bash in artifact

Jump to Best Answer
  • 1.  SDK Implement script bash in artifact

    Posted 09-13-2019 05:46:00 AM
    Hi all,

    I generated a script in bash, currently I see the following artifact.json, my goal is to insert the script in the artifact


    My tree is:



    I generated a code implemented in the plugin_runner.py

        script_content = pkgutil.get_data('resources', 'configure.sh')
    
        # Execute script on remote host
        response = libs.run_bash(<connection>, script_content)
    How can I solve the problem?
    Can you give me an example?

    Regards,
    Eugenio Pascuzzi

    ------------------------------
    Eugenio Pascuzzi
    Community Member
    Higher Logic Community Members
    ------------------------------


  • 2.  RE: SDK Implement script bash in artifact
    Best Answer

    Posted 09-13-2019 01:33:00 PM
    Hi Eugenio,

    Thanks for the question. You won't clearly see your Python files nor your bash scripts in the artifact.json file. We've changed how we package the plugin and the fields in the screenshot aren't used in GA.

    Your Python code to read the script looks correct. It looks like you have already seen this, but here is the doc on managing remote scripts. It has examples for reading and executing a script. One piece of the doc I want to call out is:

    "pkgutil.get_data cannot retrieve the contents of a resource that is not in a Python package. This means that a resource that is in the first level of your source directory will not be retrievable with pkgutil. Resources must be in a subdirectory of your source directory, and that subdirectory must contain an __init__.py file."

    Does your resources folder have an __init__.py file in it? The __init__.py file can be empty. 

    - Grant



    ------------------------------
    Grant Magdanz
    Senior Member of Technical Staff II
    Delphix
    ------------------------------



  • 3.  RE: SDK Implement script bash in artifact

    Posted 09-16-2019 03:49:00 AM
    Hi Grant,

    no the resources folder haven't  an __init__.py. 
    Now generate the file py 

    Thanks,
    Eugenio


    ------------------------------
    Eugenio -
    Community Member
    Higher Logic Community Members
    ------------------------------



  • 4.  RE: SDK Implement script bash in artifact

    Posted 09-23-2019 10:43:00 AM
    Hi Eugenio,

    Did adding the __init__.py file to the resources folder fix the problem?

    - Grant

    ------------------------------
    Grant Magdanz
    Senior Member of Technical Staff II
    Delphix
    ------------------------------