Skip to content

Commit 92a3dcd

Browse files
authored
Merge branch '4.20' into ui-improv
2 parents e7ffd8c + ac19379 commit 92a3dcd

File tree

27 files changed

+288
-86
lines changed

27 files changed

+288
-86
lines changed

engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public interface ProjectAccountDao extends GenericDao<ProjectAccountVO, Long> {
4747

4848
void removeAccountFromProjects(long accountId);
4949

50+
void removeUserFromProjects(long userId);
51+
5052
boolean canUserModifyProject(long projectId, long accountId, long userId);
5153

5254
List<ProjectAccountVO> listUsersOrAccountsByRole(long id);

engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDaoImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ public void removeAccountFromProjects(long accountId) {
192192
}
193193
}
194194

195+
@Override
196+
public void removeUserFromProjects(long userId) {
197+
SearchCriteria<ProjectAccountVO> sc = AllFieldsSearch.create();
198+
sc.setParameters("userId", userId);
199+
200+
int removedCount = remove(sc);
201+
if (removedCount > 0) {
202+
logger.debug(String.format("Removed user [%s] from %s project(s).", userId, removedCount));
203+
}
204+
}
205+
195206
@Override
196207
public boolean canUserModifyProject(long projectId, long accountId, long userId) {
197208
SearchCriteria<ProjectAccountVO> sc = AllFieldsSearch.create();

engine/schema/src/main/java/com/cloud/storage/VolumeVO.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,34 @@ public class VolumeVO implements Volume {
4848
@TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1)
4949
@GeneratedValue(strategy = GenerationType.TABLE)
5050
@Column(name = "id")
51-
long id;
51+
private long id;
5252

5353
@Column(name = "last_id")
5454
private long lastId;
5555

5656
@Column(name = "name")
57-
String name;
57+
private String name;
5858

5959
@Column(name = "pool_id")
60-
Long poolId;
60+
private Long poolId;
6161

6262
@Column(name = "last_pool_id")
63-
Long lastPoolId;
63+
private Long lastPoolId;
6464

6565
@Column(name = "account_id")
66-
long accountId;
66+
private long accountId;
6767

6868
@Column(name = "domain_id")
69-
long domainId;
69+
private long domainId;
7070

7171
@Column(name = "instance_id")
72-
Long instanceId = null;
72+
private Long instanceId = null;
7373

7474
@Column(name = "device_id")
75-
Long deviceId = null;
75+
private Long deviceId = null;
7676

7777
@Column(name = "size")
78-
Long size;
78+
private Long size;
7979

8080
@Column(name = "min_iops")
8181
private Long minIops;
@@ -84,50 +84,50 @@ public class VolumeVO implements Volume {
8484
private Long maxIops;
8585

8686
@Column(name = "folder")
87-
String folder;
87+
private String folder;
8888

8989
@Column(name = "path")
90-
String path;
90+
private String path;
9191

9292
@Column(name = "pod_id")
93-
Long podId;
93+
private Long podId;
9494

9595
@Column(name = "created")
96-
Date created;
96+
private Date created;
9797

9898
@Column(name = "attached")
9999
@Temporal(value = TemporalType.TIMESTAMP)
100-
Date attached;
100+
private Date attached;
101101

102102
@Column(name = "data_center_id")
103-
long dataCenterId;
103+
private long dataCenterId;
104104

105105
@Column(name = "host_ip")
106-
String hostip;
106+
private String hostIp;
107107

108108
@Column(name = "disk_offering_id")
109-
long diskOfferingId;
109+
private long diskOfferingId;
110110

111111
@Column(name = "template_id")
112-
Long templateId;
112+
private Long templateId;
113113

114114
@Column(name = "first_snapshot_backup_uuid")
115-
String firstSnapshotBackupUuid;
115+
private String firstSnapshotBackupUuid;
116116

117117
@Column(name = "volume_type")
118118
@Enumerated(EnumType.STRING)
119-
Type volumeType = Volume.Type.UNKNOWN;
119+
private Type volumeType = Volume.Type.UNKNOWN;
120120

121121
@Column(name = "pool_type")
122122
@Convert(converter = StoragePoolTypeConverter.class)
123-
StoragePoolType poolType;
123+
private StoragePoolType poolType;
124124

125125
@Column(name = GenericDao.REMOVED_COLUMN)
126-
Date removed;
126+
private Date removed;
127127

128128
@Column(name = "updated")
129129
@Temporal(value = TemporalType.TIMESTAMP)
130-
Date updated;
130+
private Date updated;
131131

132132
@Column(name = "update_count", updatable = true, nullable = false)
133133
protected long updatedCount; // This field should be updated everytime the
@@ -136,17 +136,17 @@ public class VolumeVO implements Volume {
136136
// dao code.
137137

138138
@Column(name = "recreatable")
139-
boolean recreatable;
139+
private boolean recreatable;
140140

141141
@Column(name = "state")
142142
@Enumerated(value = EnumType.STRING)
143143
private State state;
144144

145145
@Column(name = "chain_info", length = 65535)
146-
String chainInfo;
146+
private String chainInfo;
147147

148148
@Column(name = "uuid")
149-
String uuid;
149+
private String uuid;
150150

151151
@Column(name = "format")
152152
private Storage.ImageFormat format;
@@ -171,7 +171,7 @@ public class VolumeVO implements Volume {
171171

172172
@Transient
173173
// @Column(name="reservation")
174-
String reservationId;
174+
private String reservationId;
175175

176176
@Column(name = "hv_ss_reserve")
177177
private Integer hypervisorSnapshotReserve;
@@ -431,11 +431,11 @@ public void setPath(String path) {
431431
}
432432

433433
public String getHostIp() {
434-
return hostip;
434+
return hostIp;
435435
}
436436

437437
public void setHostIp(String hostip) {
438-
this.hostip = hostip;
438+
this.hostIp = hostip;
439439
}
440440

441441
public void setPodId(Long podId) {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.upgrade.dao;
18+
19+
import com.cloud.utils.exception.CloudRuntimeException;
20+
21+
import java.io.InputStream;
22+
import java.sql.Connection;
23+
24+
public class Upgrade41910to41920 implements DbUpgrade {
25+
26+
@Override
27+
public String[] getUpgradableVersionRange() {
28+
return new String[]{"4.19.1.0", "4.19.2.0"};
29+
}
30+
31+
@Override
32+
public String getUpgradedVersion() {
33+
return "4.19.2.0";
34+
}
35+
36+
@Override
37+
public boolean supportsRollingUpgrade() {
38+
return false;
39+
}
40+
41+
@Override
42+
public InputStream[] getPrepareScripts() {
43+
final String scriptFile = "META-INF/db/schema-41910to41920.sql";
44+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
45+
if (script == null) {
46+
throw new CloudRuntimeException("Unable to find " + scriptFile);
47+
}
48+
49+
return new InputStream[]{script};
50+
}
51+
52+
@Override
53+
public void performDataMigration(Connection conn) {
54+
}
55+
56+
@Override
57+
public InputStream[] getCleanupScripts() {
58+
final String scriptFile = "META-INF/db/schema-41910to41920-cleanup.sql";
59+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
60+
if (script == null) {
61+
throw new CloudRuntimeException("Unable to find " + scriptFile);
62+
}
63+
64+
return new InputStream[]{script};
65+
}
66+
}

engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,3 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user_data', 'removed', 'datetime COM
7070
UPDATE `cloud`.`configuration` SET
7171
`options` = 'FirstFitRouting,RandomAllocator,TestingAllocator,FirstFitAllocator,RecreateHostAllocator'
7272
WHERE `name` = 'host.allocators.order';
73-
74-
-- Add last_id to the volumes table
75-
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('volumes','last_id', 'bigint(20) unsigned DEFAULT NULL');
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade cleanup from 4.19.1.0 to 4.19.2.0
20+
--;
21+
22+
-- Delete `project_account` entries for users that were removed
23+
DELETE FROM `cloud`.`project_account` WHERE `user_id` IN (SELECT `id` FROM `cloud`.`user` WHERE `removed`);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade from 4.19.1.0 to 4.19.2.0
20+
--;
21+
22+
-- Add last_id to the volumes table
23+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.volumes', 'last_id', 'bigint(20) unsigned DEFAULT NULL');

engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ CALL `cloud`.`IDEMPOTENT_DROP_FOREIGN_KEY`('cloud.mshost_peer','fk_mshost_peer__
3737
CALL `cloud`.`IDEMPOTENT_DROP_INDEX`('i_mshost_peer__owner_peer_runid','mshost_peer');
3838
CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.mshost_peer', 'i_mshost_peer__owner_peer', '(owner_mshost, peer_mshost)');
3939
CALL `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`('cloud.mshost_peer', 'fk_mshost_peer__owner_mshost', '(owner_mshost)', '`mshost`(`id`)');
40+
41+
-- Add last_id to the volumes table
42+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.volumes', 'last_id', 'bigint(20) unsigned DEFAULT NULL');

framework/db/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ private void migrateTemplateDeployAsIsDetails(Connection conn) throws SQLExcepti
656656
String sqlTemplateDeployAsIsDetails = "SELECT template_deploy_as_is_details.value " +
657657
"FROM template_deploy_as_is_details JOIN vm_instance " +
658658
"WHERE template_deploy_as_is_details.template_id = vm_instance.vm_template_id " +
659-
"vm_instance.id = %s AND template_deploy_as_is_details.name = '%s' LIMIT 1";
659+
"AND vm_instance.id = %s AND template_deploy_as_is_details.name = '%s' LIMIT 1";
660660
try (PreparedStatement selectPstmt = conn.prepareStatement("SELECT id, vm_id, name, value FROM user_vm_deploy_as_is_details");
661661
ResultSet rs = selectPstmt.executeQuery();
662662
PreparedStatement updatePstmt = conn.prepareStatement("UPDATE user_vm_deploy_as_is_details SET value=? WHERE id=?")

plugins/user-authenticators/saml2/src/main/java/org/apache/cloudstack/saml/SAMLUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ public static void setupSamlUserCookies(final LoginCmdResponse loginResponse, fi
321321
String sessionKeyCookie = String.format("%s=%s;Domain=%s;Path=%s;%s", ApiConstants.SESSIONKEY, loginResponse.getSessionKey(), domain, path, sameSite);
322322
LOGGER.debug("Adding sessionkey cookie to response: " + sessionKeyCookie);
323323
resp.addHeader("SET-COOKIE", sessionKeyCookie);
324+
resp.addHeader("SET-COOKIE", String.format("%s=%s;HttpOnly;Path=/client/api;%s", ApiConstants.SESSIONKEY, loginResponse.getSessionKey(), sameSite));
324325
}
325326

326327
/**

0 commit comments

Comments
 (0)