Skip to content

Commit ae62219

Browse files
committed
Merge remote-tracking branch 'upstream/main' into instance
2 parents b7590ba + a8b18a5 commit ae62219

File tree

215 files changed

+6504
-2048
lines changed

Some content is hidden

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

215 files changed

+6504
-2048
lines changed

.asf.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ github:
5151

5252
collaborators:
5353
- acs-robot
54-
- rajujith
55-
- winterhazel
5654
- gpordeus
5755
- hsato03
5856
- bernardodemarco
5957
- abh1sar
6058
- FelipeM525
6159
- lucas-a-martins
60+
- nicoschmdt
6261

6362
protected_branches: ~
6463

api/src/main/java/com/cloud/configuration/Resource.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface Resource {
2121
short RESOURCE_UNLIMITED = -1;
2222
String UNLIMITED = "Unlimited";
2323

24-
enum ResourceType { // Primary and Secondary storage are allocated_storage and not the physical storage.
24+
enum ResourceType { // All storage type resources are allocated_storage and not the physical storage.
2525
user_vm("user_vm", 0),
2626
public_ip("public_ip", 1),
2727
volume("volume", 2),
@@ -33,7 +33,11 @@ enum ResourceType { // Primary and Secondary storage are allocated_storage and n
3333
cpu("cpu", 8),
3434
memory("memory", 9),
3535
primary_storage("primary_storage", 10),
36-
secondary_storage("secondary_storage", 11);
36+
secondary_storage("secondary_storage", 11),
37+
backup("backup", 12),
38+
backup_storage("backup_storage", 13),
39+
bucket("bucket", 14),
40+
object_storage("object_storage", 15);
3741

3842
private String name;
3943
private int ordinal;
@@ -62,6 +66,10 @@ public static ResourceType fromOrdinal(int ordinal) {
6266
}
6367
return null;
6468
}
69+
70+
public static Boolean isStorageType(ResourceType type) {
71+
return (type == primary_storage || type == secondary_storage || type == backup_storage || type == object_storage);
72+
}
6573
}
6674

6775
public static class ResourceOwnerType {

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,9 @@ public class EventTypes {
786786
public static final String EVENT_SHAREDFS_EXPUNGE = "SHAREDFS.EXPUNGE";
787787
public static final String EVENT_SHAREDFS_RECOVER = "SHAREDFS.RECOVER";
788788

789+
// Resource Limit
790+
public static final String EVENT_RESOURCE_LIMIT_UPDATE = "RESOURCE.LIMIT.UPDATE";
791+
789792
static {
790793

791794
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 45 additions & 96 deletions
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/com/cloud/storage/VolumeApiService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,6 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
190190
boolean stateTransitTo(Volume vol, Volume.Event event) throws NoTransitionException;
191191

192192
Pair<String, String> checkAndRepairVolume(CheckAndRepairVolumeCmd cmd) throws ResourceAllocationException;
193+
194+
Long getVolumePhysicalSize(Storage.ImageFormat format, String path, String chainInfo);
193195
}

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,19 @@ public class ApiConstants {
5151
public static final String AVAILABLE = "available";
5252
public static final String AVAILABLE_SUBNETS = "availablesubnets";
5353
public static final String AVAILABLE_VIRTUAL_MACHINE_COUNT = "availablevirtualmachinecount";
54+
public static final String BACKUP_AVAILABLE = "backupavailable";
5455
public static final String BACKUP_ID = "backupid";
56+
public static final String BACKUP_LIMIT = "backuplimit";
5557
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
5658
public static final String BACKUP_OFFERING_ID = "backupofferingid";
59+
public static final String BACKUP_STORAGE_AVAILABLE = "backupstorageavailable";
60+
public static final String BACKUP_STORAGE_LIMIT = "backupstoragelimit";
61+
public static final String BACKUP_STORAGE_TOTAL = "backupstoragetotal";
62+
public static final String BACKUP_TOTAL = "backuptotal";
5763
public static final String BASE64_IMAGE = "base64image";
5864
public static final String BGP_PEERS = "bgppeers";
5965
public static final String BGP_PEER_IDS = "bgppeerids";
66+
public static final String BATCH_SIZE = "batchsize";
6067
public static final String BITS = "bits";
6168
public static final String BOOTABLE = "bootable";
6269
public static final String BIND_DN = "binddn";
@@ -326,6 +333,7 @@ public class ApiConstants {
326333
public static final String MAC_ADDRESS = "macaddress";
327334
public static final String MAX = "max";
328335
public static final String MAX_SNAPS = "maxsnaps";
336+
public static final String MAX_BACKUPS = "maxbackups";
329337
public static final String MAX_CPU_NUMBER = "maxcpunumber";
330338
public static final String MAX_MEMORY = "maxmemory";
331339
public static final String MIN_CPU_NUMBER = "mincpunumber";
@@ -440,6 +448,7 @@ public class ApiConstants {
440448
public static final String QUALIFIERS = "qualifiers";
441449
public static final String QUERY_FILTER = "queryfilter";
442450
public static final String SCHEDULE = "schedule";
451+
public static final String SCHEDULE_ID = "scheduleid";
443452
public static final String SCOPE = "scope";
444453
public static final String SEARCH_BASE = "searchbase";
445454
public static final String SECONDARY_IP = "secondaryip";
@@ -451,7 +460,6 @@ public class ApiConstants {
451460
public static final String SENT = "sent";
452461
public static final String SENT_BYTES = "sentbytes";
453462
public static final String SERIAL = "serial";
454-
public static final String SERVICE_IP = "serviceip";
455463
public static final String SERVICE_OFFERING_ID = "serviceofferingid";
456464
public static final String SESSIONKEY = "sessionkey";
457465
public static final String SHOW_CAPACITIES = "showcapacities";
@@ -481,11 +489,12 @@ public class ApiConstants {
481489
public static final String STATE = "state";
482490
public static final String STATS = "stats";
483491
public static final String STATUS = "status";
484-
public static final String STORAGE_TYPE = "storagetype";
485-
public static final String STORAGE_POLICY = "storagepolicy";
486-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
487492
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
488493
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
494+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
495+
public static final String STORAGE_POLICY = "storagepolicy";
496+
public static final String STORAGE_POOL = "storagepool";
497+
public static final String STORAGE_TYPE = "storagetype";
489498
public static final String SUBNET = "subnet";
490499
public static final String OWNER = "owner";
491500
public static final String SWAP_OWNER = "swapowner";
@@ -960,7 +969,6 @@ public class ApiConstants {
960969
public static final String AUTOSCALE_VMGROUP_NAME = "autoscalevmgroupname";
961970
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
962971
public static final String BAREMETAL_RCT_URL = "baremetalrcturl";
963-
public static final String BATCH_SIZE = "batchsize";
964972
public static final String UCS_DN = "ucsdn";
965973
public static final String GSLB_PROVIDER = "gslbprovider";
966974
public static final String EXCLUSIVE_GSLB_PROVIDER = "isexclusivegslbprovider";
@@ -1154,7 +1162,6 @@ public class ApiConstants {
11541162
public static final String MTU = "mtu";
11551163
public static final String AUTO_ENABLE_KVM_HOST = "autoenablekvmhost";
11561164
public static final String LIST_APIS = "listApis";
1157-
public static final String OBJECT_STORAGE_ID = "objectstorageid";
11581165
public static final String VERSIONING = "versioning";
11591166
public static final String OBJECT_LOCKING = "objectlocking";
11601167
public static final String ENCRYPTION = "encryption";
@@ -1168,7 +1175,6 @@ public class ApiConstants {
11681175
public static final String DISK_PATH = "diskpath";
11691176
public static final String IMPORT_SOURCE = "importsource";
11701177
public static final String TEMP_PATH = "temppath";
1171-
public static final String OBJECT_STORAGE = "objectstore";
11721178
public static final String HEURISTIC_RULE = "heuristicrule";
11731179
public static final String HEURISTIC_TYPE_VALID_OPTIONS = "Valid options are: ISO, SNAPSHOT, TEMPLATE and VOLUME.";
11741180
public static final String MANAGEMENT = "management";
@@ -1196,6 +1202,16 @@ public class ApiConstants {
11961202
public static final String SHAREDFSVM_MIN_CPU_COUNT = "sharedfsvmmincpucount";
11971203
public static final String SHAREDFSVM_MIN_RAM_SIZE = "sharedfsvmminramsize";
11981204

1205+
// Object Storage related
1206+
public static final String BUCKET_AVAILABLE = "bucketavailable";
1207+
public static final String BUCKET_LIMIT = "bucketlimit";
1208+
public static final String BUCKET_TOTAL = "buckettotal";
1209+
public static final String OBJECT_STORAGE_ID = "objectstorageid";
1210+
public static final String OBJECT_STORAGE = "objectstore";
1211+
public static final String OBJECT_STORAGE_AVAILABLE = "objectstorageavailable";
1212+
public static final String OBJECT_STORAGE_LIMIT = "objectstoragelimit";
1213+
public static final String OBJECT_STORAGE_TOTAL = "objectstoragetotal";
1214+
11991215
public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +
12001216
"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 " +
12011217
"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 " +
@@ -1209,6 +1225,8 @@ public class ApiConstants {
12091225
"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 " +
12101226
"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.";
12111227

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

0 commit comments

Comments
 (0)