This commit is contained in:
vishesh92 2026-03-23 15:30:17 +05:30
parent 2c49e92632
commit b68661c54b
No known key found for this signature in database
GPG Key ID: 4E395186CBFA790B
6 changed files with 2 additions and 79 deletions

View File

@ -609,6 +609,4 @@ public interface ResponseGenerator {
ApiKeyPairResponse createKeyPairResponse(ApiKeyPair keyPair);
ListResponse<BaseRolePermissionResponse> createKeypairPermissionsResponse(List<ApiKeyPairPermission> permissions);
KMSKeyResponse createKMSKeyResponse(KMSKey kmsKey);
}

View File

@ -63,11 +63,6 @@ public class CreateKMSKeyCmd extends BaseCmd implements UserCmd {
description = "Description of the KMS key")
private String description;
@Parameter(name = ApiConstants.PURPOSE,
type = CommandType.STRING,
description = "Purpose of the key: volume, tls. (default: volume)")
private String purpose;
@Parameter(name = ApiConstants.ZONE_ID,
required = true,
type = CommandType.UUID,
@ -112,10 +107,6 @@ public class CreateKMSKeyCmd extends BaseCmd implements UserCmd {
return description;
}
public String getPurpose() {
return purpose == null ? "volume" : purpose;
}
public Long getZoneId() {
return zoneId;
}

View File

@ -54,11 +54,6 @@ public class ListKMSKeysCmd extends BaseListProjectAndAccountResourcesCmd implem
description = "List KMS key by UUID")
private Long id;
@Parameter(name = ApiConstants.PURPOSE,
type = CommandType.STRING,
description = "Filter by purpose: volume, tls")
private String purpose;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
@ -80,10 +75,6 @@ public class ListKMSKeysCmd extends BaseListProjectAndAccountResourcesCmd implem
return id;
}
public String getPurpose() {
return purpose;
}
public Long getZoneId() {
return zoneId;
}

View File

@ -44,10 +44,6 @@ public class KMSKeyResponse extends BaseResponse implements ControlledViewEntity
@Param(description = "the description of the key")
private String description;
@SerializedName(ApiConstants.PURPOSE)
@Param(description = "the purpose of the key (VOLUME_ENCRYPTION, TLS_CERT)")
private String purpose;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account owning the key")
private String accountName;
@ -140,14 +136,6 @@ public class KMSKeyResponse extends BaseResponse implements ControlledViewEntity
this.description = description;
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public String getAccountName() {
return accountName;
}

View File

@ -5802,48 +5802,4 @@ protected Map<String, ResourceIcon> getResourceIconsUsingOsCategory(List<Templat
response.setResponses(permissionResponses);
return response;
}
@Override
public KMSKeyResponse createKMSKeyResponse(KMSKey kmsKey) {
KMSKeyResponse response = new KMSKeyResponse();
response.setId(kmsKey.getUuid());
response.setName(kmsKey.getName());
response.setDescription(kmsKey.getDescription());
response.setPurpose(kmsKey.getPurpose().getName());
response.setAccountId(String.valueOf(kmsKey.getAccountId()));
response.setDomainId(String.valueOf(kmsKey.getDomainId()));
response.setZoneId(String.valueOf(kmsKey.getZoneId()));
response.setProvider(kmsKey.getProviderName());
response.setAlgorithm(kmsKey.getAlgorithm());
response.setKeyBits(kmsKey.getKeyBits());
response.setState(kmsKey.getState().toString());
response.setCreated(kmsKey.getCreated());
// Set account name
Account account = ApiDBUtils.findAccountById(kmsKey.getAccountId());
if (account != null) {
response.setAccountName(account.getAccountName());
}
// Set domain name
Domain domain = ApiDBUtils.findDomainById(kmsKey.getDomainId());
if (domain != null) {
response.setDomainName(domain.getName());
}
// Set zone name
DataCenter zone = ApiDBUtils.findZoneById(kmsKey.getZoneId());
if (zone != null) {
response.setZoneName(zone.getName());
}
// Set KEK label (admin only)
Account caller = CallContext.current().getCallingAccount();
if (caller != null && (caller.getType() == Account.Type.ADMIN || caller.getType() == Account.Type.RESOURCE_DOMAIN_ADMIN)) {
response.setKekLabel(kmsKey.getKekLabel());
}
response.setObjectName("kmskey");
return response;
}
}

View File

@ -318,7 +318,7 @@ public class KMSManagerImpl extends ManagerBase implements KMSManager, Pluggable
Account targetAccount = accountManager.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(),
cmd.getProjectId());
KeyPurpose keyPurpose = parseKeyPurpose(cmd.getPurpose());
KeyPurpose keyPurpose = parseKeyPurpose("volume");
int bits = cmd.getKeyBits();
if (bits != 128 && bits != 192 && bits != 256) {
@ -349,7 +349,6 @@ public class KMSManagerImpl extends ManagerBase implements KMSManager, Pluggable
response.setId(kmsKey.getUuid());
response.setName(kmsKey.getName());
response.setDescription(kmsKey.getDescription());
response.setPurpose(kmsKey.getPurpose().getName());
response.setAlgorithm(kmsKey.getAlgorithm());
response.setKeyBits(kmsKey.getKeyBits());
response.setEnabled(kmsKey.isEnabled());
@ -482,7 +481,7 @@ public class KMSManagerImpl extends ManagerBase implements KMSManager, Pluggable
SearchCriteria<KMSKeyVO> sc = searchBuilder.create();
accountManager.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts,
listProjectResourcesCriteria);
KeyPurpose keyPurpose = parseKeyPurpose(cmd.getPurpose());
KeyPurpose keyPurpose = parseKeyPurpose("volume");
if (cmd.getId() != null) {
sc.setParameters("id", cmd.getId());
}