Skip to content

Commit a94104d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into instance
2 parents d96d969 + 6059724 commit a94104d

File tree

54 files changed

+1255
-713
lines changed

Some content is hidden

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

54 files changed

+1255
-713
lines changed

.github/workflows/ui.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
npm run test:unit
5757
5858
- uses: codecov/codecov-action@v4
59+
if: github.repository == 'apache/cloudstack'
5960
with:
6061
working-directory: ui
6162
files: ./coverage/lcov.info

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
171171
* </table>
172172
*/
173173
boolean doesStoragePoolSupportDiskOffering(StoragePool destPool, DiskOffering diskOffering);
174+
175+
/**
176+
* Checks if the storage pool supports the required disk offering tags
177+
* destPool the storage pool to check the disk offering tags
178+
* diskOfferingTags the tags that should be supported
179+
* return whether the tags are supported in the storage pool
180+
*/
174181
boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags);
175182

176183
Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);

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

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

19+
import com.cloud.storage.Snapshot;
20+
import com.cloud.storage.Volume;
1921
import java.util.LinkedHashMap;
2022
import java.util.List;
2123
import java.util.Map;
@@ -224,7 +226,7 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
224226
String userData, Long userDataId, String userDataDetails, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
225227
List<Long> affinityGroupIdList, Map<String, String> customParameter, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
226228
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
227-
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId) throws InsufficientCapacityException,
229+
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId, Volume volume, Snapshot snapshot) throws InsufficientCapacityException,
228230
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
229231

