Skip to content

Commit e904b1b

Browse files
committed
Merge branch 'main' into cks-enhancements-upstream
2 parents fbe0496 + 9c6f2a9 commit e904b1b

File tree

88 files changed

+5819
-939
lines changed

Some content is hidden

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

88 files changed

+5819
-939
lines changed

api/src/main/java/com/cloud/storage/MigrationOptions.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class MigrationOptions implements Serializable {
2424

2525
private String srcPoolUuid;
2626
private Storage.StoragePoolType srcPoolType;
27+
private Long srcPoolClusterId;
2728
private Type type;
2829
private ScopeType scopeType;
2930
private String srcBackingFilePath;
@@ -38,21 +39,23 @@ public enum Type {
3839
public MigrationOptions() {
3940
}
4041

41-
public MigrationOptions(String srcPoolUuid, Storage.StoragePoolType srcPoolType, String srcBackingFilePath, boolean copySrcTemplate, ScopeType scopeType) {
42+
public MigrationOptions(String srcPoolUuid, Storage.StoragePoolType srcPoolType, String srcBackingFilePath, boolean copySrcTemplate, ScopeType scopeType, Long srcPoolClusterId) {
4243
this.srcPoolUuid = srcPoolUuid;
4344
this.srcPoolType = srcPoolType;
4445
this.type = Type.LinkedClone;
4546
this.scopeType = scopeType;
4647
this.srcBackingFilePath = srcBackingFilePath;
4748
this.copySrcTemplate = copySrcTemplate;
49+
this.srcPoolClusterId = srcPoolClusterId;
4850
}
4951

50-
public MigrationOptions(String srcPoolUuid, Storage.StoragePoolType srcPoolType, String srcVolumeUuid, ScopeType scopeType) {
52+
public MigrationOptions(String srcPoolUuid, Storage.StoragePoolType srcPoolType, String srcVolumeUuid, ScopeType scopeType, Long srcPoolClusterId) {
5153
this.srcPoolUuid = srcPoolUuid;
5254
this.srcPoolType = srcPoolType;
5355
this.type = Type.FullClone;
5456
this.scopeType = scopeType;
5557
this.srcVolumeUuid = srcVolumeUuid;
58+
this.srcPoolClusterId = srcPoolClusterId;
5659
}
5760

5861
public String getSrcPoolUuid() {
@@ -63,6 +66,10 @@ public Storage.StoragePoolType getSrcPoolType() {
6366
return srcPoolType;
6467
}
6568

69+
public Long getSrcPoolClusterId() {
70+
return srcPoolClusterId;
71+
}
72+
6673
public ScopeType getScopeType() { return scopeType; }
6774

6875
public String getSrcBackingFilePath() {

api/src/main/java/org/apache/cloudstack/api/command/user/backup/DeleteBackupScheduleCmd.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.cloudstack.api.BaseCmd;
2727
import org.apache.cloudstack.api.Parameter;
2828
import org.apache.cloudstack.api.ServerApiException;
29+
import org.apache.cloudstack.api.response.BackupScheduleResponse;
2930
import org.apache.cloudstack.api.response.SuccessResponse;
3031
import org.apache.cloudstack.api.response.UserVmResponse;
3132
import org.apache.cloudstack.backup.BackupManager;
@@ -54,10 +55,16 @@ public class DeleteBackupScheduleCmd extends BaseCmd {
5455
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID,
5556
type = CommandType.UUID,
5657
entityType = UserVmResponse.class,
57-
required = true,
5858
description = "ID of the VM")
5959
private Long vmId;
6060

61+
@Parameter(name = ApiConstants.ID,
62+
type = CommandType.UUID,
63+
entityType = BackupScheduleResponse.class,
64+
description = "ID of the schedule",
65+
since = "4.20.1")
66+
private Long id;
67+
6168
/////////////////////////////////////////////////////
6269
/////////////////// Accessors ///////////////////////
6370
/////////////////////////////////////////////////////
@@ -66,14 +73,17 @@ public Long getVmId() {
6673
return vmId;
6774
}
6875

76+
public Long getId() { return id; }
77+
78+
6979
/////////////////////////////////////////////////////
7080
/////////////// API Implementation///////////////////
7181
/////////////////////////////////////////////////////
7282

7383
@Override
7484
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
7585
try {
76-
boolean result = backupManager.deleteBackupSchedule(getVmId());
86+
boolean result = backupManager.deleteBackupSchedule(this);
7787
if (result) {
7888
SuccessResponse response = new SuccessResponse(getCommandName());
7989
response.setResponseName(getCommandName());

api/src/main/java/org/apache/cloudstack/api/response/BackupRepositoryResponse.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ public class BackupRepositoryResponse extends BaseResponse {
5757
@Param(description = "backup type")
5858
private String type;
5959

60-
@SerializedName(ApiConstants.MOUNT_OPTIONS)
61-
@Param(description = "mount options for the backup repository")
62-
private String mountOptions;
63-
6460
@SerializedName(ApiConstants.CAPACITY_BYTES)
6561
@Param(description = "capacity of the backup repository")
6662
private Long capacityBytes;
@@ -112,14 +108,6 @@ public void setAddress(String address) {
112108
this.address = address;
113109
}
114110

115-
public String getMountOptions() {
116-
return mountOptions;
117-
}
118-
119-
public void setMountOptions(String mountOptions) {
120-
this.mountOptions = mountOptions;
121-
}
122-
123111
public String getProviderName() {
124112
return providerName;
125113
}

api/src/main/java/org/apache/cloudstack/backup/BackupManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.cloudstack.api.command.admin.backup.ImportBackupOfferingCmd;
2424
import org.apache.cloudstack.api.command.admin.backup.UpdateBackupOfferingCmd;
2525
import org.apache.cloudstack.api.command.user.backup.CreateBackupScheduleCmd;
26+
import org.apache.cloudstack.api.command.user.backup.DeleteBackupScheduleCmd;
2627
import org.apache.cloudstack.api.command.user.backup.ListBackupOfferingsCmd;
2728
import org.apache.cloudstack.api.command.user.backup.ListBackupsCmd;
2829
import org.apache.cloudstack.framework.config.ConfigKey;
@@ -192,10 +193,10 @@ public interface BackupManager extends BackupService, Configurable, PluggableSer
192193

193194
/**
194195
* Deletes VM backup schedule for a VM
195-
* @param vmId
196+
* @param cmd
196197
* @return
197198
*/
198-
boolean deleteBackupSchedule(Long vmId);
199+
boolean deleteBackupSchedule(DeleteBackupScheduleCmd cmd);
199200

200201
/**
201202
* Creates backup of a VM

client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,11 @@
642642
<artifactId>cloud-plugin-storage-object-ceph</artifactId>
643643
<version>${project.version}</version>
644644
</dependency>
645+
<dependency>
646+
<groupId>org.apache.cloudstack</groupId>
647+
<artifactId>cloud-plugin-storage-object-cloudian</artifactId>
648+
<version>${project.version}</version>
649+
</dependency>
645650
<dependency>
646651
<groupId>org.apache.cloudstack</groupId>
647652
<artifactId>cloud-plugin-storage-object-simulator</artifactId>

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ private void processHostHealthCheckResult(Boolean hostHealthCheckResult, long ho
14731473
}
14741474
if (!BooleanUtils.toBoolean(EnableKVMAutoEnableDisable.valueIn(host.getClusterId()))) {
14751475
logger.debug("{} is disabled for the cluster {}, cannot process the health check result " +
1476-
"received for the host {}", EnableKVMAutoEnableDisable.key(), host.getClusterId(), host);
1476+
"received for {}", EnableKVMAutoEnableDisable.key(), host.getClusterId(), host);
14771477
return;
14781478
}
14791479

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6071,6 +6071,9 @@ protected boolean isDiskOfferingSuitableForVm(VMInstanceVO vm, VirtualMachinePro
60716071
@Override
60726072
public Map<Long, Boolean> getDiskOfferingSuitabilityForVm(long vmId, List<Long> diskOfferingIds) {
60736073
VMInstanceVO vm = _vmDao.findById(vmId);
6074+
if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_VM) != null) {
6075+
return new HashMap<>();
6076+
}
60746077
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
60756078
Pair<Long, Long> clusterAndHost = findClusterAndHostIdForVm(vm, false);
60766079
Long clusterId = clusterAndHost.first();

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ public void processHostVmStatePingReport(long hostId, Map<String, HostVmStateRep
7777
processReport(hostId, translatedInfo, force);
7878
}
7979

80-
private void updateAndPublishVmPowerStates(long hostId, Map<Long, VirtualMachine.PowerState> instancePowerStates,
81-
Date updateTime) {
80+
protected void updateAndPublishVmPowerStates(long hostId, Map<Long, VirtualMachine.PowerState> instancePowerStates,
81+
Date updateTime) {
8282
if (instancePowerStates.isEmpty()) {
8383
return;
8484
}
8585
Set<Long> vmIds = instancePowerStates.keySet();
86-
Map<Long, VirtualMachine.PowerState> notUpdated = _instanceDao.updatePowerState(instancePowerStates, hostId,
87-
updateTime);
86+
Map<Long, VirtualMachine.PowerState> notUpdated =
87+
_instanceDao.updatePowerState(instancePowerStates, hostId, updateTime);
8888
if (notUpdated.size() > vmIds.size()) {
8989
return;
9090
}
9191
for (Long vmId : vmIds) {
92-
if (!notUpdated.isEmpty() && !notUpdated.containsKey(vmId)) {
92+
if (!notUpdated.containsKey(vmId)) {
9393
logger.debug("VM state report is updated. {}, {}, power state: {}",
9494
() -> hostCache.get(hostId), () -> vmCache.get(vmId), () -> instancePowerStates.get(vmId));
9595
_messageBus.publish(null, VirtualMachineManager.Topics.VM_POWER_STATE,
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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.vm;
18+
19+
import java.util.Date;
20+
import java.util.HashMap;
21+
import java.util.Map;
22+
23+
import org.apache.cloudstack.framework.messagebus.MessageBus;
24+
import org.apache.cloudstack.framework.messagebus.PublishScope;
25+
import org.junit.Before;
26+
import org.junit.Test;
27+
import org.junit.runner.RunWith;
28+
import org.mockito.InjectMocks;
29+
import org.mockito.Mock;
30+
import org.mockito.Mockito;
31+
import org.mockito.junit.MockitoJUnitRunner;
32+
33+
import com.cloud.host.HostVO;
34+
import com.cloud.host.dao.HostDao;
35+
import com.cloud.vm.dao.VMInstanceDao;
36+
37+
@RunWith(MockitoJUnitRunner.class)
38+
public class VirtualMachinePowerStateSyncImplTest {
39+
@Mock
40+
MessageBus messageBus;
41+
@Mock
42+
VMInstanceDao instanceDao;
43+
@Mock
44+
HostDao hostDao;
45+
46+
@InjectMocks
47+
VirtualMachinePowerStateSyncImpl virtualMachinePowerStateSync = new VirtualMachinePowerStateSyncImpl();
48+
49+
@Before
50+
public void setup() {
51+
Mockito.lenient().when(instanceDao.findById(Mockito.anyLong())).thenReturn(Mockito.mock(VMInstanceVO.class));
52+
Mockito.lenient().when(hostDao.findById(Mockito.anyLong())).thenReturn(Mockito.mock(HostVO.class));
53+
}
54+
55+
@Test
56+
public void test_updateAndPublishVmPowerStates_emptyStates() {
57+
virtualMachinePowerStateSync.updateAndPublishVmPowerStates(1L, new HashMap<>(), new Date());
58+
Mockito.verify(instanceDao, Mockito.never()).updatePowerState(Mockito.anyMap(), Mockito.anyLong(),
59+
Mockito.any(Date.class));
60+
}
61+
62+
@Test
63+
public void test_updateAndPublishVmPowerStates_moreNotUpdated() {
64+
Map<Long, VirtualMachine.PowerState> powerStates = new HashMap<>();
65+
powerStates.put(1L, VirtualMachine.PowerState.PowerOff);
66+
Map<Long, VirtualMachine.PowerState> notUpdated = new HashMap<>(powerStates);
67+
notUpdated.put(2L, VirtualMachine.PowerState.PowerOn);
68+
Mockito.when(instanceDao.updatePowerState(Mockito.anyMap(), Mockito.anyLong(),
69+
Mockito.any(Date.class))).thenReturn(notUpdated);
70+
virtualMachinePowerStateSync.updateAndPublishVmPowerStates(1L, powerStates, new Date());
71+
Mockito.verify(messageBus, Mockito.never()).publish(Mockito.nullable(String.class), Mockito.anyString(),
72+
Mockito.any(PublishScope.class), Mockito.anyLong());
73+
}
74+
75+
@Test
76+
public void test_updateAndPublishVmPowerStates_allUpdated() {
77+
Map<Long, VirtualMachine.PowerState> powerStates = new HashMap<>();
78+
powerStates.put(1L, VirtualMachine.PowerState.PowerOff);
79+
Mockito.when(instanceDao.updatePowerState(Mockito.anyMap(), Mockito.anyLong(),
80+
Mockito.any(Date.class))).thenReturn(new HashMap<>());
81+
virtualMachinePowerStateSync.updateAndPublishVmPowerStates(1L, powerStates, new Date());
82+
Mockito.verify(messageBus, Mockito.times(1)).publish(null,
83+
VirtualMachineManager.Topics.VM_POWER_STATE,
84+
PublishScope.GLOBAL,
85+
1L);
86+
}
87+
88+
@Test
89+
public void test_updateAndPublishVmPowerStates_partialUpdated() {
90+
Map<Long, VirtualMachine.PowerState> powerStates = new HashMap<>();
91+
powerStates.put(1L, VirtualMachine.PowerState.PowerOn);
92+
powerStates.put(2L, VirtualMachine.PowerState.PowerOff);
93+
Map<Long, VirtualMachine.PowerState> notUpdated = new HashMap<>();
94+
notUpdated.put(2L, VirtualMachine.PowerState.PowerOff);
95+
Mockito.when(instanceDao.updatePowerState(Mockito.anyMap(), Mockito.anyLong(),
96+
Mockito.any(Date.class))).thenReturn(notUpdated);
97+
virtualMachinePowerStateSync.updateAndPublishVmPowerStates(1L, powerStates, new Date());
98+
Mockito.verify(messageBus, Mockito.times(1)).publish(null,
99+
VirtualMachineManager.Topics.VM_POWER_STATE,
100+
PublishScope.GLOBAL,
101+
1L);
102+
Mockito.verify(messageBus, Mockito.never()).publish(null,
103+
VirtualMachineManager.Topics.VM_POWER_STATE,
104+
PublishScope.GLOBAL,
105+
2L);
106+
}
107+
}

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/KvmNonManagedStorageDataMotionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ protected void copyTemplateToTargetFilesystemStorageIfNeeded(VolumeInfo srcVolum
215215
}
216216

217217
VMTemplateStoragePoolVO sourceVolumeTemplateStoragePoolVO = vmTemplatePoolDao.findByPoolTemplate(destStoragePool.getId(), srcVolumeInfo.getTemplateId(), null);
218-
if (sourceVolumeTemplateStoragePoolVO == null && (isStoragePoolTypeInList(destStoragePool.getPoolType(), StoragePoolType.Filesystem, StoragePoolType.SharedMountPoint))) {
218+
if (sourceVolumeTemplateStoragePoolVO == null && (isStoragePoolTypeInList(destStoragePool.getPoolType(), StoragePoolType.NetworkFilesystem, StoragePoolType.Filesystem, StoragePoolType.SharedMountPoint))) {
219219
DataStore sourceTemplateDataStore = dataStoreManagerImpl.getRandomImageStore(srcVolumeInfo.getDataCenterId());
220220
if (sourceTemplateDataStore != null) {
221221
TemplateInfo sourceTemplateInfo = templateDataFactory.getTemplate(srcVolumeInfo.getTemplateId(), sourceTemplateDataStore);

0 commit comments

Comments
 (0)