Skip to content

Commit 2b381c7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into vol-usage
2 parents 072645b + cd12fa5 commit 2b381c7

File tree

14 files changed

+133
-34
lines changed

14 files changed

+133
-34
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('router_health_check', 'check_result', '
2626
-- Increase length of scripts_version column to 128 due to md5sum to sha512sum change
2727
CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('cloud.domain_router', 'scripts_version', 'scripts_version', 'VARCHAR(128)');
2828

29+
-- Add uuid column to ldap_configuration table
30+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ldap_configuration', 'uuid', 'VARCHAR(40) NOT NULL');
31+
32+
-- Populate uuid for existing rows where uuid is NULL or empty
33+
UPDATE `cloud`.`ldap_configuration` SET uuid = UUID() WHERE uuid IS NULL OR uuid = '';
34+
2935
-- Add vm_id column to usage_event table for volume usage events
3036
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.usage_event','vm_id', 'bigint UNSIGNED NULL COMMENT "VM ID associated with volume usage events"');
3137
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_event','vm_id', 'bigint UNSIGNED NULL COMMENT "VM ID associated with volume usage events"');

plugins/hypervisors/external/src/main/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisioner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ public class ExternalPathPayloadProvisioner extends ManagerBase implements Exter
103103
BASE_EXTERNAL_PROVISIONER_SCRIPTS_DIR + "/provisioner.sh";
104104

105105
private static final String PROPERTIES_FILE = "server.properties";
106+
private static final String EXTENSIONS = "extensions";
106107
private static final String EXTENSIONS_DEPLOYMENT_MODE_NAME = "extensions.deployment.mode";
107108
private static final String EXTENSIONS_DIRECTORY_PROD = "/usr/share/cloudstack-management/extensions";
108-
private static final String EXTENSIONS_DATA_DIRECTORY_PROD = "/var/lib/cloudstack/management/extensions";
109-
private static final String EXTENSIONS_DIRECTORY_DEV = "extensions";
109+
private static final String EXTENSIONS_DATA_DIRECTORY_PROD = System.getProperty("user.home") + File.separator + EXTENSIONS;
110+
private static final String EXTENSIONS_DIRECTORY_DEV = EXTENSIONS;
110111
private static final String EXTENSIONS_DATA_DIRECTORY_DEV = "client/target/extensions-data";
111112

112113
@Inject

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapDeleteConfigurationCmd.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ public class LdapDeleteConfigurationCmd extends BaseCmd {
4040
@Inject
4141
private LdapManager _ldapManager;
4242

43+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = false, entityType = LdapConfigurationResponse.class, description = "ID of the LDAP configuration")
44+
private Long id;
4345

44-
@Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, required = true, description = "Hostname")
46+
@Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, description = "Hostname")
4547
private String hostname;
4648

4749
@Parameter(name = ApiConstants.PORT, type = CommandType.INTEGER, required = false, description = "port")
@@ -71,6 +73,10 @@ public Long getDomainId() {
7173
return domainId;
7274
}
7375

76+
public Long getId() {
77+
return id;
78+
}
79+
7480
@Override
7581
public void execute() throws ServerApiException {
7682
try {

plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapListConfigurationCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class LdapListConfigurationCmd extends BaseListCmd {
5353
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = false, entityType = DomainResponse.class, description = "linked domain")
5454
private Long domainId;
5555

56+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LdapConfigurationResponse.class, description = "list ldap configuration by ID; when passed, all other parameters are ignored")
57+
private Long id;
58+
5659
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "If set to true, "
5760
+ " and no domainid specified, list all LDAP configurations irrespective of the linked domain", since = "4.13.2")
5861
private Boolean listAll;
@@ -120,6 +123,10 @@ public void setDomainId(final Long domainId) {
120123
this.domainId = domainId;
121124
}
122125

