Skip to content

Commit 4739834

Browse files
committed
Address comments
1 parent 7740c5a commit 4739834

23 files changed

Lines changed: 225 additions & 150 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ public class EventTypes {
10381038
entityEventDetails.put(EVENT_KMS_KEY_WRAP, KMSKey.class);
10391039
entityEventDetails.put(EVENT_KMS_KEY_DELETE, KMSKey.class);
10401040
entityEventDetails.put(EVENT_KMS_KEY_ROTATE, KMSKey.class);
1041+
entityEventDetails.put(EVENT_VOLUME_MIGRATE_TO_KMS, KMSKey.class);
10411042

10421043
// HSM Profile Events
10431044
entityEventDetails.put(EVENT_HSM_PROFILE_CREATE, HSMProfile.class);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Set;
2424

2525
import org.apache.cloudstack.api.response.ConsoleSessionResponse;
26-
import org.apache.cloudstack.api.response.KMSKeyResponse;
2726
import org.apache.cloudstack.consoleproxy.ConsoleSession;
2827
import org.apache.cloudstack.acl.apikeypair.ApiKeyPair;
2928
import org.apache.cloudstack.acl.apikeypair.ApiKeyPairPermission;
@@ -157,7 +156,6 @@
157156
import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap;
158157
import org.apache.cloudstack.direct.download.DirectDownloadManager;
159158
import org.apache.cloudstack.gui.theme.GuiThemeJoin;
160-
import org.apache.cloudstack.kms.KMSKey;
161159
import org.apache.cloudstack.management.ManagementServerHost;
162160
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
163161
import org.apache.cloudstack.region.PortableIp;

api/src/main/java/org/apache/cloudstack/api/command/admin/kms/MigrateVolumesToKMSCmd.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@
3939
import java.util.List;
4040

4141
@APICommand(name = "migrateVolumesToKMS",
42-
description = "Migrates passphrase-based volumes to KMS (admin only)",
42+
description = "Migrates encrypted volumes to KMS",
4343
responseObject = AsyncJobResponse.class,
4444
since = "4.23.0",
4545
authorized = {RoleType.Admin},
4646
requestHasSensitiveInfo = false,
4747
responseHasSensitiveInfo = false)
4848
public class MigrateVolumesToKMSCmd extends BaseAsyncCmd {
49-
private static final String s_name = "migratevolumestokmsresponse";
5049

5150
@Inject
5251
private KMSManager kmsManager;
@@ -112,11 +111,6 @@ public void execute() {
112111
}
113112
}
114113

115-
@Override
116-
public String getCommandName() {
117-
return s_name;
118-
}
119-
120114
@Override
121115
public long getEntityOwnerId() {
122116
KMSKey key = _entityMgr.findById(KMSKey.class, kmsKeyId);
@@ -138,11 +132,11 @@ public String getEventDescription() {
138132

139133
@Override
140134
public ApiCommandResourceType getApiResourceType() {
141-
return ApiCommandResourceType.Zone;
135+
return ApiCommandResourceType.KmsKey;
142136
}
143137

144138
@Override
145139
public Long getApiResourceId() {
146-
return zoneId;
140+
return kmsKeyId;
147141
}
148142
}

api/src/main/java/org/apache/cloudstack/api/command/user/kms/DeleteKMSKeyCmd.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public ApiCommandResourceType getApiResourceType() {
8383
return ApiCommandResourceType.KmsKey;
8484
}
8585

86+
@Override
87+
public Long getApiResourceId() {
88+
return getId();
89+
}
90+
8691
@Override
8792
public String getEventType() {
8893
return EventTypes.EVENT_KMS_KEY_DELETE;

api/src/main/java/org/apache/cloudstack/api/command/user/kms/RotateKMSKeyCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import javax.inject.Inject;
3737

3838
@APICommand(name = "rotateKMSKey",
39-
description = "Rotates KEK by creating new version and scheduling gradual re-encryption",
39+
description = "Rotates KMS key (KEK) by creating new version and scheduling gradual re-encryption",
4040
responseObject = AsyncJobResponse.class,
4141
since = "4.23.0",
4242
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
@@ -123,6 +123,6 @@ public ApiCommandResourceType getApiResourceType() {
123123

124124
@Override
125125
public Long getApiResourceId() {
126-
return id;
126+
return getId();
127127
}
128128
}

api/src/main/java/org/apache/cloudstack/api/command/user/kms/UpdateKMSKeyCmd.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public ApiCommandResourceType getApiResourceType() {
104104
return ApiCommandResourceType.KmsKey;
105105
}
106106

107+
@Override
108+
public Long getApiResourceId() {
109+
return getId();
110+
}
111+
107112
@Override
108113
public String getEventType() {
109114
return EventTypes.EVENT_KMS_KEY_UPDATE;

api/src/main/java/org/apache/cloudstack/api/command/user/kms/hsm/AddHSMProfileCmd.java renamed to api/src/main/java/org/apache/cloudstack/api/command/user/kms/hsm/CreateHSMProfileCmd.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.cloud.utils.StringUtils;
2626
import org.apache.cloudstack.acl.RoleType;
2727
import org.apache.cloudstack.api.APICommand;
28+
import org.apache.cloudstack.api.ApiCommandResourceType;
2829
import org.apache.cloudstack.api.ApiConstants;
2930
import org.apache.cloudstack.api.ApiErrorCode;
3031
import org.apache.cloudstack.api.BaseCmd;
@@ -45,10 +46,10 @@
4546
import java.util.HashMap;
4647
import java.util.Map;
4748

48-
@APICommand(name = "addHSMProfile", description = "Adds a new HSM profile", responseObject = HSMProfileResponse.class,
49+
@APICommand(name = "createHSMProfile", description = "Creates a new HSM profile", responseObject = HSMProfileResponse.class,
4950
requestHasSensitiveInfo = true, responseHasSensitiveInfo = true, since = "4.23.0",
5051
authorized = { RoleType.Admin })
51-
public class AddHSMProfileCmd extends BaseCmd {
52+
public class CreateHSMProfileCmd extends BaseCmd {
5253

5354
@Inject
5455
private KMSManager kmsManager;
@@ -77,10 +78,10 @@ public class AddHSMProfileCmd extends BaseCmd {
7778
description = "the ID of the project to add the HSM profile for")
7879
private Long projectId;
7980

80-
@Parameter(name = "system", type = CommandType.BOOLEAN,
81-
description = "whether this is a system HSM profile available to all users globally (root admin only). "
81+
@Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN,
82+
description = "whether this is a public HSM profile available to all users globally (root admin only). "
8283
+ "Default is false")
83-
private Boolean system;
84+
private Boolean isPublic;
8485

8586
@Parameter(name = ApiConstants.VENDOR_NAME, type = CommandType.STRING, description = "the vendor name of the HSM")
8687
private String vendorName;
@@ -116,8 +117,8 @@ public Long getProjectId() {
116117
return projectId;
117118
}
118119

119-
public Boolean isSystem() {
120-
return system != null && system;
120+
public Boolean getIsPublic() {
121+
return isPublic != null && isPublic;
121122
}
122123

123124
public String getVendorName() {
@@ -159,4 +160,9 @@ public long getEntityOwnerId() {
159160
}
160161
return CallContext.current().getCallingAccount().getId();
161162
}
163+
164+
@Override
165+
public ApiCommandResourceType getApiResourceType() {
166+
return ApiCommandResourceType.HsmProfile;
167+
}
162168
}

api/src/main/java/org/apache/cloudstack/api/command/user/kms/hsm/DeleteHSMProfileCmd.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.cloud.exception.ResourceUnavailableException;
2525
import org.apache.cloudstack.acl.RoleType;
2626
import org.apache.cloudstack.api.APICommand;
27+
import org.apache.cloudstack.api.ApiCommandResourceType;
2728
import org.apache.cloudstack.api.ApiConstants;
2829
import org.apache.cloudstack.api.ApiErrorCode;
2930
import org.apache.cloudstack.api.BaseCmd;
@@ -78,4 +79,15 @@ public long getEntityOwnerId() {
7879
}
7980
return CallContext.current().getCallingAccount().getId();
8081
}
82+
83+
84+
@Override
85+
public ApiCommandResourceType getApiResourceType() {
86+
return ApiCommandResourceType.HsmProfile;
87+
}
88+
89+
@Override
90+
public Long getApiResourceId() {
91+
return getId();
92+
}
8193
}

api/src/main/java/org/apache/cloudstack/api/command/user/kms/hsm/UpdateHSMProfileCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.cloud.exception.ResourceUnavailableException;
2525
import org.apache.cloudstack.acl.RoleType;
2626
import org.apache.cloudstack.api.APICommand;
27+
import org.apache.cloudstack.api.ApiCommandResourceType;
2728
import org.apache.cloudstack.api.ApiConstants;
2829
import org.apache.cloudstack.api.ApiErrorCode;
2930
import org.apache.cloudstack.api.BaseCmd;
@@ -90,4 +91,14 @@ public long getEntityOwnerId() {
9091
}
9192
return CallContext.current().getCallingAccount().getId();
9293
}
94+
95+
@Override
96+
public ApiCommandResourceType getApiResourceType() {
97+
return ApiCommandResourceType.HsmProfile;
98+
}
99+
100+
@Override
101+
public Long getApiResourceId() {
102+
return getId();
103+
}
93104
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public class HSMProfileResponse extends BaseResponse implements ControlledViewEn
9090
@Param(description = "whether the HSM profile is enabled")
9191
private Boolean enabled;
9292

93-
@SerializedName("system")
93+
@SerializedName(ApiConstants.IS_PUBLIC)
9494
@Param(description = "whether this is a system HSM profile available to all users globally")
95-
private Boolean system;
95+
private Boolean isPublic;
9696

9797
@SerializedName(ApiConstants.CREATED)
9898
@Param(description = "the date the HSM profile was created")
@@ -168,8 +168,8 @@ public void setEnabled(Boolean enabled) {
168168
this.enabled = enabled;
169169
}
170170

171-
public void setSystem(Boolean system) {
172-
this.system = system;
171+
public void setIsPublic(Boolean isPublic) {
172+
this.isPublic = isPublic;
173173
}
174174

175175
public void setCreated(Date created) {

0 commit comments

Comments
 (0)