Skip to content

Commit 5ec4552

Browse files
committed
Merge branch 'main' into nsx-integration
2 parents dc1665c + 72cf974 commit 5ec4552

File tree

58 files changed

+1719
-1091
lines changed

Some content is hidden

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

58 files changed

+1719
-1091
lines changed

PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This PR...
2222
- [ ] Bug fix (non-breaking change which fixes an issue)
2323
- [ ] Enhancement (improves an existing feature and functionality)
2424
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
25+
- [ ] build/CI
2526

2627
### Feature/Enhancement Scale or Bug Severity
2728

@@ -43,8 +44,12 @@ This PR...
4344

4445

4546
### How Has This Been Tested?
47+
4648
<!-- Please describe in detail how you tested your changes. -->
4749
<!-- Include details of your testing environment, and the tests you ran to -->
50+
51+
#### How did you try to break this feature and the system with this change?
52+
4853
<!-- see how your change affects other areas of the code, etc. -->
4954

5055

agent/conf/agent.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ hypervisor.type=kvm
279279
# If this parameter is used, property host.overcommit.mem.mb must be set to 0.
280280
#host.reserved.mem.mb=1024
281281

282+
# Number of CPU cores to subtract from advertised available cores.
283+
# These are reserved for system activity, or otherwise share host CPU resources with
284+
# CloudStack VM allocation.
285+
# host.reserved.cpu.count = 0
286+
282287
# The model of Watchdog timer to present to the Guest.
283288
# For all models refer to the libvirt documentation.
284289
#vm.watchdog.model=i6300esb

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,15 @@ public class AgentProperties{
502502
*/
503503
public static final Property<Integer> HOST_RESERVED_MEM_MB = new Property<>("host.reserved.mem.mb", 1024);
504504

505+
/**
506+
* How many host CPUs to reserve for non-allocation.<br>
507+
* This can be used to set aside CPU cores on the host for other tasks, such as running hyperconverged storage<br>
508+
* processes, etc.
509+
* Data type: Integer.<br>
510+
* Default value: <code>0</code>
511+
*/
512+
public static final Property<Integer> HOST_RESERVED_CPU_CORE_COUNT = new Property<>("host.reserved.cpu.count", 0);
513+
505514
/**
506515
* The model of Watchdog timer to present to the Guest.<br>
507516
* For all models refer to the libvirt documentation.<br>

framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public ConfigKey(Class<T> type, String name, String category, String defaultValu
149149

150150
public ConfigKey(Class<T> type, String name, String category, String defaultValue, String description, boolean isDynamic, Scope scope, T multiplier,
151151
String displayText, String parent, Ternary<String, String, Long> group, Pair<String, Long> subGroup) {
152-
this(type, name, category, defaultValue, description, isDynamic, scope, multiplier, null, parent, null, null, null, null);
152+
this(type, name, category, defaultValue, description, isDynamic, scope, multiplier, displayText, parent, group, subGroup, null, null);
153153
}
154154

155155
public ConfigKey(Class<T> type, String name, String category, String defaultValue, String description, boolean isDynamic, Scope scope, T multiplier,

framework/config/src/test/java/org/apache/cloudstack/framework/config/impl/ConfigDepotAdminTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,17 @@ public void testAutoPopulation() {
9898
ConfigurationVO staticIntCV = new ConfigurationVO("UnitTestComponent", StaticIntCK);
9999
dynamicIntCV.setValue("200");
100100
ConfigurationVO testCV = new ConfigurationVO("UnitTestComponent", TestCK);
101+
ConfigurationGroupVO groupVO = new ConfigurationGroupVO();
102+
ConfigurationSubGroupVO subGroupVO = new ConfigurationSubGroupVO();
101103

102104
when(_configurable.getConfigComponentName()).thenReturn("UnitTestComponent");
103105
when(_configurable.getConfigKeys()).thenReturn(new ConfigKey<?>[] {DynamicIntCK, StaticIntCK, TestCK});
104106
when(_configDao.findById(StaticIntCK.key())).thenReturn(null);
105107
when(_configDao.findById(DynamicIntCK.key())).thenReturn(dynamicIntCV);
106108
when(_configDao.findById(TestCK.key())).thenReturn(testCV);
107109
when(_configDao.persist(any(ConfigurationVO.class))).thenReturn(dynamicIntCV);
110+
when(_configGroupDao.persist(any(ConfigurationGroupVO.class))).thenReturn(groupVO);
111+
when(_configSubGroupDao.persist(any(ConfigurationSubGroupVO.class))).thenReturn(subGroupVO);
108112
_depotAdmin.populateConfigurations();
109113

110114
// This is once because DynamicIntCK is returned.

framework/db/src/main/java/com/cloud/dao/EntityManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public <T> SearchBuilder<T> createSearchBuilder(Class<T> entityType) {
8686

8787
public <T, K> GenericSearchBuilder<T, K> createGenericSearchBuilder(Class<T> entityType, Class<K> resultType) {
8888
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
89-
return dao.createSearchBuilder((Class<K>)resultType.getClass());
89+
return dao.createSearchBuilder((Class<K>)resultType);
9090
}
9191

9292
@Override

framework/db/src/main/java/com/cloud/utils/db/DbUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static PrimaryKeyJoinColumn[] getPrimaryKeyJoinColumns(Class<?> clazz) {
124124
public static Field findField(Class<?> clazz, String columnName) {
125125
for (Field field : clazz.getDeclaredFields()) {
126126
if (field.getAnnotation(Embedded.class) != null || field.getAnnotation(EmbeddedId.class) != null) {
127-
findField(field.getClass(), columnName);
127+
findField(field.getType(), columnName);
128128
} else {
129129
if (columnName.equals(DbUtil.getColumnName(field))) {
130130
return field;
@@ -170,7 +170,7 @@ public static final boolean isIdField(Field field) {
170170
}
171171

172172
if (field.getAnnotation(EmbeddedId.class) != null) {
173-
assert (field.getClass().getAnnotation(Embeddable.class) != null) : "Class " + field.getClass().getName() + " must be Embeddable to be used as Embedded Id";
173+
assert (field.getType().getAnnotation(Embeddable.class) != null) : "Class " + field.getType().getName() + " must be Embeddable to be used as Embedded Id";
174174
return true;
175175
}
176176

framework/db/src/main/java/com/cloud/utils/db/DriverLoader.java

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

19+
import java.lang.reflect.InvocationTargetException;
20+
import java.sql.Driver;
1921
import java.util.ArrayList;
2022
import java.util.HashMap;
2123
import java.util.List;
@@ -56,12 +58,13 @@ public static void loadDriver(String dbDriver) {
5658
}
5759

5860
try {
59-
Class.forName(driverClass).newInstance();
61+
Class<Driver> klazz = (Class<Driver>) Class.forName(driverClass);
62+
klazz.getDeclaredConstructor().newInstance();
6063
LOADED_DRIVERS.add(dbDriver);
6164
if (LOGGER.isDebugEnabled()) {
6265
LOGGER.debug("Successfully loaded DB driver " + driverClass);
6366
}
64-
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
67+
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
6568
LOGGER.error("Failed to load DB driver " + driverClass);
6669
throw new CloudRuntimeException("Failed to load DB driver " + driverClass, e);
6770
}

framework/db/src/main/java/com/cloud/utils/db/EcInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public EcInfo(Attribute attr, Attribute idAttr) {
5757
rawClass = HashSet.class;
5858
} else if (List.class == rawClazz) {
5959
rawClass = ArrayList.class;
60-
} else if (Collection.class == Collection.class) {
60+
} else if (Collection.class == rawClazz) {
6161
rawClass = ArrayList.class;
6262
} else {
63-
assert (false) : " We don't know how to create this calss " + rawType.toString() + " for " + attr.field.getName();
63+
assert (false) : " We don't know how to create this class " + rawType.toString() + " for " + attr.field.getName();
6464
}
6565
} catch (NoSuchMethodException e) {
6666
throw new CloudRuntimeException("Write your own support for " + rawClazz + " defined by " + attr.field.getName());

framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ protected String buildSelectByIdSql(final StringBuilder sql) {
874874
if (_idField.getAnnotation(EmbeddedId.class) == null) {
875875
sql.append(_table).append(".").append(DbUtil.getColumnName(_idField, null)).append(" = ? ");
876876
} else {
877-
final Class<?> clazz = _idField.getClass();
877+
s_logger.debug(String.format("field type vs declarator : %s vs %s", _idField.getType(), _idField.getDeclaringClass()));
878+
final Class<?> clazz = _idField.getType();
878879
final AttributeOverride[] overrides = DbUtil.getAttributeOverrides(_idField);
879880
for (final Field field : clazz.getDeclaredFields()) {
880881
sql.append(_table).append(".").append(DbUtil.getColumnName(field, overrides)).append(" = ? AND ");

0 commit comments

Comments
 (0)