Skip to content

Commit fead215

Browse files
committed
add configs
1 parent 9c6f2a9 commit fead215

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

server/src/main/java/com/cloud/api/response/ApiResponseSerializer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.cloud.api.ApiResponseGsonHelper;
2121
import com.cloud.api.ApiServer;
2222
import com.cloud.serializer.Param;
23+
import com.cloud.server.ManagementServerImpl;
2324
import com.cloud.user.Account;
2425
import com.cloud.utils.HttpUtils;
2526
import com.cloud.utils.encoding.URLEncoder;
@@ -171,9 +172,16 @@ private static String toXMLSerializedString(ResponseObject result, StringBuilder
171172
if (result != null && log != null) {
172173
StringBuilder sb = new StringBuilder();
173174
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
174-
sb.append("<").append(result.getResponseName()).append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\">");
175175
log.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
176-
log.append("<").append(result.getResponseName()).append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\">");
176+
177+
sb.append("<").append(result.getResponseName());
178+
log.append("<").append(result.getResponseName());
179+
if (ManagementServerImpl.exposeCloudStackVersionInApiXmlResponse.value()) {
180+
sb.append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\"");
181+
log.append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\"");
182+
}
183+
sb.append(">");
184+
log.append(">");
177185

178186
if (result instanceof ListResponse) {
179187
Integer count = ((ListResponse)result).getCount();

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
854854
static final ConfigKey<Integer> sshKeyLength = new ConfigKey<>("Advanced", Integer.class, "ssh.key.length", "2048", "Specifies custom SSH key length (bit)", true, ConfigKey.Scope.Global);
855855
static final ConfigKey<Boolean> humanReadableSizes = new ConfigKey<>("Advanced", Boolean.class, "display.human.readable.sizes", "true", "Enables outputting human readable byte sizes to logs and usage records.", false, ConfigKey.Scope.Global);
856856
public static final ConfigKey<String> customCsIdentifier = new ConfigKey<>("Advanced", String.class, "custom.cs.identifier", UUID.randomUUID().toString().split("-")[0].substring(4), "Custom identifier for the cloudstack installation", true, ConfigKey.Scope.Global);
857+
public static final ConfigKey<Boolean> exposeCloudStackVersionInApiXmlResponse = new ConfigKey<Boolean>("Advanced", Boolean.class, "expose.cloudstack.version.api.xml.response", "true", "Indicates whether ACS version should appear in the root element of an API XML response.", true, ConfigKey.Scope.Global);
858+
public static final ConfigKey<Boolean> exposeCloudStackVersionInApiListCapabilities = new ConfigKey<Boolean>("Advanced", Boolean.class, "expose.cloudstack.version.api.list.capabilities", "true", "Indicates whether ACS version should show in the listCapabilities API.", true, ConfigKey.Scope.Global);
859+
857860
private static final VirtualMachine.Type []systemVmTypes = { VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.ConsoleProxy};
858861
private static final List<HypervisorType> LIVE_MIGRATION_SUPPORTING_HYPERVISORS = List.of(HypervisorType.Hyperv, HypervisorType.KVM,
859862
HypervisorType.LXC, HypervisorType.Ovm, HypervisorType.Ovm3, HypervisorType.Simulator, HypervisorType.VMware, HypervisorType.XenServer);
@@ -4055,7 +4058,7 @@ public String getConfigComponentName() {
40554058

40564059
@Override
40574060
public ConfigKey<?>[] getConfigKeys() {
4058-
return new ConfigKey<?>[] {vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier};
4061+
return new ConfigKey<?>[] {exposeCloudStackVersionInApiXmlResponse, exposeCloudStackVersionInApiListCapabilities, vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier};
40594062
}
40604063

40614064
protected class EventPurgeTask extends ManagedContextRunnable {
@@ -4481,10 +4484,12 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
44814484

44824485
final Integer fsVmMinCpu = Integer.parseInt(_configDao.getValue("sharedfsvm.min.cpu.count"));
44834486
final Integer fsVmMinRam = Integer.parseInt(_configDao.getValue("sharedfsvm.min.ram.size"));
4487+
if (exposeCloudStackVersionInApiListCapabilities.value()) {
4488+
capabilities.put("cloudStackVersion", getVersion());
4489+
}
44844490

44854491
capabilities.put("securityGroupsEnabled", securityGroupsEnabled);
44864492
capabilities.put("userPublicTemplateEnabled", userPublicTemplateEnabled);
4487-
capabilities.put("cloudStackVersion", getVersion());
44884493
capabilities.put("supportELB", supportELB);
44894494
capabilities.put("projectInviteRequired", _projectMgr.projectInviteRequired());
44904495
capabilities.put("allowusercreateprojects", _projectMgr.allowUserToCreateProject());

0 commit comments

Comments
 (0)