本文整理汇总了Java中com.vmware.vim25.ObjectContent类的典型用法代码示例。如果您正苦于以下问题:Java ObjectContent类的具体用法?Java ObjectContent怎么用?Java ObjectContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectContent类属于com.vmware.vim25包,在下文中一共展示了ObjectContent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getObjectProperties
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
/**
* Retrieve contents for a single object based on the property collector
* registered with the service.
*
* @param collector
* Property collector registered with service
* @param mobj
* Managed Object Reference to get contents for
* @param properties
* names of properties of object to retrieve
*
* @return retrieved object contents
* @throws RuntimeFaultFaultMsg
* @throws InvalidPropertyFaultMsg
*/
private ObjectContent[] getObjectProperties(ManagedObjectReference mobj,
String[] properties)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
if (mobj == null) {
return null;
}
PropertyFilterSpec spec = new PropertyFilterSpec();
spec.getPropSet().add(new PropertySpec());
if ((properties == null || properties.length == 0)) {
spec.getPropSet().get(0).setAll(Boolean.TRUE);
} else {
spec.getPropSet().get(0).setAll(Boolean.FALSE);
}
spec.getPropSet().get(0).setType(mobj.getType());
spec.getPropSet().get(0).getPathSet().addAll(Arrays.asList(properties));
spec.getObjectSet().add(new ObjectSpec());
spec.getObjectSet().get(0).setObj(mobj);
spec.getObjectSet().get(0).setSkip(Boolean.FALSE);
List<PropertyFilterSpec> listpfs = new ArrayList<PropertyFilterSpec>(1);
listpfs.add(spec);
List<ObjectContent> listobjcont = retrievePropertiesAllObjects(listpfs);
return listobjcont.toArray(new ObjectContent[listobjcont.size()]);
}
开发者ID:servicecatalog,项目名称:development,代码行数:40,代码来源:ManagedObjectAccessor.java
示例2: 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);
}
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:GetMoRef.java
示例3: 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;
}
开发者ID:vmware,项目名称:photon-model,代码行数:40,代码来源:GetMoRef.java
示例4: 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;
}
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:GetMoRef.java
示例5: 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;
}
开发者ID:Juniper,项目名称:vijava,代码行数:28,代码来源:ManagedObject.java
示例6: 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;
}
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:25,代码来源:VmUtils.java
示例7: 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;
}
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:35,代码来源:MoRefHandler.java
示例8: 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;
}
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:20,代码来源:MoRefHandler.java
示例9: findDatastore
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
public ManagedObjectReference findDatastore(String name) throws Exception {
// added Apache CloudStack specific name convention, we will use custom field "cloud.uuid" as datastore name as well
CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(_context, _context.getServiceContent().getCustomFieldsManager());
int key = cfmMo.getCustomFieldKey("Datastore", CustomFieldConstants.CLOUD_UUID);
assert (key != 0);
List<ObjectContent> ocs = getDatastorePropertiesOnHostDatastoreSystem(new String[] {"name", String.format("value[%d]", key)});
if (ocs != null) {
for (ObjectContent oc : ocs) {
if (oc.getPropSet().get(0).getVal().equals(name))
return oc.getObj();
if (oc.getPropSet().size() > 1) {
DynamicProperty prop = oc.getPropSet().get(1);
if (prop != null && prop.getVal() != null) {
if (prop.getVal() instanceof CustomFieldStringValue) {
String val = ((CustomFieldStringValue)prop.getVal()).getValue();
if (val.equalsIgnoreCase(name))
return oc.getObj();
}
}
}
}
}
return null;
}
开发者ID:apache,项目名称:cloudstack,代码行数:27,代码来源:HostDatastoreSystemMO.java
示例10: getDatastorePropertiesOnHostDatastoreSystem
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
public List<ObjectContent> getDatastorePropertiesOnHostDatastoreSystem(String[] propertyPaths) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
TraversalSpec hostDsSys2DatastoreTraversal = new TraversalSpec();
hostDsSys2DatastoreTraversal.setType("HostDatastoreSystem");
hostDsSys2DatastoreTraversal.setPath("datastore");
hostDsSys2DatastoreTraversal.setName("hostDsSys2DatastoreTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(hostDsSys2DatastoreTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
}
开发者ID:apache,项目名称:cloudstack,代码行数:25,代码来源:HostDatastoreSystemMO.java
示例11: getLocalDatastoreOnHost
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
public List<Pair<ManagedObjectReference, String>> getLocalDatastoreOnHost() throws Exception {
List<Pair<ManagedObjectReference, String>> dsList = new ArrayList<Pair<ManagedObjectReference, String>>();
ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] {"name", "summary"});
if (ocs != null) {
for (ObjectContent oc : ocs) {
DatastoreSummary dsSummary = (DatastoreSummary)VmwareHelper.getPropValue(oc, "summary");
if (dsSummary.isMultipleHostAccess() == false && dsSummary.isAccessible() && dsSummary.getType().equalsIgnoreCase("vmfs")) {
ManagedObjectReference morDs = oc.getObj();
String name = (String)VmwareHelper.getPropValue(oc, "name");
if (!name.startsWith("-iqn.") && !name.startsWith("_iqn.")) {
dsList.add(new Pair<ManagedObjectReference, String>(morDs, name));
}
}
}
}
return dsList;
}
开发者ID:apache,项目名称:cloudstack,代码行数:20,代码来源:HostMO.java
示例12: 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;
}
开发者ID:apache,项目名称:cloudstack,代码行数:27,代码来源:HypervisorHostHelper.java
示例13: getDatastorePropertiesOnDatacenter
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
public List<ObjectContent> getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
TraversalSpec dc2DatastoreTraversal = new TraversalSpec();
dc2DatastoreTraversal.setType("Datacenter");
dc2DatastoreTraversal.setPath("datastore");
dc2DatastoreTraversal.setName("dc2DatastoreTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.getSelectSet().add(dc2DatastoreTraversal);
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.getPropSet().add(pSpec);
pfSpec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
pfSpecArr.add(pfSpec);
return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
}
开发者ID:apache,项目名称:cloudstack,代码行数:26,代码来源:DatacenterMO.java
示例14: 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;
}
开发者ID:apache,项目名称:cloudstack,代码行数:35,代码来源:VirtualMachineMO.java
示例15: getHyperHostDefaultGateway
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
@Override
public String getHyperHostDefaultGateway() throws Exception {
ObjectContent[] ocs = getHostPropertiesOnCluster(new String[] {"config.network.routeTableInfo.ipRoute"});
if (ocs != null && ocs.length > 0) {
for (ObjectContent oc : ocs) {
ArrayOfHostIpRouteEntry entries = (ArrayOfHostIpRouteEntry)oc.getPropSet().get(0).getVal();
if (entries != null) {
for (HostIpRouteEntry entry : entries.getHostIpRouteEntry()) {
if (entry.getNetwork().equalsIgnoreCase("0.0.0.0"))
return entry.getGateway();
}
}
}
}
throw new Exception("Could not find host default gateway, host is not properly configured?");
}
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:ClusterMO.java
示例16: retrieveMoRefProperties
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
private List<ObjectContent> retrieveMoRefProperties(ManagedObjectReference mObj, List<String> props) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setAll(false);
pSpec.setType(mObj.getType());
pSpec.getPathSet().addAll(props);
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(mObj);
oSpec.setSkip(false);
PropertyFilterSpec spec = new PropertyFilterSpec();
spec.getPropSet().add(pSpec);
spec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>();
specArr.add(spec);
return vimPort.retrieveProperties(getPropCol(), specArr);
}
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:VmwareClient.java
示例17: getTargetHyperHost
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
private VmwareHypervisorHost getTargetHyperHost(DatacenterMO dcMo, String destIp) throws Exception {
VmwareManager mgr = dcMo.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
List<ObjectContent> ocs = dcMo.getHostPropertiesOnDatacenterHostFolder(new String[] {"name", "parent"});
if (ocs != null && ocs.size() > 0) {
for (ObjectContent oc : ocs) {
HostMO hostMo = new HostMO(dcMo.getContext(), oc.getObj());
VmwareHypervisorHostNetworkSummary netSummary = hostMo.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost(hostMo));
if (destIp.equalsIgnoreCase(netSummary.getHostIp())) {
return new HostMO(dcMo.getContext(), oc.getObj());
}
}
}
throw new Exception("Unable to locate dest host by " + destIp);
}
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:VmwareResource.java
示例18: getDynamicProperty
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
public List<DynamicProperty> getDynamicProperty(ManagedObjectReference mor,
String[] propertyNames) throws Exception {
ObjectContent[] objContent = getObjectProperties(mor, propertyNames);
if (objContent != null) {
return objContent[0].getPropSet();
}
return null;
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:ManagedObjectAccessor.java
示例19: retrievePropertiesAllObjects
import com.vmware.vim25.ObjectContent; //导入依赖的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;
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:45,代码来源:ManagedObjectAccessor.java
示例20: ComputeResourceOverlay
import com.vmware.vim25.ObjectContent; //导入依赖的package包/类
protected ComputeResourceOverlay(ObjectContent cont) {
super(cont);
String type = getId().getType();
if (!type.equals(VimNames.TYPE_COMPUTE_RESOURCE) &&
!type.equals(VimNames.TYPE_CLUSTER_COMPUTE_RESOURCE)) {
String msg = String.format("Cannot overlay type '%s' on top of %s", type, VimUtils
.convertMoRefToString(getId()));
throw new IllegalArgumentException(msg);
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:11,代码来源:ComputeResourceOverlay.java
注:本文中的com.vmware.vim25.ObjectContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论