1 2 Previous Next 22 Replies Latest reply on May 26, 2010 11:10 AM by afurman NameToUpdate

    Creating file deploy job using NSH

      I am working on a NSH job which creates a BladeLogic job tree structure, copies a zip file from a source location to a staging location, unzips it in a staging directory, creates a file deploy job (using the unzipped files) and sets several options associated with the file deploy job.The last remaining challenge is to set the backup type option for the file deploy job. These options are visible in the GUI by accessing the Options tab, and are listed within the ‘Backup Options’ section. We need to programmatically set the ‘Backup’ and/or ‘Save with suffix’ option. The text fields associated with either option are been solutioned. Version being used by us is 7.4.5.9923

        • 1. Re: Creating file deploy job using NSH
          Bill Robinson

          I have a complex command that does this:

           

          <!DOCTYPE command_inventory SYSTEM "file://bladelogic.com/dtds/Command-Inventory.dtd">
          <command_inventory>
                  <name_space name="FileDeployJob">
                          <complex_command command_id="createFileDeployJobWithBackupSuffix-DEFAULT-0001" published="yes" release="yes">
                                  <name>createFileDeployJobWithBackupSuffix</name>
                                  <description/>
                                  <argument_list>
                                          <argument desc="" name="jobGroup">java.lang.String</argument>
                                          <argument desc="" name="jobName">java.lang.String</argument>
                                          <argument desc="" name="sourcePath">java.lang.String</argument>
                                          <argument desc="" name="destDir">java.lang.String</argument>
                                          <argument desc="" name="device">java.lang.String</argument>
                                          <argument desc="" name="backupType">int</argument>
                                          <argument desc="" name="suffix">java.lang.String</argument>
                                  </argument_list>
                                  <commands_to_execute>
                                          <command_invocation>
                                                  <namespace_ref>JobGroup</namespace_ref>
                                                  <name>groupNameToId</name>
                                                  <input>$jobGroup$</input>
                                                  <store_result>
                                                          <name>jobGroupId</name>
                                                  </store_result>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>SourceFile</namespace_ref>
                                                  <name>loadNew</name>
                                                  <input/>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>SourceFile</namespace_ref>
                                                  <name>setSource</name>
                                                  <input>$sourcePath$</input>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>Utility</namespace_ref>
                                                  <name>objectToList</name>
                                                  <input/>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>Utility</namespace_ref>
                                                  <name>setTargetObject</name>
                                                  <input/>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>Utility</namespace_ref>
                                                  <name>storeTargetObject</name>
                                                  <input>sourceList</input>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>Server</namespace_ref>
                                                  <name>getServerDBKeyByName</name>
                                                  <input>$device$</input>
                                                  <store_result>
                                                          <name>serverKey</name>
                                                  </store_result>
                                          </command_invocation>
                                          <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>loadNew</name>
                                                  <input/>
                                          </command_invocation>
                                          <command_invocation>

                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>setName</name>
                                               <input>$jobName$</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>setGroupId</name>
                                                  <input>NAMED_OBJECT=jobGroupId</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>setSourceList</name>
                                                  <input>NAMED_OBJECT=sourceList</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>setDestDir</name>
                                                  <input>$destDir$</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>addSJobDevice</name>
                                                  <input>NAMED_OBJECT=serverKey</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>setJobBackupType</name>
                                                  <input>$backupType$</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>setBackupSuffix</name>
                                                  <input>$suffix$</input>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>Job</namespace_ref>
                                                  <name>create</name>
                                                  <input/>
                                           </command_invocation>
                                           <command_invocation>
                                                  <namespace_ref>FileDeployJob</namespace_ref>
                                                  <name>getDBKey</name>
                                                  <input/>
                                           </command_invocation>
                            </commands_to_execute>
                          </complex_command>
                  </name_space>
          </command_inventory>

           

          put this into a file named "FileDeployJob-PS-Extra.xml" in the <install>/br/xml/cli directory.  And then you can call it like:

           

           

          blcli_execute FileDeployJob createFileDeployJobWithBackupSuffix "/Workspace/Path/To" "NameOfJob" "sourcePath" "destionation" "target" 2 .bak

          • 2. Re: Creating file deploy job using NSH

            Thanks for your prompt response. I have one query.

             

            blcli FileDeployJob createFileDeployJob "$DEPOT_GROUP" "$CHNG_RQST" "$ASSET_PATH" "$DST_PATH" "$TARGET_SERVER" "$BACKUP_NAME"

             

             

            I am using this command to create the file deploy job According to ur reply you are passing the parameters for the suffix and backup. Please tell me how to pass parameter for backup name and backup dir. I think it will solve my prob as I have to create job itself.

            • 3. Re: Creating file deploy job using NSH
              Bill Robinson

              We need to write another command for the backup name and backup dir - I can try that later today

              • 4. Re: Creating file deploy job using NSH

                Hi,

                 

                It will be great if you help me to find the solution. Thanks in advance.

                • 5. Re: Creating file deploy job using NSH
                  Bill Robinson

                  create another xml file - FileDeployJob-PS-Extra-2.xml

                   

                  <!DOCTYPE command_inventory SYSTEM "file://bladelogic.com/dtds/Command-Inventory.dtd">
                  <command_inventory>
                          <name_space name="FileDeployJob">
                                  <complex_command command_id="createFileDeployJobWithBackupDir-DEFAULT-0001" published="yes" release="yes">
                                          <name>createFileDeployJobWithBackupDir</name>
                                          <description/>
                                          <argument_list>
                                                  <argument desc="" name="jobGroup">java.lang.String</argument>
                                                  <argument desc="" name="jobName">java.lang.String</argument>
                                                  <argument desc="" name="sourcePath">java.lang.String</argument>
                                                  <argument desc="" name="destDir">java.lang.String</argument>
                                                  <argument desc="" name="device">java.lang.String</argument>
                                                  <argument desc="" name="backupType">int</argument>
                                                  <argument desc="" name="backupName">java.lang.String</argument>
                                                  <argument desc="" name="backupDir">java.lang.String</argument>
                                          </argument_list>
                                          <commands_to_execute>
                                                  <command_invocation>
                                                          <namespace_ref>JobGroup</namespace_ref>
                                                          <name>groupNameToId</name>
                                                          <input>$jobGroup$</input>
                                                          <store_result>
                                                                  <name>jobGroupId</name>
                                                          </store_result>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>SourceFile</namespace_ref>
                                                          <name>loadNew</name>
                                                          <input/>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>SourceFile</namespace_ref>
                                                          <name>setSource</name>
                                                          <input>$sourcePath$</input>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>Utility</namespace_ref>
                                                          <name>objectToList</name>
                                                          <input/>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>Utility</namespace_ref>
                                                          <name>setTargetObject</name>
                                                          <input/>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>Utility</namespace_ref>
                                                          <name>storeTargetObject</name>
                                                          <input>sourceList</input>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>Server</namespace_ref>
                                                          <name>getServerDBKeyByName</name>
                                                          <input>$device$</input>
                                                          <store_result>
                                                                  <name>serverKey</name>
                                                          </store_result>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>loadNew</name>
                                                          <input/>
                                                  </command_invocation>
                                                  <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setName</name>
                                                       <input>$jobName$</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setGroupId</name>
                                                          <input>NAMED_OBJECT=jobGroupId</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setSourceList</name>
                                                          <input>NAMED_OBJECT=sourceList</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setDestDir</name>
                                                          <input>$destDir$</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>addSJobDevice</name>
                                                          <input>NAMED_OBJECT=serverKey</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setJobBackupType</name>
                                                          <input>$backupType$</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setBackupName</name>
                                                          <input>$backupName$</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>setBackupDir</name>
                                                          <input>$backupDir$</input>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>Job</namespace_ref>
                                                          <name>create</name>
                                                          <input/>
                                                   </command_invocation>
                                                   <command_invocation>
                                                          <namespace_ref>FileDeployJob</namespace_ref>
                                                          <name>getDBKey</name>
                                                          <input/>
                                                   </command_invocation>
                                    </commands_to_execute>
                                  </complex_command>
                          </name_space>
                  </command_inventory>

                   

                  and run it like:

                   

                   

                  blcli_execute FileDeployJob createFileDeployJobWithBackupSuffix "/Workspace/Path/To" "NameOfJob" "sourcePath" "destionation" "target" 3 backupName backupDir

                  1 of 1 people found this helpful
                  • 6. Re: Creating file deploy job using NSH

                    I am checking it and will get back to you.

                    • 7. Re: Creating file deploy job using NSH

                      Bill:

                       

                      I do believe this works.

                       

                      I wish I had realised I just needed to pass the '3' (which I had previously figured out (the value stored by Option 208) and then just the arguments, as part of the initial setCreate....

                       

                      I had been trying to use the setOption directly...

                       

                      For what its worth, option "2" should set the value to 'suffix'.

                       

                      Also, found one error in the XML above, it referenced createFileDeployJobWithBackupSuffix which didn't match the XML name you indicated... getting the xml in sync with the command in the script resolves that error.

                       

                      Thanks much for your help... this is big for us...

                       

                      Larry

                      • 8. Re: Creating file deploy job using NSH
                        Bill Robinson

                        cool. I just needed some time to sit down and do it.

                        • 9. Re: Creating file deploy job using NSH

                          You got plenty of that.

                          • 10. Re: Creating file deploy job using NSH

                            Thanks for the perfect solution.

                            • 11. Re: Creating file deploy job using NSH

                              Anticipating future questions and steps I need to include in my workflow to best utilize this solution, one question below. I'd like to utilize the command we worked through to associate more than one target server to the job. Ideally, I'm pulling a list of targets using

                               

                              blcli_execute Server listServersInGroup "<PATH TO/GROUP>" however this result cannot be passed into the command below as only a single value is expected. Is it a matter of just adding an additional parameter into the XML so we can pass a GRP or SMART GROUP as a parameter instead?

                               

                              COMMAND THAT WORKS FOR A SINGLE TARGET SERVER

                              blcli_execute FileDeployJob createFileDeployJobWithBackupDir "$DEPOT_GROUP" "$CHNG_RQST" "$STG_PATH/$CHNG_RQST" "$DST_PATH" "$TARGET_SERVER" 3 "$BACKUP_NAME" "$BACKUP_DIR"

                              • 12. Re: Creating file deploy job using NSH
                                Bill Robinson

                                I think you can just do a for loop w/ Job.addTargetServer or Job.addTargetServers after the job is created.

                                • 13. Re: Creating file deploy job using NSH

                                  I was already thinking that, but seeing how a SmartGroup can be added as a target in the GUI, I assume the same can be done via CLI. This is, or cour

                                  se, preferable.

                                   

                                  I'll work on the loop and hope someone knows the structure for adding the SmartGroup as a target.

                                  • 14. Re: Creating file deploy job using NSH
                                    Bill Robinson

                                    Job.addTargetGroup

                                     

                                    Not sure if that will work w/ smart groups or not.  best to try it out.

                                    1 2 Previous Next