8 Replies Latest reply on Jun 23, 2016 8:05 AM by Sae Park

    export snapshot result

    Sae Park

      Hi,

      I have a need to export snapshot result into csv format through blcli and not having much luck.

      The snapshot is component based and a server could have multiple components, making it very difficult to export the result for me.

      Can somebody point me to the right direction by any chance?

       

      For example, I have a component template called XZY.

      Using local properties, I get something like XYZ [abc] (server1)

      After a snapshot job is done, how do I iterate through each snapshot result and export them to files?

      Thanks!

        • 1. Re: export snapshot result
          Bill Robinson

          #!/bin/nsh

           

          blcli_setoption serviceProfileName defaultProfile

          blcli_setoption roleName BLAdmins

          blcli_connect

           

          #jobGroup="/Workspace/Recommended Scheduled Jobs"

          jobGroup="/Recommended Scheduled Jobs/Inventory"

          jobName="Inventory - Linux"

          date=`date +'%Y%m%d-%H%M%S'`

           

          blcli_execute Util getSystemProperty DatabaseVersion true

          blcli_storeenv bladeVersion

           

          blcli_execute SnapshotJob getDBKeyByGroupAndName "${jobGroup}" "${jobName}"

          blcli_storeenv jobKey

          blcli_execute JobRun findLastRunKeyByJobKey ${jobKey}

          blcli_storeenv jobRunKey

          blcli_execute JobRun jobRunKeyToJobRunId ${jobRunKey}

          blcli_storeenv jobRunId

           

          if [ "${bladeVersion}" = "7.6.0" ]

              then

              blcli_execute LogItem getLogItemsByJobRun ${jobKey} ${jobRunId}

              blcli_execute Utility setTargetObject

              blcli_execute JobLogItem getDeviceId

              blcli_execute Utility setTargetObject

              blcli_execute Utility listPrint

              blcli_storeenv deviceIds

              for deviceId in ${deviceIds}

                  do

                  if [ ${deviceId} != 0 ]

                      then

                      blcli_execute Server findById ${deviceId}

                      blcli_execute Server getName

                      blcli_storeenv serverName

                      srvServers="${serverName} ${srvServers}"

                  fi

              done

              serverList="$(for server in ${srvServers}; do echo ${server}; done | sort -u)"

          else

              blcli_execute JobRun getTargetsForJobRunId ${jobRunId}

              blcli_execute Utility mapPrint

              blcli_storeenv targetMap

              echo "${targetMap}" > $$.out

           

              componentKeys=`grep "^COMPONENT" $$.out | cut -f2 -d= | sed "s/\[//g;s/\]//g" | sed "s/,//g"`

              for componentKey in ${componentKeys}

                      do

                      componentKey=`echo ${componentKey} | sed "s/\(.*\):.*/\1/g"`

                      blcli_execute Component findByDBKey ${componentKey}

                      blcli_execute Component getDeviceId

                      blcli_storeenv serverId

                      blcli_execute Server findById ${serverId}

                      blcli_execute Server getName

                      blcli_storeenv serverName

                      cmpServers=(${serverName} ${cmpServers[@]})

              done

           

              serverKeys=`grep "^SERVER" $$.out | cut -f2 -d= | sed "s/\[//g;s/\]//g" | sed "s/,//g"`

              for serverKey in ${serverKeys}

                      do

                      serverKey=`echo ${serverKey} | sed "s/\(.*\):.*/\1/g"`

                      blcli_execute Server findById ${serverKey}

                      blcli_execute Server getName

                      blcli_storeenv serverName

                      srvServers=(${serverName} ${srvServers[@]})

              done

              serverList=(${cmpServers[@]} ${srvServers[@]})

          fi

           

          for server in ${serverList}

          do

          blcli_execute Utility exportSnapshotRun "${jobGroup}" "${jobName}" ${jobRunId} "" "" ${server} "/tmp/${server}-${jobName}-${date}.csv" CSV

          done

          rm -f $$.out

          • 2. Re: export snapshot result
            Sae Park

            Wow! That was fast! Thank you very much!

            I think it took more time for me to test than for you to come up with the script.

             

            However, I'm getting error messages:

            Command execution failed. com.bladelogic.om.infra.mfw.util.BlException: Found more than one snapshot for job key: DBKey:SJobModelKeyImpl:47753-5-12040908 and job run id : 150903

            • 3. Re: export snapshot result
              Bill Robinson

              yeah - i'd already done this for another customer a while ago

               

              can you run it and echo out the export command that's being run:

              ...

              echo blcli_execute Utility exportSnapshotRun "${jobGroup}" "${jobName}" ${jobRunId} "" "" ${server} "/tmp/${server}-${jobName}-${date}.csv" CSV

              done

               

              ?

              is it not getting the server name?  i'm not sure how you would have multiple snapshots for the same job run per server.

              • 4. Re: export snapshot result
                Sae Park

                Here is what I get:

                blcli_execute Utility exportSnapshotRun /PAYX Release Engineering WLS Admin snapshot 152345   iwn1apw1 /tmp/iwn1apw1-WLS Admin snapshot-20160620-151725.csv CSV

                blcli_execute Utility exportSnapshotRun /PAYX Release Engineering WLS Admin snapshot 152345   iwn1apw1 /tmp/iwn1apw1-WLS Admin snapshot-20160620-151725.csv CSV

                blcli_execute Utility exportSnapshotRun /PAYX Release Engineering WLS Admin snapshot 152345   iwn1apw1 /tmp/iwn1apw1-WLS Admin snapshot-20160620-151725.csv CSV

                blcli_execute Utility exportSnapshotRun /PAYX Release Engineering WLS Admin snapshot 152345   iwn1apw1 /tmp/iwn1apw1-WLS Admin snapshot-20160620-151725.csv CSV

                blcli_execute Utility exportSnapshotRun /PAYX Release Engineering WLS Admin snapshot 152345   iwn1apw1 /tmp/iwn1apw1-WLS Admin snapshot-20160620-151725.csv CSV

                 

                Also, here is the screenshot of the components I'm trying to take a snapshot of.

                component.jpg

                 

                Thanks!

                • 5. Re: export snapshot result
                  Bill Robinson

                  hmm - so i don't see a way to dump the results out when a server has multiple components of the same template.  the export commands expect a single snapshot per server for the template.

                   

                  what do you need to do w/ the data once you get it out ?

                  • 6. Re: export snapshot result
                    Sae Park

                    That's a real bummer.

                     

                    We were trying to integrate BSA with XLR, which is a tool we use for release.

                    As a part of release, we want XLR to kick off snapshot job in BSA and get the result so that XLR can parse the output and stop if there is any status changes.

                    • 7. Re: export snapshot result
                      Bill Robinson

                      Imo this is a defect – you should be able to do the export… can you open a ticket for this ?

                      • 8. Re: export snapshot result
                        Sae Park

                        Sorry for the late response on this.

                        I've opened 00170851 for this.