Skip to content

Commit 8b71117

Browse files
authored
Merge branch '4.22' into linstor-nas
2 parents 33f73b0 + 7048944 commit 8b71117

File tree

48 files changed

+483
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+483
-409
lines changed

.github/workflows/merge-conflict-checker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
name: "PR Merge Conflict Check"
1919
on:
2020
push:
21-
pull_request_target:
22-
types: [synchronize]
21+
pull_request:
22+
types: [opened, synchronize, reopened]
2323

2424
permissions: # added using https://github.com/step-security/secure-workflows
2525
contents: read

api/src/main/java/org/apache/cloudstack/api/ApiServerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,7 @@ public ResponseObject loginUser(HttpSession session, String username, String pas
4949

5050
boolean resetPassword(UserAccount userAccount, String token, String password);
5151

52+
String getDomainId(Map<String, Object[]> params);
53+
5254
boolean isPostRequestsAndTimestampsEnforced();
5355
}

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd {
4646
@Parameter(name = ApiConstants.GATEWAY_ID,
4747
type = CommandType.UUID,
4848
entityType = PrivateGatewayResponse.class,
49-
required = true,
5049
description = "The gateway ID we are creating static route for. Mutually exclusive with the nexthop parameter")
5150
private Long gatewayId;
5251

core/src/main/java/com/cloud/agent/api/ModifyStoragePoolAnswer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes,
4646
templateInfo = tInfo;
4747
}
4848

