Skip to content

Commit 10a386f

Browse files
committed
Add UUID field for LDAP configuration
1 parent f2d6356 commit 10a386f

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,10 @@ SET `cs`.`domain_id` = (
757757

758758
-- Re-apply VPC: update default network offering for vpc tier to conserve_mode=1 (#8309)
759759
UPDATE `cloud`.`network_offerings` SET conserve_mode = 1 WHERE name = 'DefaultIsolatedNetworkOfferingForVpcNetworks';
760+
761+
-- Move to 4.22
762+
-- Add uuid column to ldap_configuration table
763+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ldap_configuration', 'uuid', 'VARCHAR(40) NOT NULL');
764+
765+
-- Populate uuid for existing rows where uuid is NULL or empty
766+
UPDATE `cloud`.`ldap_configuration` SET uuid = UUID() WHERE uuid IS NULL OR uuid = '';

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
@EntityReference(value = LdapConfiguration.class)
2929
public class LdapConfigurationResponse extends BaseResponse {
30+
@SerializedName("id")
31+
@Param(description = "the ID of the LDAP configuration")
32+
private String id;
33+
3034
@SerializedName(ApiConstants.HOST_NAME)
3135
@Param(description = "name of the host running the ldap server")
3236
private String hostname;
@@ -53,9 +57,18 @@ public LdapConfigurationResponse(final String hostname, final int port) {
5357
setPort(port);
5458
}
5559

56-
public LdapConfigurationResponse(final String hostname, final int port, final String domainId) {
60+
public LdapConfigurationResponse(final String hostname, final int port, final String domainId, final String id) {
5761
this(hostname, port);
5862
setDomainId(domainId);
63+
setId(id);
64+
}
65+
66+
public String getId() {
67+
return id;
68+
}
69+
70+
public void setId(String id) {
71+
this.id = id;
5972
}
6073

6174
public String getHostname() {

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapConfigurationVO.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import org.apache.cloudstack.api.InternalIdentity;
2727

28+
import java.util.UUID;
29+
2830
@Entity
2931
@Table(name = "ldap_configuration")
3032
public class LdapConfigurationVO implements InternalIdentity {
@@ -36,19 +38,24 @@ public class LdapConfigurationVO implements InternalIdentity {
3638
@Column(name = "id")
3739
private Long id;
3840

41+
@Column(name = "uuid")
42+
private String uuid;
43+
3944
@Column(name = "port")
4045
private int port;
4146

4247
@Column(name = "domain_id")
4348
private Long domainId;
4449

4550
public LdapConfigurationVO() {
51+
this.uuid = UUID.randomUUID().toString();
4652
}
4753

4854
public LdapConfigurationVO(final String hostname, final int port, final Long domainId) {
4955
this.hostname = hostname;
5056
this.port = port;
5157
this.domainId = domainId;
58+
this.uuid = UUID.randomUUID().toString();
5259
}
5360

5461
public String getHostname() {
@@ -60,6 +67,10 @@ public long getId() {
6067
return id;
6168
}
6269

70+
public String getUuid() {
71+
return uuid;
72+
}
73+
6374
public int getPort() {
6475
return port;
6576
}

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public LdapConfigurationResponse createLdapConfigurationResponse(final LdapConfi
240240
domainUuid = domain.getUuid();
241241
}
242242
}
243-
return new LdapConfigurationResponse(configuration.getHostname(), configuration.getPort(), domainUuid);
243+
return new LdapConfigurationResponse(configuration.getHostname(), configuration.getPort(), domainUuid, configuration.getUuid());
244244
}
245245

246246
@Override

0 commit comments

Comments
 (0)