def main()

in tools/service-catalog.py [0:0]


def main():

    # List existing RADLab Modules
    module = list_modules()
    
    sc_path = os.getcwd() + '/radlab-service-catalog'

    # Creating RadLab Service Catalog Package folder
    os.system('mkdir -p ' + sc_path)

    # Pull specific folder from RADLab GitHub Repo
    shutil.copytree(os.path.dirname(os.getcwd()) + '/modules/'+ module, sc_path + '/' + module)

    for filename in os.listdir(sc_path + '/' + module):

        f = os.path.join(sc_path + '/' + module, filename)

        # Remove all non.tf files from the root of the module
        if os.path.isfile(f) and os.path.splitext(f)[1] != ".tf":
            os.remove(f)

    # Zip the module in such a way that .tf files are at the root of the zipped file
    os.system('cd ' + sc_path + '/' + module + '; zip -r ' + module + '.zip *')

    # Move thezip package to the RADLab Service Catalog Folder
    os.system('mv ' + sc_path + '/' + module + '/' + module + '.zip ' + sc_path )

    # Remove the downloaded module
    os.system('rm -r ' + sc_path + '/' + module)

    # Printing path to RADLab's Service Catalog Solution.
    print("Please find the zipped solution here: " + sc_path + '/' + module +'.zip')