mirror of https://github.com/apache/cloudstack.git
bug CS-14964: use shorter UUID for datastore names
Reviewed-by: anthony
This commit is contained in:
parent
0a00845c98
commit
fd1e282827
|
|
@ -39,6 +39,7 @@ import com.cloud.agent.api.to.StorageFilerTO;
|
|||
import com.cloud.hypervisor.vmware.mo.CustomFieldConstants;
|
||||
import com.cloud.hypervisor.vmware.mo.DatacenterMO;
|
||||
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.VmwareHypervisorHost;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
|
|
@ -126,7 +127,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
if (templateMo == null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
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);
|
||||
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
|
||||
|
||||
|
|
@ -173,7 +174,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
morDs = hyperHost.findDatastore(cmd.getPool().getUuid());
|
||||
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
|
||||
|
||||
try {
|
||||
vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
|
||||
|
|
@ -343,12 +344,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
} else {
|
||||
StorageFilerTO poolTO = cmd.getPool();
|
||||
|
||||
ManagedObjectReference morDatastore = hyperHost.findDatastore(poolTO.getUuid());
|
||||
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
|
||||
if (morDatastore == null) {
|
||||
morDatastore = hyperHost.mountDatastore(
|
||||
false,
|
||||
poolTO.getHost(), 0, poolTO.getPath(),
|
||||
poolTO.getUuid());
|
||||
poolTO.getUuid().replace("-", ""));
|
||||
|
||||
if (morDatastore == null) {
|
||||
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
|
||||
|
|
@ -389,7 +390,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
|
||||
ManagedObjectReference morPrimaryDs = hyperHost.findDatastore(primaryStorageNameLabel);
|
||||
ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
|
||||
if (morPrimaryDs == null) {
|
||||
String msg = "Unable to find datastore: " + primaryStorageNameLabel;
|
||||
s_logger.error(msg);
|
||||
|
|
@ -783,7 +784,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
String exportName = UUID.randomUUID().toString();
|
||||
|
||||
try {
|
||||
ManagedObjectReference morDs = hyperHost.findDatastore(poolId);
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId);
|
||||
|
||||
if (morDs == null) {
|
||||
String msg = "Unable to find volumes's storage pool for copy volume operation";
|
||||
|
|
|
|||
|
|
@ -1661,7 +1661,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
if (vol.getType() != Volume.Type.ISO) {
|
||||
String poolUuid = vol.getPoolUuid();
|
||||
if(poolMors.get(poolUuid) == null) {
|
||||
ManagedObjectReference morDataStore = hyperHost.findDatastore(poolUuid);
|
||||
ManagedObjectReference morDataStore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolUuid);
|
||||
if (morDataStore == null) {
|
||||
String msg = "Failed to get the mounted datastore for the volume's pool " + poolUuid;
|
||||
s_logger.error(msg);
|
||||
|
|
@ -2338,7 +2338,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
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);
|
||||
DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
|
||||
|
|
@ -2403,7 +2404,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getPoolUuid());
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
|
||||
if (morDs == null) {
|
||||
String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
|
||||
s_logger.error(msg);
|
||||
|
|
@ -2512,11 +2513,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
URI uri = new URI(storeUrl);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return morDatastore;
|
||||
}
|
||||
|
|
@ -2674,7 +2674,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
try {
|
||||
VmwareContext context = getServiceContext();
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getStorageId());
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getStorageId());
|
||||
|
||||
if (morDs != null) {
|
||||
DatastoreMO datastoreMo = new DatastoreMO(context, morDs);
|
||||
|
|
@ -2850,7 +2850,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
VolumeTO vol = cmd.getVolume();
|
||||
|
||||
ManagedObjectReference morDs = hyperHost.findDatastore(vol.getPoolUuid());
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, vol.getPoolUuid());
|
||||
if (morDs == null) {
|
||||
String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint();
|
||||
s_logger.error(msg);
|
||||
|
|
@ -3013,12 +3013,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
|
||||
|
||||
VmwareManager vmwareMgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
ManagedObjectReference morDatastore = hyperHost.findDatastore(pool.getUuid());
|
||||
if (morDatastore == null) {
|
||||
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
|
||||
if (morDatastore == null)
|
||||
throw new Exception("Unable to find datastore in vSphere");
|
||||
}
|
||||
|
||||
DatastoreMO dsMo = new DatastoreMO(context, morDatastore);
|
||||
|
||||
if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,15 @@ public class HypervisorHostHelper {
|
|||
}
|
||||
}
|
||||
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 {
|
||||
ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} );
|
||||
|
|
|
|||
Loading…
Reference in New Issue