To Retrieve applications on the Hosts

Hi All,

My goal is to retrieve the hosts in my environment using SDK and then print the applications on these hosts.
I was able to successfully get the hosts using the below code:-

Collection hos= confservice.retrieveMultipleObjects(CfgHost.class,
new CfgHostQuery());
System.out.println(hos.size());
for (CfgHost hs : hos)
{
System.out.println(hs.getName());
}
I need reference on the code to fetch applications on these particular hosts. Any reference will help me alot.

Thanks

Hi,

I don’t think there is a specific search you can do to obtain all applications by host.

Probably the best way would be to retrieve all applications and then iterate through each application and find which host it is on.

Hope this helps,

Pete.

Hi Pete,

Thanks for your response!

I found a way to get application by host and it is more or less the way you are suggesting.
Happy to share the code with you/all :-

Collection hos= confservice.retrieveMultipleObjects(CfgHost.class,
new CfgHostQuery());

      for (CfgHost hs : hos)
      {
    	 
    	  Integer dbid = hs.getDBID();
    	  
    	  
    	  CfgApplicationQuery query = new CfgApplicationQuery();
    	  query.setHostDbid(dbid);
    	  
    	  Collection<CfgApplication> app = confservice.retrieveMultipleObjects(CfgApplication.class, query);
    	  for (CfgApplication ap : app)
    	  {
    	       
    	       
    		   System.out.println("AppName" + " " + ap.getName());
    		   
    
    	  }   
    		      
      }