mirror of https://github.com/apache/cloudstack.git
adding the logic to list and search zones and domains based on the user (normal,admin,domain admin)
This commit is contained in:
parent
14e3893f75
commit
67beda5244
|
|
@ -62,4 +62,6 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
|
|||
List<DataCenterVO> findZonesByDomainId(Long domainId);
|
||||
|
||||
List<DataCenterVO> listPublicZones();
|
||||
|
||||
List<DataCenterVO> findChildZones(Object[] ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
|
||||
protected SearchBuilder<DataCenterVO> NameSearch;
|
||||
protected SearchBuilder<DataCenterVO> ListZonesByDomainIdSearch;
|
||||
protected SearchBuilder<DataCenterVO> PublicZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> PublicZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> ChildZonesSearch;
|
||||
|
||||
protected static final DataCenterIpAddressDaoImpl _ipAllocDao = ComponentLocator.inject(DataCenterIpAddressDaoImpl.class);
|
||||
protected static final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class);
|
||||
|
|
@ -78,6 +79,13 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> findChildZones(Object[] ids){
|
||||
SearchCriteria<DataCenterVO> sc = ChildZonesSearch.create();
|
||||
sc.setParameters("domainid", ids);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> listPublicZones(){
|
||||
SearchCriteria<DataCenterVO> sc = PublicZonesSearch.create();
|
||||
|
|
@ -239,6 +247,10 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
PublicZonesSearch.and("domainId", PublicZonesSearch.entity().getDomainId(), SearchCriteria.Op.NULL);
|
||||
PublicZonesSearch.done();
|
||||
|
||||
ChildZonesSearch = createSearchBuilder();
|
||||
ChildZonesSearch.and("domainid", ChildZonesSearch.entity().getDomainId(), SearchCriteria.Op.IN);
|
||||
ChildZonesSearch.done();
|
||||
|
||||
_tgMacAddress = _tgs.get("macAddress");
|
||||
assert _tgMacAddress != null : "Couldn't get mac address table generator";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package com.cloud.domain.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -26,5 +28,6 @@ public interface DomainDao extends GenericDao<DomainVO, Long> {
|
|||
public DomainVO create(DomainVO domain);
|
||||
public DomainVO findDomainByPath(String domainPath);
|
||||
public boolean isChildDomain(Long parentId, Long childId);
|
||||
DomainVO findImmediateChildForParent(Long parentId);
|
||||
DomainVO findImmediateChildForParent(Long parentId);
|
||||
List<DomainVO> findAllChildren(String path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
protected SearchBuilder<DomainVO> ParentDomainNameLikeSearch;
|
||||
protected SearchBuilder<DomainVO> DomainPairSearch;
|
||||
protected SearchBuilder<DomainVO> ImmediateChildDomainSearch;
|
||||
protected SearchBuilder<DomainVO> FindAllChildrenSearch;
|
||||
|
||||
public DomainDaoImpl () {
|
||||
DomainNameLikeSearch = createSearchBuilder();
|
||||
|
|
@ -59,7 +60,11 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
|
||||
ImmediateChildDomainSearch = createSearchBuilder();
|
||||
ImmediateChildDomainSearch.and("parent", ImmediateChildDomainSearch.entity().getParent(), SearchCriteria.Op.EQ);
|
||||
ImmediateChildDomainSearch.done();
|
||||
ImmediateChildDomainSearch.done();
|
||||
|
||||
FindAllChildrenSearch = createSearchBuilder();
|
||||
FindAllChildrenSearch.and("path", FindAllChildrenSearch.entity().getPath(), SearchCriteria.Op.LIKE);
|
||||
FindAllChildrenSearch.done();
|
||||
}
|
||||
|
||||
public void update(Long id, String domainName) {
|
||||
|
|
@ -203,6 +208,13 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
return (listBy(sc).size() > 0 ? listBy(sc).get(0) : null);//may need to revisit for multiple children case
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainVO> findAllChildren(String path){
|
||||
SearchCriteria<DomainVO> sc = FindAllChildrenSearch.create();
|
||||
sc.setParameters("path", path);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildDomain(Long parentId, Long childId) {
|
||||
if ((parentId == null) || (childId == null)) {
|
||||
|
|
|
|||
|
|
@ -1209,6 +1209,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String tags = cmd.getTags();
|
||||
Long domainId = Long.valueOf(DomainVO.ROOT_DOMAIN); // disk offering always gets created under the root domain.Bug # 6055
|
||||
|
||||
if(!isCustomized && numGibibytes == null){
|
||||
throw new InvalidParameterValueException("Disksize is required for non-customized disk offering");
|
||||
}
|
||||
|
||||
return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1369,18 +1369,29 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
//this covers till leaf
|
||||
if(domainRecord != null){
|
||||
DomainVO localParent = domainRecord;
|
||||
DomainVO immediateChild = null;
|
||||
while(true){
|
||||
//find immediate child domain
|
||||
immediateChild = _domainDao.findImmediateChildForParent(localParent.getId());
|
||||
if(immediateChild != null){
|
||||
dcs.addAll(_dcDao.findZonesByDomainId(immediateChild.getId()));
|
||||
localParent = immediateChild;//traverse down the list
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
// DomainVO localParent = domainRecord;
|
||||
// DomainVO immediateChild = null;
|
||||
// while(true){
|
||||
// //find immediate child domain
|
||||
// immediateChild = _domainDao.findImmediateChildForParent(localParent.getId());
|
||||
// if(immediateChild != null){
|
||||
// dcs.addAll(_dcDao.findZonesByDomainId(immediateChild.getId()));
|
||||
// localParent = immediateChild;//traverse down the list
|
||||
// }else{
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
//find all children for this domain based on a like search by path
|
||||
List<DomainVO> allChildDomains = _domainDao.findAllChildren(domainRecord.getPath());
|
||||
List<Long> allChildDomainIds = new ArrayList<Long>();
|
||||
//create list of domainIds for search
|
||||
for(DomainVO domain : allChildDomains){
|
||||
allChildDomainIds.add(domain.getId());
|
||||
}
|
||||
//now make a search for zones based on this
|
||||
List<DataCenterVO> childZones = _dcDao.findChildZones((allChildDomainIds.toArray()));
|
||||
dcs.addAll(childZones);
|
||||
}
|
||||
//add all public zones too
|
||||
dcs.addAll(_dcDao.listPublicZones());
|
||||
|
|
|
|||
Loading…
Reference in New Issue