本文整理汇总了Java中com.vmware.vim25.ObjectContent.getPropSet方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectContent.getPropSet方法的具体用法?Java ObjectContent.getPropSet怎么用?Java ObjectContent.getPropSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.vim25.ObjectContent
的用法示例。
在下文中一共展示了ObjectContent.getPropSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultsToTgtMorefMap
import com.vmware.vim25.ObjectContent; //导入方法依赖的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: inContainerByType
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
/**
* Returns all the MOREFs of the specified type that are present under the
* container
*
* @param container {@link ManagedObjectReference} of the container to begin the
* search from
* @param morefType Type of the managed entity that needs to be searched
* @param morefProperties Array of properties to be fetched for the moref
* @return Map of MOREF and Map of name value pair of properties requested of
* the managed objects present. If none exist then empty Map is
* returned
* @throws InvalidPropertyFaultMsg
* @throws RuntimeFaultFaultMsg
*/
public Map<ManagedObjectReference, Map<String, Object>> inContainerByType(
ManagedObjectReference container, String morefType,
String[] morefProperties, RetrieveOptions retrieveOptions)
throws InvalidPropertyFaultMsg,
RuntimeFaultFaultMsg {
List<ObjectContent> oCont = containerViewByType(container, morefType, retrieveOptions,
morefProperties).getObjects();
Map<ManagedObjectReference, Map<String, Object>> tgtMoref =
new HashMap<ManagedObjectReference, Map<String, Object>>();
if (oCont != null) {
for (ObjectContent oc : oCont) {
Map<String, Object> propMap = new HashMap<String, Object>();
List<DynamicProperty> dps = oc.getPropSet();
if (dps != null) {
for (DynamicProperty dp : dps) {
propMap.put(dp.getName(), dp.getVal());
}
}
tgtMoref.put(oc.getObj(), propMap);
}
}
return tgtMoref;
}
示例3: populate
import com.vmware.vim25.ObjectContent; //导入方法依赖的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;
}
示例4: getCurrentProperty
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
/**
* @param propertyName The property name of current managed object
* @return it will return either an array of related data objects, or an data object itself.
* ManagedObjectReference objects are data objects!!!
* @throws RemoteException
* @throws RuntimeFault
* @throws InvalidProperty
* @
*/
protected Object getCurrentProperty(String propertyName)
{
ObjectContent objContent = retrieveObjectProperties(new String[] { propertyName });
Object propertyValue = null;
if (objContent != null)
{
DynamicProperty[] dynaProps = objContent.getPropSet();
if ((dynaProps != null) && (dynaProps[0]!= null))
{
propertyValue = PropertyCollectorUtil.convertProperty(dynaProps[0].getVal());
}
}
return propertyValue;
}
示例5: getMorHost
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
public ManagedObjectReference getMorHost(String hostname, ConnectionResources connectionResources,
ManagedObjectReference vmMor) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ManagedObjectReference host = null;
if (isNotBlank(hostname)) {
host = getManagedObjectReference(hostname, connectionResources,
ManagedObjectType.HOST_SYSTEM.getValue(), ErrorMessages.HOST_NOT_FOUND);
} else if (StringUtils.isBlank(hostname) && vmMor != null) {
ObjectContent[] objectContents = GetObjectProperties.getObjectProperties(connectionResources, vmMor,
new String[]{ManagedObjectType.SUMMARY.getValue()});
for (ObjectContent objectItem : objectContents) {
List<DynamicProperty> vmProperties = objectItem.getPropSet();
for (DynamicProperty propertyItem : vmProperties) {
VirtualMachineSummary virtualMachineSummary = (VirtualMachineSummary) propertyItem.getVal();
host = virtualMachineSummary.getRuntime().getHost();
break;
}
break;
}
} else {
host = connectionResources.getHostMor();
}
return host;
}
示例6: entityProps
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
/**
* Method to retrieve properties of a {@link ManagedObjectReference}
*
* @param entityMor {@link ManagedObjectReference} of the entity
* @param props Array of properties to be looked up
* @return Map of the property name and its corresponding value
* @throws InvalidPropertyFaultMsg If a property does not exist
* @throws RuntimeFaultFaultMsg
*/
public Map<String, Object> entityProps(ManagedObjectReference entityMor, String[] props)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
final HashMap<String, Object> retVal = new HashMap<>();
// Create PropertyFilterSpec using the PropertySpec and ObjectPec
PropertyFilterSpec[] propertyFilterSpecs = {new PropertyFilterSpecBuilder().propSet(
// Create Property Spec
new PropertySpecBuilder().all(false).type(entityMor.getType()).pathSet(props))
.objectSet(
// Now create Object Spec
new ObjectSpecBuilder().obj(entityMor))};
List<ObjectContent> objCont = vimPort.retrievePropertiesEx(serviceContent.getPropertyCollector(),
Arrays.asList(propertyFilterSpecs), new RetrieveOptions()).getObjects();
if (objCont != null) {
for (ObjectContent oc : objCont) {
List<DynamicProperty> dps = oc.getPropSet();
for (DynamicProperty dp : dps) {
retVal.put(dp.getName(), dp.getVal());
}
}
}
return retVal;
}
示例7: populate
import com.vmware.vim25.ObjectContent; //导入方法依赖的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;
}
示例8: findVmFromObjectContent
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
public static VirtualMachineMO findVmFromObjectContent(VmwareContext context, ObjectContent[] ocs, String name, String instanceNameCustomField) {
if (ocs != null && ocs.length > 0) {
for (ObjectContent oc : ocs) {
String vmNameInvCenter = null;
String vmInternalCSName = null;
List<DynamicProperty> objProps = oc.getPropSet();
if (objProps != null) {
for (DynamicProperty objProp : objProps) {
if (objProp.getName().equals("name")) {
vmNameInvCenter = (String)objProp.getVal();
} else if (objProp.getName().contains(instanceNameCustomField)) {
if (objProp.getVal() != null)
vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
}
if ((vmNameInvCenter != null && name.equalsIgnoreCase(vmNameInvCenter)) || (vmInternalCSName != null && name.equalsIgnoreCase(vmInternalCSName))) {
VirtualMachineMO vmMo = new VirtualMachineMO(context, oc.getObj());
return vmMo;
}
}
}
}
}
return null;
}
示例9: getFileLayout
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
public VirtualMachineFileLayoutEx getFileLayout() throws Exception {
VirtualMachineFileLayoutEx fileLayout = null;
PropertySpec pSpec = new PropertySpec();
pSpec.setType("VirtualMachine");
pSpec.getPathSet().add("layoutEx");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.FALSE);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
List<ObjectContent> ocs = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
if (ocs != null) {
for (ObjectContent oc : ocs) {
List<DynamicProperty> props = oc.getPropSet();
if (props != null) {
for (DynamicProperty prop : props) {
if (prop.getName().equals("layoutEx")) {
fileLayout = (VirtualMachineFileLayoutEx)prop.getVal();
break;
}
}
}
}
}
return fileLayout;
}
示例10: AbstractOverlay
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
protected AbstractOverlay(ObjectContent cont) {
this(cont.getObj(), new HashMap<>());
for (DynamicProperty dp : cont.getPropSet()) {
this.props.put(dp.getName(), dp.getVal());
}
}
示例11: getParent
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
private ManagedObjectReference getParent(ObjectContent cont) {
for (DynamicProperty dp : cont.getPropSet()) {
if (dp.getName().equals("parent")) {
return (ManagedObjectReference) dp.getVal();
}
}
// root object
return null;
}
示例12: getName
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
private String getName(ObjectContent cont) throws FinderException {
for (DynamicProperty dp : cont.getPropSet()) {
if (dp.getName().equals("name")) {
return (String) dp.getVal();
}
}
// probably bad spec
throw new FinderException("Name property not found/fetched for " + cont.getObj().getType());
}
示例13: getName
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
private String getName(ObjectContent oc) throws FinderException {
for (DynamicProperty dp : oc.getPropSet()) {
if (dp.getName().equals("name")) {
return (String) dp.getVal();
}
}
throw new FinderException("No name fetched for " + oc.getObj());
}
示例14: entityProps
import com.vmware.vim25.ObjectContent; //导入方法依赖的package包/类
/**
* Method to retrieve properties of a {@link ManagedObjectReference}
*
* @param entityMor {@link ManagedObjectReference} of the entity
* @param props Array of properties to be looked up
* @return Map of the property name and its corresponding value
* @throws InvalidPropertyFaultMsg If a property does not exist
* @throws RuntimeFaultFaultMsg
*/
public Map<String, Object> entityProps(
ManagedObjectReference entityMor, String... props)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
init();
final HashMap<String, Object> retVal = new HashMap<>();
// Create PropertyFilterSpec using the PropertySpec and ObjectPec
PropertyFilterSpec[] propertyFilterSpecs = {
new PropertyFilterSpecBuilder()
.propSet(
// Create Property Spec
new PropertySpecBuilder()
.all(Boolean.FALSE)
.type(entityMor.getType())
.pathSet(props)
)
.objectSet(
// Now create Object Spec
new ObjectSpecBuilder()
.obj(entityMor)
)
};
List<ObjectContent> oCont =
this.vimPort.retrievePropertiesEx(this.serviceContent.getPropertyCollector(),
Arrays.asList(propertyFilterSpecs), new RetrieveOptions()).getObjects();
if (oCont != null) {
for (ObjectContent oc : oCont) {
List<DynamicProperty> dps = oc.getPropSet();
for (DynamicProperty dp : dps) {
retVal.put(dp.getName(), dp.getVal());
}
}
}
return retVal;
}
示例15: initClusterHostMap
import com.vmware.vim25.ObjectContent; //导入方法依赖的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;
}
}