Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/806#discussion_r39265179
  
    --- Diff: 
vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java ---
    @@ -577,41 +590,48 @@ public ManagedObjectReference 
getDecendentMoRef(ManagedObjectReference root, Str
                 return null;
             }
     
    -        // Create PropertySpecs
    -        PropertySpec pSpec = new PropertySpec();
    -        pSpec.setType(type);
    -        pSpec.setAll(false);
    -        pSpec.getPathSet().add("name");
    -
    -        ObjectSpec oSpec = new ObjectSpec();
    -        oSpec.setObj(root);
    -        oSpec.setSkip(false);
    -        oSpec.getSelectSet().addAll(constructCompleteTraversalSpec());
    -
    -        PropertyFilterSpec spec = new PropertyFilterSpec();
    -        spec.getPropSet().add(pSpec);
    -        spec.getObjectSet().add(oSpec);
    -        List<PropertyFilterSpec> specArr = new 
ArrayList<PropertyFilterSpec>();
    -        specArr.add(spec);
    -
    -        List<ObjectContent> ocary = 
vimPort.retrieveProperties(getPropCol(), specArr);
    -
    -        if (ocary == null || ocary.size() == 0) {
    -            return null;
    -        }
    +        try {
    +            // Create PropertySpecs
    +            PropertySpec pSpec = new PropertySpec();
    +            pSpec.setType(type);
    +            pSpec.setAll(false);
    +            pSpec.getPathSet().add("name");
    +
    +            ObjectSpec oSpec = new ObjectSpec();
    +            oSpec.setObj(root);
    +            oSpec.setSkip(false);
    +            oSpec.getSelectSet().addAll(constructCompleteTraversalSpec());
    +
    +            PropertyFilterSpec spec = new PropertyFilterSpec();
    +            spec.getPropSet().add(pSpec);
    +            spec.getObjectSet().add(oSpec);
    +            List<PropertyFilterSpec> specArr = new 
ArrayList<PropertyFilterSpec>();
    +            specArr.add(spec);
    +
    +            ManagedObjectReference propCollector = getPropCol();
    +            List<ObjectContent> ocary = 
vimPort.retrieveProperties(propCollector, specArr);
    +
    +            if (ocary == null || ocary.size() == 0) {
    +                return null;
    +            }
     
    -        // filter through retrieved objects to get the first match.
    -        for (ObjectContent oc : ocary) {
    -            ManagedObjectReference mor = oc.getObj();
    -            List<DynamicProperty> propary = oc.getPropSet();
    -            if (type == null || type.equals(mor.getType())) {
    -                if (propary.size() > 0) {
    -                    String propval = (String)propary.get(0).getVal();
    -                    if (propval != null && name.equalsIgnoreCase(propval))
    -                        return mor;
    +            // filter through retrieved objects to get the first match.
    +            for (ObjectContent oc : ocary) {
    +                ManagedObjectReference mor = oc.getObj();
    +                List<DynamicProperty> propary = oc.getPropSet();
    +                if (type == null || type.equals(mor.getType())) {
    +                    if (propary.size() > 0) {
    +                        String propval = (String)propary.get(0).getVal();
    +                        if (propval != null && 
name.equalsIgnoreCase(propval))
    +                            return mor;
    +                    }
                     }
                 }
    +        } catch (Exception e) {
    +            s_logger.debug("Failed to get mor for name: " + name + " and 
type: " + type, e);
    --- End diff --
    
    (mor == more || mor is MoRef)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to