Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -26,6 +26,7 @@ public class ApiConstants {
public static final String ACTIVATION_RULE = "activationrule";
public static final String ACTIVITY = "activity";
public static final String ADAPTER_TYPE = "adaptertype";
public static final String ADDITONAL_CONFIG_ENABLED = "additionalconfigenabled";
public static final String ADDRESS = "address";
public static final String ALGORITHM = "algorithm";
public static final String ALIAS = "alias";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void execute() {
response.setSharedFsVmMinCpuCount((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT));
response.setSharedFsVmMinRamSize((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE));
response.setDynamicScalingEnabled((Boolean) capabilities.get(ApiConstants.DYNAMIC_SCALING_ENABLED));
response.setAdditionalConfigEnabled((Boolean) capabilities.get(ApiConstants.ADDITONAL_CONFIG_ENABLED));
response.setObjectName("capability");
response.setResponseName(getCommandName());
this.setResponseObject(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ public class CapabilitiesResponse extends BaseResponse {
@Param(description = "true if dynamically scaling for instances is enabled", since = "4.21.0")
private Boolean dynamicScalingEnabled;

@SerializedName(ApiConstants.ADDITONAL_CONFIG_ENABLED)
@Param(description = "true if additional configurations or extraconfig can be passed to Instances", since = "4.20.2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR but as some point we should start using a generic Map response or some other means. Adding a new response param for a new global setting value is an unnecessary hassle

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

private Boolean additionalConfigEnabled;

public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
this.securityGroupsEnabled = securityGroupsEnabled;
}
Expand Down Expand Up @@ -255,4 +259,8 @@ public void setSharedFsVmMinRamSize(Integer sharedFsVmMinRamSize) {
public void setDynamicScalingEnabled(Boolean dynamicScalingEnabled) {
this.dynamicScalingEnabled = dynamicScalingEnabled;
}

public void setAdditionalConfigEnabled(Boolean additionalConfigEnabled) {
this.additionalConfigEnabled = additionalConfigEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4535,6 +4535,8 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
}
capabilities.put(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT, fsVmMinCpu);
capabilities.put(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE, fsVmMinRam);
capabilities.put(ApiConstants.ADDITONAL_CONFIG_ENABLED, UserVmManager.EnableAdditionalVmConfig.valueIn(caller.getId()));


return capabilities;
}
Expand Down
9 changes: 9 additions & 0 deletions server/src/main/java/com/cloud/vm/UserVmManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ public interface UserVmManager extends UserVmService {
"If set to true, tags specified in `resource.limit.host.tags` are also included in vm.strict.host.tags.",
true);

ConfigKey<Boolean> EnableAdditionalVmConfig = new ConfigKey<>(
"Advanced",
Boolean.class,
"enable.additional.vm.configuration",
"false",
"allow additional arbitrary configuration to vm",
true,
ConfigKey.Scope.Account);

static final int MAX_USER_DATA_LENGTH_BYTES = 2048;

public static final String CKS_NODE = "cksnode";
Expand Down
5 changes: 1 addition & 4 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,6 @@ public void setKubernetesServiceHelpers(final List<KubernetesServiceHelper> kube
private static final ConfigKey<Boolean> AllowDeployVmIfGivenHostFails = new ConfigKey<Boolean>("Advanced", Boolean.class, "allow.deploy.vm.if.deploy.on.given.host.fails", "false",
"allow vm to deploy on different host if vm fails to deploy on the given host ", true);

private static final ConfigKey<Boolean> EnableAdditionalVmConfig = new ConfigKey<>("Advanced", Boolean.class,
"enable.additional.vm.configuration", "false", "allow additional arbitrary configuration to vm", true, ConfigKey.Scope.Account);

private static final ConfigKey<String> KvmAdditionalConfigAllowList = new ConfigKey<>(String.class,
"allow.additional.vm.configuration.list.kvm", "Advanced", "", "Comma separated list of allowed additional configuration options.", true, ConfigKey.Scope.Account, null, null, EnableAdditionalVmConfig.key(), null, null, ConfigKey.Kind.CSV, null);

Expand Down Expand Up @@ -6388,8 +6385,8 @@ protected void persistExtraConfigKvm(String decodedUrl, UserVm vm) {
// validate config against denied cfg commands
validateKvmExtraConfig(decodedUrl, vm.getAccountId());
String[] extraConfigs = decodedUrl.split("\n\n");
int i = 1;
for (String cfg : extraConfigs) {
int i = 1;
String[] cfgParts = cfg.split("\n");
String extraConfigKey = ApiConstants.EXTRA_CONFIG;
String extraConfigValue;
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 @@ -975,6 +975,8 @@
"label.externalid": "External Id",
"label.externalloadbalanceripaddress": "External load balancer IP address.",
"label.extra": "Extra arguments",
"label.extraconfig": "Additional Configuration",
"label.extraconfig.tooltip": "Additional configuration parameters (extraconfig) to pass to the instance in plain text",
"label.f5": "F5",
"label.f5.ip.loadbalancer": "F5 BIG-IP load balancer.",
"label.failed": "Failed",
Expand Down
12 changes: 12 additions & 0 deletions ui/src/views/compute/DeployVM.vue
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,12 @@
</div>
</a-card>
</a-form-item>
<a-form-item v-if="extraConfigEnabledValue" name="extraconfig" ref="extraconfig">
<template #label>
<tooltip-label :title="$t('label.extraconfig')" :tooltip="$t('label.extraconfig.tooltip')"/>
</template>
<a-textarea v-model:value="form.extraconfig"/>
</a-form-item>
<a-form-item :label="$t('label.affinity.groups')">
<affinity-group-selection
:items="options.affinityGroups"
Expand Down Expand Up @@ -1418,6 +1424,9 @@ export default {
dynamicScalingVmConfigValue () {
return this.$store.getters.features.dynamicscalingenabled
},
extraConfigEnabledValue () {
return this.$store.getters.features.additionalconfigenabled
},
isCustomizedDiskIOPS () {
return this.diskSelected?.iscustomizediops || false
},
Expand Down Expand Up @@ -2054,6 +2063,9 @@ export default {
if (isUserdataAllowed && values.userdata && values.userdata.length > 0) {
deployVmData.userdata = this.$toBase64AndURIEncoded(values.userdata)
}
if (values.extraconfig && values.extraconfig.length > 0) {
deployVmData.extraconfig = encodeURIComponent(values.extraconfig)
}
// step 2: select template/iso
if (this.tabKey === 'templateid') {
deployVmData.templateid = values.templateid
Expand Down
12 changes: 11 additions & 1 deletion ui/src/views/compute/EditVM.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
<a-textarea v-model:value="form.userdata">
</a-textarea>
</a-form-item>
<a-form-item v-if="extraConfigEnabled">
<template #label>
<tooltip-label :title="$t('label.extraconfig')" :tooltip="$t('label.extraconfig.tooltip')"/>
</template>
<a-textarea v-model:value="form.extraconfig"/>
</a-form-item>
<a-form-item ref="securitygroupids" name="securitygroupids" :label="$t('label.security.groups')" v-if="securityGroupsEnabled">
<a-select
mode="multiple"
Expand Down Expand Up @@ -164,7 +170,8 @@ export default {
groups: {
loading: false,
opts: []
}
},
extraConfigEnabled: this.$store.getters.features.additionalconfigenabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious - why a computed variable in DeployVM and a data variable here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no specific reason. It could have been a data variable in DeployVM as well. Just followed the existing pattern in the file.

}
},
beforeCreate () {
Expand Down Expand Up @@ -342,6 +349,9 @@ export default {
if (values.userdata && values.userdata.length > 0) {
params.userdata = this.$toBase64AndURIEncoded(values.userdata)
}
if (values.extraconfig && values.extraconfig.length > 0) {
params.extraconfig = encodeURIComponent(values.extraconfig)
}
this.loading = true

api('updateVirtualMachine', {}, 'POST', params).then(json => {
Expand Down
Loading