Skip to content

Commit 3f992aa

Browse files
Marcus SorensenMarcus Sorensen
authored andcommitted
Volume encryption feature
Signed-off-by: Marcus Sorensen <[email protected]>
1 parent 711d4b9 commit 3f992aa

File tree

108 files changed

+4028
-364
lines changed

Some content is hidden

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

108 files changed

+4028
-364
lines changed

api/src/main/java/com/cloud/agent/api/to/DiskTO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class DiskTO {
4040
public static final String VMDK = "vmdk";
4141
public static final String EXPAND_DATASTORE = "expandDatastore";
4242
public static final String TEMPLATE_RESIGN = "templateResign";
43+
public static final String SECRET_CONSUMER_DETAIL = "storageMigrateSecretConsumer";
4344

4445
private DataTO data;
4546
private Long diskSeq;

api/src/main/java/com/cloud/host/Host.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static String[] toStrings(Host.Type... types) {
5353
}
5454
}
5555
public static final String HOST_UEFI_ENABLE = "host.uefi.enable";
56+
public static final String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
5657

5758
/**
5859
* @return name of the machine.

api/src/main/java/com/cloud/offering/DiskOffering.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@ public String toString() {
149149
boolean isComputeOnly();
150150

151151
boolean getDiskSizeStrictness();
152+
153+
boolean getEncrypt();
154+
155+
void setEncrypt(boolean encrypt);
152156
}

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,34 @@ public static enum TemplateType {
130130
}
131131

132132
public static enum StoragePoolType {
133-
Filesystem(false, true), // local directory
134-
NetworkFilesystem(true, true), // NFS
135-
IscsiLUN(true, false), // shared LUN, with a clusterfs overlay
136-
Iscsi(true, false), // for e.g., ZFS Comstar
137-
ISO(false, false), // for iso image
138-
LVM(false, false), // XenServer local LVM SR
139-
CLVM(true, false),
140-
RBD(true, true), // http://libvirt.org/storage.html#StorageBackendRBD
141-
SharedMountPoint(true, false),
142-
VMFS(true, true), // VMware VMFS storage
143-
PreSetup(true, true), // for XenServer, Storage Pool is set up by customers.
144-
EXT(false, true), // XenServer local EXT SR
145-
OCFS2(true, false),
146-
SMB(true, false),
147-
Gluster(true, false),
148-
PowerFlex(true, true), // Dell EMC PowerFlex/ScaleIO (formerly VxFlexOS)
149-
ManagedNFS(true, false),
150-
Linstor(true, true),
151-
DatastoreCluster(true, true); // for VMware, to abstract pool of clusters
133+
Filesystem(false, true, true), // local directory
134+
NetworkFilesystem(true, true, true), // NFS
135+
IscsiLUN(true, false, false), // shared LUN, with a clusterfs overlay
136+
Iscsi(true, false, false), // for e.g., ZFS Comstar
137+
ISO(false, false, false), // for iso image
138+
LVM(false, false, false), // XenServer local LVM SR
139+
CLVM(true, false, false),
140+
RBD(true, true, false), // http://libvirt.org/storage.html#StorageBackendRBD
141+
SharedMountPoint(true, false, true),
142+
VMFS(true, true, false), // VMware VMFS storage
143+
PreSetup(true, true, false), // for XenServer, Storage Pool is set up by customers.
144+
EXT(false, true, false), // XenServer local EXT SR
145+
OCFS2(true, false, false),
146+
SMB(true, false, false),
147+
Gluster(true, false, false),
148+
PowerFlex(true, true, true), // Dell EMC PowerFlex/ScaleIO (formerly VxFlexOS)
149+
ManagedNFS(true, false, false),
150+
Linstor(true, true, false),
151+
DatastoreCluster(true, true, false); // for VMware, to abstract pool of clusters
152152

153153
private final boolean shared;
154154
private final boolean overprovisioning;
155+
private final boolean encryption;
155156

156-
StoragePoolType(boolean shared, boolean overprovisioning) {
157+
StoragePoolType(boolean shared, boolean overprovisioning, boolean encryption) {
157158
this.shared = shared;
158159
this.overprovisioning = overprovisioning;
160+
this.encryption = encryption;
159161
}
160162

161163
public boolean isShared() {
@@ -165,6 +167,8 @@ public boolean isShared() {
165167
public boolean supportsOverProvisioning() {
166168
return overprovisioning;
167169
}
170+
171+
public boolean supportsEncryption() { return encryption; }
168172
}
169173

170174
public static List<StoragePoolType> getNonSharedStoragePoolTypes() {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,12 @@ enum Event {
247247
String getExternalUuid();
248248

249249
void setExternalUuid(String externalUuid);
250+
251+
public Long getPassphraseId();
252+
253+
public void setPassphraseId(Long id);
254+
255+
public String getEncryptFormat();
256+
257+
public void setEncryptFormat(String encryptFormat);
250258
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class DiskProfile {
4444
private String cacheMode;
4545
private Long minIops;
4646
private Long maxIops;
47+
private boolean requiresEncryption;
4748

4849
private HypervisorType hyperType;
4950

@@ -63,6 +64,12 @@ public DiskProfile(long volumeId, Volume.Type type, String name, long diskOfferi
6364
this.volumeId = volumeId;
6465
}
6566

67+
public DiskProfile(long volumeId, Volume.Type type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable,
68+
Long templateId, boolean requiresEncryption) {
69+
this(volumeId, type, name, diskOfferingId, size, tags, useLocalStorage, recreatable, templateId);
70+
this.requiresEncryption = requiresEncryption;
71+
}
72+
6673
public DiskProfile(Volume vol, DiskOffering offering, HypervisorType hyperType) {
6774
this(vol.getId(),
6875
vol.getVolumeType(),
@@ -75,6 +82,7 @@ public DiskProfile(Volume vol, DiskOffering offering, HypervisorType hyperType)
7582
null);
7683
this.hyperType = hyperType;
7784
this.provisioningType = offering.getProvisioningType();
85+
this.requiresEncryption = offering.getEncrypt() || vol.getPassphraseId() != null;
7886
}
7987

8088
public DiskProfile(DiskProfile dp) {
@@ -230,7 +238,6 @@ public String getCacheMode() {
230238
return cacheMode;
231239
}
232240

233-
234241
public Long getMinIops() {
235242
return minIops;
236243
}
@@ -247,4 +254,7 @@ public void setMaxIops(Long maxIops) {
247254
this.maxIops = maxIops;
248255
}
249256

257+
public boolean requiresEncryption() { return requiresEncryption; }
258+
259+
public void setEncryption(boolean encrypt) { this.requiresEncryption = encrypt; }
250260
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public class ApiConstants {
109109
public static final String CUSTOM_JOB_ID = "customjobid";
110110
public static final String CURRENT_START_IP = "currentstartip";
111111
public static final String CURRENT_END_IP = "currentendip";
112+
public static final String ENCRYPT = "encrypt";
113+
public static final String ENCRYPT_ROOT = "encryptroot";
114+
public static final String ENCRYPTION_SUPPORTED = "encryptionsupported";
112115
public static final String MIN_IOPS = "miniops";
113116
public static final String MAX_IOPS = "maxiops";
114117
public static final String HYPERVISOR_SNAPSHOT_RESERVE = "hypervisorsnapshotreserve";

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,14 @@ public class CreateDiskOfferingCmd extends BaseCmd {
163163
@Parameter(name = ApiConstants.DISK_SIZE_STRICTNESS, type = CommandType.BOOLEAN, description = "To allow or disallow the resize operation on the disks created from this disk offering, if the flag is true then resize is not allowed", since = "4.17")
164164
private Boolean diskSizeStrictness;
165165

166+
@Parameter(name = ApiConstants.ENCRYPT, type = CommandType.BOOLEAN, required=false, description = "Volumes using this offering should be encrypted", since = "4.18")
167+
private Boolean encrypt;
168+
166169
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "details to specify disk offering parameters", since = "4.16")
167170
private Map details;
168171

172+
173+
169174
/////////////////////////////////////////////////////
170175
/////////////////// Accessors ///////////////////////
171176
/////////////////////////////////////////////////////
@@ -202,6 +207,13 @@ public Long getMaxIops() {
202207
return maxIops;
203208
}
204209

210+
public boolean getEncrypt() {
211+
if (encrypt == null) {
212+
return false;
213+
}
214+
return encrypt;
215+
}
216+
205217
public List<Long> getDomainIds() {
206218
if (CollectionUtils.isNotEmpty(domainIds)) {
207219
Set<Long> set = new LinkedHashSet<>(domainIds);

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ public class CreateServiceOfferingCmd extends BaseCmd {
242242
since = "4.17")
243243
private Boolean diskOfferingStrictness;
244244

245+
@Parameter(name = ApiConstants.ENCRYPT_ROOT, type = CommandType.BOOLEAN, description = "VMs using this offering require root volume encryption", since="4.18")
246+
private Boolean encryptRoot;
247+
248+
245249
/////////////////////////////////////////////////////
246250
/////////////////// Accessors ///////////////////////
247251
/////////////////////////////////////////////////////
@@ -472,6 +476,13 @@ public boolean getDiskOfferingStrictness() {
472476
return diskOfferingStrictness == null ? false : diskOfferingStrictness;
473477
}
474478

479+
public boolean getEncryptRoot() {
480+
if (encryptRoot != null) {
481+
return encryptRoot;
482+
}
483+
return false;
484+
}
485+
475486
/////////////////////////////////////////////////////
476487
/////////////// API Implementation///////////////////
477488
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public class ListDiskOfferingsCmd extends BaseListDomainResourcesCmd {
5858
@Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, description = "The ID of the storage pool, tags of the storage pool are used to filter the offerings", since = "4.17")
5959
private Long storagePoolId;
6060

61+
@Parameter(name = ApiConstants.ENCRYPT, type = CommandType.BOOLEAN, description = "listed offerings support disk encryption", since = "4.18")
62+
private Boolean encrypt;
63+
6164
/////////////////////////////////////////////////////
6265
/////////////////// Accessors ///////////////////////
6366
/////////////////////////////////////////////////////
@@ -78,9 +81,9 @@ public Long getVolumeId() {
7881
return volumeId;
7982
}
8083

81-
public Long getStoragePoolId() {
82-
return storagePoolId;
83-
}
84+
public Long getStoragePoolId() { return storagePoolId; }
85+
86+
public Boolean getEncrypt() { return encrypt; }
8487

8588
/////////////////////////////////////////////////////
8689
/////////////// API Implementation///////////////////

0 commit comments

Comments
 (0)