[
https://issues.apache.org/jira/browse/CLOUDSTACK-8609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15125600#comment-15125600
]
ASF GitHub Bot commented on CLOUDSTACK-8609:
--------------------------------------------
Github user pedro-martins commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/556#discussion_r51372149
--- Diff:
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
---
@@ -1765,7 +1767,18 @@ protected StartAnswer execute(StartCommand cmd) {
// Since VM was successfully powered-on, if there was an
existing VM in a different cluster that was unregistered, delete all the files
associated with it.
if (existingVmName != null && existingVmFileLayout != null) {
- deleteUnregisteredVmFiles(existingVmFileLayout, dcMo,
true);
+ List<String> skipDatastores = new ArrayList<String>();
+ List<String> vmDatastoreNames = new ArrayList<String>();
+ for (DatastoreMO vmDatastore : vmMo.getAllDatastores()) {
+ vmDatastoreNames.add(vmDatastore.getName());
+ }
+ // Don't delete files that are in a datastore that is
being used by the new VM as well (zone-wide datastore).
+ for (DatastoreMO existingDatastore : existingDatastores) {
+ if
(vmDatastoreNames.contains(existingDatastore.getName())) {
+ skipDatastores.add(existingDatastore.getName());
+ }
+ }
+ deleteUnregisteredVmFiles(existingVmFileLayout, dcMo,
true, skipDatastores);
}
--- End diff --
Hi, likitha.
Could you extract the code between lines 1770 - 1775 and 1776 - 1780 to
methods with a little test case and Javadoc explaining what the methods do, the
params that they use and what they return?
Another thing, how about you replace the logic in 'if's at lines 2272, 2283
and 2291 for a method with a little test case and a Javadoc, that receives 2
params, (List<String> skipDatastores, String name ) and returns skipDatastores
== null || !skipDatastores.contains(name).
Ty.
> [VMware] VM is not accessible after a migration across clusters.
> ----------------------------------------------------------------
>
> Key: CLOUDSTACK-8609
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8609
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Reporter: Likitha Shetty
> Assignee: Likitha Shetty
> Fix For: 4.6.1
>
>
> +Steps to reproduce+
> 1. Deploy a VMware zone with 2 clusters (a host each, H1 and H2) and one
> zone-wide primary storage spanning the two clusters.
> 2. Deploy a VM (VM1) on one of the hosts (H1).
> 3. Stop VM1.
> 4. Make the host that contains the VM unsuitable for further VM deployments
> - host runs out of capacity (cpu/memory)
> - host has maximum VMs deployed on it
> 5. Start VM1.
> 6. VM will be powered on H2 but will not be accessible because the .vmx and
> other VM files associated with the VM have been deleted.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)