Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter list VMs by IP address #9547

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1447,13 +1447,18 @@
}

if (keyword != null) {
userVmSearchBuilder.and().op("keywordDisplayName", userVmSearchBuilder.entity().getDisplayName(), Op.LIKE);
userVmSearchBuilder.or("keywordName", userVmSearchBuilder.entity().getHostName(), Op.LIKE);
userVmSearchBuilder.or("keywordState", userVmSearchBuilder.entity().getState(), Op.EQ);
SearchBuilder<UserVmJoinVO> userVmJoinSearchBuilder = _userVmJoinDao.createSearchBuilder();
vishesh92 marked this conversation as resolved.
Show resolved Hide resolved
userVmJoinSearchBuilder.and().op("keywordDisplayName", userVmJoinSearchBuilder.entity().getDisplayName(), Op.LIKE);
userVmJoinSearchBuilder.or("keywordName", userVmJoinSearchBuilder.entity().getHostName(), Op.LIKE);
userVmJoinSearchBuilder.or("keywordState", userVmJoinSearchBuilder.entity().getState(), Op.EQ);
userVmJoinSearchBuilder.or("keywordIpAddress", userVmJoinSearchBuilder.entity().getIpAddress(), Op.LIKE);
userVmJoinSearchBuilder.or("keywordPublicIpAddress", userVmJoinSearchBuilder.entity().getPublicIpAddress(), Op.LIKE);
userVmJoinSearchBuilder.or("keywordIp6Address", userVmJoinSearchBuilder.entity().getIp6Address(), Op.LIKE);

Check warning on line 1456 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L1450-L1456

Added lines #L1450 - L1456 were not covered by tests
if (isRootAdmin) {
userVmSearchBuilder.or("keywordInstanceName", userVmSearchBuilder.entity().getInstanceName(), Op.LIKE );
userVmJoinSearchBuilder.or("keywordInstanceName", userVmJoinSearchBuilder.entity().getInstanceName(), Op.LIKE );

Check warning on line 1458 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L1458

Added line #L1458 was not covered by tests
}
userVmSearchBuilder.cp();
userVmJoinSearchBuilder.cp();
userVmSearchBuilder.join("keyword", userVmJoinSearchBuilder, userVmJoinSearchBuilder.entity().getId(), userVmSearchBuilder.entity().getId(), JoinBuilder.JoinType.INNER);

Check warning on line 1461 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L1460-L1461

Added lines #L1460 - L1461 were not covered by tests
}

if (backupOfferingId != null) {
Expand Down Expand Up @@ -1543,11 +1548,14 @@

if (keyword != null) {
String keywordMatch = "%" + keyword + "%";
userVmSearchCriteria.setParameters("keywordDisplayName", keywordMatch);
userVmSearchCriteria.setParameters("keywordName", keywordMatch);
userVmSearchCriteria.setParameters("keywordState", keyword);
userVmSearchCriteria.setJoinParameters("keyword","keywordDisplayName", keywordMatch);
userVmSearchCriteria.setJoinParameters("keyword","keywordName", keywordMatch);
userVmSearchCriteria.setJoinParameters("keyword","keywordState", keywordMatch);
userVmSearchCriteria.setJoinParameters("keyword","keywordIpAddress", keywordMatch);
userVmSearchCriteria.setJoinParameters("keyword","keywordPublicIpAddress", keywordMatch);
userVmSearchCriteria.setJoinParameters("keyword", "keywordIp6Address", keywordMatch);

Check warning on line 1556 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L1551-L1556

Added lines #L1551 - L1556 were not covered by tests
if (isRootAdmin) {
userVmSearchCriteria.setParameters("keywordInstanceName", keywordMatch);
userVmSearchCriteria.setJoinParameters("keyword", "keywordInstanceName", keywordMatch);

Check warning on line 1558 in server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L1558

Added line #L1558 was not covered by tests
}
}

Expand Down
Loading