use of com.cloud.api.command.admin.cloudops.ListWhoHasThisMacCmd in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method listWhoHasThisMac.
public ListResponse<WhoHasThisAddressResponse> listWhoHasThisMac(final ListWhoHasThisMacCmd cmd) {
final ListResponse<WhoHasThisAddressResponse> whoHasThisIpList = new ListResponse<>();
final List<WhoHasThisAddressResponse> responsesList = new ArrayList<>();
final String cleanedMacAddress = StringUtils.deleteWhitespace(cmd.getMacAddress());
final List<NicVO> nics = _nicDao.listByMacAddress(cleanedMacAddress);
nics.forEach(nic -> {
final WhoHasThisAddressResponse response = new WhoHasThisAddressResponse();
response.setObjectName("whohasthismac");
queryNicsTableResponse(responsesList, nic, response);
});
final Account account = CallContext.current().getCallingAccount();
final Domain domain = _domainDao.findById(account.getDomainId());
final List<WhoHasThisAddressResponse> filteredResponsesList = responsesList.stream().filter(response -> ((account.getDomainId() == Domain.ROOT_DOMAIN || domain.getUuid().equals(response.getDomainUuid())) && (StringUtils.isEmpty(cmd.getUuid()) || (!StringUtils.isEmpty(cmd.getUuid()) && response.getUuid().equals(cmd.getUuid()))))).skip(cmd.getStartIndex()).limit(cmd.getPageSizeVal()).collect(Collectors.toList());
whoHasThisIpList.setResponses(filteredResponsesList);
return whoHasThisIpList;
}
Aggregations