49+
public ModifyStoragePoolAnswer(final Command command, final boolean success, final String details) {
50+
super(command, success, details);
51+
}
52+
4953
public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, boolean success, String details) {
5054
super(cmd, success, details);
5155
}

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,8 @@ public void prepareAllNicsForMigration(final VirtualMachineProfile vm, final Dep
23262326
for (final NetworkElement element : networkElements) {
23272327
if (providersToImplement.contains(element.getProvider())) {
23282328
if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
2329-
throw new CloudRuntimeException(String.format("Service provider %s either doesn't exist or is not enabled in physical network: %s", element.getProvider().getName(), _physicalNetworkDao.findById(network.getPhysicalNetworkId())));
2329+
throw new CloudRuntimeException(String.format("Service provider %s either doesn't exist or is not enabled in physical network: %s",
2330+
element.getProvider().getName(), _physicalNetworkDao.findById(network.getPhysicalNetworkId())));
23302331
}
23312332
if (element instanceof NetworkMigrationResponder) {
23322333
if (!((NetworkMigrationResponder) element).prepareMigration(profile, network, vm, dest, context)) {
@@ -2633,6 +2634,10 @@ && isDhcpAccrossMultipleSubnetsSupported(dhcpServiceProvider)) {
26332634

26342635
final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
26352636
guru.deallocate(network, profile, vm);
2637+
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Create) {
2638+
applyProfileToNicForRelease(nic, profile);
2639+
_nicDao.update(nic.getId(), nic);
2640+
}
26362641
if (BooleanUtils.isNotTrue(preserveNics)) {
26372642
_nicDao.remove(nic.getId());
26382643
}

engine/schema/src/main/java/com/cloud/user/UserVO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public UserVO() {
123123
}
124124

125125
public UserVO(long id) {
126+
this();
126127
this.id = id;
127-
this.uuid = UUID.randomUUID().toString();
128128
}
129129

130130
public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, Source source) {

engine/schema/src/main/java/com/cloud/user/dao/AccountDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121

2222
import com.cloud.user.Account;
2323
import com.cloud.user.AccountVO;
24-
import com.cloud.user.User;
2524
import com.cloud.utils.Pair;
2625
import com.cloud.utils.db.Filter;
2726
import com.cloud.utils.db.GenericDao;
2827

2928
public interface AccountDao extends GenericDao<AccountVO, Long> {
30-
Pair<User, Account> findUserAccountByApiKey(String apiKey);
3129

3230
List<AccountVO> findAccountsLike(String accountName);
3331

engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717
package com.cloud.user.dao;
1818

19-
import java.sql.PreparedStatement;
20-
import java.sql.ResultSet;
2119
import java.util.Date;
2220
import java.util.List;
2321

@@ -27,24 +25,17 @@
2725
import com.cloud.user.Account;
2826
import com.cloud.user.Account.State;
2927
import com.cloud.user.AccountVO;
30-
import com.cloud.user.User;
31-
import com.cloud.user.UserVO;
3228
import com.cloud.utils.Pair;
33-
import com.cloud.utils.crypt.DBEncryptionUtil;
3429
import com.cloud.utils.db.Filter;
3530
import com.cloud.utils.db.GenericDaoBase;
3631
import com.cloud.utils.db.GenericSearchBuilder;
3732
import com.cloud.utils.db.SearchBuilder;
3833
import com.cloud.utils.db.SearchCriteria;
3934
import com.cloud.utils.db.SearchCriteria.Func;
4035
import com.cloud.utils.db.SearchCriteria.Op;
41-
import com.cloud.utils.db.TransactionLegacy;
4236

4337
@Component
4438
public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao {
45-
private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, u.api_key_access, "
46-
+ "a.id, a.account_name, a.type, a.role_id, a.domain_id, a.state, a.api_key_access " + "FROM `cloud`.`user` u, `cloud`.`account` a "
47-
+ "WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL";
4839

4940
protected final SearchBuilder<AccountVO> AllFieldsSearch;
5041
protected final SearchBuilder<AccountVO> AccountTypeSearch;
@@ -132,51 +123,6 @@ public List<AccountVO> findCleanupsForDisabledAccounts() {
132123
return listBy(sc);
133124
}
134125

135-
@Override
136-
public Pair<User, Account> findUserAccountByApiKey(String apiKey) {
137-
TransactionLegacy txn = TransactionLegacy.currentTxn();
138-
PreparedStatement pstmt = null;
139-
Pair<User, Account> userAcctPair = null;
140-
try {
141-
String sql = FIND_USER_ACCOUNT_BY_API_KEY;
142-
pstmt = txn.prepareAutoCloseStatement(sql);
143-
pstmt.setString(1, apiKey);
144-
ResultSet rs = pstmt.executeQuery();
145-
// TODO: make sure we don't have more than 1 result? ApiKey had better be unique
146-
if (rs.next()) {
147-
User u = new UserVO(rs.getLong(1));
148-
u.setUsername(rs.getString(2));
149-
u.setAccountId(rs.getLong(3));
150-
u.setSecretKey(DBEncryptionUtil.decrypt(rs.getString(4)));
151-
u.setState(State.getValueOf(rs.getString(5)));
152-
boolean apiKeyAccess = rs.getBoolean(6);
153-
if (rs.wasNull()) {
154-
u.setApiKeyAccess(null);
155-
} else {
156-
u.setApiKeyAccess(apiKeyAccess);
157-
}
158-
159-
AccountVO a = new AccountVO(rs.getLong(7));
160-
a.setAccountName(rs.getString(8));
161-
a.setType(Account.Type.getFromValue(rs.getInt(9)));
162-
a.setRoleId(rs.getLong(10));
163-
a.setDomainId(rs.getLong(11));
164-
a.setState(State.getValueOf(rs.getString(12)));
165-
apiKeyAccess = rs.getBoolean(13);
166-
if (rs.wasNull()) {
167-
a.setApiKeyAccess(null);
168-
} else {
169-
a.setApiKeyAccess(apiKeyAccess);
170-
}
171-
172-
userAcctPair = new Pair<User, Account>(u, a);
173-
}
174-
} catch (Exception e) {
175-
logger.warn("Exception finding user/acct by api key: " + apiKey, e);
176-
}
177-
return userAcctPair;
178-
}
179-
180126
@Override
181127
public List<AccountVO> findAccountsLike(String accountName) {
182128
return findAccountsLike(accountName, null).first();
@@ -341,11 +287,9 @@ public long getDomainIdForGivenAccountId(long id) {
341287
domain_id = account_vo.getDomainId();
342288
}
343289
catch (Exception e) {
344-
logger.warn("getDomainIdForGivenAccountId: Exception :" + e.getMessage());
345-
}
346-
finally {
347-
return domain_id;
290+
logger.warn("Can not get DomainId for the given AccountId; exception message : {}", e.getMessage());
348291
}
292+
return domain_id;
349293
}
350294

351295
@Override

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,18 @@ public HashMap<String, Long> countVgpuVMs(Long dcId, Long podId, Long clusterId)
846846

847847
try {
848848
pstmtLegacy = txn.prepareAutoCloseStatement(finalQueryLegacy.toString());
849-
pstmt = txn.prepareAutoCloseStatement(finalQuery.toString());
850849
for (int i = 0; i < resourceIdList.size(); i++) {
851850
pstmtLegacy.setLong(1 + i, resourceIdList.get(i));
852-
pstmt.setLong(1 + i, resourceIdList.get(i));
853851
}
854852
ResultSet rs = pstmtLegacy.executeQuery();
855853
while (rs.next()) {
856854
result.put(rs.getString(1).concat(rs.getString(2)), rs.getLong(3));
857855
}
856+
857+
pstmt = txn.prepareAutoCloseStatement(finalQuery.toString());
858+
for (int i = 0; i < resourceIdList.size(); i++) {
859+
pstmt.setLong(1 + i, resourceIdList.get(i));
860+
}
858861
rs = pstmt.executeQuery();
859862
while (rs.next()) {
860863
result.put(rs.getString(1).concat(rs.getString(2)), rs.getLong(3));

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDaoImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
6767
private SearchBuilder<SnapshotDataStoreVO> searchFilteringStoreIdEqStoreRoleEqStateNeqRefCntNeq;
6868
protected SearchBuilder<SnapshotDataStoreVO> searchFilteringStoreIdEqStateEqStoreRoleEqIdEqUpdateCountEqSnapshotIdEqVolumeIdEq;
6969
private SearchBuilder<SnapshotDataStoreVO> stateSearch;
70-
private SearchBuilder<SnapshotDataStoreVO> idStateNeqSearch;
70+
private SearchBuilder<SnapshotDataStoreVO> idStateNinSearch;
7171
protected SearchBuilder<SnapshotVO> snapshotVOSearch;
7272
private SearchBuilder<SnapshotDataStoreVO> snapshotCreatedSearch;
7373
private SearchBuilder<SnapshotDataStoreVO> dataStoreAndInstallPathSearch;
@@ -146,10 +146,10 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
146146
stateSearch.done();
147147

148148

149-
idStateNeqSearch = createSearchBuilder();
150-
idStateNeqSearch.and(SNAPSHOT_ID, idStateNeqSearch.entity().getSnapshotId(), SearchCriteria.Op.EQ);
151-
idStateNeqSearch.and(STATE, idStateNeqSearch.entity().getState(), SearchCriteria.Op.NEQ);
152-
idStateNeqSearch.done();
149+
idStateNinSearch = createSearchBuilder();
150+
idStateNinSearch.and(SNAPSHOT_ID, idStateNinSearch.entity().getSnapshotId(), SearchCriteria.Op.EQ);
151+
idStateNinSearch.and(STATE, idStateNinSearch.entity().getState(), SearchCriteria.Op.NOTIN);
152+
idStateNinSearch.done();
153153

154154
snapshotVOSearch = snapshotDao.createSearchBuilder();
155155
snapshotVOSearch.and(VOLUME_ID, snapshotVOSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
@@ -480,15 +480,15 @@ public List<SnapshotDataStoreVO> findBySnapshotId(long snapshotId) {
480480

481481
@Override
482482
public List<SnapshotDataStoreVO> findBySnapshotIdWithNonDestroyedState(long snapshotId) {
483-
SearchCriteria<SnapshotDataStoreVO> sc = idStateNeqSearch.create();
483+
SearchCriteria<SnapshotDataStoreVO> sc = idStateNinSearch.create();
484484
sc.setParameters(SNAPSHOT_ID, snapshotId);
485485
sc.setParameters(STATE, State.Destroyed.name());
486486
return listBy(sc);
487487
}
488488

489489
@Override
490490
public List<SnapshotDataStoreVO> findBySnapshotIdAndNotInDestroyedHiddenState(long snapshotId) {
491-
SearchCriteria<SnapshotDataStoreVO> sc = idStateNeqSearch.create();
491+
SearchCriteria<SnapshotDataStoreVO> sc = idStateNinSearch.create();
492492
sc.setParameters(SNAPSHOT_ID, snapshotId);
493493
sc.setParameters(STATE, State.Destroyed.name(), State.Hidden.name());
494494
return listBy(sc);

0 commit comments

Comments
 (0)