Skip to content

Commit bee935c

Browse files
authored
Merge branch '4.20' into ssvm-mount
2 parents 722c2e3 + f1f779a commit bee935c

File tree

98 files changed

+894
-514
lines changed

Some content is hidden

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

98 files changed

+894
-514
lines changed

api/src/main/java/com/cloud/network/NetworkModel.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ public interface NetworkModel {
125125
*/
126126
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
127127

128+
String getUniqueMacAddress(long macAddress, long networkId, long datacenterId) throws InsufficientAddressCapacityException;
129+
130+
boolean isMACUnique(String mac, long networkId);
131+
128132
PublicIpAddress getPublicIpAddress(long ipAddressId);
129133

130134
List<? extends Vlan> listPodVlans(long podId);
@@ -362,4 +366,8 @@ List<String[]> generateVmData(String userData, String userDataDetails, String se
362366

363367
boolean checkSecurityGroupSupportForNetwork(Account account, DataCenter zone, List<Long> networkIds,
364368
List<Long> securityGroupsIds);
369+
370+
default long getMacIdentifier(Long dataCenterId) {
371+
return 0;
372+
}
365373
}

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public interface VmDetailConstants {
5454
String NIC_MULTIQUEUE_NUMBER = "nic.multiqueue.number";
5555
String NIC_PACKED_VIRTQUEUES_ENABLED = "nic.packed.virtqueues.enabled";
5656

57+
// KVM specific, disk controllers
58+
String KVM_SKIP_FORCE_DISK_CONTROLLER = "skip.force.disk.controller";
59+
5760
// Mac OSX guest specific (internal)
5861
String SMC_PRESENT = "smc.present";
5962
String FIRMWARE = "firmware";

core/src/main/java/com/cloud/storage/template/HttpTemplateDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void checkCredentials(String user, String password) {
151151
client.getParams().setAuthenticationPreemptive(true);
152152
Credentials defaultcreds = new UsernamePasswordCredentials(user, password);
153153
client.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds);
154-
logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second());
154+
logger.info("Added username={}, password=****** for host {}:{}", user, hostAndPort.first(), hostAndPort.second());
155155
} else {
156156
logger.info("No credentials configured for host=" + hostAndPort.first() + ":" + hostAndPort.second());
157157
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ enum State {
3333
Destroying("Template is destroying"),
3434
Destroyed("Template is destroyed"),
3535
Failed("Failed to download Template");
36-
String _description;
36+
final String _description;
3737

38-
private State(String description) {
38+
State(String description) {
3939
_description = description;
4040
}
4141

@@ -48,7 +48,7 @@ enum Event {
4848
CreateRequested,
4949
CreateOnlyRequested,
5050
DestroyRequested,
51-
OperationSuccessed,
51+
OperationSucceeded,
5252
OperationFailed,
5353
CopyRequested,
5454
CopyingRequested,

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotDataFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface SnapshotDataFactory {
3030

3131
SnapshotInfo getSnapshot(long snapshotId, long storeId, DataStoreRole role);
3232

33+
SnapshotInfo getSnapshotIncludingRemoved(long snapshotId, long storeId, DataStoreRole role);
34+
3335
SnapshotInfo getSnapshotWithRoleAndZone(long snapshotId, DataStoreRole role, long zoneId);
3436

3537
SnapshotInfo getSnapshotOnPrimaryStore(long snapshotId);

engine/components-api/src/main/java/com/cloud/network/addr/PublicIp.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public PublicIp(IPAddressVO addr, VlanVO vlan, long macAddress) {
4040
}
4141

4242
public static PublicIp createFromAddrAndVlan(IPAddressVO addr, VlanVO vlan) {
43-
return new PublicIp(addr, vlan, NetUtils.createSequenceBasedMacAddress(addr.getMacAddress(), NetworkModel.MACIdentifier.value()));
43+
long macIdentifier = NetworkModel.MACIdentifier.valueIn(addr.getDataCenterId());
44+
if (macIdentifier == 0) {
45+
macIdentifier = addr.getDataCenterId();
46+
}
47+
return new PublicIp(addr, vlan, NetUtils.createSequenceBasedMacAddress(addr.getMacAddress(), macIdentifier));
4448
}
4549

4650
@Override
@@ -274,6 +278,4 @@ public void setRuleState(State ruleState) {
274278
public boolean isForSystemVms() {
275279
return false;
276280
}
277-
278-
279281
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ protected void configureNicProfileBasedOnRequestedIp(NicProfile requestedNicProf
12701270
nicProfile.setIPv4Gateway(ipv4Gateway);
12711271
nicProfile.setIPv4Netmask(ipv4Netmask);
12721272

1273-
if (nicProfile.getMacAddress() == null) {
1273+
if (nicProfile.getMacAddress() == null || !_networkModel.isMACUnique(nicProfile.getMacAddress(), network.getId())) {
12741274
try {
12751275
String macAddress = _networkModel.getNextAvailableMacAddressInNetwork(network.getId());
12761276
nicProfile.setMacAddress(macAddress);

engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ private void configureTestConfigureNicProfileBasedOnRequestedIpTests(NicProfile
396396
when(testOrchestrator._ipAddressDao.acquireInLockTable(Mockito.anyLong())).thenReturn(ipVoSpy);
397397
when(testOrchestrator._ipAddressDao.update(Mockito.anyLong(), Mockito.any(IPAddressVO.class))).thenReturn(true);
398398
when(testOrchestrator._ipAddressDao.releaseFromLockTable(Mockito.anyLong())).thenReturn(true);
399+
when(testOrchestrator._networkModel.isMACUnique(Mockito.anyString(), Mockito.anyLong())).thenReturn(true);
399400
try {
400401
when(testOrchestrator._networkModel.getNextAvailableMacAddressInNetwork(Mockito.anyLong())).thenReturn(macAddress);
401402
} catch (InsufficientAddressCapacityException e) {

engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
213213

214214
private static final String LEFT_JOIN_VM_TEMPLATE = "LEFT JOIN vm_template ON vm_template.id = vi.vm_template_id ";
215215

216+
private static final String STORAGE_POOLS_WITH_CHILDREN = "SELECT DISTINCT parent FROM storage_pool WHERE parent != 0 AND removed IS NULL";
217+
216218
public CapacityDaoImpl() {
217219
_hostIdTypeSearch = createSearchBuilder();
218220
_hostIdTypeSearch.and("hostId", _hostIdTypeSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
@@ -379,6 +381,11 @@ public List<SummedCapacity> listCapacitiesGroupedByLevelAndType(Integer capacity
379381
finalQuery.append(" AND capacity_type = ?");
380382
resourceIdList.add(capacityType.longValue());
381383
}
384+
385+
// Exclude storage pools with children from capacity calculations to avoid double counting
386+
finalQuery.append(" AND NOT (capacity.capacity_type = ").append(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED)
387+
.append(" AND capacity.host_id IN (").append(STORAGE_POOLS_WITH_CHILDREN).append("))");
388+
382389
if (CollectionUtils.isNotEmpty(hostIds)) {
383390
finalQuery.append(String.format(" AND capacity.host_id IN (%s)", StringUtils.join(hostIds, ",")));
384391
if (capacityType == null) {
@@ -541,6 +548,10 @@ public List<SummedCapacity> findFilteredCapacityBy(Integer capacityType, Long zo
541548
StringBuilder sql = new StringBuilder(LIST_CAPACITY_GROUP_BY_CAPACITY_PART1);
542549
List<Long> resourceIdList = new ArrayList<Long>();
543550

551+
// Exclude storage pools with children from capacity calculations to avoid double counting
552+
sql.append(" AND NOT (capacity.capacity_type = ").append(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED)
553+
.append(" AND capacity.host_id IN (").append(STORAGE_POOLS_WITH_CHILDREN).append("))");
554+
544555
if (zoneId != null) {
545556
sql.append(" AND capacity.data_center_id = ?");
546557
resourceIdList.add(zoneId);

engine/schema/src/main/java/com/cloud/network/dao/NetworkDaoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ public List<NetworkVO> getAllPersistentNetworksFromZone(long dataCenterId) {
432432
public String getNextAvailableMacAddress(final long networkConfigId, Integer zoneMacIdentifier) {
433433
final SequenceFetcher fetch = SequenceFetcher.getInstance();
434434
long seq = fetch.getNextSequence(Long.class, _tgMacAddress, networkConfigId);
435-
if(zoneMacIdentifier != null && zoneMacIdentifier.intValue() != 0 ){
436-
seq = seq | _prefix << 40 | (long)zoneMacIdentifier << 32 | networkConfigId << 16 & 0x00000000ffff0000l;
435+
if (zoneMacIdentifier != null && zoneMacIdentifier != 0) {
436+
seq = seq | _prefix << 40 | (long)zoneMacIdentifier << 32 | networkConfigId << 16 & 0x00000000ffff0000L;
437437
}
438438
return NetUtils.long2Mac(seq);
439439
}

0 commit comments

Comments
 (0)