Merge branch '4.18' into 4.19

This commit is contained in:
Suresh Kumar Anaparti 2024-07-15 00:59:06 +05:30
commit 7f8f113709
No known key found for this signature in database
GPG Key ID: D7CEAE3A9E71D0AA
2 changed files with 26 additions and 17 deletions

View File

@ -29,6 +29,7 @@ import com.cloud.utils.db.QueryBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException;
@ -540,21 +541,25 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
@Override
public void removeOldUsageRecords(int days) {
String sql = DELETE_ALL_BY_INTERVAL;
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
PreparedStatement pstmt = null;
try {
txn.start();
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, days);
pstmt.executeUpdate();
txn.commit();
} catch (Exception ex) {
txn.rollback();
s_logger.error("error removing old cloud_usage records for interval: " + days);
} finally {
txn.close();
}
Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
try {
txn.start();
pstmt = txn.prepareAutoCloseStatement(DELETE_ALL_BY_INTERVAL);
pstmt.setLong(1, days);
pstmt.executeUpdate();
txn.commit();
} catch (Exception ex) {
txn.rollback();
s_logger.error("error removing old cloud_usage records for interval: " + days);
} finally {
txn.close();
}
}
});
}
public UsageVO persistUsage(final UsageVO usage) {

View File

@ -26,6 +26,7 @@ import java.util.List;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
@ -49,8 +50,7 @@ public class LibvirtOvsFetchInterfaceCommandWrapperTest {
while(interfaces.hasMoreElements()) {
NetworkInterface networkInterface = interfaces.nextElement();
if (networkInterface.getInetAddresses().hasMoreElements() &&
(networkInterface.getName().startsWith("eth") ||
networkInterface.getName().startsWith("wl"))) {
networkInterface.getName().matches("^(eth|wl|en).*")) {
interfaceName = networkInterface.getName();
Enumeration<InetAddress> addresses = networkInterface.getInetAddresses();
while(addresses.hasMoreElements()) {
@ -60,9 +60,13 @@ public class LibvirtOvsFetchInterfaceCommandWrapperTest {
break;
};
}
if (StringUtils.isNotBlank(interfaceName) && StringUtils.isNotBlank(ipAddress)) {
break;
}
}
}
} catch (SocketException ignored) {}
Assume.assumeTrue(StringUtils.isNotBlank(interfaceName));
Ternary<String, String, String> result = null;
try {
result = wrapper.getInterfaceDetails(interfaceName);