bug CS-14964: use shorter UUID for datastore names

This commit is contained in:
Kelven Yang 2012-05-24 15:02:42 -07:00
parent b6e5530a0b
commit 1e84fa4b12
3 changed files with 534 additions and 528 deletions

View File

@ -39,6 +39,7 @@ import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.hypervisor.vmware.mo.CustomFieldConstants; import com.cloud.hypervisor.vmware.mo.CustomFieldConstants;
import com.cloud.hypervisor.vmware.mo.DatacenterMO; import com.cloud.hypervisor.vmware.mo.DatacenterMO;
import com.cloud.hypervisor.vmware.mo.DatastoreMO; import com.cloud.hypervisor.vmware.mo.DatastoreMO;
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO; import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost; import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
import com.cloud.hypervisor.vmware.util.VmwareContext; import com.cloud.hypervisor.vmware.util.VmwareContext;
@ -126,7 +127,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
if (templateMo == null) { if (templateMo == null) {
if(s_logger.isInfoEnabled()) if(s_logger.isInfoEnabled())
s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName); s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getPoolUuid()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
assert (morDs != null); assert (morDs != null);
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs); DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
@ -170,10 +171,9 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
VmwareContext context = hostService.getServiceContext(cmd); VmwareContext context = hostService.getServiceContext(cmd);
VirtualMachineMO vmMo = null; VirtualMachineMO vmMo = null;
try { try {
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd); VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
morDs = hyperHost.findDatastore(cmd.getPool().getUuid()); morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
try { try {
vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName()); vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
@ -343,12 +343,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
} else { } else {
StorageFilerTO poolTO = cmd.getPool(); StorageFilerTO poolTO = cmd.getPool();
ManagedObjectReference morDatastore = hyperHost.findDatastore(poolTO.getUuid()); ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
if (morDatastore == null) { if (morDatastore == null) {
morDatastore = hyperHost.mountDatastore( morDatastore = hyperHost.mountDatastore(
false, false,
poolTO.getHost(), 0, poolTO.getPath(), poolTO.getHost(), 0, poolTO.getPath(),
poolTO.getUuid()); poolTO.getUuid().replace("-", ""));
if (morDatastore == null) { if (morDatastore == null) {
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath()); throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
@ -389,7 +389,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
try { try {
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd); VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
ManagedObjectReference morPrimaryDs = hyperHost.findDatastore(primaryStorageNameLabel); ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
if (morPrimaryDs == null) { if (morPrimaryDs == null) {
String msg = "Unable to find datastore: " + primaryStorageNameLabel; String msg = "Unable to find datastore: " + primaryStorageNameLabel;
s_logger.error(msg); s_logger.error(msg);
@ -783,7 +783,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String exportName = UUID.randomUUID().toString(); String exportName = UUID.randomUUID().toString();
try { try {
ManagedObjectReference morDs = hyperHost.findDatastore(poolId); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId);
if (morDs == null) { if (morDs == null) {
String msg = "Unable to find volumes's storage pool for copy volume operation"; String msg = "Unable to find volumes's storage pool for copy volume operation";

View File

@ -1639,7 +1639,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (vol.getType() != Volume.Type.ISO) { if (vol.getType() != Volume.Type.ISO) {
String poolUuid = vol.getPoolUuid(); String poolUuid = vol.getPoolUuid();
if(poolMors.get(poolUuid) == null) { if(poolMors.get(poolUuid) == null) {
ManagedObjectReference morDataStore = hyperHost.findDatastore(poolUuid); ManagedObjectReference morDataStore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolUuid);
if (morDataStore == null) { if (morDataStore == null) {
String msg = "Failed to get the mounted datastore for the volume's pool " + poolUuid; String msg = "Failed to get the mounted datastore for the volume's pool " + poolUuid;
s_logger.error(msg); s_logger.error(msg);
@ -2305,7 +2305,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
throw new Exception("Unsupported storage pool type " + pool.getType()); throw new Exception("Unsupported storage pool type " + pool.getType());
} }
ManagedObjectReference morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid()); ManagedObjectReference morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(),
pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
assert (morDatastore != null); assert (morDatastore != null);
DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary(); DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
@ -2370,7 +2371,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
throw new Exception(msg); throw new Exception(msg);
} }
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getPoolUuid()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
if (morDs == null) { if (morDs == null) {
String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName(); String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
s_logger.error(msg); s_logger.error(msg);
@ -2479,11 +2480,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
URI uri = new URI(storeUrl); URI uri = new URI(storeUrl);
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName); ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName.replace("-", ""));
if (morDatastore == null) { if (morDatastore == null)
throw new Exception("Unable to mount secondary storage on host. storeUrl: " + storeUrl); throw new Exception("Unable to mount secondary storage on host. storeUrl: " + storeUrl);
}
return morDatastore; return morDatastore;
} }
@ -2641,7 +2641,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getStorageId()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getStorageId());
if (morDs != null) { if (morDs != null) {
DatastoreMO datastoreMo = new DatastoreMO(context, morDs); DatastoreMO datastoreMo = new DatastoreMO(context, morDs);
@ -2817,7 +2817,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
VolumeTO vol = cmd.getVolume(); VolumeTO vol = cmd.getVolume();
ManagedObjectReference morDs = hyperHost.findDatastore(vol.getPoolUuid()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, vol.getPoolUuid());
if (morDs == null) { if (morDs == null) {
String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint(); String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint();
s_logger.error(msg); s_logger.error(msg);
@ -2980,12 +2980,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter()); DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
VmwareManager vmwareMgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
if (morDatastore == null)
ManagedObjectReference morDatastore = hyperHost.findDatastore(pool.getUuid());
if (morDatastore == null) {
throw new Exception("Unable to find datastore in vSphere"); throw new Exception("Unable to find datastore in vSphere");
}
DatastoreMO dsMo = new DatastoreMO(context, morDatastore); DatastoreMO dsMo = new DatastoreMO(context, morDatastore);
if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) { if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) {

View File

@ -65,6 +65,14 @@ public class HypervisorHostHelper {
return null; return null;
} }
public static ManagedObjectReference findDatastoreWithBackwardsCompatibility(VmwareHypervisorHost hyperHost, String uuidName) throws Exception {
ManagedObjectReference morDs = hyperHost.findDatastore(uuidName.replace("-", ""));
if(morDs == null)
morDs = hyperHost.findDatastore(uuidName);
return morDs;
}
public static DatastoreMO getHyperHostDatastoreMO(VmwareHypervisorHost hyperHost, String datastoreName) throws Exception { public static DatastoreMO getHyperHostDatastoreMO(VmwareHypervisorHost hyperHost, String datastoreName) throws Exception {
ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} ); ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} );
if(ocs != null && ocs.length > 0) { if(ocs != null && ocs.length > 0) {