Skip to content

Add UUID field for LDAP configuration #11462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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 @@ -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 = '';
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import org.apache.cloudstack.api.InternalIdentity;

import java.util.UUID;

@Entity
@Table(name = "ldap_configuration")
public class LdapConfigurationVO implements InternalIdentity {
Expand All @@ -36,19 +38,24 @@ public class LdapConfigurationVO implements InternalIdentity {
@Column(name = "id")
private Long id;

@Column(name = "uuid")
private String uuid;

@Column(name = "port")
private int port;

@Column(name = "domain_id")
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();
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn’t this be read from the DB somehow?

}

public String getHostname() {
Expand All @@ -60,6 +67,10 @@ public long getId() {
return id;
}

public String getUuid() {
return uuid;
}

public int getPort() {
return port;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading