Пример #1
0
def do_package_create(mc, args):
    """Create an application package."""
    if args.template and args.classes_dir:
        raise exceptions.CommandError(
            "Provide --template for a HOT-based package, OR"
            " --classes-dir for a MuranoPL-based package")
    if not args.template and not args.classes_dir:
        raise exceptions.CommandError(
            "Provide --template for a HOT-based package, OR at least"
            " --classes-dir for a MuranoPL-based package")
    directory_path = None
    try:
        archive_name = args.output if args.output else None
        if args.template:
            directory_path = hot_package.prepare_package(args)
            if not archive_name:
                archive_name = os.path.basename(args.template)
                archive_name = os.path.splitext(archive_name)[0] + ".zip"
        else:
            directory_path = mpl_package.prepare_package(args)
            if not archive_name:
                archive_name = tempfile.mkstemp(
                    prefix="murano_", dir=os.getcwd())[1] + ".zip"

        _make_archive(archive_name, directory_path)
        print("Application package is available at " +
              os.path.abspath(archive_name))
    finally:
        if directory_path:
            shutil.rmtree(directory_path)
Пример #2
0
def do_package_create(mc, args):
    """Create an application package."""
    if args.template and args.classes_dir:
        raise exceptions.CommandError(
            "Provide --template for a HOT-based package, OR"
            " --classes-dir for a MuranoPL-based package")
    if not args.template and not args.classes_dir:
        raise exceptions.CommandError(
            "Provide --template for a HOT-based package, OR at least"
            " --classes-dir for a MuranoPL-based package")
    directory_path = None
    try:
        archive_name = args.output if args.output else None
        if args.template:
            directory_path = hot_package.prepare_package(args)
            if not archive_name:
                archive_name = os.path.basename(args.template)
                archive_name = os.path.splitext(archive_name)[0] + ".zip"
        else:
            directory_path = mpl_package.prepare_package(args)
            if not archive_name:
                archive_name = tempfile.mkstemp(prefix="murano_",
                                                dir=os.getcwd())[1] + ".zip"

        _make_archive(archive_name, directory_path)
        print("Application package is available at " +
              os.path.abspath(archive_name))
    finally:
        if directory_path:
            shutil.rmtree(directory_path)
Пример #3
0
    def test_prepare_hot_package(self):
        args = TestArgs()
        args.template = TEMPLATE
        args.name = 'test_name'
        args.author = 'TestAuthor'
        args.full_name = 'test.full.name.TestName'
        args.tags = 'test, tag, Heat'
        args.description = 'Test description'
        args.logo = LOGO
        package_dir = hot_package.prepare_package(args)

        prepared_files = ['manifest.yaml', 'logo.png', 'template.yaml']
        self.assertEqual(sorted(os.listdir(package_dir)),
                         sorted(prepared_files))
        shutil.rmtree(package_dir)
Пример #4
0
    def test_prepare_hot_package(self):
        args = TestArgs()
        args.template = TEMPLATE
        args.name = 'test_name'
        args.author = 'TestAuthor'
        args.full_name = 'test.full.name.TestName'
        args.tags = 'test, tag, Heat'
        args.description = 'Test description'
        args.logo = LOGO
        package_dir = hot_package.prepare_package(args)

        prepared_files = ['manifest.yaml', 'logo.png', 'template.yaml']
        self.assertEqual(sorted(prepared_files),
                         sorted(os.listdir(package_dir)))
        shutil.rmtree(package_dir)
Пример #5
0
def prepare_hot_package(filepath):
    
    
    import yaml
    
    decr = ""
    stream = open(filepath, "r")
    docs = yaml.load_all(stream)
    for doc in docs:
        for k,v in doc.items():            
            print k, "->", v
            if k == "description":
                decr = v
    print "\n",
    
    import os
    from muranoclient.v1.package_creator import hot_package    
    
   
    archive_name = os.path.basename(filepath)
    archive_name = os.path.splitext(archive_name)[0]
   
    LOGO = CUSTOM_PACKAGE_DIR+"/custom_package_default_logo.png"    
    args = InitArgs()
    args.template = filepath    
    args.name = str(archive_name)
    args.author = username
    args.full_name = str('io.murano.apps.generated.'+archive_name.title())
    args.tags = ["Heat-generated"]
    args.description = str(decr)
    args.logo = LOGO        
  
    package_dir = hot_package.prepare_package(args)
    print package_dir
    
    ZIP_DIR = CUSTOM_PACKAGE_DIR
    
    
    zip_files(package_dir,ZIP_DIR+"/custom/"+args.full_name)
    
    return ZIP_DIR+"/custom/"+args.full_name+".zip"
    
    
    #murano package-create --template my_hot_template --logo logo.png
    '''
Пример #6
0
    def take_action(self, parsed_args):
        LOG.debug("take_action({0})".format(parsed_args))
        parsed_args.os_username = os.getenv('OS_USERNAME')

        def _make_archive(archive_name, path):
            zip_file = zipfile.ZipFile(archive_name, 'w')
            for root, dirs, files in os.walk(path):
                for f in files:
                    zip_file.write(os.path.join(root, f),
                                   arcname=os.path.join(
                                   os.path.relpath(root, path), f))

        if parsed_args.template and parsed_args.classes_dir:
            raise exc.CommandError(
                "Provide --template for a HOT-based package, OR"
                " --classes-dir for a MuranoPL-based package")
        if not parsed_args.template and not parsed_args.classes_dir:
            raise exc.CommandError(
                "Provide --template for a HOT-based package, OR at least"
                " --classes-dir for a MuranoPL-based package")
        directory_path = None
        try:
            archive_name = parsed_args.output if parsed_args.output else None
            if parsed_args.template:
                directory_path = hot_package.prepare_package(parsed_args)
                if not archive_name:
                    archive_name = os.path.basename(parsed_args.template)
                    archive_name = os.path.splitext(archive_name)[0] + ".zip"
            else:
                directory_path = mpl_package.prepare_package(parsed_args)
                if not archive_name:
                    archive_name = tempfile.mkstemp(
                        prefix="murano_", dir=os.getcwd())[1] + ".zip"

            _make_archive(archive_name, directory_path)
            print("Application package is available at " +
                  os.path.abspath(archive_name))
        finally:
            if directory_path:
                shutil.rmtree(directory_path)