vmware: Disk controller vmware deploy as is (#5006)

Fixes #4344
This commit is contained in:
Spaceman1984 2021-05-19 11:03:16 +02:00 committed by GitHub
parent 2eae0f5385
commit 5f734f718e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 46 deletions

View File

@ -2067,9 +2067,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
VirtualMachineDiskInfo matchingExistingDisk = getMatchingExistingDisk(diskInfoBuilder, vol, hyperHost, context);
controllerKey = getDiskController(matchingExistingDisk, vol, vmSpec, ideControllerKey, scsiControllerKey);
String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo);
String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo, deployAsIs);
if (DiskControllerType.getType(diskController) == DiskControllerType.osdefault) {
diskController = vmMo.getRecommendedDiskController(null);
}
@ -3273,47 +3271,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return null;
}
private int getDiskController(VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, VirtualMachineTO vmSpec, int ideControllerKey, int scsiControllerKey) {
int controllerKey;
if (matchingExistingDisk != null) {
s_logger.info("Chose disk controller based on existing information: " + matchingExistingDisk.getDiskDeviceBusName());
if (matchingExistingDisk.getDiskDeviceBusName().startsWith("ide"))
return ideControllerKey;
else
return scsiControllerKey;
}
if (vol.getType() == Volume.Type.ROOT) {
Map<String, String> vmDetails = vmSpec.getDetails();
if (vmDetails != null && vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER) != null) {
if (vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER).equalsIgnoreCase("scsi")) {
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi, based on root disk controller settings: "
+ vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER));
controllerKey = scsiControllerKey;
} else {
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> ide, based on root disk controller settings: "
+ vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER));
controllerKey = ideControllerKey;
}
} else {
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi. due to null root disk controller setting");
controllerKey = scsiControllerKey;
}
} else {
// DATA volume always use SCSI device
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi");
controllerKey = scsiControllerKey;
}
return controllerKey;
}
private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, Pair<String, String> controllerInfo) throws Exception {
int controllerKey;
private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, Pair<String, String> controllerInfo, boolean deployAsIs) throws Exception {
DiskControllerType controllerType = DiskControllerType.none;
if (matchingExistingDisk != null) {
if (deployAsIs && matchingExistingDisk != null) {
String currentBusName = matchingExistingDisk.getDiskDeviceBusName();
if (currentBusName != null) {
s_logger.info("Chose disk controller based on existing information: " + currentBusName);

View File

@ -2521,6 +2521,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
String extraConfig = cmd.getExtraConfig();
UserVmVO vmInstance = _vmDao.findById(cmd.getId());
if (MapUtils.isNotEmpty(details) || cmd.isCleanupDetails()) {
VMTemplateVO template = _templateDao.findById(vmInstance.getTemplateId());
if (template != null && template.isDeployAsIs()) {
throw new CloudRuntimeException("Detail settings are read from OVA, it cannot be changed by API call.");
}
}
long accountId = vmInstance.getAccountId();
if (isDisplayVm != null && isDisplayVm != vmInstance.isDisplay()) {

View File

@ -80,11 +80,12 @@
slot="actions"
v-if="!disableSettings && 'updateTemplate' in $store.getters.apis &&
'updateVirtualMachine' in $store.getters.apis && isAdminOrOwner() && allowEditOfDetail(item.name)">
<tootip-button :tooltip="$t('label.cancel')" @click="hideEditDetail(index)" v-if="item.edit" iconType="close-circle" iconTwoToneColor="#f5222d" />
<tootip-button :tooltip="$t('label.ok')" @click="updateDetail(index)" v-if="item.edit" iconType="check-circle" iconTwoToneColor="#52c41a" />
<tooltip-button :tooltip="$t('label.cancel')" @click="hideEditDetail(index)" v-if="item.edit" iconType="close-circle" iconTwoToneColor="#f5222d" />
<tooltip-button :tooltip="$t('label.ok')" @click="updateDetail(index)" v-if="item.edit" iconType="check-circle" iconTwoToneColor="#52c41a" />
<tooltip-button
:tooltip="$t('label.edit')"
icon="edit"
:disabled="deployasistemplate === true"
v-if="!item.edit"
@click="showEditDetail(index)" />
</div>
@ -99,7 +100,7 @@
:cancelText="$t('label.no')"
placement="left"
>
<tooltip-button :tooltip="$t('label.delete')" type="danger" icon="delete" />
<tooltip-button :tooltip="$t('label.delete')" :disabled="deployasistemplate === true" type="danger" icon="delete" />
</a-popconfirm>
</div>
</a-list-item>
@ -130,6 +131,7 @@ export default {
newValue: '',
loading: false,
resourceType: 'UserVm',
deployasistemplate: false,
error: false
}
},
@ -163,6 +165,9 @@ export default {
this.detailOptions = json.listdetailoptionsresponse.detailoptions.details
})
this.disableSettings = (this.$route.meta.name === 'vm' && this.resource.state !== 'Stopped')
api('listTemplates', { templatefilter: 'all', id: this.resource.templateid }).then(json => {
this.deployasistemplate = json.listtemplatesresponse.template[0].deployasis
})
},
filterOrReadOnlyDetails () {
for (var i = 0; i < this.details.length; i++) {