Prepare secondary storage in migration target host before migration happens, unlike primary storage, secondary storage is prepared on-demand

This commit is contained in:
Kelven Yang 2012-02-01 15:20:52 -08:00
parent e6b1929d1a
commit dcee71e923

View File

@ -2149,6 +2149,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
final String vmName = vm.getName(); final String vmName = vm.getName();
try { try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
// find VM through datacenter (VM is not at the target host yet) // find VM through datacenter (VM is not at the target host yet)
VirtualMachineMO vmMo = hyperHost.findVmOnPeerHyperHost(vmName); VirtualMachineMO vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
@ -2164,6 +2165,19 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic); prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic);
} }
String secStoreUrl = mgr.getSecondaryStorageStoreUrl(Long.parseLong(_dcId));
if(secStoreUrl == null) {
String msg = "secondary storage for dc " + _dcId + " is not ready yet?";
throw new Exception(msg);
}
mgr.prepareSecondaryStorageStore(secStoreUrl);
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
if (morSecDs == null) {
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl;
throw new Exception(msg);
}
synchronized (_vms) { synchronized (_vms) {
_vms.put(vm.getName(), State.Migrating); _vms.put(vm.getName(), State.Migrating);
} }