def prepare_package(args):
    """Compose required files for murano application package.

    :param args: list of command line arguments
    :returns: absolute path to directory with prepared files
    """
    manifest = generate_manifest(args)

    temp_dir = tempfile.mkdtemp()
    manifest_file = os.path.join(temp_dir, 'manifest.yaml')
    template_file = os.path.join(temp_dir, 'template.yaml')

    if args.resources_dir:
        if not os.path.isdir(args.resources_dir):
            raise exceptions.CommandError(
                "'--resources-dir' parameter should be a directory")
        resource_directory = os.path.join(temp_dir, 'Resources')
        shutil.copytree(args.resources_dir, resource_directory)

    logo_file = os.path.join(temp_dir, 'logo.png')
    if not args.logo:
        shutil.copyfile(muranoclient.get_resource('heat_logo.png'), logo_file)
    else:
        if os.path.isfile(args.logo):
            shutil.copyfile(args.logo, logo_file)

    with open(manifest_file, 'w') as f:
        f.write(yaml.dump(manifest, default_flow_style=False))
    shutil.copyfile(args.template, template_file)

    return temp_dir
Example #2
0
def prepare_package(args):
    """Compose required files for murano application package.

    :param args: list of command line arguments
    :returns: absolute path to directory with prepared files
    """
    manifest = generate_manifest(args)

    temp_dir = tempfile.mkdtemp()
    manifest_file = os.path.join(temp_dir, 'manifest.yaml')
    template_file = os.path.join(temp_dir, 'template.yaml')

    if args.resources_dir:
        if not os.path.isdir(args.resources_dir):
            raise exceptions.CommandError(
                "'--resources-dir' parameter should be a directory")
        resource_directory = os.path.join(temp_dir, 'Resources')
        shutil.copytree(args.resources_dir, resource_directory)

    logo_file = os.path.join(temp_dir, 'logo.png')
    if not args.logo:
        shutil.copyfile(muranoclient.get_resource('heat_logo.png'), logo_file)
    else:
        if os.path.isfile(args.logo):
            shutil.copyfile(args.logo, logo_file)

    with open(manifest_file, 'w') as f:
        f.write(yaml.dump(manifest, default_flow_style=False))
    shutil.copyfile(args.template, template_file)

    return temp_dir
Example #3
0
def prepare_package(args):
    """Prepare for application package

    Prepare all files and directories for that application package.
    Generates manifest file and all required parameters for that.

    :param args: list of command line arguments
    :returns: absolute path to directory with prepared files
    """
    if args.type and args.type not in ['Application', 'Library']:
        raise exceptions.CommandError(
            "--type should be set to 'Application' or 'Library'")

    manifest = generate_manifest(args)
    if args.type == 'Application':
        if not args.ui:
            raise exceptions.CommandError("'--ui' is required parameter")
        if not os.path.exists(args.ui) or not os.path.isfile(args.ui):
            raise exceptions.CommandError(
                "{0} is not a file or doesn`t exist".format(args.ui))

    temp_dir = tempfile.mkdtemp()
    manifest_file = os.path.join(temp_dir, 'manifest.yaml')
    classes_directory = os.path.join(temp_dir, 'Classes')
    resource_directory = os.path.join(temp_dir, 'Resources')

    with open(manifest_file, 'w') as f:
        f.write(yaml.dump(manifest, default_flow_style=False))

    logo_file = os.path.join(temp_dir, 'logo.png')
    if not args.logo or (args.logo and not os.path.isfile(args.logo)):
        shutil.copyfile(muranoclient.get_resource('mpl_logo.png'), logo_file)
    else:
        shutil.copyfile(args.logo, logo_file)

    shutil.copytree(args.classes_dir, classes_directory)
    if args.resources_dir:
        if not os.path.isdir(args.resources_dir):
            raise exceptions.CommandError(
                "'--resources-dir' parameter should be a directory")
        shutil.copytree(args.resources_dir, resource_directory)
    if args.ui:
        ui_directory = os.path.join(temp_dir, 'UI')
        os.mkdir(ui_directory)
        shutil.copyfile(args.ui, os.path.join(ui_directory, 'ui.yaml'))
    return temp_dir
def prepare_package(args):
    """Prepare for application package

    Prepare all files and directories for that application package.
    Generates manifest file and all required parameters for that.

    :param args: list of command line arguments
    :returns: absolute path to directory with prepared files
    """
    if args.type and args.type not in ['Application', 'Library']:
        raise exceptions.CommandError(
            "--type should be set to 'Application' or 'Library'")

    manifest = generate_manifest(args)
    if args.type == 'Application':
        if not args.ui:
            raise exceptions.CommandError("'--ui' is required parameter")
        if not os.path.exists(args.ui) or not os.path.isfile(args.ui):
            raise exceptions.CommandError(
                "{0} is not a file or doesn`t exist".format(args.ui))

    temp_dir = tempfile.mkdtemp()
    manifest_file = os.path.join(temp_dir, 'manifest.yaml')
    classes_directory = os.path.join(temp_dir, 'Classes')
    resource_directory = os.path.join(temp_dir, 'Resources')

    with open(manifest_file, 'w') as f:
        f.write(yaml.dump(manifest, default_flow_style=False))

    logo_file = os.path.join(temp_dir, 'logo.png')
    if not args.logo or(args.logo and not os.path.isfile(args.logo)):
        shutil.copyfile(muranoclient.get_resource('mpl_logo.png'), logo_file)
    else:
        shutil.copyfile(args.logo, logo_file)

    shutil.copytree(args.classes_dir, classes_directory)
    if args.resources_dir:
        if not os.path.isdir(args.resources_dir):
            raise exceptions.CommandError(
                "'--resources-dir' parameter should be a directory")
        shutil.copytree(args.resources_dir, resource_directory)
    if args.ui:
        ui_directory = os.path.join(temp_dir, 'UI')
        os.mkdir(ui_directory)
        shutil.copyfile(args.ui, os.path.join(ui_directory, 'ui.yaml'))
    return temp_dir