mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Register Disk to first class disk whereever possible
This commit is contained in:
parent
41b3fc19d6
commit
53fa3beecf
@ -181,6 +181,7 @@ import com.cloud.hypervisor.vmware.mo.StoragepodMO;
|
|||||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||||
import com.cloud.hypervisor.vmware.mo.VirtualMachineDiskInfoBuilder;
|
import com.cloud.hypervisor.vmware.mo.VirtualMachineDiskInfoBuilder;
|
||||||
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
|
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
|
||||||
|
import com.cloud.hypervisor.vmware.mo.VirtualStorageObjectManagerMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
|
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
|
||||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
||||||
@ -226,6 +227,7 @@ import com.cloud.vm.VmDetailConstants;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.vmware.vim25.AboutInfo;
|
import com.vmware.vim25.AboutInfo;
|
||||||
|
import com.vmware.vim25.AlreadyExistsFaultMsg;
|
||||||
import com.vmware.vim25.ArrayUpdateOperation;
|
import com.vmware.vim25.ArrayUpdateOperation;
|
||||||
import com.vmware.vim25.BoolPolicy;
|
import com.vmware.vim25.BoolPolicy;
|
||||||
import com.vmware.vim25.ComputeResourceSummary;
|
import com.vmware.vim25.ComputeResourceSummary;
|
||||||
@ -245,6 +247,7 @@ import com.vmware.vim25.HostCapability;
|
|||||||
import com.vmware.vim25.HostHostBusAdapter;
|
import com.vmware.vim25.HostHostBusAdapter;
|
||||||
import com.vmware.vim25.HostInternetScsiHba;
|
import com.vmware.vim25.HostInternetScsiHba;
|
||||||
import com.vmware.vim25.HostPortGroupSpec;
|
import com.vmware.vim25.HostPortGroupSpec;
|
||||||
|
import com.vmware.vim25.ID;
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
import com.vmware.vim25.NasDatastoreInfo;
|
import com.vmware.vim25.NasDatastoreInfo;
|
||||||
import com.vmware.vim25.ObjectContent;
|
import com.vmware.vim25.ObjectContent;
|
||||||
@ -266,6 +269,8 @@ import com.vmware.vim25.VAppProductSpec;
|
|||||||
import com.vmware.vim25.VAppPropertyInfo;
|
import com.vmware.vim25.VAppPropertyInfo;
|
||||||
import com.vmware.vim25.VAppPropertySpec;
|
import com.vmware.vim25.VAppPropertySpec;
|
||||||
import com.vmware.vim25.VMwareDVSPortSetting;
|
import com.vmware.vim25.VMwareDVSPortSetting;
|
||||||
|
import com.vmware.vim25.VStorageObject;
|
||||||
|
import com.vmware.vim25.VStorageObjectConfigInfo;
|
||||||
import com.vmware.vim25.VimPortType;
|
import com.vmware.vim25.VimPortType;
|
||||||
import com.vmware.vim25.VirtualDevice;
|
import com.vmware.vim25.VirtualDevice;
|
||||||
import com.vmware.vim25.VirtualDeviceBackingInfo;
|
import com.vmware.vim25.VirtualDeviceBackingInfo;
|
||||||
@ -746,6 +751,24 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
} else if (newSize == oldSize) {
|
} else if (newSize == oldSize) {
|
||||||
return new ResizeVolumeAnswer(cmd, true, "success", newSize * ResourceType.bytesToKiB);
|
return new ResizeVolumeAnswer(cmd, true, "success", newSize * ResourceType.bytesToKiB);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// FR41 this is yet to fix
|
||||||
|
ManagedObjectReference morDS1 = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
|
||||||
|
DatastoreMO dsMo1 = new DatastoreMO(hyperHost.getContext(), morDS1);
|
||||||
|
vmdkDataStorePath = VmwareStorageLayoutHelper.getLegacyDatastorePathFromVmdkFileName(dsMo1, path + VMDK_EXTENSION);
|
||||||
|
DatastoreFile dsFile1 = new DatastoreFile(vmdkDataStorePath);
|
||||||
|
|
||||||
|
s_logger.debug("vDiskid does not exist for volume " + vmdkDataStorePath + " registering the disk now");
|
||||||
|
VirtualStorageObjectManagerMO vStorageObjectManagerMO = new VirtualStorageObjectManagerMO(getServiceContext());
|
||||||
|
try {
|
||||||
|
VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsFile1, null, dsMo1.getOwnerDatacenter().second());
|
||||||
|
VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
|
||||||
|
ID vdiskId = diskConfigInfo.getId();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
if (e instanceof AlreadyExistsFaultMsg) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
if (vmName.equalsIgnoreCase("none")) {
|
if (vmName.equalsIgnoreCase("none")) {
|
||||||
// OfflineVmwareMigration: we need to refactor the worker vm creation out for use in migration methods as well as here
|
// OfflineVmwareMigration: we need to refactor the worker vm creation out for use in migration methods as well as here
|
||||||
|
|||||||
@ -2436,13 +2436,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
String deviceNumbering = getDeviceBusName(devices, device);
|
String deviceNumbering = getDeviceBusName(devices, device);
|
||||||
|
|
||||||
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
|
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
|
||||||
if (((VirtualDisk) device).getVDiskId() == null) {
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
s_logger.debug("vDiskid does not exist for volume " + vmdkDatastorePath + " registering the disk now");
|
|
||||||
VirtualStorageObjectManagerMO vStorageObjectManagerMO = new VirtualStorageObjectManagerMO(getOwnerDatacenter().first().getContext());
|
|
||||||
VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsBackingFile, null, getOwnerDatacenter().first().getName());
|
|
||||||
VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
|
|
||||||
((VirtualDisk) device).setVDiskId(diskConfigInfo.getId());
|
|
||||||
}
|
|
||||||
return new Pair<>((VirtualDisk)device, deviceNumbering);
|
return new Pair<>((VirtualDisk)device, deviceNumbering);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2513,15 +2507,17 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
if (matchExactly) {
|
if (matchExactly) {
|
||||||
if (backingBaseName.equalsIgnoreCase(srcBaseName)) {
|
if (backingBaseName.equalsIgnoreCase(srcBaseName)) {
|
||||||
String deviceNumbering = getDeviceBusName(devices, device);
|
String deviceNumbering = getDeviceBusName(devices, device);
|
||||||
|
|
||||||
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
|
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
|
||||||
|
|
||||||
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
|
return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (backingBaseName.contains(trimmedSrcBaseName)) {
|
if (backingBaseName.contains(trimmedSrcBaseName)) {
|
||||||
String deviceNumbering = getDeviceBusName(devices, device);
|
String deviceNumbering = getDeviceBusName(devices, device);
|
||||||
|
|
||||||
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
|
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
|
||||||
|
|
||||||
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
|
return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2536,6 +2532,20 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerVirtualDisk(VirtualDisk device, DatastoreFile dsBackingFile) {
|
||||||
|
if (((VirtualDisk) device).getVDiskId() == null) {
|
||||||
|
try {
|
||||||
|
s_logger.debug("vDiskid does not exist for volume " + dsBackingFile.getFileName() + " registering the disk now");
|
||||||
|
VirtualStorageObjectManagerMO vStorageObjectManagerMO = new VirtualStorageObjectManagerMO(getOwnerDatacenter().first().getContext());
|
||||||
|
VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsBackingFile, null, getOwnerDatacenter().first().getName());
|
||||||
|
VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
|
||||||
|
((VirtualDisk) device).setVDiskId(diskConfigInfo.getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.warn("Exception while trying to register a disk as first class disk to get the unique identifier, main operation still continues: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
|
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
|
||||||
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
@ -2591,6 +2601,8 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
builder.addDisk(deviceBusName, diskBackingInfo.getFileName());
|
builder.addDisk(deviceBusName, diskBackingInfo.getFileName());
|
||||||
diskBackingInfo = diskBackingInfo.getParent();
|
diskBackingInfo = diskBackingInfo.getParent();
|
||||||
}
|
}
|
||||||
|
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
|
||||||
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2609,6 +2621,8 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
|
VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
|
||||||
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
|
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
|
||||||
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
|
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
|
||||||
|
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
|
||||||
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
disks.add(new Pair<Integer, ManagedObjectReference>(new Integer(device.getKey()), diskBackingInfo.getDatastore()));
|
disks.add(new Pair<Integer, ManagedObjectReference>(new Integer(device.getKey()), diskBackingInfo.getDatastore()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2717,6 +2731,10 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
if (device instanceof VirtualDisk) {
|
if (device instanceof VirtualDisk) {
|
||||||
|
VirtualDeviceBackingInfo backingInfo = device.getBacking();
|
||||||
|
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
|
||||||
|
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
|
||||||
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
virtualDisks.add((VirtualDisk)device);
|
virtualDisks.add((VirtualDisk)device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2751,6 +2769,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
reConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
reConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
||||||
}
|
}
|
||||||
|
registerVirtualDisk((VirtualDisk) device, dsBackingFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2778,6 +2797,23 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
if (device instanceof VirtualDisk) {
|
if (device instanceof VirtualDisk) {
|
||||||
|
if (((VirtualDisk) device).getVDiskId() == null) {
|
||||||
|
try {
|
||||||
|
// Register as first class disk
|
||||||
|
VirtualDeviceBackingInfo backingInfo = device.getBacking();
|
||||||
|
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
|
||||||
|
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo) backingInfo;
|
||||||
|
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
|
||||||
|
s_logger.debug("vDiskid does not exist for volume " + diskBackingInfo.getFileName() + " registering the disk now");
|
||||||
|
VirtualStorageObjectManagerMO vStorageObjectManagerMO = new VirtualStorageObjectManagerMO(getOwnerDatacenter().first().getContext());
|
||||||
|
VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsBackingFile, null, getOwnerDatacenter().first().getName());
|
||||||
|
VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
|
||||||
|
((VirtualDisk) device).setVDiskId(diskConfigInfo.getId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.warn("Exception while trying to register a disk as first class disk to get the unique identifier, main operation still continues: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
deviceList.add((VirtualDisk)device);
|
deviceList.add((VirtualDisk)device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user