230232
/**
@@ -300,7 +302,7 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
300302
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, List<DiskOfferingInfo> dataDiskOfferingsInfo, String group, HypervisorType hypervisor,
301303
HTTPMethod httpmethod, String userData, Long userDataId, String userDataDetails, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
302304
List<Long> affinityGroupIdList, Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
303-
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap, Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId, String vmType) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
305+
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap, Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId, String vmType, Volume volume, Snapshot snapshot) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
304306

305307
/**
306308
* Creates a User VM in Advanced Zone (Security Group feature is disabled)
@@ -372,7 +374,7 @@ UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
372374
String hostName, String displayName, Long diskOfferingId, Long diskSize, List<DiskOfferingInfo> dataDiskOfferingsInfo, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
373375
Long userDataId, String userDataDetails, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
374376
Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
375-
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String vmType, Long overrideDiskOfferingId)
377+
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String vmType, Long overrideDiskOfferingId, Volume volume, Snapshot snapshot)
376378

377379
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
378380

api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ public class DeployVMCmd extends BaseDeployVMCmd {
4949
private Long serviceOfferingId;
5050

5151
@ACL
52-
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, required = true, description = "the ID of the template for the virtual machine")
52+
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "the ID of the template for the virtual machine")
5353
private Long templateId;
54+
@Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class, since = "4.21")
55+
private Long volumeId;
5456

57+
@Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class, since = "4.21")
58+
private Long snapshotId;
5559
/////////////////////////////////////////////////////
5660
/////////////////// Accessors ///////////////////////
5761
/////////////////////////////////////////////////////
@@ -64,6 +68,17 @@ public Long getTemplateId() {
6468
return templateId;
6569
}
6670

71+
public Long getVolumeId() {
72+
return volumeId;
73+
}
74+
75+
public Long getSnapshotId() {
76+
return snapshotId;
77+
}
78+
79+
public boolean isVolumeOrSnapshotProvided() {
80+
return volumeId != null || snapshotId != null;
81+
}
6782
@Override
6883
public void execute() {
6984
UserVm result;
@@ -108,6 +123,10 @@ public void execute() {
108123

109124
@Override
110125
public void create() throws ResourceAllocationException {
126+
if (Stream.of(templateId, snapshotId, volumeId).filter(Objects::nonNull).count() != 1) {
127+
throw new CloudRuntimeException("Please provide only one of the following parameters - template ID, volume ID or snapshot ID");
128+
}
129+
111130
try {
112131
UserVm vm = _userVmService.createVirtualMachine(this);
113132

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616
// under the License.
1717
package com.cloud.agent.api;
1818

19-
import org.apache.cloudstack.vm.UnmanagedInstanceTO;
20-
2119
public class ConvertInstanceAnswer extends Answer {
2220

2321
private String temporaryConvertUuid;
2422

2523
public ConvertInstanceAnswer() {
2624
super();
2725
}
28-
private UnmanagedInstanceTO convertedInstance;
29-
30-
public ConvertInstanceAnswer(Command command, boolean success, String details) {
31-
super(command, success, details);
32-
}
33-
34-
public ConvertInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
35-
super(command, true, "");
36-
this.convertedInstance = convertedInstance;
37-
}
3826

3927
public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
4028
super(command, true, "");
@@ -44,8 +32,4 @@ public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
4432
public String getTemporaryConvertUuid() {
4533
return temporaryConvertUuid;
4634
}
47-
48-
public UnmanagedInstanceTO getConvertedInstance() {
49-
return convertedInstance;
50-
}
5135
}

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
import com.cloud.agent.api.to.RemoteInstanceTO;
2121
import com.cloud.hypervisor.Hypervisor;
2222

23-
import java.util.List;
24-
2523
public class ConvertInstanceCommand extends Command {
2624

2725
private RemoteInstanceTO sourceInstance;
2826
private Hypervisor.HypervisorType destinationHypervisorType;
29-
private List<String> destinationStoragePools;
3027
private DataStoreTO conversionTemporaryLocation;
3128
private String templateDirOnConversionLocation;
3229
private boolean checkConversionSupport;
@@ -36,12 +33,10 @@ public class ConvertInstanceCommand extends Command {
3633
public ConvertInstanceCommand() {
3734
}
3835

39-
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType,
40-
List<String> destinationStoragePools, DataStoreTO conversionTemporaryLocation,
36+
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType, DataStoreTO conversionTemporaryLocation,
4137
String templateDirOnConversionLocation, boolean checkConversionSupport, boolean exportOvfToConversionLocation) {
4238
this.sourceInstance = sourceInstance;
4339
this.destinationHypervisorType = destinationHypervisorType;
44-
this.destinationStoragePools = destinationStoragePools;
4540
this.conversionTemporaryLocation = conversionTemporaryLocation;
4641
this.templateDirOnConversionLocation = templateDirOnConversionLocation;
4742
this.checkConversionSupport = checkConversionSupport;
@@ -56,10 +51,6 @@ public Hypervisor.HypervisorType getDestinationHypervisorType() {
5651
return destinationHypervisorType;
5752
}
5853

59-
public List<String> getDestinationStoragePools() {
60-
return destinationStoragePools;
61-
}
62-
6354
public DataStoreTO getConversionTemporaryLocation() {
6455
return conversionTemporaryLocation;
6556
}

core/src/main/java/org/apache/cloudstack/direct/download/HttpsDirectTemplateDownloader.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939

4040
import javax.net.ssl.HttpsURLConnection;
4141
import javax.net.ssl.SSLContext;
42-
import javax.net.ssl.TrustManager;
4342

44-
import org.apache.cloudstack.utils.security.SSLUtils;
4543
import org.apache.commons.collections.MapUtils;
4644
import org.apache.commons.httpclient.HttpStatus;
4745
import org.apache.commons.io.IOUtils;
@@ -55,6 +53,7 @@
5553
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
5654
import org.apache.http.impl.client.CloseableHttpClient;
5755
import org.apache.http.impl.client.HttpClients;
56+
import org.apache.http.ssl.SSLContexts;
5857
import org.apache.http.util.EntityUtils;
5958

6059
import com.cloud.utils.Pair;
@@ -98,8 +97,8 @@ protected void createUriRequest(String downloadUrl, Map<String, String> headers)
9897
req = new HttpGet(downloadUrl);
9998
setFollowRedirects(this.isFollowRedirects());
10099
if (MapUtils.isNotEmpty(headers)) {
101-
for (String headerKey: headers.keySet()) {
102-
req.setHeader(headerKey, headers.get(headerKey));
100+
for (Map.Entry<String, String> entry : headers.entrySet()) {
101+
req.setHeader(entry.getKey(), entry.getValue());
103102
}
104103
}
105104
}
@@ -120,10 +119,10 @@ private SSLContext getSSLContext() {
120119
String password = "changeit";
121120
defaultKeystore.load(is, password.toCharArray());
122121
}
123-
TrustManager[] tm = HttpsMultiTrustManager.getTrustManagersFromKeyStores(customKeystore, defaultKeystore);
124-
SSLContext sslContext = SSLUtils.getSSLContext();
125-
sslContext.init(null, tm, null);
126-
return sslContext;
122+
return SSLContexts.custom()
123+
.loadTrustMaterial(customKeystore, null)
124+
.loadTrustMaterial(defaultKeystore, null)
125+
.build();
127126
} catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException | KeyManagementException e) {
128127
logger.error(String.format("Failure getting SSL context for HTTPS downloader, using default SSL context: %s", e.getMessage()), e);
129128
try {

core/src/main/java/org/apache/cloudstack/direct/download/HttpsMultiTrustManager.java

Lines changed: 0 additions & 102 deletions
This file was deleted.

engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java

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

19+
import com.cloud.storage.Snapshot;
20+
import com.cloud.storage.Volume;
1921
import java.net.URI;
2022
import java.util.HashMap;
2123
import java.util.LinkedHashMap;
@@ -129,11 +131,11 @@ interface Topics {
129131
* @throws InsufficientCapacityException If there are insufficient capacity to deploy this vm.
130132
*/
131133
void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, DiskOfferingInfo rootDiskOfferingInfo,
132-
List<DiskOfferingInfo> dataDiskOfferings, LinkedHashMap<? extends Network, List<? extends NicProfile>> auxiliaryNetworks, DeploymentPlan plan,
133-
HypervisorType hyperType, Map<String, Map<Integer, String>> extraDhcpOptions, Map<Long, DiskOffering> datadiskTemplateToDiskOfferingMap) throws InsufficientCapacityException;
134+
List<DiskOfferingInfo> dataDiskOfferings, LinkedHashMap<? extends Network, List<? extends NicProfile>> auxiliaryNetworks, DeploymentPlan plan,
135+
HypervisorType hyperType, Map<String, Map<Integer, String>> extraDhcpOptions, Map<Long, DiskOffering> datadiskTemplateToDiskOfferingMap, Volume volume, Snapshot snapshot) throws InsufficientCapacityException;
134136

135137
void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering,
136-
LinkedHashMap<? extends Network, List<? extends NicProfile>> networkProfiles, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException;
138+
LinkedHashMap<? extends Network, List<? extends NicProfile>> networkProfiles, DeploymentPlan plan, HypervisorType hyperType, Volume volume, Snapshot snapshot) throws InsufficientCapacityException;
137139

138140
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params);
139141

engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Lon
149149
* Allocate a volume or multiple volumes in case of template is registered with the 'deploy-as-is' option, allowing multiple disks
150150
*/
151151
List<DiskProfile> allocateTemplatedVolumes(Type type, String name, DiskOffering offering, Long rootDisksize, Long minIops, Long maxIops, VirtualMachineTemplate template, VirtualMachine vm,
152-
Account owner);
152+
Account owner, Volume volume, Snapshot snapshot);
153153

154154
String getVmNameFromVolumeId(long volumeId);
155155

0 commit comments

Comments
 (0)