Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47E5B18A1E for ; Sun, 21 Feb 2016 18:31:33 +0000 (UTC) Received: (qmail 14988 invoked by uid 500); 21 Feb 2016 18:31:20 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 14929 invoked by uid 500); 21 Feb 2016 18:31:20 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 14918 invoked by uid 99); 21 Feb 2016 18:31:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Feb 2016 18:31:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D6374DFC9D; Sun, 21 Feb 2016 18:31:19 +0000 (UTC) From: GabrielBrascher To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: CLOUDSTACK-8609. [VMware] VM is not acces... Content-Type: text/plain Message-Id: <20160221183119.D6374DFC9D@git1-us-west.apache.org> Date: Sun, 21 Feb 2016 18:31:19 +0000 (UTC) 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 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 pfSpecArr = new ArrayList(); + pfSpecArr.add(pfSpec); + + List ocs = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr); + + List datastores = new ArrayList(); + 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. ---