Skip to content

Commit 7916542

Browse files
anshulgangwardevdeep
authored andcommitted
CLOUDSTACK-6399: When there are no vms running on hyperv host, then agent was returning null. In
that case cloudstack was not doing anything and not updating the state of the vms to stopped. Now the agent returns empty list of hostvmstatereport. Management server will then update the vm state to stopped (instead of not acting upon the return state).
1 parent 0f79223 commit 7916542

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@
9090
import com.cloud.agent.api.StartCommand;
9191
import com.cloud.agent.api.StartupCommand;
9292
import com.cloud.agent.api.StartupRoutingCommand;
93-
import com.cloud.agent.api.UnPlugNicAnswer;
94-
import com.cloud.agent.api.UnPlugNicCommand;
9593
import com.cloud.agent.api.StartupRoutingCommand.VmState;
9694
import com.cloud.agent.api.StartupStorageCommand;
95+
import com.cloud.agent.api.UnPlugNicAnswer;
96+
import com.cloud.agent.api.UnPlugNicCommand;
9797
import com.cloud.agent.api.UnsupportedAnswer;
9898
import com.cloud.agent.api.check.CheckSshAnswer;
9999
import com.cloud.agent.api.check.CheckSshCommand;
@@ -355,16 +355,20 @@ public final ArrayList<Map<String, String>> requestHostVmStateReport() {
355355
}
356356
s_logger.debug("HostVmStateReportCommand received response "
357357
+ s_gson.toJson(result));
358-
if (!result.isEmpty()) {
359-
return result;
358+
if (result != null) {
359+
if (!result.isEmpty()) {
360+
return result;
361+
} else {
362+
return new ArrayList<Map<String, String>>();
363+
}
360364
}
361365
return null;
362366
}
363367

364368
protected HashMap<String, HostVmStateReportEntry> getHostVmStateReport() {
365369
final HashMap<String, HostVmStateReportEntry> vmStates = new HashMap<String, HostVmStateReportEntry>();
366370
ArrayList<Map<String, String>> vmList = requestHostVmStateReport();
367-
if (vmList == null || vmList.isEmpty()) {
371+
if (vmList == null) {
368372
return null;
369373
}
370374

0 commit comments

Comments
 (0)