nvazquez commented on code in PR #9925:
URL: https://github.com/apache/cloudstack/pull/9925#discussion_r1927968985


##########
plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java:
##########
@@ -790,16 +798,16 @@ public File getSystemVMKeyFile() {
         if (keyFile == null || !keyFile.exists()) {
             keyFile = new 
File("/usr/share/cloudstack-common/scripts/vm/systemvm/id_rsa.cloud");
         }
-        assert (keyFile != null);

Review Comment:
   No need for this check anymore?



##########
plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java:
##########
@@ -1588,13 +1566,87 @@ public List<StoragePool> 
listVsphereStoragePolicyCompatibleStoragePools(ListVsph
     }
 
     @Override
-    public List<UnmanagedInstanceTO> listVMsInDatacenter(ListVmwareDcVmsCmd 
cmd) {
+    public List<HostMO> listHostsInDatacenter(ListVmwareDcHostsCmd cmd) {
+        VcenterData vmwaredc = getVcenterData(cmd);
+
+        try {
+            VmwareContext context = getVmwareContext(vmwaredc);
+            DatacenterMO dcMo = getDatacenterMO(context, vmwaredc);
+            return dcMo.getAllHostsOnDatacenter();
+        } catch (RuntimeFaultFaultMsg | URISyntaxException | 
VmwareClientException | InvalidLocaleFaultMsg |
+                 InvalidLoginFaultMsg | InvalidPropertyFaultMsg e) {
+            String errorMsg = String.format("Error retrieving stopped VMs from 
the VMware VC %s datacenter %s: %s",
+                    vmwaredc.vcenter, vmwaredc.datacenterName, e.getMessage());
+            s_logger.error(errorMsg, e);
+            throw new CloudRuntimeException(errorMsg);
+        }
+
+    }
+
+    @Override
+    public Pair<String, List<UnmanagedInstanceTO>> 
listVMsInDatacenter(ListVmwareDcVmsCmd cmd) {
+        Integer maxObjects = cmd.getBatchSize();
+        String token = cmd.getToken();
+        String host = cmd.getHost();
+
+        VcenterData vmwaredc = getVcenterData(cmd);
+
+        try {
+            VmwareContext context = getVmwareContext(vmwaredc);
+
+            DatacenterMO dcMo = getDatacenterMO(context, vmwaredc);
+
+            if (com.cloud.utils.StringUtils.isNotBlank(host)) {
+                ManagedObjectReference hostMor = dcMo.findHost(host);
+                if (hostMor == null) {
+                    throw new VmwareClientException(String.format("no host 
'%s' found.",host));

Review Comment:
   ```suggestion
                       throw new VmwareClientException(String.format("No host 
'%s' found on DC: %s.", host, dcMo.getName()));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to