Skip to content

Commit 5f734f7

Browse files
authored
vmware: Disk controller vmware deploy as is (#5006)
Fixes #4344
1 parent 2eae0f5 commit 5f734f7

3 files changed

Lines changed: 18 additions & 46 deletions

File tree

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,9 +2067,7 @@ protected StartAnswer execute(StartCommand cmd) {
20672067
}
20682068

20692069
VirtualMachineDiskInfo matchingExistingDisk = getMatchingExistingDisk(diskInfoBuilder, vol, hyperHost, context);
2070-
controllerKey = getDiskController(matchingExistingDisk, vol, vmSpec, ideControllerKey, scsiControllerKey);
2071-
String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo);
2072-
2070+
String diskController = getDiskController(vmMo, matchingExistingDisk, vol, controllerInfo, deployAsIs);
20732071
if (DiskControllerType.getType(diskController) == DiskControllerType.osdefault) {
20742072
diskController = vmMo.getRecommendedDiskController(null);
20752073
}
@@ -3273,47 +3271,9 @@ private VirtualMachineDiskInfo getMatchingExistingDisk(VirtualMachineDiskInfoBui
32733271
return null;
32743272
}
32753273

3276-
private int getDiskController(VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, VirtualMachineTO vmSpec, int ideControllerKey, int scsiControllerKey) {
3277-
3278-
int controllerKey;
3279-
if (matchingExistingDisk != null) {
3280-
s_logger.info("Chose disk controller based on existing information: " + matchingExistingDisk.getDiskDeviceBusName());
3281-
if (matchingExistingDisk.getDiskDeviceBusName().startsWith("ide"))
3282-
return ideControllerKey;
3283-
else
3284-
return scsiControllerKey;
3285-
}
3286-
3287-
if (vol.getType() == Volume.Type.ROOT) {
3288-
Map<String, String> vmDetails = vmSpec.getDetails();
3289-
if (vmDetails != null && vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER) != null) {
3290-
if (vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER).equalsIgnoreCase("scsi")) {
3291-
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi, based on root disk controller settings: "
3292-
+ vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER));
3293-
controllerKey = scsiControllerKey;
3294-
} else {
3295-
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> ide, based on root disk controller settings: "
3296-
+ vmDetails.get(VmDetailConstants.ROOT_DISK_CONTROLLER));
3297-
controllerKey = ideControllerKey;
3298-
}
3299-
} else {
3300-
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi. due to null root disk controller setting");
3301-
controllerKey = scsiControllerKey;
3302-
}
3303-
3304-
} else {
3305-
// DATA volume always use SCSI device
3306-
s_logger.info("Chose disk controller for vol " + vol.getType() + " -> scsi");
3307-
controllerKey = scsiControllerKey;
3308-
}
3309-
3310-
return controllerKey;
3311-
}
3312-
3313-
private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, Pair<String, String> controllerInfo) throws Exception {
3314-
int controllerKey;
3274+
private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo matchingExistingDisk, DiskTO vol, Pair<String, String> controllerInfo, boolean deployAsIs) throws Exception {
33153275
DiskControllerType controllerType = DiskControllerType.none;
3316-
if (matchingExistingDisk != null) {
3276+
if (deployAsIs && matchingExistingDisk != null) {
33173277
String currentBusName = matchingExistingDisk.getDiskDeviceBusName();
33183278
if (currentBusName != null) {
33193279
s_logger.info("Chose disk controller based on existing information: " + currentBusName);

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,13 @@ public UserVm updateVirtualMachine(UpdateVMCmd cmd) throws ResourceUnavailableEx
25212521
String extraConfig = cmd.getExtraConfig();
25222522

25232523
UserVmVO vmInstance = _vmDao.findById(cmd.getId());
2524+
if (MapUtils.isNotEmpty(details) || cmd.isCleanupDetails()) {
2525+
VMTemplateVO template = _templateDao.findById(vmInstance.getTemplateId());
2526+
if (template != null && template.isDeployAsIs()) {
2527+
throw new CloudRuntimeException("Detail settings are read from OVA, it cannot be changed by API call.");
2528+
}
2529+
}
2530+
25242531
long accountId = vmInstance.getAccountId();
25252532

25262533
if (isDisplayVm != null && isDisplayVm != vmInstance.isDisplay()) {

ui/src/components/view/DetailSettings.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@
8080
slot="actions"
8181
v-if="!disableSettings && 'updateTemplate' in $store.getters.apis &&
8282
'updateVirtualMachine' in $store.getters.apis && isAdminOrOwner() && allowEditOfDetail(item.name)">
83-
<tootip-button :tooltip="$t('label.cancel')" @click="hideEditDetail(index)" v-if="item.edit" iconType="close-circle" iconTwoToneColor="#f5222d" />
84-
<tootip-button :tooltip="$t('label.ok')" @click="updateDetail(index)" v-if="item.edit" iconType="check-circle" iconTwoToneColor="#52c41a" />
83+
<tooltip-button :tooltip="$t('label.cancel')" @click="hideEditDetail(index)" v-if="item.edit" iconType="close-circle" iconTwoToneColor="#f5222d" />
84+
<tooltip-button :tooltip="$t('label.ok')" @click="updateDetail(index)" v-if="item.edit" iconType="check-circle" iconTwoToneColor="#52c41a" />
8585
<tooltip-button
8686
:tooltip="$t('label.edit')"
8787
icon="edit"
88+
:disabled="deployasistemplate === true"
8889
v-if="!item.edit"
8990
@click="showEditDetail(index)" />
9091
</div>
@@ -99,7 +100,7 @@
99100
:cancelText="$t('label.no')"
100101
placement="left"
101102
>
102-
<tooltip-button :tooltip="$t('label.delete')" type="danger" icon="delete" />
103+
<tooltip-button :tooltip="$t('label.delete')" :disabled="deployasistemplate === true" type="danger" icon="delete" />
103104
</a-popconfirm>
104105
</div>
105106
</a-list-item>
@@ -130,6 +131,7 @@ export default {
130131
newValue: '',
131132
loading: false,
132133
resourceType: 'UserVm',
134+
deployasistemplate: false,
133135
error: false
134136
}
135137
},
@@ -163,6 +165,9 @@ export default {
163165
this.detailOptions = json.listdetailoptionsresponse.detailoptions.details
164166
})
165167
this.disableSettings = (this.$route.meta.name === 'vm' && this.resource.state !== 'Stopped')
168+
api('listTemplates', { templatefilter: 'all', id: this.resource.templateid }).then(json => {
169+
this.deployasistemplate = json.listtemplatesresponse.template[0].deployasis
170+
})
166171
},
167172
filterOrReadOnlyDetails () {
168173
for (var i = 0; i < this.details.length; i++) {

0 commit comments

Comments
 (0)