Skip to content

Commit b1f683d

Browse files
authored
Allow more generic searches of ACLs (#9566)
1 parent 501d8c1 commit b1f683d

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ public Pair<List<? extends NetworkACLItem>, Integer> listNetworkACLItems(final L
697697
final String trafficType = cmd.getTrafficType();
698698
final String protocol = cmd.getProtocol();
699699
final String action = cmd.getAction();
700+
final String keyword = cmd.getKeyword();
700701
final Map<String, String> tags = cmd.getTags();
701702
final Account caller = CallContext.current().getCallingAccount();
702703

@@ -708,6 +709,7 @@ public Pair<List<? extends NetworkACLItem>, Integer> listNetworkACLItems(final L
708709
sb.and("trafficType", sb.entity().getTrafficType(), Op.EQ);
709710
sb.and("protocol", sb.entity().getProtocol(), Op.EQ);
710711
sb.and("action", sb.entity().getAction(), Op.EQ);
712+
sb.and("reason", sb.entity().getReason(), Op.EQ);
711713

712714
if (tags != null && !tags.isEmpty()) {
713715
final SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
@@ -730,6 +732,12 @@ public Pair<List<? extends NetworkACLItem>, Integer> listNetworkACLItems(final L
730732

731733
final SearchCriteria<NetworkACLItemVO> sc = sb.create();
732734

735+
if (StringUtils.isNotBlank(keyword)) {
736+
final SearchCriteria<NetworkACLItemVO> ssc = _networkACLItemDao.createSearchCriteria();
737+
ssc.addOr("protocol", SearchCriteria.Op.LIKE, "%" + keyword + "%");
738+
ssc.addOr("reason", SearchCriteria.Op.LIKE, "%" + keyword + "%");
739+
sc.addAnd("acl_id", SearchCriteria.Op.SC, ssc);
740+
}
733741
if (id != null) {
734742
sc.setParameters("id", id);
735743
}
@@ -747,7 +755,6 @@ public Pair<List<? extends NetworkACLItem>, Integer> listNetworkACLItems(final L
747755
if (trafficType != null) {
748756
sc.setParameters("trafficType", trafficType);
749757
}
750-
751758
if (aclId != null) {
752759
// Get VPC and check access
753760
final NetworkACL acl = _networkACLDao.findById(aclId);
@@ -764,7 +771,7 @@ public Pair<List<? extends NetworkACLItem>, Integer> listNetworkACLItems(final L
764771

765772
// aclId is not specified
766773
// List permitted VPCs and filter aclItems
767-
final List<Long> permittedAccounts = new ArrayList<Long>();
774+
final List<Long> permittedAccounts = new ArrayList<>();
768775
Long domainId = cmd.getDomainId();
769776
boolean isRecursive = cmd.isRecursive();
770777
final String accountName = cmd.getAccountName();
@@ -780,7 +787,7 @@ public Pair<List<? extends NetworkACLItem>, Integer> listNetworkACLItems(final L
780787
final SearchCriteria<VpcVO> scVpc = sbVpc.create();
781788
_accountMgr.buildACLSearchCriteria(scVpc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
782789
final List<VpcVO> vpcs = _vpcDao.search(scVpc, null);
783-
final List<Long> vpcIds = new ArrayList<Long>();
790+
final List<Long> vpcIds = new ArrayList<>();
784791
for (final VpcVO vpc : vpcs) {
785792
vpcIds.add(vpc.getId());
786793
}

ui/src/views/network/AclListRulesTab.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
<template>
1919
<a-spin :spinning="fetchLoading">
20-
<div style="width: 100%; display: flex">
20+
21+
<div style="width: 100%; display: flex">
2122
<a-button
2223
type="dashed"
2324
style="width: 100%; margin-right: 10px"
@@ -31,6 +32,14 @@
3132
<template #icon><download-outlined /></template>
3233
{{ $t('label.acl.export') }}
3334
</a-button>
35+
<div class="search-bar">
36+
<a-input-search
37+
style="width: 25vw;float: right;margin-left: 10px; z-index: 8"
38+
:placeholder="$t('label.search')"
39+
v-model:value="searchQuery"
40+
@search="fetchData"
41+
/>
42+
</div>
3443
</div>
3544

3645
<div class="list">
@@ -324,6 +333,7 @@ export default {
324333
},
325334
data () {
326335
return {
336+
searchQuery: '', // Bind this to the search input
327337
acls: [],
328338
fetchLoading: false,
329339
protocolNumbers: [],
@@ -433,7 +443,11 @@ export default {
433443
},
434444
fetchData () {
435445
this.fetchLoading = true
436-
api('listNetworkACLs', { aclid: this.resource.id }).then(json => {
446+
const params = {
447+
aclid: this.resource.id,
448+
keyword: this.searchQuery
449+
}
450+
api('listNetworkACLs', params).then(json => {
437451
this.acls = json.listnetworkaclsresponse.networkacl || []
438452
if (this.acls.length > 0) {
439453
this.acls.sort((a, b) => a.number - b.number)

0 commit comments

Comments
 (0)