Exemplo n.º 1
0
def compile_blueprint(bp_file):

    user_bp_module = get_blueprint_module_from_file(bp_file)
    UserBlueprint = get_blueprint_class_from_module(user_bp_module)
    if UserBlueprint is None:
        return None

    bp_payload = None
    if isinstance(UserBlueprint, type(SimpleBlueprint)):
        bp_payload = UserBlueprint.make_bp_dict()
    else:
        UserBlueprintPayload, _ = create_blueprint_payload(UserBlueprint)
        bp_payload = UserBlueprintPayload.get_dict()

        # Adding the display map to client attr
        display_name_map = get_dsl_metadata_map()
        bp_payload["spec"]["resources"]["client_attrs"] = {"None": display_name_map}

        # Note - Install/Uninstall runbooks are not actions in Packages.
        # Remove package actions after compiling.
        cdict = bp_payload["spec"]["resources"]
        for package in cdict["package_definition_list"]:
            if "action_list" in package:
                del package["action_list"]

    return bp_payload
Exemplo n.º 2
0
def compile_blueprint(bp_file, no_sync=False):

    # Sync only if no_sync flag is not set
    if not no_sync:
        LOG.info("Syncing cache")
        Cache.sync()

    user_bp_module = get_blueprint_module_from_file(bp_file)
    UserBlueprint = get_blueprint_class_from_module(user_bp_module)
    if UserBlueprint is None:
        return None

    bp_payload = None
    if isinstance(UserBlueprint, type(SimpleBlueprint)):
        bp_payload = UserBlueprint.make_bp_dict()
    else:
        UserBlueprintPayload, _ = create_blueprint_payload(UserBlueprint)
        bp_payload = UserBlueprintPayload.get_dict()

        # Note - Install/Uninstall runbooks are not actions in Packages.
        # Remove package actions after compiling.
        cdict = bp_payload["spec"]["resources"]
        for package in cdict["package_definition_list"]:
            if "action_list" in package:
                del package["action_list"]

    return bp_payload
Exemplo n.º 3
0
def compile_blueprint(bp_file, brownfield_deployment_file=None):

    # Constructing metadata payload
    # Note: This should be constructed before loading bp module. As metadata will be used while getting bp_payload
    metadata_payload = get_metadata_payload(bp_file)

    user_bp_module = get_blueprint_module_from_file(bp_file)
    UserBlueprint = get_blueprint_class_from_module(user_bp_module)
    if UserBlueprint is None:
        return None

    # Fetching bf_deployments
    bf_deployments = get_brownfield_deployment_classes(brownfield_deployment_file)
    if bf_deployments:
        bf_dep_map = {bd.__name__: bd for bd in bf_deployments}
        for pf in UserBlueprint.profiles:
            for ind, dep in enumerate(pf.deployments):
                if dep.__name__ in bf_dep_map:
                    bf_dep = bf_dep_map[dep.__name__]
                    # Add the packages and substrates from deployment
                    bf_dep.packages = dep.packages
                    bf_dep.substrate = dep.substrate

                    # If name attribute not exists in brownfield deployment file and given in blueprint file,
                    # Use the one that is given in blueprint file
                    if dep.name and (not bf_dep.name):
                        bf_dep.name = dep.name

                    # Replacing new deployment in profile.deployments
                    pf.deployments[ind] = bf_dep

    bp_payload = None
    if isinstance(UserBlueprint, type(SimpleBlueprint)):
        bp_payload = UserBlueprint.make_bp_dict()
        if "project_reference" in metadata_payload:
            bp_payload["metadata"]["project_reference"] = metadata_payload[
                "project_reference"
            ]
    else:
        if isinstance(UserBlueprint, type(VmBlueprint)):
            UserBlueprint = UserBlueprint.make_bp_obj()

        UserBlueprintPayload, _ = create_blueprint_payload(
            UserBlueprint, metadata=metadata_payload
        )
        bp_payload = UserBlueprintPayload.get_dict()

        # Adding the display map to client attr
        display_name_map = get_dsl_metadata_map()
        bp_payload["spec"]["resources"]["client_attrs"] = {"None": display_name_map}

        # Note - Install/Uninstall runbooks are not actions in Packages.
        # Remove package actions after compiling.
        cdict = bp_payload["spec"]["resources"]
        for package in cdict["package_definition_list"]:
            if "action_list" in package:
                del package["action_list"]

    return bp_payload
Exemplo n.º 4
0
def compile_blueprint(bp_file, no_sync=False):

    # Sync only if no_sync flag is not set
    if not no_sync:
        Cache.sync()

    user_bp_module = get_blueprint_module_from_file(bp_file)
    UserBlueprint = get_blueprint_class_from_module(user_bp_module)
    if UserBlueprint is None:
        return None

    bp_payload = None
    if isinstance(UserBlueprint, type(SimpleBlueprint)):
        bp_payload = UserBlueprint.make_bp_dict()
    else:
        UserBlueprintPayload, _ = create_blueprint_payload(UserBlueprint)
        bp_payload = UserBlueprintPayload.get_dict()

    return bp_payload