126+
public Long getId() {
127+
return id;
128+
}
129+
123130
public boolean listAll() {
124131
return listAll != null && listAll;
125132
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323

2424
import com.cloud.serializer.Param;
2525
import org.apache.cloudstack.api.EntityReference;
26-
import org.apache.cloudstack.ldap.LdapConfiguration;
26+
import org.apache.cloudstack.ldap.LdapConfigurationVO;
2727

28-
@EntityReference(value = LdapConfiguration.class)
28+
@EntityReference(value = LdapConfigurationVO.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: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,40 @@
2323
import javax.persistence.Id;
2424
import javax.persistence.Table;
2525

26+
import org.apache.cloudstack.api.Identity;
2627
import org.apache.cloudstack.api.InternalIdentity;
2728

29+
import java.util.UUID;
30+
2831
@Entity
2932
@Table(name = "ldap_configuration")
30-
public class LdapConfigurationVO implements InternalIdentity {
31-
@Column(name = "hostname")
32-
private String hostname;
33-
33+
public class LdapConfigurationVO implements Identity, InternalIdentity {
3434
@Id
3535
@GeneratedValue(strategy = GenerationType.IDENTITY)
3636
@Column(name = "id")
3737
private Long id;
3838

39+
@Column(name = "hostname")
40+
private String hostname;
41+
42+
@Column(name = "uuid")
43+
private String uuid;
44+
3945
@Column(name = "port")
4046
private int port;
4147

4248
@Column(name = "domain_id")
4349
private Long domainId;
4450

4551
public LdapConfigurationVO() {
52+
this.uuid = UUID.randomUUID().toString();
4653
}
4754

4855
public LdapConfigurationVO(final String hostname, final int port, final Long domainId) {
4956
this.hostname = hostname;
5057
this.port = port;
5158
this.domainId = domainId;
59+
this.uuid = UUID.randomUUID().toString();
5260
}
5361

5462
public String getHostname() {
@@ -60,6 +68,10 @@ public long getId() {
6068
return id;
6169
}
6270

71+
public String getUuid() {
72+
return uuid;
73+
}
74+
6375
public int getPort() {
6476
return port;
6577
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.apache.cloudstack.ldap.dao.LdapConfigurationDao;
5353
import org.apache.cloudstack.ldap.dao.LdapTrustMapDao;
5454
import org.apache.commons.lang.Validate;
55+
import org.apache.commons.lang3.StringUtils;
5556
import org.springframework.stereotype.Component;
5657

5758
import com.cloud.domain.DomainVO;
@@ -240,7 +241,7 @@ public LdapConfigurationResponse createLdapConfigurationResponse(final LdapConfi
240241
domainUuid = domain.getUuid();
241242
}
242243
}
243-
return new LdapConfigurationResponse(configuration.getHostname(), configuration.getPort(), domainUuid);
244+
return new LdapConfigurationResponse(configuration.getHostname(), configuration.getPort(), domainUuid, configuration.getUuid());
244245
}
245246

246247
@Override
@@ -257,6 +258,19 @@ public LdapUserResponse createLdapUserResponse(final LdapUser user) {
257258

258259
@Override
259260
public LdapConfigurationResponse deleteConfiguration(final LdapDeleteConfigurationCmd cmd) throws InvalidParameterValueException {
261+
Long id = cmd.getId();
262+
String hostname = cmd.getHostname();
263+
if (id == null && StringUtils.isEmpty(hostname)) {
264+
throw new InvalidParameterValueException("Either id or hostname must be specified");
265+
}
266+
if (id != null) {
267+
final LdapConfigurationVO config = _ldapConfigurationDao.findById(cmd.getId());
268+
if (config != null) {
269+
_ldapConfigurationDao.remove(config.getId());
270+
return createLdapConfigurationResponse(config);
271+
}
272+
throw new InvalidParameterValueException("Cannot find configuration with id " + id);
273+
}
260274
return deleteConfigurationInternal(cmd.getHostname(), cmd.getPort(), cmd.getDomainId());
261275
}
262276

@@ -377,7 +391,8 @@ public Pair<List<? extends LdapConfigurationVO>, Integer> listConfigurations(fin
377391
final int port = cmd.getPort();
378392
final Long domainId = cmd.getDomainId();
379393
final boolean listAll = cmd.listAll();
380-
final Pair<List<LdapConfigurationVO>, Integer> result = _ldapConfigurationDao.searchConfigurations(hostname, port, domainId, listAll);
394+
final Long id = cmd.getId();
395+
final Pair<List<LdapConfigurationVO>, Integer> result = _ldapConfigurationDao.searchConfigurations(id, hostname, port, domainId, listAll);
381396
return new Pair<List<? extends LdapConfigurationVO>, Integer>(result.first(), result.second());
382397
}
383398

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ public interface LdapConfigurationDao extends GenericDao<LdapConfigurationVO, Lo
4141

4242
Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(String hostname, int port, Long domainId);
4343

44-
Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(String hostname, int port, Long domainId, boolean listAll);
44+
Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(Long id, String hostname, int port, Long domainId, boolean listAll);
4545
}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public LdapConfigurationDaoImpl() {
4848
listGlobalConfigurationsSearch.done();
4949

5050
listDomainConfigurationsSearch = createSearchBuilder();
51+
listDomainConfigurationsSearch.and("id", listDomainConfigurationsSearch.entity().getId(), SearchCriteria.Op.EQ);
5152
listDomainConfigurationsSearch.and("hostname", listDomainConfigurationsSearch.entity().getHostname(), Op.EQ);
5253
listDomainConfigurationsSearch.and("port", listDomainConfigurationsSearch.entity().getPort(), Op.EQ);
5354
listDomainConfigurationsSearch.and("domain_id", listDomainConfigurationsSearch.entity().getDomainId(), Op.EQ);
@@ -63,31 +64,35 @@ public LdapConfigurationVO findByHostname(final String hostname) {
6364

6465
@Override
6566
public LdapConfigurationVO find(String hostname, int port, Long domainId) {
66-
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, false);
67+
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(null, hostname, port, domainId, false);
6768
return findOneBy(sc);
6869
}
6970

7071
@Override
7172
public LdapConfigurationVO find(String hostname, int port, Long domainId, boolean listAll) {
72-
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, listAll);
73+
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(null, hostname, port, domainId, listAll);
7374
return findOneBy(sc);
7475
}
7576

7677
@Override
7778
public Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(final String hostname, final int port, final Long domainId) {
78-
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, false);
79+
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(null, hostname, port, domainId, false);
7980
return searchAndCount(sc, null);
8081
}
8182

8283
@Override
83-
public Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(final String hostname, final int port, final Long domainId, final boolean listAll) {
84-
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, listAll);
84+
public Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(final Long id, final String hostname, final int port, final Long domainId, final boolean listAll) {
85+
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(id, hostname, port, domainId, listAll);
8586
return searchAndCount(sc, null);
8687
}
8788

88-
private SearchCriteria<LdapConfigurationVO> getSearchCriteria(String hostname, int port, Long domainId,boolean listAll) {
89+
private SearchCriteria<LdapConfigurationVO> getSearchCriteria(Long id, String hostname, int port, Long domainId,boolean listAll) {
8990
SearchCriteria<LdapConfigurationVO> sc;
90-
if (domainId != null) {
91+
if (id != null) {
92+
// If id is present, ignore all other parameters
93+
sc = listDomainConfigurationsSearch.create();
94+
sc.setParameters("id", id);
95+
} else if (domainId != null) {
9196
// If domainid is present, ignore listall
9297
sc = listDomainConfigurationsSearch.create();
9398
sc.setParameters("domain_id", domainId);

scripts/vm/hypervisor/kvm/gpudiscovery.sh

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,40 @@
324324
# "used_by_vm": null
325325
# }
326326
# ]
327-
# }
327+
# },
328+
# {
329+
# "pci_address":"05:00.0",
330+
# "vendor_id":"1002",
331+
# "device_id":"74a5",
332+
# "vendor":"Advanced Micro Devices, Inc. [AMD/ATI]",
333+
# "device":"Aqua Vanjaram [Instinct MI325X]",
334+
# "driver":"amdgpu",
335+
# "pci_class":"Processing accelerators [1200]",
336+
# "iommu_group":"null",
337+
# "pci_root":"0000:05:00.0",
338+
# "numa_node":-1,
339+
# "sriov_totalvfs":0,
340+
# "sriov_numvfs":0,
341+
# "max_instances":null,
342+
# "video_ram":null,
343+
# "max_heads":null,
344+
# "max_resolution_x":null,
345+
# "max_resolution_y":null,
346+
#
347+
# "full_passthrough": {
348+
# "enabled":1,
349+
# "libvirt_address": {
350+
# "domain":"0x0000",
351+
# "bus":"0x05",
352+
# "slot":"0x00",
353+
# "function":"0x0"
354+
# },
355+
# "used_by_vm":null
356+
# },
357+
358+
# "vgpu_instances":[],
359+
# "vf_instances":[]
360+
# }
328361
# ]
329362
# }
330363
#
@@ -716,7 +749,7 @@ for LINE in "${LINES[@]}"; do
716749
fi
717750

718751
# Only process GPU classes (3D controller)
719-
if [[ ! "$PCI_CLASS" =~ (3D\ controller) ]]; then
752+
if [[ ! "$PCI_CLASS" =~ (3D\ controller|Processing\ accelerators) ]]; then
720753
continue
721754
fi
722755

0 commit comments

Comments
 (0)