public static Map<String, Object> asMap(List<DynamicProperty> propSet) { Map<String, Object> result = new HashMap<String, Object>(); for (DynamicProperty prop : propSet) { result.put(prop.getName(), prop.getVal()); } return result; }
public static Object getDynamicProperty(ObjectContent objectContent, String name) { for (DynamicProperty prop : objectContent.getPropSet()) { if (name.equals(prop.getName())) { return prop.getVal(); } } return null; } }
private ManagedObjectReference getParent(ObjectContent cont) { for (DynamicProperty dp : cont.getPropSet()) { if (dp.getName().equals("parent")) { return (ManagedObjectReference) dp.getVal(); } } // root object return null; }
@SuppressWarnings("unchecked") private <T> T prop(ObjectContent oc, String prop) { for (DynamicProperty dp : oc.getPropSet()) { if (prop.equals(dp.getName())) { return (T) dp.getVal(); } } return null; }
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); } } }
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()); } }
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; } }
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()); }
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; }
if (dps != null) { for (DynamicProperty dp : dps) { propMap.put(dp.getName(), dp.getVal());
/** * @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; }
String nameInPropSet = (String) propSet[0].getVal(); if(name.equalsIgnoreCase(nameInPropSet))
ret[p] = dp.getVal();
public ManagedObjectReference getMorHost(String hostname, ConnectionResources connectionResources, ManagedObjectReference vmMor) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg { ManagedObjectReference host = null; if (StringUtils.isNotBlank(hostname)) { ManagedObjectReference reference = connectionResources.getMorRootFolder(); host = new MorObjectHandler().getSpecificMor(connectionResources, reference, VmParameter.HOST_SYSTEM.getValue(), hostname); if (host == null) { throw new RuntimeException(ErrorMessages.HOST_NOT_FOUND); } } else if (StringUtils.isBlank(hostname) && vmMor != null) { ObjectContent[] objectContents = GetObjectProperties.getObjectProperties(connectionResources, vmMor, new String[]{VmParameter.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; }
List<DynamicProperty> vmProperties = objectItem.getPropSet(); for (DynamicProperty propertyItem : vmProperties) { VirtualMachineSummary virtualMachineSummary = (VirtualMachineSummary) propertyItem.getVal(); String vmPathName = virtualMachineSummary.getConfig().getVmPathName(); dataStoreName = vmPathName.substring(1, vmPathName.indexOf(Constants.RIGHT_SQUARE_BRACKET));
if (dps != null) { for (DynamicProperty dp : dps) { propMap.put(dp.getName(), dp.getVal());
List<DynamicProperty> dps = oc.getPropSet(); for (DynamicProperty dp : dps) { retVal.put(dp.getName(), dp.getVal());
List<DynamicProperty> dps = oc.getPropSet(); for (DynamicProperty dp : dps) { retVal.put(dp.getName(), dp.getVal());
for(int j=0; props!=null && j < props.length; j++) Object obj = convertProperty(props[j].getVal()); if(obj==null)
List<DynamicProperty> vmProperties = objectItem.getPropSet(); for (DynamicProperty propertyItem : vmProperties) { VirtualMachineSummary virtualMachineSummary = (VirtualMachineSummary) propertyItem.getVal(); VirtualMachineConfigSummary virtualMachineConfigSummary = virtualMachineSummary.getConfig();