Skip to content

Commit 453aeb0

Browse files
authored
Add ID search capability to sshkeypairs (apache#5963)
1 parent c7885f5 commit 453aeb0

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/ssh/ListSSHKeyPairsCmd.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class ListSSHKeyPairsCmd extends BaseListProjectAndAccountResourcesCmd {
4040
/////////////////////////////////////////////////////
4141
//////////////// API parameters /////////////////////
4242
/////////////////////////////////////////////////////
43+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SSHKeyPairResponse.class, description = "the ID of the ssh keypair")
44+
private Long id;
4345

4446
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "A key pair name to look for")
4547
private String name;
@@ -50,6 +52,9 @@ public class ListSSHKeyPairsCmd extends BaseListProjectAndAccountResourcesCmd {
5052
/////////////////////////////////////////////////////
5153
/////////////////// Accessors ///////////////////////
5254
/////////////////////////////////////////////////////
55+
public Long getId() {
56+
return id;
57+
}
5358

5459
public String getName() {
5560
return name;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121
import org.apache.cloudstack.api.ApiConstants;
2222

2323
import com.cloud.serializer.Param;
24+
import com.cloud.user.SSHKeyPair;
25+
2426
import org.apache.cloudstack.api.BaseResponseWithAnnotations;
27+
import org.apache.cloudstack.api.EntityReference;
2528

29+
@EntityReference(value = SSHKeyPair.class)
2630
public class SSHKeyPairResponse extends BaseResponseWithAnnotations {
2731

2832
@SerializedName(ApiConstants.ID)

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,6 +4150,7 @@ public boolean deleteSSHKeyPair(final DeleteSSHKeyPairCmd cmd) {
41504150

41514151
@Override
41524152
public Pair<List<? extends SSHKeyPair>, Integer> listSSHKeyPairs(final ListSSHKeyPairsCmd cmd) {
4153+
final Long id = cmd.getId();
41534154
final String name = cmd.getName();
41544155
final String fingerPrint = cmd.getFingerprint();
41554156
final String keyword = cmd.getKeyword();
@@ -4169,6 +4170,10 @@ public Pair<List<? extends SSHKeyPair>, Integer> listSSHKeyPairs(final ListSSHKe
41694170
final SearchCriteria<SSHKeyPairVO> sc = sb.create();
41704171
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
41714172

4173+
if (id != null) {
4174+
sc.addAnd("id", SearchCriteria.Op.EQ, id);
4175+
}
4176+
41724177
if (name != null) {
41734178
sc.addAnd("name", SearchCriteria.Op.EQ, name);
41744179
}

ui/src/components/view/InfoCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@
605605
<div v-for="item in $route.meta.related" :key="item.path">
606606
<router-link
607607
v-if="$router.resolve('/' + item.name).route.name !== '404'"
608-
:to="{ path: '/' + item.name + '?' + item.param + '=' + (item.value ? resource[item.value] : item.param === 'account' ? resource.name + '&domainid=' + resource.domainid : resource.id) }">
608+
:to="{ path: '/' + item.name + '?' + item.param + '=' + (item.value ? resource[item.value] : item.param === 'account' ? resource.name + '&domainid=' + resource.domainid : item.param === 'keypair' ? resource.name : resource.id) }">
609609
<a-button style="margin-right: 10px" :icon="$router.resolve('/' + item.name).route.meta.icon" >
610610
{{ $t('label.view') + ' ' + $t(item.title) }}
611611
</a-button>

0 commit comments

Comments
 (0)