Quality Center / ALM Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

Creating Hostgroup with hosts using OTA API

Occasional Collector

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.

1 REPLY
Highlighted
Occasional Collector

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")