mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	bug 7824: implementing search for pools by id
status 7824: resolved fixed
This commit is contained in:
		
							parent
							
								
									cb7b6867c6
								
							
						
					
					
						commit
						f3e91de0bd
					
				@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants;
 | 
			
		||||
import com.cloud.api.BaseListCmd;
 | 
			
		||||
import com.cloud.api.Implementation;
 | 
			
		||||
import com.cloud.api.Parameter;
 | 
			
		||||
import com.cloud.api.BaseCmd.CommandType;
 | 
			
		||||
import com.cloud.api.response.ListResponse;
 | 
			
		||||
import com.cloud.api.response.StoragePoolResponse;
 | 
			
		||||
import com.cloud.async.AsyncJob;
 | 
			
		||||
@ -59,6 +60,9 @@ public class ListStoragePoolsCmd extends BaseListCmd {
 | 
			
		||||
 | 
			
		||||
    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the storage pool")
 | 
			
		||||
    private Long zoneId;
 | 
			
		||||
    
 | 
			
		||||
    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the storage pool")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////
 | 
			
		||||
    /////////////////// Accessors ///////////////////////
 | 
			
		||||
@ -87,6 +91,10 @@ public class ListStoragePoolsCmd extends BaseListCmd {
 | 
			
		||||
    public Long getZoneId() {
 | 
			
		||||
        return zoneId;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Long getId() {
 | 
			
		||||
    	return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////
 | 
			
		||||
    /////////////// API Implementation///////////////////
 | 
			
		||||
 | 
			
		||||
@ -3680,6 +3680,7 @@ public class ManagementServerImpl implements ManagementServer {
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<? extends StoragePoolVO> searchForStoragePools(ListStoragePoolsCmd cmd) {
 | 
			
		||||
        Criteria c = new Criteria("id", Boolean.TRUE, cmd.getStartIndex(), cmd.getPageSizeVal());
 | 
			
		||||
        c.addCriteria(Criteria.ID, cmd.getId());
 | 
			
		||||
        c.addCriteria(Criteria.NAME, cmd.getStoragePoolName());
 | 
			
		||||
        c.addCriteria(Criteria.CLUSTERID, cmd.getClusterId());
 | 
			
		||||
        c.addCriteria(Criteria.ADDRESS, cmd.getIpAddress());
 | 
			
		||||
@ -3696,6 +3697,7 @@ public class ManagementServerImpl implements ManagementServer {
 | 
			
		||||
        Filter searchFilter = new Filter(StoragePoolVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
 | 
			
		||||
        SearchCriteria<StoragePoolVO> sc = _poolDao.createSearchCriteria();
 | 
			
		||||
 | 
			
		||||
        Object id = c.getCriteria(Criteria.ID);
 | 
			
		||||
        Object name = c.getCriteria(Criteria.NAME);
 | 
			
		||||
        Object host = c.getCriteria(Criteria.HOST);
 | 
			
		||||
        Object path = c.getCriteria(Criteria.PATH);
 | 
			
		||||
@ -3713,6 +3715,10 @@ public class ManagementServerImpl implements ManagementServer {
 | 
			
		||||
            sc.addAnd("name", SearchCriteria.Op.SC, ssc);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (id != null) {
 | 
			
		||||
        	sc.addAnd("id", SearchCriteria.Op.EQ, id);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (name != null) {
 | 
			
		||||
            sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user