1 Reply Latest reply on Sep 10, 2012 2:59 PM by Bill Robinson

    Working with Template Based Components (Jython)

      Hi,

       

      I am trying to extract some data collected via a template discovery job and hoping that I can do it without having to run a snapshot job to output the data.  I am not sure if this is possible but any help is appreciated.

       

      Presently I have a template setup with parts pointing to three registry keys and one specific windows service.  What I need to get to is the data that comes from browsing the created component.

       

      The template is looking at the below keys and service

      HKEY_LOCAL_MACHINE\SOFTWARE\Shavlik\Scheduler\Dirname

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_SHAVLIK_SCHEDULER\0000\ClassGUID

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_SHAVLIK_SCHEDULER\0000\Service

      Shavlik Remote Scheduler Service

       

      When I run the discovery job, I have the components available under the template name; When I browse the template and view properties of the "Shavlik Remote Scheduler Service", I get a few properties available (Name, Internal Name, Logon As, Status, etc).  I am looking to extract startup type and status from the service entry and the data property from the ClassGuid entry for starters.

       

      I have attempted to follow some of the discussions that relate but haven't been successful at extracting the part data I am looking for.

       

      I have tried it as a Component and a Template to no avail...

      sNamedObject="NAMED_OBJECT=" + str(dbKey_Component)

      sResult_Component = runBlcliCmd('Component','getFullyResolvedPropertyValue',[sNamedObject,'HKEY_LOCAL_MACHINE\\SOFTWARE\\Shavlik\\Scheduler\\Dirname']).returnValue

      -- or --

      sResult_Component = runBlcliCmd('Template','getFullyResolvedPropertyValue',[TEMPLATE_FOLDER_1,TEMPLATE_NAME_1,'HKEY_LOCAL_MACHINE\\SOFTWARE\\Shavlik\\Scheduler\\Dirname']).returnValue

       

       

      Here is an example of the output of the part names...

      Info Sep 7, 2012 2:36:27 PM DEBUG    sTPart = HKEY_LOCAL_MACHINE\SOFTWARE\Shavlik\Scheduler\Dirname

      Info Sep 7, 2012 2:36:27 PM DEBUG    sTPart = Shavlik Remote Scheduler Service

      Info Sep 7, 2012 2:36:27 PM DEBUG    sTPart = HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_SHAVLIK_SCHEDULER\0000\ClassGUID

      Info Sep 7, 2012 2:36:27 PM DEBUG    sTPart = HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_SHAVLIK_SCHEDULER\0000\Service

       

       

      Here is the base code I am running to get to the point of extracting the part data...

       

      dbKey_Template = runBlcliCmd('Template','getDBKeyByGroupAndName',[TEMPLATE_FOLDER_1,TEMPLATE_NAME_1]).returnValue
      logging.info("Using template " + str(TEMPLATE_FOLDER_1) + "/" + str(TEMPLATE_NAME_1))
      logging.debug("dbKey_Template = " + str(dbKey_Template))
      #
      # Emulate Professional Services Code - Template getServerIdsByTemplateKey (4 lines of code)
      #
      runBlcliCmd('Component','findAllByTemplate',[dbKey_Template])
      runBlcliCmd('Component','getDeviceId',[])
      runBlcliCmd('Utility','setTargetObject',[])
      targetServerIDs_TemplateJob = runBlcliCmd('Utility','listPrint',[]).returnValue
      logging.debug("targetServerIDs_TemplateJob = " + str(targetServerIDs_TemplateJob))

      #
      # Emulate Professional Services Code - Template listAllTemplatePartsByGroupAndName (6 lines of code)
      #
      dbKey_Template = runBlcliCmd('Template','getDBKeyByGroupAndName',[TEMPLATE_FOLDER_1,TEMPLATE_NAME_1]).returnValue
      logging.info("Using template " + str(TEMPLATE_FOLDER_1) + "/" + str(TEMPLATE_NAME_1))
      logging.debug("dbKey_Template = " + str(dbKey_Template))
      runBlcliCmd('Template','getParts',[])
      runBlcliCmd('Utility','setTargetObject',[])
      runBlcliCmd('TemplatePart','getEscapedPath',[])
      runBlcliCmd('Utility','setTargetObject',[])
      targetTemplateParts_Template = runBlcliCmd('Utility','listPrint',[]).returnValue
      logging.debug("targetTemplateParts_Template = " + str(targetTemplateParts_Template))
      for sTPart in targetTemplateParts_Template.split('\n'):
        if sTPart != "":
          logging.debug("sTPart = " + str(sTPart))

      #
      # Get server names for IDs
      #
      iCount = 0
      dbKey_Template = runBlcliCmd('Template','getDBKeyByGroupAndName',[TEMPLATE_FOLDER_1,TEMPLATE_NAME_1]).returnValue
      logging.debug("dbKey_Template = " + str(dbKey_Template))
      for sServer in targetServerIDs_TemplateJob.split('\n'):
        if sServer != "":
          targetServerName_Server = runBlcliCmd('Server','getServerNameById',[sServer]).returnValue
          iCount = iCount + 1
          logging.debug("sServer = " + str(sServer))
          logging.debug("targetServerName_Server = " + str(targetServerName_Server))
          dbKey_Component = runBlcliCmd('Component','getDBKeyByTemplateAndServer',[dbKey_Template,sServer,'0']).returnValue
          logging.debug("dbKey_Component = " + str(dbKey_Component))
          sys.exit(0) # Just one iteration for testing

       

       

       

      Thanks,

       

      Mike E.