This is an automated email from the ASF dual-hosted git repository.

pearl11594 pushed a commit to branch add-uuid-ldap-conf
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 10a386f27b4133067bc99eba576cc9075b1ba41b
Author: Pearl Dsilva <[email protected]>
AuthorDate: Mon Aug 18 09:30:13 2025 -0400

    Add UUID field for LDAP configuration
---
 .../main/resources/META-INF/db/schema-42010to42100.sql    |  7 +++++++
 .../api/response/LdapConfigurationResponse.java           | 15 ++++++++++++++-
 .../org/apache/cloudstack/ldap/LdapConfigurationVO.java   | 11 +++++++++++
 .../java/org/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 167dd92730c..206e2080024 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 744c73d8e77..7fe068fb549 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 @@ import org.apache.cloudstack.ldap.LdapConfiguration;
 
 @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 class LdapConfigurationResponse extends BaseResponse {
         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 ee9f0930c47..9381297c21f 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 javax.persistence.Table;
 
 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 class LdapConfigurationVO implements InternalIdentity 
{
         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 05b8578bb42..b51907f005f 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 class LdapManagerImpl extends ComponentLifecycleBase 
implements LdapManag
                 domainUuid = domain.getUuid();
             }
         }
-        return new LdapConfigurationResponse(configuration.getHostname(), 
configuration.getPort(), domainUuid);
+        return new LdapConfigurationResponse(configuration.getHostname(), 
configuration.getPort(), domainUuid, configuration.getUuid());
     }
 
     @Override

Reply via email to