Skip to content

Commit ba76d64

Browse files
committed
Merge remote-tracking branch 'upstream/main' into multi-scope
2 parents 05f051a + 0dcb8da commit ba76d64

File tree

169 files changed

+5154
-1856
lines changed

Some content is hidden

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

169 files changed

+5154
-1856
lines changed

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
@@ -785,6 +785,9 @@ public class EventTypes {
785785
public static final String EVENT_SHAREDFS_EXPUNGE = "SHAREDFS.EXPUNGE";
786786
public static final String EVENT_SHAREDFS_RECOVER = "SHAREDFS.RECOVER";
787787

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

790793
// 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";
@@ -322,6 +329,7 @@ public class ApiConstants {
322329
public static final String MAC_ADDRESS = "macaddress";
323330
public static final String MAX = "max";
324331
public static final String MAX_SNAPS = "maxsnaps";
332+
public static final String MAX_BACKUPS = "maxbackups";
325333
public static final String MAX_CPU_NUMBER = "maxcpunumber";
326334
public static final String MAX_MEMORY = "maxmemory";
327335
public static final String MIN_CPU_NUMBER = "mincpunumber";
@@ -436,6 +444,7 @@ public class ApiConstants {
436444
public static final String QUALIFIERS = "qualifiers";
437445
public static final String QUERY_FILTER = "queryfilter";
438446
public static final String SCHEDULE = "schedule";
447+
public static final String SCHEDULE_ID = "scheduleid";
439448
public static final String SCOPE = "scope";
440449
public static final String SEARCH_BASE = "searchbase";
441450
public static final String SECONDARY_IP = "secondaryip";
@@ -447,7 +456,6 @@ public class ApiConstants {
447456
public static final String SENT = "sent";
448457
public static final String SENT_BYTES = "sentbytes";
449458
public static final String SERIAL = "serial";
450-
public static final String SERVICE_IP = "serviceip";
451459
public static final String SERVICE_OFFERING_ID = "serviceofferingid";
452460
public static final String SESSIONKEY = "sessionkey";
453461
public static final String SHOW_CAPACITIES = "showcapacities";
@@ -477,11 +485,12 @@ public class ApiConstants {
477485
public static final String STATE = "state";
478486
public static final String STATS = "stats";
479487
public static final String STATUS = "status";
480-
public static final String STORAGE_TYPE = "storagetype";
481-
public static final String STORAGE_POLICY = "storagepolicy";
482-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
483488
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
484489
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";
485494
public static final String SUBNET = "subnet";
486495
public static final String OWNER = "owner";
487496
public static final String SWAP_OWNER = "swapowner";
@@ -954,7 +963,6 @@ public class ApiConstants {
954963
public static final String AUTOSCALE_VMGROUP_NAME = "autoscalevmgroupname";
955964
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
956965
public static final String BAREMETAL_RCT_URL = "baremetalrcturl";
957-
public static final String BATCH_SIZE = "batchsize";
958966
public static final String UCS_DN = "ucsdn";
959967
public static final String GSLB_PROVIDER = "gslbprovider";
960968
public static final String EXCLUSIVE_GSLB_PROVIDER = "isexclusivegslbprovider";
@@ -1148,7 +1156,6 @@ public class ApiConstants {
11481156
public static final String MTU = "mtu";
11491157
public static final String AUTO_ENABLE_KVM_HOST = "autoenablekvmhost";
11501158
public static final String LIST_APIS = "listApis";
1151-
public static final String OBJECT_STORAGE_ID = "objectstorageid";
11521159
public static final String VERSIONING = "versioning";
11531160
public static final String OBJECT_LOCKING = "objectlocking";
11541161
public static final String ENCRYPTION = "encryption";
@@ -1162,7 +1169,6 @@ public class ApiConstants {
11621169
public static final String DISK_PATH = "diskpath";
11631170
public static final String IMPORT_SOURCE = "importsource";
11641171
public static final String TEMP_PATH = "temppath";
1165-
public static final String OBJECT_STORAGE = "objectstore";
11661172
public static final String HEURISTIC_RULE = "heuristicrule";
11671173
public static final String HEURISTIC_TYPE_VALID_OPTIONS = "Valid options are: ISO, SNAPSHOT, TEMPLATE and VOLUME.";
11681174
public static final String MANAGEMENT = "management";
@@ -1190,6 +1196,16 @@ public class ApiConstants {
11901196
public static final String SHAREDFSVM_MIN_CPU_COUNT = "sharedfsvmmincpucount";
11911197
public static final String SHAREDFSVM_MIN_RAM_SIZE = "sharedfsvmminramsize";
11921198

1199+
// Object Storage related
1200+
public static final String BUCKET_AVAILABLE = "bucketavailable";
1201+
public static final String BUCKET_LIMIT = "bucketlimit";
1202+
public static final String BUCKET_TOTAL = "buckettotal";
1203+
public static final String OBJECT_STORAGE_ID = "objectstorageid";
1204+
public static final String OBJECT_STORAGE = "objectstore";
1205+
public static final String OBJECT_STORAGE_AVAILABLE = "objectstorageavailable";
1206+
public static final String OBJECT_STORAGE_LIMIT = "objectstoragelimit";
1207+
public static final String OBJECT_STORAGE_TOTAL = "objectstoragetotal";
1208+
11931209
public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +
11941210
"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 " +
11951211
"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 " +
@@ -1203,6 +1219,8 @@ public class ApiConstants {
12031219
"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 " +
12041220
"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.";
12051221

1222+
public static final String VMWARE_DC = "vmwaredc";
1223+
12061224
/**
12071225
* This enum specifies IO Drivers, each option controls specific policies on I/O.
12081226
* 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)