6 Replies Latest reply on May 5, 2011 1:23 AM by Eyal NameToUpdate

    Add a folder to the depot using BLCLI

      Is there any way to automate adding a folder to the depot as a BLPackage, or even adding a folder to an existing BLPackage, using BLCLI?

        • 1. Re: Add a folder to the depot using BLCLI
          Bill Robinson

          You want to add a folder from a target server to a blpackage – either new or existing?

          • 2. Re: Add a folder to the depot using BLCLI

            Correct. I want to basically package up an entire directory as a BLPackage so that I can then deploy that directory to other servers.

            • 3. Re: Add a folder to the depot using BLCLI

              I would use a file deploy job in this case. Use the directory as the source.

              • 4. Re: Add a folder to the depot using BLCLI

                Any recommendation on a BLCLI solution for creating and executing a File Depoly Job.

                 

                The BLCLI command:

                 

                FileDeployJob createFileDeployJob

                 

                is coming back with:

                 

                "Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Name space : FileDeployJob has no commands by name : createFileDeployJob"

                • 5. Re: Add a folder to the depot using BLCLI
                  Bill Robinson

                  I wrote a complex command to do this.  put the attached in an xml file named FileDeployJob-PS-Additional.xml and put it in <install dir>/br/xml/cli on the system(s) running the blcli.

                   

                  then run like

                  blcli FileDeployJob createFileDeploy <jobGroup> <jobName> <sourcePath> <destDir> <server>

                   

                  <?xml version="1.0" encoding="UTF-8"?>

                  <!DOCTYPE command_inventory SYSTEM "file://bladelogic.com/dtds/Command-Inventory.dtd">

                  <command_inventory>

                          <name_space name="FileDeployJob">

                                  <complex_command command_id="createFileDeployJob-CREATE-0001" published="yes" release="yes">

                                          <name>createFileDeployJob</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_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>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>

                   

                  1 of 1 people found this helpful
                  • 6. Re: Add a folder to the depot using BLCLI

                    Bill you're awesome!

                     

                    I've looked all over for something like this - the only thing I found was to create a component template, and then use "createPackageFromAsset" to create the package.

                     

                    Based on your change tracking script I made this script:

                    (I replaced the parameters with string to make it simpler)

                     

                    But now that I can use this complex command I'll probably replace my script

                     

                     

                    #!/usr/bin/env jython
                    # vim: syntax=python
                    #
                    # System Jython libraries
                    import sys
                    import os
                    import string as s
                    import getopt
                    import re
                     
                    # BladeLogic class libraries
                    import bladelogic.cli.CLI as blcli
                    # import NSH
                    # import sysexec
                    from com.bladelogic.client import BRProfile
                     
                    #####
                    #
                    # GLOBAL VARIABLES
                    #
                    #####
                    DEBUG=1
                    DEBUG_HI=0
                     
                    ### Global Functions
                    #
                    def printInfo(text):
                            print " -- INFO: " + text
                     
                    def printError(error):
                      print " -- ERROR: "+error
                      # Some error occured - make script fail by concatinating string and int
                      print 'This script failed '+ 1
                     
                    def printDebug(text):
                            if(DEBUG): print " -- DEBUG: "+text
                    def printDebugHigh(text):
                            if(DEBUG_HI): print " -- HIGH DEBUG: "+text
                     
                    def runBlcliCmd(NameSpace,blcliCmd,args):
                            cmd = []
                            cmd.append(NameSpace)
                            cmd.append(blcliCmd)
                            dataType = str(type(args))
                            if dataType.find('list') >= 0:
                                    for arg in args:
                                            cmd.append(str(arg))
                            else:
                                    cmd.append(str(args)) 
                            try:
                                    printInfo('BLCLI ARGS - ' + str(cmd))
                                    blcliResult = jli.run(cmd)
                                    assert blcliResult, "ERROR: Failed executing " + blcliCmd
                            except AssertionError,e:
                                    print e
                     
                            if ( blcliResult.getError() ):
                                    printError (str(blcliResult.error))
                            return blcliResult
                    def main(): 
                    
                            parentFolder = runBlcliCmd('DepotGroup',
                                                       'groupNameToId',
                                                       ['/Deploy/Components']).returnValue
                    
                            newFolder = runBlcliCmd('DepotGroup',
                                                    'createDepotGroup',
                                                    ['Version_2_0_5',parentFolder]).returnValue
                    
                            templateID = runBlcliCmd('Template',
                                                     'getDBKeyByGroupAndName',
                                                   ['/Deploy/Components/New Version Template',
                                                     'Version Update']).returnValue
                    
                            newPackageID = runBlcliCmd('BlPackage',
                                                       'createPackageFromAsset',
                                                       ['Version_2_0_5',
                                                       newFolder,
                                                       'false',
                                                       'false',
                                                       'false',
                                                       'true',
                                                       'false',
                                                       templateID,
                                                       'Source-Repositort-Server',
                                                       'NotRequired',
                                                       'NotRequired']).returnValue
                    
                    # end def main
                    ##
                    ## CALLING THE MAIN METHOD ##
                    ##
                    printInfo('Initializing BLCLI connection.  Standby.')
                     
                    jli = blcli.CLI()
                    jli.connect()
                     
                    printInfo('BLCLI connection established. Processing script.')
                    if (__name__ == '__main__'):
                            main()
                    
                    


                    Thanks,

                    Eyal