cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GabrielBrascher <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-8609. [VMware] VM is not acces...
Date Sun, 21 Feb 2016 18:31:19 GMT
Github user GabrielBrascher commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/556#discussion_r53570662
  
    --- Diff: vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java ---
    @@ -880,6 +880,38 @@ else if (prop.getName().startsWith("value[")) {
             return networks;
         }
     
    +    public List<DatastoreMO> getAllDatastores() throws Exception {
    +        PropertySpec pSpec = new PropertySpec();
    +        pSpec.setType("Datastore");
    +        pSpec.getPathSet().add("name");
    +
    +        TraversalSpec vmDatastoreTraversal = new TraversalSpec();
    +        vmDatastoreTraversal.setType("VirtualMachine");
    +        vmDatastoreTraversal.setPath("datastore");
    +        vmDatastoreTraversal.setName("vmDatastoreTraversal");
    +
    +        ObjectSpec oSpec = new ObjectSpec();
    +        oSpec.setObj(_mor);
    +        oSpec.setSkip(Boolean.TRUE);
    +        oSpec.getSelectSet().add(vmDatastoreTraversal);
    +
    +        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);
    +
    +        List<DatastoreMO> datastores = new ArrayList<DatastoreMO>();
    +        if (ocs != null && ocs.size() > 0) {
    --- End diff --
    
    Hi @likitha, you could use CollectionUtils.isEmpty for this conditional.
    It returns true if the List is empty or null.
    Thanks.
    Documentation: https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/CollectionUtils.html#isEmpty%28java.util.Collection%29


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message