本文整理汇总了Java中com.vmware.vim25.RetrieveResult.getObjects方法的典型用法代码示例。如果您正苦于以下问题:Java RetrieveResult.getObjects方法的具体用法?Java RetrieveResult.getObjects怎么用?Java RetrieveResult.getObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.vim25.RetrieveResult
的用法示例。
在下文中一共展示了RetrieveResult.getObjects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultsToTgtMorefMap
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
private void resultsToTgtMorefMap(RetrieveResult results,
Map<String, ManagedObjectReference> tgtMoref) {
List<ObjectContent> oCont = (results != null) ? results.getObjects() : null;
if (oCont != null) {
for (ObjectContent oc : oCont) {
ManagedObjectReference mr = oc.getObj();
String entityNm = null;
List<DynamicProperty> dps = oc.getPropSet();
if (dps != null) {
for (DynamicProperty dp : dps) {
entityNm = (String) dp.getVal();
}
}
tgtMoref.put(entityNm, mr);
}
}
}
示例2: populate
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
public static String populate(final RetrieveResult rslts,
final Map<String, ManagedObjectReference> tgtMoref) {
String token = null;
if (rslts != null) {
token = rslts.getToken();
for (ObjectContent oc : rslts.getObjects()) {
ManagedObjectReference mr = oc.getObj();
String entityNm = null;
List<DynamicProperty> dps = oc.getPropSet();
if (dps != null) {
for (DynamicProperty dp : dps) {
entityNm = (String) dp.getVal();
}
}
tgtMoref.put(entityNm, mr);
}
}
return token;
}
示例3: populate
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
private static String populate(final RetrieveResult results, final Map<String, ManagedObjectReference> tgtMoref) {
String token = null;
if (results != null) {
token = results.getToken();
for (ObjectContent oc : results.getObjects()) {
ManagedObjectReference mr = oc.getObj();
String entityNm = null;
List<DynamicProperty> dps = oc.getPropSet();
if (dps != null) {
for (DynamicProperty dp : dps) {
entityNm = (String) dp.getVal();
}
}
tgtMoref.put(entityNm, mr);
}
}
return token;
}
示例4: retrievePropertiesAllObjects
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
/**
* Uses the new RetrievePropertiesEx method to emulate the now deprecated
* RetrieveProperties method
*
* @param filterSpecs
* @return list of object content
* @throws RuntimeFaultFaultMsg
* @throws InvalidPropertyFaultMsg
* @throws Exception
*/
private List<ObjectContent> retrievePropertiesAllObjects(
List<PropertyFilterSpec> filterSpecs)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
RetrieveOptions retrieveOptions = new RetrieveOptions();
ManagedObjectReference collector = serviceContent
.getPropertyCollector();
List<ObjectContent> contents = new ArrayList<ObjectContent>();
RetrieveResult results = vimPort.retrievePropertiesEx(collector,
filterSpecs, retrieveOptions);
if (results != null && results.getObjects() != null
&& !results.getObjects().isEmpty()) {
contents.addAll(results.getObjects());
}
String token = null;
if (results != null && results.getToken() != null) {
token = results.getToken();
}
while (token != null && token.length() > 0) {
results = vimPort.continueRetrievePropertiesEx(collector, token);
token = null;
if (results != null) {
token = results.getToken();
if (results.getObjects() != null
&& !results.getObjects().isEmpty()) {
contents.addAll(results.getObjects());
}
}
}
return contents;
}
示例5: retrievePropertiesAllObjects
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
/**
* Uses the new RetrievePropertiesEx method to emulate the now deprecated
* RetrieveProperties method.
*
* @param listpfs
* @return list of object content
* @throws Exception
*/
public static List<ObjectContent> retrievePropertiesAllObjects(
VimPortType vimPort, ManagedObjectReference propCollectorRef,
List<PropertyFilterSpec> listpfs)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
RetrieveOptions propObjectRetrieveOpts = new RetrieveOptions();
List<ObjectContent> listobjcontent = new ArrayList<ObjectContent>();
RetrieveResult rslts = vimPort.retrievePropertiesEx(propCollectorRef,
listpfs, propObjectRetrieveOpts);
if (rslts != null && rslts.getObjects() != null
&& !rslts.getObjects().isEmpty()) {
listobjcontent.addAll(rslts.getObjects());
}
String token = null;
if (rslts != null && rslts.getToken() != null) {
token = rslts.getToken();
}
while (token != null && !token.isEmpty()) {
rslts = vimPort.continueRetrievePropertiesEx(propCollectorRef,
token);
token = null;
if (rslts != null) {
token = rslts.getToken();
if (rslts.getObjects() != null
&& !rslts.getObjects().isEmpty()) {
listobjcontent.addAll(rslts.getObjects());
}
}
}
return listobjcontent;
}
示例6: initClusterHostMap
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
/**
* initClusterHostMap is a self recursive method for generating VM/ESX to Cluster Hash Map.
* In the first iteration it gathers all clusters and in consecutive calls for each cluster it updates Hash Map.
* The logic here is use ComputeResource Entity as a base for gathering all virtual machines and ESX Hosts.
* As part of configurations, GraphiteReceiver invokes this method at regular intervals (configured) and during runtime
* if VM/ESX does not exist in the hash map.
*/
public static boolean initClusterHostMap(String clusterName, ManagedObjectReference rootFolder, ExecutionContext context, Map<String,String> clusterMap){
try {
if(clusterName == null){
clusterMap.clear();
}
VimConnection connection = context.getConnection();
RetrieveResult retrieveResult = getRetrieveResult(clusterName, connection, rootFolder);
while((retrieveResult != null) && (retrieveResult.getObjects() != null) && (retrieveResult.getObjects().size() > 0)){
String token = retrieveResult.getToken();
for(ObjectContent objectContent : retrieveResult.getObjects()){
List<DynamicProperty> dynamicProperties = objectContent.getPropSet();
if(clusterName != null){
String dpsGet = String.valueOf(dynamicProperties.get(0).getVal());
clusterMap.put(dpsGet.replace(" ", "_"), clusterName.replace(" ", "_"));
} else {
initClusterHostMap((String) (dynamicProperties.get(0).getVal()), objectContent.getObj(), context, clusterMap);
}
}
if (token == null) {
return true;
}
retrieveResult = connection.getVimPort().continueRetrievePropertiesEx(connection.getPropertyCollector(), token);
}
return true;
} catch(Exception e){
logger.fatal("Critical Error Detected.");
logger.fatal(e.getLocalizedMessage());
return false;
}
}
示例7: retrievePropertiesAllObjects
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
/**
* Uses the new RetrievePropertiesEx method to emulate the now deprecated
* RetrieveProperties method
*
* @param propertyFilterSpecList
* @return list of object content
* @throws Exception
*/
private static List<ObjectContent> retrievePropertiesAllObjects(ConnectionResources connectionResources,
List<PropertyFilterSpec> propertyFilterSpecList)
throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
VimPortType vimPort = connectionResources.getVimPortType();
ManagedObjectReference serviceInstance = connectionResources.getServiceInstance();
ServiceContent serviceContent = vimPort.retrieveServiceContent(serviceInstance);
ManagedObjectReference propertyCollectorReference = serviceContent.getPropertyCollector();
RetrieveOptions propertyObjectRetrieveOptions = new RetrieveOptions();
List<ObjectContent> objectContentList = new ArrayList<>();
RetrieveResult results = vimPort.retrievePropertiesEx(propertyCollectorReference,
propertyFilterSpecList,
propertyObjectRetrieveOptions);
if (results != null && results.getObjects() != null && !results.getObjects().isEmpty()) {
objectContentList.addAll(results.getObjects());
}
String token = null;
if (results != null && results.getToken() != null) {
token = results.getToken();
}
while (token != null && !token.isEmpty()) {
results = vimPort.continueRetrievePropertiesEx(propertyCollectorReference, token);
token = null;
if (results != null) {
token = results.getToken();
if (results.getObjects() != null && !results.getObjects().isEmpty()) {
objectContentList.addAll(results.getObjects());
}
}
}
return objectContentList;
}
示例8: getFromRetrieveResult
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
private ManagedObjectReference getFromRetrieveResult(final RetrieveResult retrieveResult, final String id) {
for (final ObjectContent oc : retrieveResult.getObjects()) {
if (StringUtilities.equals(id, oc.getObj().getValue())) {
return oc.getObj();
}
}
return null;
}
示例9: vmByVMname
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
/**
* Get the MOR of the Virtual Machine by its name.
*
* @param vmName The name of the Virtual Machine
* @param propCollectorRef
* @return The Managed Object reference for this VM
* @throws RuntimeFaultFaultMsg
* @throws InvalidPropertyFaultMsg
*/
public ManagedObjectReference vmByVMname(
final String vmName, final ManagedObjectReference propCollectorRef
) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
init();
ManagedObjectReference rootFolder = this.serviceContent.getRootFolder();
TraversalSpec tSpec = getVMTraversalSpec();
// Create Property Spec
PropertySpec propertySpec = new PropertySpecBuilder()
.all(Boolean.FALSE)
.pathSet("name")
.type("VirtualMachine");
// Now create Object Spec
ObjectSpec objectSpec = new ObjectSpecBuilder()
.obj(rootFolder)
.skip(Boolean.TRUE)
.selectSet(tSpec);
// Create PropertyFilterSpec using the PropertySpec and ObjectPec
// created above.
PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpecBuilder()
.propSet(propertySpec)
.objectSet(objectSpec);
List<PropertyFilterSpec> listpfs =
new ArrayList<PropertyFilterSpec>(1);
listpfs.add(propertyFilterSpec);
RetrieveOptions options = new RetrieveOptions();
// Query returns a fixed number of results
// if token is returned we can get more results
RetrieveResult retrieveResult =
this.vimPort.retrievePropertiesEx(propCollectorRef, listpfs, options);
String token = null;
do {
token = (retrieveResult != null) ? retrieveResult.getToken() : null;
List<ObjectContent> listobcont =
(retrieveResult != null) ?
retrieveResult.getObjects() : null;
if (listobcont != null) {
for (ObjectContent oc : listobcont) {
ManagedObjectReference mr = oc.getObj();
String vmnm = null;
List<DynamicProperty> dps = oc.getPropSet();
if (dps != null) {
for (DynamicProperty dp : dps) {
vmnm = (String) dp.getVal();
if (vmName.equals(vmnm)) {
return mr;
}
}
}
}
}
if (token != null) {
retrieveResult = this.vimPort.continueRetrievePropertiesEx(propCollectorRef, token);
}
} while (token != null);
return null;
}
示例10: getEntityProps
import com.vmware.vim25.RetrieveResult; //导入方法依赖的package包/类
public static Map<String, Object> getEntityProps(VMwareConnection connection, ManagedObjectReference entityMor, String[] props)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
Map<String, Object> retVal = new HashMap<>();
PropertySpec propertySpec = new PropertySpec();
propertySpec.setAll(Boolean.FALSE);
propertySpec.setType(entityMor.getType());
propertySpec.getPathSet().addAll(Arrays.asList(props));
ObjectSpec objectSpec = new ObjectSpec();
objectSpec.setObj(entityMor);
// Create PropertyFilterSpec using the PropertySpec and ObjectPec created above.
PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();
propertyFilterSpec.getPropSet().add(propertySpec);
propertyFilterSpec.getObjectSet().add(objectSpec);
List<PropertyFilterSpec> propertyFilterSpecs = new ArrayList<>();
propertyFilterSpecs.add(propertyFilterSpec);
RetrieveResult rslts = connection.getVimPortType().retrievePropertiesEx(connection.getServiceContent().getPropertyCollector(),
propertyFilterSpecs, new RetrieveOptions());
List<ObjectContent> listobjcontent = new ArrayList<>();
if (rslts != null && rslts.getObjects() != null && !rslts.getObjects().isEmpty()) {
listobjcontent.addAll(rslts.getObjects());
}
String token = null;
if (rslts != null && rslts.getToken() != null) {
token = rslts.getToken();
}
while (token != null && !token.isEmpty()) {
rslts = connection.getVimPortType().continueRetrievePropertiesEx(connection.getServiceContent().getPropertyCollector(),
token);
token = null;
if (rslts != null) {
token = rslts.getToken();
if (rslts.getObjects() != null && !rslts.getObjects().isEmpty()) {
listobjcontent.addAll(rslts.getObjects());
}
}
}
for (ObjectContent oc : listobjcontent) {
List<DynamicProperty> dps = oc.getPropSet();
if (dps != null) {
for (DynamicProperty dp : dps) {
retVal.put(dp.getName(), dp.getVal());
}
}
}
return retVal;
}