Re: Creating Hostgroup with hosts using OTA API (350 Views)
Reply
Occasional Collector
vaishnavi_alm
Posts: 7
Registered: ‎09-01-2011
Message 1 of 2 (363 Views)

Creating Hostgroup with hosts using OTA API

Hi All,

 

Trying to create a  QTP hostgroup with a host by passing the hostgroup name and hostname as parameters.

When I give the host group name and host name as strings it works. When I pass them as variables, it doesn't work.

This is the piece of code:

 

  QCHostGroupName = "HOSTGRP1"
  QCHostName = "LABMACHINE"

  Set TSHostGroupFactory = TDConnection.HostGroupFactory
  Set TSHostGroup = TSHostGroupFactory.AddItem(QCHostGroupName)
  Set thisGroup = TSHostGroupFactory.Item(QCHostGroupName)
  Set TSAddHost = thisGroup.AddHost(QCHostName)

 

Can someone, help, please?

 

Thanks,

Vaishnavi.

Please use plain text.
Occasional Collector
vaishnavi_alm
Posts: 7
Registered: ‎09-01-2011
Message 2 of 2 (350 Views)

Re: Creating Hostgroup with hosts using OTA API

Just to add clarity to the question:

 

This is the piece of code that does not work:

  QCHostGroupName = "HOSTGRP1"
  QCHostName = "LABMACHINE"

  Set TSHostGroupFactory = TDConnection.HostGroupFactory
  Set TSHostGroup = TSHostGroupFactory.AddItem(QCHostGroupName)
  Set thisGroup = TSHostGroupFactory.Item(QCHostGroupName)
  Set TSAddHost = thisGroup.AddHost(QCHostName)

 

This is the piece of code that works:

  Set TSHostGroupFactory = TDConnection.HostGroupFactory
  Set TSHostGroup = TSHostGroupFactory.AddItem("HOSTGRP1")
  Set thisGroup = TSHostGroupFactory.Item("HOSTGRP1")
  Set TSAddHost = thisGroup.AddHost("LABMACHINE") 

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation