Display vlan ip range for specified domainid (#4634)

* Display vlan ip range for specified domainid

Currently if we try to list vlan ip range by passing
domainid then it lists for all domain. Make sure that
it lists only for that domain

* orgazine imports

Co-authored-by: Rakesh Venkatesh <rakeshv@apache.org>
This commit is contained in:
Rakesh 2021-09-20 07:07:21 +02:00 committed by GitHub
parent 40b4b2c894
commit 3b4523f22a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -44,6 +44,8 @@ import javax.crypto.spec.SecretKeySpec;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.dc.DomainVlanMapVO;
import com.cloud.dc.dao.DomainVlanMapDao;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
@ -889,6 +891,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private VpcDao _vpcDao;
@Inject
private AnnotationDao annotationDao;
@Inject
private DomainVlanMapDao _domainVlanMapDao;
private LockControllerListener _lockControllerListener;
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
@ -1894,6 +1898,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.join("accountVlanMapSearch", accountVlanMapSearch, sb.entity().getId(), accountVlanMapSearch.entity().getVlanDbId(), JoinBuilder.JoinType.INNER);
}
if (domainId != null) {
DomainVO domain = ApiDBUtils.findDomainById(domainId);
if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain with id " + domainId);
}
final SearchBuilder<DomainVlanMapVO> domainVlanMapSearch = _domainVlanMapDao.createSearchBuilder();
domainVlanMapSearch.and("domainId", domainVlanMapSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
sb.join("domainVlanMapSearch", domainVlanMapSearch, sb.entity().getId(), domainVlanMapSearch.entity().getVlanDbId(), JoinType.INNER);
}
if (podId != null) {
final SearchBuilder<PodVlanMapVO> podVlanMapSearch = _podVlanMapDao.createSearchBuilder();
podVlanMapSearch.and("podId", podVlanMapSearch.entity().getPodId(), SearchCriteria.Op.EQ);
@ -1937,6 +1951,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (physicalNetworkId != null) {
sc.setParameters("physicalNetworkId", physicalNetworkId);
}
if (domainId != null) {
sc.setJoinParameters("domainVlanMapSearch", "domainId", domainId);
}
}
final Pair<List<VlanVO>, Integer> result = _vlanDao.searchAndCount(sc, searchFilter);