本帖最后由 WHW1984 于 2010-11-09 18:13:56 编辑 我看Tivoli的ncm_pdf_api_61.pdf文档,里面的Find and retrieve resources by VTMOS这个例子。
代码如下:
public void findAndRetrieveResourceByVTMOS()
{
ResourceManager rMgr;
ResourceContainerKey containerKey = null;
boolean subrealmsFlag = false;
String vendor = "*";
String type = "*";
String model = "*";
String os = "*";
try
{
rMgr = Connection.getInstance().apiSession.resourceManager();
// set up search criterion based on vendor/type/model/os
// setting a null value is the same as "*"
// for example setVendor(null) means the same as setVendor(*)
VtmosCriterion vtmos = rMgr.dataFactory().newVtmosCriterion();
vtmos.setVendor(vendor);
vtmos.setType(type);
vtmos.setModel(model);
vtmos.setOsVersion(os);
ResourceSearch rs = rMgr.dataFactory().newResourceSearch();
rs.setCriterion(vtmos);
rs.setResourceName(null);
// ArrayList<String> rTypeAL = new ArrayList<String>();
// rTypeAL.add(Resource.RESOURCE_COMMANDSET); // set resource type(s) as needed
// rs.setResourceTypes(rTypeAL);
ResourceContainerDescriptor realmRCD = rMgr.getContainer("root/3k");
if(realmRCD!=null){
containerKey = realmRCD.getKey();
}
rs.setStartingContainer(containerKey);
rs.setSubRealms(subrealmsFlag);
// now do the search
@SuppressWarnings("unchecked")