From 10a386f27b4133067bc99eba576cc9075b1ba41b Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Mon, 18 Aug 2025 09:30:13 -0400 Subject: [PATCH] Add UUID field for LDAP configuration --- .../resources/META-INF/db/schema-42010to42100.sql | 7 +++++++ .../api/response/LdapConfigurationResponse.java | 15 ++++++++++++++- .../cloudstack/ldap/LdapConfigurationVO.java | 11 +++++++++++ .../apache/cloudstack/ldap/LdapManagerImpl.java | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql index 167dd92730cc..206e2080024d 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql @@ -757,3 +757,10 @@ SET `cs`.`domain_id` = ( -- Re-apply VPC: update default network offering for vpc tier to conserve_mode=1 (#8309) UPDATE `cloud`.`network_offerings` SET conserve_mode = 1 WHERE name = 'DefaultIsolatedNetworkOfferingForVpcNetworks'; + +-- Move to 4.22 +-- Add uuid column to ldap_configuration table +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ldap_configuration', 'uuid', 'VARCHAR(40) NOT NULL'); + +-- Populate uuid for existing rows where uuid is NULL or empty +UPDATE `cloud`.`ldap_configuration` SET uuid = UUID() WHERE uuid IS NULL OR uuid = ''; diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java index 744c73d8e774..7fe068fb549d 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java @@ -27,6 +27,10 @@ @EntityReference(value = LdapConfiguration.class) public class LdapConfigurationResponse extends BaseResponse { + @SerializedName("id") + @Param(description = "the ID of the LDAP configuration") + private String id; + @SerializedName(ApiConstants.HOST_NAME) @Param(description = "name of the host running the ldap server") private String hostname; @@ -53,9 +57,18 @@ public LdapConfigurationResponse(final String hostname, final int port) { setPort(port); } - public LdapConfigurationResponse(final String hostname, final int port, final String domainId) { + public LdapConfigurationResponse(final String hostname, final int port, final String domainId, final String id) { this(hostname, port); setDomainId(domainId); + setId(id); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; } public String getHostname() { diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapConfigurationVO.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapConfigurationVO.java index ee9f0930c47f..9381297c21f4 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapConfigurationVO.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapConfigurationVO.java @@ -25,6 +25,8 @@ import org.apache.cloudstack.api.InternalIdentity; +import java.util.UUID; + @Entity @Table(name = "ldap_configuration") public class LdapConfigurationVO implements InternalIdentity { @@ -36,6 +38,9 @@ public class LdapConfigurationVO implements InternalIdentity { @Column(name = "id") private Long id; + @Column(name = "uuid") + private String uuid; + @Column(name = "port") private int port; @@ -43,12 +48,14 @@ public class LdapConfigurationVO implements InternalIdentity { private Long domainId; public LdapConfigurationVO() { + this.uuid = UUID.randomUUID().toString(); } public LdapConfigurationVO(final String hostname, final int port, final Long domainId) { this.hostname = hostname; this.port = port; this.domainId = domainId; + this.uuid = UUID.randomUUID().toString(); } public String getHostname() { @@ -60,6 +67,10 @@ public long getId() { return id; } + public String getUuid() { + return uuid; + } + public int getPort() { return port; } diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java index 05b8578bb420..b51907f005ff 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java @@ -240,7 +240,7 @@ public LdapConfigurationResponse createLdapConfigurationResponse(final LdapConfi domainUuid = domain.getUuid(); } } - return new LdapConfigurationResponse(configuration.getHostname(), configuration.getPort(), domainUuid); + return new LdapConfigurationResponse(configuration.getHostname(), configuration.getPort(), domainUuid, configuration.getUuid()); } @Override