2 Replies Latest reply on Jun 27, 2012 8:42 PM by Bill Robinson

    capturing the correct component DBkey

      I have found a problem in my scripts where, once multiple components are created against the same template ID and server ID, then I can not see a logical way of selecting the correct component in order to assign more than one property value.

       

      To explain in more detail: So assume an evironment where 1 component exists and is "bound" to an existing server.

      Scripts create a second component from the same template and bound to the same server.

      Once I have created the component I have the correct component DBkey

      push a single setPropertyValue command which the in turn updates the component property value

      run getComponentKeyByTemplateKeyAndServerId to get the updated DBkey but this is where it will fail because there is no way to know the correct index value of the new component.

       

      The only option I can see is to use getAllComponentKeysByTemplateKeyAndServerId and then for each one run componentKeyToName till I know I have the correct component, but seen as there could be 20 components mapped to a single server then this is convoluted. 

       

      Any unreleased?  Any good suggestions?

       

      An extract of the code:

      create_component ()

      {

       

      blcli_execute Template getDBKeyByGroupAndName $InstanceTemplatePath $InstanceTemplateName

      if [ $? != 0 ]

      then

              fatal "\nUnable to find the Component Template :  $err"

       

      fi

      blcli_storeenv INSTANCE_TEMPLATE_ID

       

      blcli_execute Server getServerIdByName $TARGET

      if [ $? != 0 ]

      then

              fatal "\nUnable to find the target Server ID :  $err"

      fi

      blcli_storeenv SERVER_ID

       

      ##########

      #Create the Instance Component

       

      blcli_execute Component createComponent "Instance: ${_ApplicationName}_${_Environment}($TARGET)"  $INSTANCE_TEMPLATE_ID $SERVER_ID

      blcli_storeenv COMPONENT_ID1

       

      blcli_execute Component applyAclTemplate $COMPONENT_ID1${_JBossUser}_ADMIN_DEFAULT false

      blcli_storeenv COMPONENT_ID1

       

      blcli_execute Component setPropertyValue $COMPONENT_ID1 _JBOSS_APPLICATION_NAME${_ApplicationName}

      if [ $? != 0 ]

      then

              fatal "\nUnable to set the Component value _JBOSS_APPLICATION_NAME :  $err"

      fi

      blcli_execute Component getComponentKeyByTemplateKeyAndServerId $INSTANCE_TEMPLATE_ID$SERVER_ID 0

      blcli_storeenv COMPONENT_ID1

      #IT WILL FAIL HERE BECAUSE THE INDEX OF THE COMPONENT I NEED IS NOT 0

      blcli_execute Component setPropertyValue $COMPONENT_ID1 _JBOSS_ENV${_Environment}

      if [ $? != 0 ]

      then

              fatal "\nUnable to set the Component value _JBOSS_ENV :  $err"

      fi

      blcli_execute Component getComponentKeyByTemplateKeyAndServerId $INSTANCE_TEMPLATE_ID$SERVER_ID 0

      blcli_storeenv COMPONENT_ID1

       

      }

        • 1. capturing the correct component DBkey

          FYI I can get it working using

          getAllComponentKeysByTemplateKeyAndServerId and a for loop that compares the name of the component to the component I am looking for.  Not exactly eloquent.

           

          blcli_execute Component getAllComponentKeysByTemplateKeyAndServerId $INSTANCE_TEMPLATE_ID$SERVER_ID

          blcli_storeenv COMPONENTKEYLIST

           

          for KEY in $COMPONENTKEYLIST ; do

                blcli_execute ComponentcomponentKeyToName $KEY

                blcli_storeenv COMPNAME

                if [ "$COMPNAME"="Instance: ${_ApplicationName}_${_Environment}($TARGET)" ]

                then

                      COMPONENT_ID1=$KEY

                break

                fi

          done

          • 2. Re: capturing the correct component DBkey
            Bill Robinson

            So what you want is a command that can find the dbkey by template, server and instance name ?    or something like that?

             

            Would be a good rfe…