Skip to content

Commit 0dcb8da

Browse files
committed
Merge branch '4.20'
2 parents 0a92cc0 + 4f3e8e8 commit 0dcb8da

File tree

112 files changed

+2958
-1584
lines changed

Some content is hidden

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

112 files changed

+2958
-1584
lines changed

api/src/main/java/com/cloud/exception/StorageAccessException.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public class StorageAccessException extends RuntimeException {
2727
private static final long serialVersionUID = SerialVersionUID.StorageAccessException;
2828

29-
public StorageAccessException(String message) {
30-
super(message);
29+
public StorageAccessException(String message, Exception causer) {
30+
super(message, causer);
3131
}
3232
}

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

+45-96
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@
1616
// under the License.
1717
package com.cloud.storage;
1818

19+
import org.apache.commons.lang.NotImplementedException;
20+
1921
import java.util.ArrayList;
20-
import java.util.LinkedHashMap;
2122
import java.util.List;
22-
import java.util.Map;
23-
import java.util.Objects;
24-
25-
import org.apache.commons.lang.NotImplementedException;
26-
import org.apache.commons.lang3.StringUtils;
2723

2824
public class Storage {
2925
public static enum ImageFormat {
@@ -139,6 +135,21 @@ public static enum TemplateType {
139135
ISODISK /* Template corresponding to a iso (non root disk) present in an OVA */
140136
}
141137

138+
public enum EncryptionSupport {
139+
/**
140+
* Encryption not supported.
141+
*/
142+
Unsupported,
143+
/**
144+
* Will use hypervisor encryption driver (qemu -> luks)
145+
*/
146+
Hypervisor,
147+
/**
148+
* Storage pool handles encryption and just provides an encrypted volume
149+
*/
150+
Storage
151+
}
152+
142153
/**
143154
* StoragePoolTypes carry some details about the format and capabilities of a storage pool. While not necessarily a
144155
* 1:1 with PrimaryDataStoreDriver (and for KVM agent, KVMStoragePool and StorageAdaptor) implementations, it is
@@ -150,61 +161,37 @@ public static enum TemplateType {
150161
* ensure this is available on the agent side as well. This is best done by defining the StoragePoolType in a common
151162
* package available on both management server and agent plugin jars.
152163
*/
153-
public static class StoragePoolType {
154-
private static final Map<String, StoragePoolType> map = new LinkedHashMap<>();
155-
156-
public static final StoragePoolType Filesystem = new StoragePoolType("Filesystem", false, true, true);
157-
public static final StoragePoolType NetworkFilesystem = new StoragePoolType("NetworkFilesystem", true, true, true);
158-
public static final StoragePoolType IscsiLUN = new StoragePoolType("IscsiLUN", true, false, false);
159-
public static final StoragePoolType Iscsi = new StoragePoolType("Iscsi", true, false, false);
160-
public static final StoragePoolType ISO = new StoragePoolType("ISO", false, false, false);
161-
public static final StoragePoolType LVM = new StoragePoolType("LVM", false, false, false);
162-
public static final StoragePoolType CLVM = new StoragePoolType("CLVM", true, false, false);
163-
public static final StoragePoolType RBD = new StoragePoolType("RBD", true, true, false);
164-
public static final StoragePoolType SharedMountPoint = new StoragePoolType("SharedMountPoint", true, true, true);
165-
public static final StoragePoolType VMFS = new StoragePoolType("VMFS", true, true, false);
166-
public static final StoragePoolType PreSetup = new StoragePoolType("PreSetup", true, true, false);
167-
public static final StoragePoolType EXT = new StoragePoolType("EXT", false, true, false);
168-
public static final StoragePoolType OCFS2 = new StoragePoolType("OCFS2", true, false, false);
169-
public static final StoragePoolType SMB = new StoragePoolType("SMB", true, false, false);
170-
public static final StoragePoolType Gluster = new StoragePoolType("Gluster", true, false, false);
171-
public static final StoragePoolType PowerFlex = new StoragePoolType("PowerFlex", true, true, true);
172-
public static final StoragePoolType ManagedNFS = new StoragePoolType("ManagedNFS", true, false, false);
173-
public static final StoragePoolType Linstor = new StoragePoolType("Linstor", true, true, false);
174-
public static final StoragePoolType DatastoreCluster = new StoragePoolType("DatastoreCluster", true, true, false);
175-
public static final StoragePoolType StorPool = new StoragePoolType("StorPool", true,true,true);
176-
public static final StoragePoolType FiberChannel = new StoragePoolType("FiberChannel", true,true,false);
177-
178-
179-
private final String name;
164+
public static enum StoragePoolType {
165+
Filesystem(false, true, EncryptionSupport.Hypervisor), // local directory
166+
NetworkFilesystem(true, true, EncryptionSupport.Hypervisor), // NFS
167+
IscsiLUN(true, false, EncryptionSupport.Unsupported), // shared LUN, with a clusterfs overlay
168+
Iscsi(true, false, EncryptionSupport.Unsupported), // for e.g., ZFS Comstar
169+
ISO(false, false, EncryptionSupport.Unsupported), // for iso image
170+
LVM(false, false, EncryptionSupport.Unsupported), // XenServer local LVM SR
171+
CLVM(true, false, EncryptionSupport.Unsupported),
172+
RBD(true, true, EncryptionSupport.Unsupported), // http://libvirt.org/storage.html#StorageBackendRBD
173+
SharedMountPoint(true, true, EncryptionSupport.Hypervisor),
174+
VMFS(true, true, EncryptionSupport.Unsupported), // VMware VMFS storage
175+
PreSetup(true, true, EncryptionSupport.Unsupported), // for XenServer, Storage Pool is set up by customers.
176+
EXT(false, true, EncryptionSupport.Unsupported), // XenServer local EXT SR
177+
OCFS2(true, false, EncryptionSupport.Unsupported),
178+
SMB(true, false, EncryptionSupport.Unsupported),
179+
Gluster(true, false, EncryptionSupport.Unsupported),
180+
PowerFlex(true, true, EncryptionSupport.Hypervisor), // Dell EMC PowerFlex/ScaleIO (formerly VxFlexOS)
181+
ManagedNFS(true, false, EncryptionSupport.Unsupported),
182+
Linstor(true, true, EncryptionSupport.Storage),
183+
DatastoreCluster(true, true, EncryptionSupport.Unsupported), // for VMware, to abstract pool of clusters
184+
StorPool(true, true, EncryptionSupport.Hypervisor),
185+
FiberChannel(true, true, EncryptionSupport.Unsupported); // Fiber Channel Pool for KVM hypervisors is used to find the volume by WWN value (/dev/disk/by-id/wwn-<wwnvalue>)
186+
180187
private final boolean shared;
181188
private final boolean overProvisioning;
182-
private final boolean encryption;
189+
private final EncryptionSupport encryption;
183190

184-
/**
185-
* New StoragePoolType, set the name to check with it in Dao (Note: Do not register it into the map of pool types).
186-
* @param name name of the StoragePoolType.
187-
*/
188-
public StoragePoolType(String name) {
189-
this.name = name;
190-
this.shared = false;
191-
this.overProvisioning = false;
192-
this.encryption = false;
193-
}
194-
195-
/**
196-
* Define a new StoragePoolType, and register it into the map of pool types known to the management server.
197-
* @param name Simple unique name of the StoragePoolType.
198-
* @param shared Storage pool is shared/accessible to multiple hypervisors
199-
* @param overProvisioning Storage pool supports overProvisioning
200-
* @param encryption Storage pool supports encrypted volumes
201-
*/
202-
public StoragePoolType(String name, boolean shared, boolean overProvisioning, boolean encryption) {
203-
this.name = name;
191+
StoragePoolType(boolean shared, boolean overProvisioning, EncryptionSupport encryption) {
204192
this.shared = shared;
205193
this.overProvisioning = overProvisioning;
206194
this.encryption = encryption;
207-
addStoragePoolType(this);
208195
}
209196

210197
public boolean isShared() {
@@ -216,49 +203,11 @@ public boolean supportsOverProvisioning() {
216203
}
217204

218205
public boolean supportsEncryption() {
219-
return encryption;
220-
}
221-
222-
private static void addStoragePoolType(StoragePoolType storagePoolType) {
223-
map.putIfAbsent(storagePoolType.name, storagePoolType);
224-
}
225-
226-
public static StoragePoolType[] values() {
227-
return map.values().toArray(StoragePoolType[]::new).clone();
228-
}
229-
230-
public static StoragePoolType valueOf(String name) {
231-
if (StringUtils.isBlank(name)) {
232-
return null;
233-
}
234-
235-
StoragePoolType storage = map.get(name);
236-
if (storage == null) {
237-
throw new IllegalArgumentException("StoragePoolType '" + name + "' not found");
238-
}
239-
return storage;
206+
return encryption == EncryptionSupport.Hypervisor || encryption == EncryptionSupport.Storage;
240207
}
241208

242-
@Override
243-
public String toString() {
244-
return name;
245-
}
246-
247-
public String name() {
248-
return name;
249-
}
250-
251-
@Override
252-
public boolean equals(Object o) {
253-
if (this == o) return true;
254-
if (o == null || getClass() != o.getClass()) return false;
255-
StoragePoolType that = (StoragePoolType) o;
256-
return Objects.equals(name, that.name);
257-
}
258-
259-
@Override
260-
public int hashCode() {
261-
return Objects.hash(name);
209+
public EncryptionSupport encryptionSupportMode() {
210+
return encryption;
262211
}
263212
}
264213

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class ApiConstants {
6363
public static final String BASE64_IMAGE = "base64image";
6464
public static final String BGP_PEERS = "bgppeers";
6565
public static final String BGP_PEER_IDS = "bgppeerids";
66+
public static final String BATCH_SIZE = "batchsize";
6667
public static final String BITS = "bits";
6768
public static final String BOOTABLE = "bootable";
6869
public static final String BIND_DN = "binddn";
@@ -455,7 +456,6 @@ public class ApiConstants {
455456
public static final String SENT = "sent";
456457
public static final String SENT_BYTES = "sentbytes";
457458
public static final String SERIAL = "serial";
458-
public static final String SERVICE_IP = "serviceip";
459459
public static final String SERVICE_OFFERING_ID = "serviceofferingid";
460460
public static final String SESSIONKEY = "sessionkey";
461461
public static final String SHOW_CAPACITIES = "showcapacities";
@@ -485,11 +485,12 @@ public class ApiConstants {
485485
public static final String STATE = "state";
486486
public static final String STATS = "stats";
487487
public static final String STATUS = "status";
488-
public static final String STORAGE_TYPE = "storagetype";
489-
public static final String STORAGE_POLICY = "storagepolicy";
490-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
491488
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
492489
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
490+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
491+
public static final String STORAGE_POLICY = "storagepolicy";
492+
public static final String STORAGE_POOL = "storagepool";
493+
public static final String STORAGE_TYPE = "storagetype";
493494
public static final String SUBNET = "subnet";
494495
public static final String OWNER = "owner";
495496
public static final String SWAP_OWNER = "swapowner";
@@ -962,7 +963,6 @@ public class ApiConstants {
962963
public static final String AUTOSCALE_VMGROUP_NAME = "autoscalevmgroupname";
963964
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
964965
public static final String BAREMETAL_RCT_URL = "baremetalrcturl";
965-
public static final String BATCH_SIZE = "batchsize";
966966
public static final String UCS_DN = "ucsdn";
967967
public static final String GSLB_PROVIDER = "gslbprovider";
968968
public static final String EXCLUSIVE_GSLB_PROVIDER = "isexclusivegslbprovider";
@@ -1210,6 +1210,7 @@ public class ApiConstants {
12101210
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
12111211
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
12121212
"value will be applied.";
1213+
12131214
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
12141215
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
12151216
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";
@@ -1218,6 +1219,8 @@ public class ApiConstants {
12181219
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
12191220
"added, it will be interpreted as \"23:59:59\"). If the recommended format is not used, the date will be considered in the server timezone.";
12201221

1222+
public static final String VMWARE_DC = "vmwaredc";
1223+
12211224
/**
12221225
* This enum specifies IO Drivers, each option controls specific policies on I/O.
12231226
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
152152
@Deprecated
153153
@SerializedName("memoryallocated")
154154
@Param(description = "the amount of the host's memory currently allocated")
155-
private long memoryAllocated;
155+
private Long memoryAllocated;
156156

157157
@SerializedName("memoryallocatedpercentage")
158158
@Param(description = "the amount of the host's memory currently allocated in percentage")
@@ -415,7 +415,7 @@ public void setMemWithOverprovisioning(String memWithOverprovisioning){
415415
this.memWithOverprovisioning=memWithOverprovisioning;
416416
}
417417

418-
public void setMemoryAllocated(long memoryAllocated) {
418+
public void setMemoryAllocated(Long memoryAllocated) {
419419
this.memoryAllocated = memoryAllocated;
420420
}
421421

@@ -703,8 +703,8 @@ public Long getMemoryTotal() {
703703
return memoryTotal;
704704
}
705705

706-
public long getMemoryAllocated() {
707-
return memoryAllocated;
706+
public Long getMemoryAllocated() {
707+
return memoryAllocated == null ? 0 : memoryAllocated;
708708
}
709709

710710
public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) {

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public class ManagementServerResponse extends BaseResponse {
7474
@Param(description = "the running OS kernel version for this Management Server")
7575
private String kernelVersion;
7676

77-
@SerializedName(ApiConstants.SERVICE_IP)
77+
@SerializedName(ApiConstants.IP_ADDRESS)
7878
@Param(description = "the IP Address for this Management Server")
79-
private String serviceIp;
79+
private String ipAddress;
8080

8181
@SerializedName(ApiConstants.PEERS)
8282
@Param(description = "the Management Server Peers")
@@ -130,8 +130,8 @@ public Date getLastBoot() {
130130
return lastBoot;
131131
}
132132

133-
public String getServiceIp() {
134-
return serviceIp;
133+
public String getIpAddress() {
134+
return ipAddress;
135135
}
136136

137137
public Long getAgentsCount() {
@@ -186,8 +186,8 @@ public void setKernelVersion(String kernelVersion) {
186186
this.kernelVersion = kernelVersion;
187187
}
188188

189-
public void setServiceIp(String serviceIp) {
190-
this.serviceIp = serviceIp;
189+
public void setIpAddress(String ipAddress) {
190+
this.ipAddress = ipAddress;
191191
}
192192

193193
public void setAgentsCount(Long agentsCount) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.agent.api;
21+
22+
/**
23+
* This command will destroy a leftover VM during the expunge process if it wasn't destroyed before.
24+
*
25+
*/
26+
public class CleanupVMCommand extends Command {
27+
String vmName;
28+
boolean executeInSequence;
29+
30+
public CleanupVMCommand(String vmName) {
31+
this(vmName, false);
32+
}
33+
public CleanupVMCommand(String vmName, boolean executeInSequence) {
34+
this.vmName = vmName;
35+
this.executeInSequence = executeInSequence;
36+
}
37+
38+
@Override
39+
public boolean executeInSequence() {
40+
return executeInSequence;
41+
}
42+
43+
public String getVmName() {
44+
return vmName;
45+
}
46+
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, VirtualMachinePro
18071807
try {
18081808
volService.grantAccess(volFactory.getVolume(newVol.getId()), host, destPool);
18091809
} catch (Exception e) {
1810-
throw new StorageAccessException(String.format("Unable to grant access to the volume [%s] on host [%s].", newVolToString, host));
1810+
throw new StorageAccessException(String.format("Unable to grant access to the volume [%s] on host [%s].", newVolToString, host), e);
18111811
}
18121812
}
18131813

@@ -1847,7 +1847,7 @@ protected void grantVolumeAccessToHostIfNeeded(PrimaryDataStore volumeStore, lon
18471847
try {
18481848
volService.grantAccess(volFactory.getVolume(volumeId), host, volumeStore);
18491849
} catch (Exception e) {
1850-
throw new StorageAccessException(String.format("Unable to grant access to volume [%s] on host [%s].", volToString, host));
1850+
throw new StorageAccessException(String.format("Unable to grant access to volume [%s] on host [%s].", volToString, host), e);
18511851
}
18521852
}
18531853

@@ -1928,7 +1928,7 @@ public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws Sto
19281928
try {
19291929
volService.grantAccess(volFactory.getVolume(vol.getId()), host, store);
19301930
} catch (Exception e) {
1931-
throw new StorageAccessException(String.format("Unable to grant access to volume [%s] on host [%s].", volToString, host));
1931+
throw new StorageAccessException(String.format("Unable to grant access to volume [%s] on host [%s].", volToString, host), e);
19321932
}
19331933
} else {
19341934
grantVolumeAccessToHostIfNeeded(store, vol.getId(), host, volToString);

engine/schema/src/main/java/com/cloud/dc/ClusterDetailsDao.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
import java.util.Map;
2121

2222
import com.cloud.utils.db.GenericDao;
23+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
2324

24-
public interface ClusterDetailsDao extends GenericDao<ClusterDetailsVO, Long> {
25+
public interface ClusterDetailsDao extends GenericDao<ClusterDetailsVO, Long>, ResourceDetailsDao<ClusterDetailsVO> {
2526
Map<String, String> findDetails(long clusterId);
2627

2728
void persist(long clusterId, Map<String, String> details);

0 commit comments

Comments
 (0)