4 Replies Latest reply on Mar 12, 2018 2:02 AM by Dennis Yeo

    Getting Modified and Created Date of a template component

    Dennis Yeo

      Once i have the component key(s), after running these:

      TEMPLATE_GROUP="/parent/group1"

      TEMPLATE_NAME="template1"

      SERVER="xxxx"

      TEMPLATE_KEY=`blcli Template getDBKeyByGroupAndName "/BL2Atrium Templates" "Bl2Atrium Linux Template"`

      SERVER_ID=`blcli Server getServerIdByName ${SERVER}`

      COMPONENT_KEY_LIST=`blcli Component getAllComponentKeysByTemplateKeyAndServerId $TEMPLATE_KEY $SERVER_ID`

       

      How do i get the Date_Created and Date_Modified of a template component?

       

      I want to know when the component was first created and when it was last modified.

        • 1. Re: Getting Modified and Created Date of a template component
          Bill Robinson

          Template.getDateCreated and Template.getDateModified - both of those are unreleased blcli commands.

          • 2. Re: Getting Modified and Created Date of a template component
            Dennis Yeo

            Both Template.getDateCreated and Template.getDateModified do not need input argument, so do i pass in the component key?

            • 3. Re: Getting Modified and Created Date of a template component
              Bill Robinson

              you need to load the object and then use those to act on it.

               

               

              TEMPLATE_GROUP="/parent/group1"
              TEMPLATE_NAME="template1"
              SERVER="xxxx"
              blcli_execute Template getDBKeyByGroupAndName  "${TEMPLATE_GROUP}" "${TEMPLATE_NAME}"
              blcli_storeenv TEMPLATE_KEY
              blcli_execute Server getServerIdByName ${SERVER}blcli_storeenv SERVER_ID
              blcli_execute Component getAllComponentKeysByTemplateKeyAndServerId ${TEMPLATE_KEY} ${SERVER_ID}
              blcli_storeenv COMPONENT_KEY_LIST
              while read COMPONENT_KEY
                      do
                      blcli_execute Component findByDBKey ${COMPONENT_KEY}
                      blcli_execute Component getName
                      blcli_storeenv COMPONENT_NAME
                      blcli_execute Component getDateCreated
                      blcli_storeenv DATE_CREATED
                      blcli_execute Component getDateModified
                      blcli_storeenv DATE_MODIFIED
                      echo "${COMPONENT_NAME}|${DATE_CREATED}|${DATE_MODIFIED}"
              done <<< "$(awk 'NF' <<< "${COMPONENT_KEY_LIST}")"
              
              • 4. Re: Getting Modified and Created Date of a template component
                Dennis Yeo

                I used this instead:

                 

                TEMPLATE_GROUP="/parent/group1" 

                TEMPLATE_NAME="template1" 

                SERVER="xxxx" 

                blcli_execute Template getDBKeyByGroupAndName  "${TEMPLATE_GROUP}" "${TEMPLATE_NAME}" 

                blcli_storeenv TEMPLATE_KEY

                blcli_execute Server getServerIdByName ${SERVER}

                blcli_storeenv SERVER_ID

                 

                blcli_execute Component getAllComponentKeysByTemplateKeyAndServerId $TEMPLATE_KEY $SERVER_ID

                blcli_storeenv COMPONENTKEYLIST

                for KEY in $COMPONENTKEYLIST ;

                do

                                blcli_execute Component getFullyResolvedPropertyValue $KEY DATE_CREATED

                                blcli_storeenv DC

                                blcli_execute Component getFullyResolvedPropertyValue $KEY DATE_MODIFIED

                                blcli_storeenv DM

                                echo "$SERVER,$DC,$DM" >> compodetails.txt

                done