6 Replies Latest reply on Jul 15, 2015 9:10 PM by Yanick Girouard

    BLCLI - Edit path of on object in a BLPackage

      Hi Everyone,


      We are looking for a BLCLI call that will edit the path that an object, inside a BLPackage, gets deployed to.


      The manual way is to open the package, find the file and modify the path on the right hand side. Is there any way to do this same task using the BLCLI?


      It can be as simple as having one folder in a BLPackage and we just need to change where that folder gets deployed.



        • 1. BLCLI - Edit path of on object in a BLPackage
          Sean Berry

          The typical way to do this is to use a parameterized path, and set the path as a property of the BLPackage.

          • 2. BLCLI - Edit path of on object in a BLPackage



            I am aware of using parameters in the path- but I am specifically looking for a way to edit the path of an object with the BLCLI.


            We are creating the packages using BLCLI calls but we need to then be able to modify the path of files/folders inside the package. We are creating the BLPackages by creating a template and then using create package from template. Maybe we could even modify the paths in the template before we run the create package command......


            Any ideas?



            • 3. Re: BLCLI - Edit path of on object in a BLPackage
              Bill Robinson

              I don’t think there is any blcli to do this, I know there have been some threads on this recently.  I think you should get the paths straight in the template.

              1 of 1 people found this helpful
              • 4. Re: BLCLI - Edit path of on object in a BLPackage
                Sean Berry

                I make sure my templates are parameterized before packaging: this nicely bakes the parameterized paths into the BLPackages.  I’d recommend that path to you.

                1 of 1 people found this helpful
                • 5. Re: BLCLI - Edit path of on object in a BLPackage
                  Mike Reider

                  I ran into this issue several times and could never find a good solution (there were some posts about hacking the blpackage.xml and doing sed on the path from there, but its messy), or using a Comp Template which is also messy and creates unnecessary metadata


                  Found this post (for some reason Google finds it but BMC Comms doesnt)

                  Altering the path where a file resource is installed



                  The key is how you are creating the BLPkg, you can edit the path directly from there,


                  heres an example NSH script, it

                  1. it reads a Yaml file that specifies a package name and related properties,
                  2. parses a directory and adds any files it finds into an array
                  3. Then creates an empty blpkg,
                  4. Adds a blpkg property name called TMP_DIR and adds a value, /tmp
                  5. then adds each file to the blpkg it but also changes the path of the file.


                  so in the end, I want all my files in blpkg to have this path






                  the bolded part below is the key to the whole thing,



                  ## Get values from YAML, remove ticks, remove extra spaces

                  PKG_NAME=`grep -v "^#" $YAML | grep ":name" | head -1 | awk -F: '{print $3}' | sed "s/\'//g" | sed 's/ //g'`

                  PROP_NAME=`grep -v "^#" $YAML | grep ":name" | tail -1 | awk -F: '{print $3}' | sed "s/\'//g" | sed 's/ //g'`

                  PROP_VALUE=`grep -v "^#" $YAML | grep ":value" | tail -1 | awk -F: '{print $3}' | sed "s/\'//g" | sed 's/ //g'`

                  PKG_DESC=`grep -v "^#" $YAML | grep ":desc" | head -1 | awk -F: '{print $3}' | sed "s/\'//g" | sed 's/ //g'`


                  ## Add Files into the Depot

                  echo "\n*** Adding files into the Depot"


                  ## create an array with filenames that you want to add into the blpkg

                  FILES_ARRAY=($(ls | grep $PKG_NAME | grep -v .yaml))


                  ## add each file to bladelogic depot

                  for file in ${FILES_ARRAY[@]}; do

                    blcli_execute DepotFile addFileToDepot "$PARENT_DEPOT_FOLDER/${PKG_NAME}-pkg-release" $WORKDIR/$file $file $PKG_NAME



                  ## Create Empty BLPkg

                  echo "\n*** Creating BLPackage. Hoorah!"

                  DATE=`date +%m-%d-%Y-%H-%M`


                  blcli_execute BlPackage createEmptyPackage ${BLPKG_NAME} "$PKG_DESC" $BLPKG_DEPOT_FOLDER_ID

                  blcli_storeenv BLPKG_DBKEY


                  ## Add Property to BLPkg

                  blcli_execute BlPackage addLocalParameter ${BLPKG_NAME} "$PARENT_DEPOT_FOLDER/${PKG_NAME}-pkg-release/blpackages" $PROP_NAME "property from yaml file" Primitive:/String true false "${PROP_VALUE}"



                  ## Add Files into BLPkg

                  for file in ${FILES_ARRAY[@]}; do

                    blcli_execute BlPackage importDepotObjectToPackage "$PARENT_DEPOT_FOLDER/${PKG_NAME}-pkg-release/blpackages" "$BLPKG_NAME" false true false false false "$PARENT_DEPOT_FOLDER/${PKG_NAME}-pkg-release" "$file" DEPOT_FILE_OBJECT "Action,Path" "Add,??$PROP_NAME??/$file" NotRequired NotRequired


                  • 6. Re: BLCLI - Edit path of on object in a BLPackage
                    Yanick Girouard

                    Mike Reider this is Zipkit-worthy ! I can see more than one person who would want to use your trick to create blpackages automatically like that. Kudos for sharing this !