Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public class ApiConstants {
public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage";
public static final String FORCE_DELETE_HOST = "forcedeletehost";
public static final String FORCE_MS_TO_IMPORT_VM_FILES = "forcemstoimportvmfiles";
public static final String FORCE_UPDATE_OS_TYPE = "forceupdateostype";
public static final String FORMAT = "format";
public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
public static final String FOR_SYSTEM_VMS = "forsystemvms";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
description = "the ID of the OS type that best represents the OS of this image.")
private Long osTypeId;

@Parameter(name = ApiConstants.FORCE_UPDATE_OS_TYPE, type = CommandType.BOOLEAN, since = "4.21", description = "Force OS type update. Warning: Updating OS type will " +
"update the guest OS configuration for all the existing Instances deployed with this template/iso, which may affect their behavior.")
private Boolean forceUpdateOsType;

@Parameter(name = ApiConstants.FORMAT, type = CommandType.STRING, description = "the format for the image")
private String format;

Expand Down Expand Up @@ -112,6 +116,10 @@ public Long getOsTypeId() {
return osTypeId;
}

public Boolean getForceUpdateOsType() {
return forceUpdateOsType;
}

public Boolean getPasswordEnabled() {
return passwordEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,12 @@ private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
sc.addAnd("state", SearchCriteria.Op.NEQ, State.Expunging);
List<VMInstanceVO> vms = _vmInstanceDao.search(sc, null);
if (vms != null && !vms.isEmpty()) {
if (Boolean.FALSE.equals(cmd.getForceUpdateOsType())) {
String message = String.format("Updating OS type will update the guest OS configuration " +
"for all of the %d Instance(s) deployed with this Template/ISO, which may affect their behavior. " +
"To proceed, please set the 'forceupdateostype' parameter to true.", vms.size());
throw new InvalidParameterValueException(message);
}
for (VMInstanceVO vm: vms) {
vm.setGuestOSId(guestOSId);
_vmInstanceDao.update(vm.getId(), vm);
Expand Down
2 changes: 2 additions & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@
"label.forbidden": "Forbidden",
"label.forced": "Force",
"label.force.ms.to.import.vm.files": "Enable to force OVF Download via Management Server. Disable to use KVM Host ovftool (if installed)",
"label.force.update.os.type": "Force update OS type",
"label.force.stop": "Force stop",
"label.force.reboot": "Force reboot",
"label.forceencap": "Force UDP encapsulation of ESP packets",
Expand Down Expand Up @@ -3691,6 +3692,7 @@
"message.success.update.ipaddress": "Successfully updated IP address",
"message.success.update.iprange": "Successfully updated IP range",
"message.success.update.ipv4.subnet": "Successfully updated IPv4 subnet",
"message.success.update.iso": "Successfully updated ISO",
"message.success.update.kubeversion": "Successfully updated Kubernetes supported version",
"message.success.update.network": "Successfully updated Network",
"message.success.update.template": "Successfully updated Template",
Expand Down
20 changes: 18 additions & 2 deletions ui/src/views/image/UpdateISO.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
</a-select-option>
</a-select>
</a-form-item>
<a-form-item name="forceupdateostype" ref="forceupdateostype" v-if="hasOstypeidChanged()">
<template #label>
<tooltip-label :title="$t('label.force.update.os.type')" :tooltip="apiParams.forceupdateostype.description"/>
</template>
<a-switch v-model:checked="form.forceupdateostype" />
</a-form-item>

<a-form-item name="isdynamicallyscalable" ref="isdynamicallyscalable">
<template #label>
<tooltip-label :title="$t('label.isdynamicallyscalable')" :tooltip="apiParams.isdynamicallyscalable.description"/>
Expand Down Expand Up @@ -172,7 +179,8 @@ export default {
userdataid: null,
userdatapolicy: null,
userdatapolicylist: {},
architectureTypes: {}
architectureTypes: {},
originalOstypeid: null
}
},
beforeCreate () {
Expand All @@ -195,7 +203,7 @@ export default {
displaytext: [{ required: true, message: this.$t('message.error.required.input') }],
ostypeid: [{ required: true, message: this.$t('message.error.select') }]
})
const resourceFields = ['name', 'displaytext', 'passwordenabled', 'isdynamicallyscalable', 'ostypeid', 'userdataid', 'userdatapolicy']
const resourceFields = ['name', 'displaytext', 'passwordenabled', 'isdynamicallyscalable', 'ostypeid', 'forceupdateostype', 'userdataid', 'userdatapolicy']

for (var field of resourceFields) {
var fieldValue = this.resource[field]
Expand All @@ -207,13 +215,20 @@ export default {
case 'userdatapolicy':
this.userdatapolicy = fieldValue
break
case 'ostypeid':
this.form[field] = fieldValue
this.originalOstypeid = fieldValue
break
default:
this.form[field] = fieldValue
break
}
}
}
},
hasOstypeidChanged () {
return this.form.ostypeid !== this.originalOstypeid
},
fetchData () {
this.fetchOsTypes()
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
Expand Down Expand Up @@ -295,6 +310,7 @@ export default {
if (!this.isValidValueForKey(values, key)) continue
params[key] = values[key]
}
params.forceupdateostype = this.form.forceupdateostype || false
postAPI('updateIso', params).then(json => {
if (this.userdataid !== null) {
this.linkUserdataToTemplate(this.userdataid, json.updateisoresponse.iso.id, this.userdatapolicy)
Expand Down
19 changes: 18 additions & 1 deletion ui/src/views/image/UpdateTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@
</a-select>
</a-form-item>
</a-col>
<a-col :md="24" :lg="24" v-if="hasOstypeidChanged()">
<a-form-item name="forceupdateostype" ref="forceupdateostype">
<template #label>
<tooltip-label :title="$t('label.force.update.os.type')" :tooltip="apiParams.forceupdateostype.description"/>
</template>
<a-switch v-model:checked="form.forceupdateostype" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :md="24" :lg="12">
Expand Down Expand Up @@ -251,7 +259,8 @@ export default {
userdataid: null,
userdatapolicy: null,
userdatapolicylist: {},
architectureTypes: {}
architectureTypes: {},
originalOstypeid: null
}
},
beforeCreate () {
Expand Down Expand Up @@ -295,6 +304,10 @@ export default {
case 'userdatapolicy':
this.userdatapolicy = fieldValue
break
case 'ostypeid':
this.form[field] = fieldValue
this.originalOstypeid = fieldValue
break
default:
this.form[field] = fieldValue
break
Expand Down Expand Up @@ -510,6 +523,7 @@ export default {
}
params[key] = values[key]
}
params.forceupdateostype = this.form.forceupdateostype || false
postAPI('updateTemplate', params).then(json => {
if (this.userdataid !== null) {
this.linkUserdataToTemplate(this.userdataid, json.updatetemplateresponse.template.id, this.userdatapolicy)
Expand Down Expand Up @@ -546,6 +560,9 @@ export default {
}).finally(() => {
this.loading = false
})
},
hasOstypeidChanged () {
return this.form.ostypeid !== this.originalOstypeid
}
}
}
Expand Down
Loading