incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [3/50] git commit: CLOUDSTACK-355: Create DB view to fix count issue for listDiskOfferingsCmd.
Date Fri, 25 Jan 2013 12:55:10 GMT
CLOUDSTACK-355: Create DB view to fix count issue for
listDiskOfferingsCmd.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/6db719d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/6db719d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/6db719d5

Branch: refs/heads/events-framework
Commit: 6db719d58b996034773a0f10dcb4945d85adb719
Parents: 04d93ef
Author: Min Chen <min.chen@citrix.com>
Authored: Mon Jan 21 10:48:03 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Mon Jan 21 10:50:10 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/server/ManagementService.java    |   11 +-
 .../user/offering/ListDiskOfferingsCmd.java        |   13 +-
 .../org/apache/cloudstack/query/QueryService.java  |    4 +
 server/src/com/cloud/api/ApiDBUtils.java           |   14 +
 server/src/com/cloud/api/ApiResponseHelper.java    |   21 +--
 server/src/com/cloud/api/ApiServer.java            |    2 +
 .../src/com/cloud/api/query/QueryManagerImpl.java  |  177 +++++++++++-
 .../com/cloud/api/query/ViewResponseHelper.java    |   10 +
 .../cloud/api/query/dao/DiskOfferingJoinDao.java   |   29 ++
 .../api/query/dao/DiskOfferingJoinDaoImpl.java     |  101 +++++++
 .../com/cloud/api/query/vo/DiskOfferingJoinVO.java |  233 +++++++++++++++
 .../configuration/DefaultComponentLibrary.java     |    2 +
 .../src/com/cloud/server/ManagementServerImpl.java |  195 +------------
 setup/db/create-schema-view.sql                    |   25 ++-
 setup/db/db/schema-40to410.sql                     |   24 ++
 15 files changed, 628 insertions(+), 233 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 5302daa..9935565 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -144,7 +144,7 @@ public interface ManagementService {
     /**
      * Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
      * "podId"
-     * 
+     *
      * @param cmd
      * @return List of Hosts
      */
@@ -243,15 +243,6 @@ public interface ManagementService {
      */
     Set<Pair<Long, Long>> listTemplates(ListTemplatesCmd cmd);
 
-    /**
-     * Search for disk offerings based on search criteria
-     *
-     * @param cmd
-     *            the command containing the criteria to use for searching for disk offerings
-     * @return a list of disk offerings that match the given criteria
-     */
-    List<? extends DiskOffering> searchForDiskOfferings(ListDiskOfferingsCmd cmd);
-
 
     /**
      * List system VMs by the given search criteria

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java
index 7209429..1fc7978 100644
--- a/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java
@@ -25,6 +25,7 @@ import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListCmd;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.AsyncJobResponse;
 import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ListResponse;
@@ -78,16 +79,8 @@ public class ListDiskOfferingsCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends DiskOffering> result = _mgr.searchForDiskOfferings(this);
-        ListResponse<DiskOfferingResponse> response = new ListResponse<DiskOfferingResponse>();
-        List<DiskOfferingResponse> diskOfferingResponses = new ArrayList<DiskOfferingResponse>();
-        for (DiskOffering offering : result) {
-            DiskOfferingResponse diskOffResp = _responseGenerator.createDiskOfferingResponse(offering);
-            diskOffResp.setObjectName("diskoffering");
-            diskOfferingResponses.add(diskOffResp);
-        }
-
-        response.setResponses(diskOfferingResponses);
+
+        ListResponse<DiskOfferingResponse> response = _queryService.searchForDiskOfferings(this);
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/api/src/org/apache/cloudstack/query/QueryService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/query/QueryService.java b/api/src/org/apache/cloudstack/query/QueryService.java
index b03a7fc..f2b0d32 100644
--- a/api/src/org/apache/cloudstack/query/QueryService.java
+++ b/api/src/org/apache/cloudstack/query/QueryService.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
 import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
 import org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd;
+import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
 import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
 import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
 import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
@@ -35,6 +36,7 @@ import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
 import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
 import org.apache.cloudstack.api.response.EventResponse;
 import org.apache.cloudstack.api.response.HostResponse;
@@ -92,4 +94,6 @@ public interface QueryService {
     public ListResponse<AccountResponse> searchForAccounts(ListAccountsCmd cmd);
 
     public ListResponse<AsyncJobResponse>  searchForAsyncJobs(ListAsyncJobsCmd cmd);
+
+    public ListResponse<DiskOfferingResponse>  searchForDiskOfferings(ListDiskOfferingsCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index dfdeb9c..3f2f0bb 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.ApiConstants.HostDetails;
 import org.apache.cloudstack.api.ApiConstants.VMDetails;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
 import org.apache.cloudstack.api.response.EventResponse;
 import org.apache.cloudstack.api.response.HostResponse;
@@ -42,6 +43,7 @@ import org.apache.cloudstack.api.response.VolumeResponse;
 
 import com.cloud.api.query.dao.AccountJoinDao;
 import com.cloud.api.query.dao.AsyncJobJoinDao;
+import com.cloud.api.query.dao.DiskOfferingJoinDao;
 import com.cloud.api.query.dao.DomainRouterJoinDao;
 import com.cloud.api.query.dao.HostJoinDao;
 import com.cloud.api.query.dao.InstanceGroupJoinDao;
@@ -56,6 +58,7 @@ import com.cloud.api.query.dao.UserVmJoinDao;
 import com.cloud.api.query.dao.VolumeJoinDao;
 import com.cloud.api.query.vo.AccountJoinVO;
 import com.cloud.api.query.vo.AsyncJobJoinVO;
+import com.cloud.api.query.vo.DiskOfferingJoinVO;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
 import com.cloud.api.query.vo.EventJoinVO;
 import com.cloud.api.query.vo.HostJoinVO;
@@ -163,6 +166,7 @@ import com.cloud.network.vpc.VpcVO;
 import com.cloud.network.vpc.dao.StaticRouteDao;
 import com.cloud.network.vpc.dao.VpcGatewayDao;
 import com.cloud.network.vpc.dao.VpcOfferingDao;
+import com.cloud.offering.DiskOffering;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.offerings.NetworkOfferingVO;
@@ -333,6 +337,7 @@ public class ApiDBUtils {
     private static StoragePoolJoinDao _poolJoinDao;
     private static AccountJoinDao _accountJoinDao;
     private static AsyncJobJoinDao _jobJoinDao;
+    private static DiskOfferingJoinDao _diskOfferingJoinDao;
 
     private static PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao;
     private static PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
@@ -437,6 +442,7 @@ public class ApiDBUtils {
         _vpcOfferingDao = locator.getDao(VpcOfferingDao.class);
         _snapshotPolicyDao = locator.getDao(SnapshotPolicyDao.class);
         _asyncJobDao = locator.getDao(AsyncJobDao.class);
+        _diskOfferingJoinDao = locator.getDao(DiskOfferingJoinDao.class);
 
         // Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
         _statsCollector = StatsCollector.getInstance();
@@ -1399,4 +1405,12 @@ public class ApiDBUtils {
    public static AsyncJobJoinVO newAsyncJobView(AsyncJob e){
        return _jobJoinDao.newAsyncJobView(e);
    }
+
+   public static DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
+       return _diskOfferingJoinDao.newDiskOfferingResponse(offering);
+   }
+
+   public static DiskOfferingJoinVO newDiskOfferingView(DiskOffering offering){
+       return _diskOfferingJoinDao.newDiskOfferingView(offering);
+   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index c346a6b..07646d8 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -44,6 +44,7 @@ import com.cloud.api.query.ViewResponseHelper;
 import com.cloud.api.query.vo.AccountJoinVO;
 import com.cloud.api.query.vo.AsyncJobJoinVO;
 import com.cloud.api.query.vo.ControlledViewEntity;
+import com.cloud.api.query.vo.DiskOfferingJoinVO;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
 import com.cloud.api.query.vo.EventJoinVO;
 import com.cloud.api.query.vo.HostJoinVO;
@@ -298,24 +299,8 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public DiskOfferingResponse createDiskOfferingResponse(DiskOffering offering) {
-        DiskOfferingResponse diskOfferingResponse = new DiskOfferingResponse();
-        diskOfferingResponse.setId(offering.getUuid());
-        diskOfferingResponse.setName(offering.getName());
-        diskOfferingResponse.setDisplayText(offering.getDisplayText());
-        diskOfferingResponse.setCreated(offering.getCreated());
-        diskOfferingResponse.setDiskSize(offering.getDiskSize() / (1024 * 1024 * 1024));
-        if (offering.getDomainId() != null) {
-            Domain domain = ApiDBUtils.findDomainById(offering.getDomainId());
-            if (domain != null) {
-                diskOfferingResponse.setDomain(domain.getName());
-                diskOfferingResponse.setDomainId(domain.getUuid());
-            }
-        }
-        diskOfferingResponse.setTags(offering.getTags());
-        diskOfferingResponse.setCustomized(offering.isCustomized());
-        diskOfferingResponse.setStorageType(offering.getUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
-        diskOfferingResponse.setObjectName("diskoffering");
-        return diskOfferingResponse;
+        DiskOfferingJoinVO vOffering = ApiDBUtils.newDiskOfferingView(offering);
+        return ApiDBUtils.newDiskOfferingResponse(vOffering);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index ac1ba0a..19c8851 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -95,6 +95,7 @@ import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
 import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
+import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
 import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
 import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
 import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
@@ -514,6 +515,7 @@ public class ApiServer implements HttpRequestHandler {
                     && !(cmdObj instanceof ListUsersCmd)
                     && !(cmdObj instanceof ListAccountsCmd)
                     && !(cmdObj instanceof ListStoragePoolsCmd)
+                    && !(cmdObj instanceof ListDiskOfferingsCmd)
                     ) {
                 buildAsyncListResponse((BaseListCmd) cmdObj, caller);
             }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index b61f10a..c38603f 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -32,6 +32,7 @@ import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
 import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
 import org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd;
+import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
 import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
 import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
 import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
@@ -41,6 +42,7 @@ import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
 import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
 import org.apache.cloudstack.api.response.EventResponse;
 import org.apache.cloudstack.api.response.HostResponse;
@@ -60,6 +62,7 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.query.dao.AccountJoinDao;
 import com.cloud.api.query.dao.AsyncJobJoinDao;
+import com.cloud.api.query.dao.DiskOfferingJoinDao;
 import com.cloud.api.query.dao.DomainRouterJoinDao;
 import com.cloud.api.query.dao.HostJoinDao;
 import com.cloud.api.query.dao.InstanceGroupJoinDao;
@@ -74,6 +77,7 @@ import com.cloud.api.query.dao.UserVmJoinDao;
 import com.cloud.api.query.dao.VolumeJoinDao;
 import com.cloud.api.query.vo.AccountJoinVO;
 import com.cloud.api.query.vo.AsyncJobJoinVO;
+import com.cloud.api.query.vo.DiskOfferingJoinVO;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
 import com.cloud.api.query.vo.EventJoinVO;
 import com.cloud.api.query.vo.HostJoinVO;
@@ -87,10 +91,12 @@ import com.cloud.api.query.vo.StoragePoolJoinVO;
 import com.cloud.api.query.vo.UserAccountJoinVO;
 import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.api.query.vo.VolumeJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.domain.Domain;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.event.dao.EventJoinDao;
+import com.cloud.exception.CloudAuthenticationException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.ha.HighAvailabilityManager;
@@ -104,6 +110,7 @@ import com.cloud.projects.ProjectManager;
 import com.cloud.projects.dao.ProjectAccountDao;
 import com.cloud.projects.dao.ProjectDao;
 import com.cloud.server.Criteria;
+import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolVO;
 import com.cloud.storage.Volume;
@@ -200,6 +207,9 @@ public class QueryManagerImpl implements QueryService, Manager {
     private AccountDao _accountDao;
 
     @Inject
+    private ConfigurationDao _configDao;
+
+    @Inject
     private AccountJoinDao _accountJoinDao;
 
     @Inject
@@ -209,6 +219,9 @@ public class QueryManagerImpl implements QueryService, Manager {
     private StoragePoolJoinDao _poolJoinDao;
 
     @Inject
+    private DiskOfferingJoinDao _diskOfferingJoinDao;
+
+    @Inject
     private HighAvailabilityManager _haMgr;
 
     @Override
@@ -1603,7 +1616,7 @@ public class QueryManagerImpl implements QueryService, Manager {
     }
 
 
-    public Pair<List<AccountJoinVO>, Integer> searchForAccountsInternal(ListAccountsCmd cmd) {
+    private Pair<List<AccountJoinVO>, Integer> searchForAccountsInternal(ListAccountsCmd cmd) {
         Account caller = UserContext.current().getCaller();
         Long domainId = cmd.getDomainId();
         Long accountId = cmd.getId();
@@ -1729,7 +1742,7 @@ public class QueryManagerImpl implements QueryService, Manager {
     }
 
 
-    public Pair<List<AsyncJobJoinVO>, Integer> searchForAsyncJobsInternal(ListAsyncJobsCmd cmd) {
+    private Pair<List<AsyncJobJoinVO>, Integer> searchForAsyncJobsInternal(ListAsyncJobsCmd cmd) {
 
         Account caller = UserContext.current().getCaller();
 
@@ -1808,7 +1821,7 @@ public class QueryManagerImpl implements QueryService, Manager {
         return response;
     }
 
-    public Pair<List<StoragePoolJoinVO>, Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd) {
+    private Pair<List<StoragePoolJoinVO>, Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd) {
 
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
         Object id = cmd.getId();
@@ -1888,5 +1901,163 @@ public class QueryManagerImpl implements QueryService, Manager {
 
     }
 
+    @Override
+    public ListResponse<DiskOfferingResponse> searchForDiskOfferings(ListDiskOfferingsCmd cmd) {
+        Pair<List<DiskOfferingJoinVO>, Integer> result = searchForDiskOfferingsInternal(cmd);
+        ListResponse<DiskOfferingResponse> response = new ListResponse<DiskOfferingResponse>();
+        List<DiskOfferingResponse> offeringResponses = ViewResponseHelper.createDiskOfferingResponse(result.first().toArray(new DiskOfferingJoinVO[result.first().size()]));
+        response.setResponses(offeringResponses, result.second());
+        return response;
+    }
+
+    private Pair<List<DiskOfferingJoinVO>, Integer> searchForDiskOfferingsInternal(ListDiskOfferingsCmd cmd) {
+        // Note
+        // The list method for offerings is being modified in accordance with
+        // discussion with Will/Kevin
+        // For now, we will be listing the following based on the usertype
+        // 1. For root, we will list all offerings
+        // 2. For domainAdmin and regular users, we will list everything in
+        // their domains+parent domains ... all the way
+        // till
+        // root
+
+        Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
+        isAscending = (isAscending == null ? true : isAscending);
+        Filter searchFilter = new Filter(DiskOfferingJoinVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal());
+        SearchBuilder<DiskOfferingJoinVO> sb = _diskOfferingJoinDao.createSearchBuilder();
+
+
+        Account account = UserContext.current().getCaller();
+        Object name = cmd.getDiskOfferingName();
+        Object id = cmd.getId();
+        Object keyword = cmd.getKeyword();
+        Long domainId = cmd.getDomainId();
+        // Keeping this logic consistent with domain specific zones
+        // if a domainId is provided, we just return the disk offering
+        // associated with this domain
+        if (domainId != null) {
+            if (account.getType() == Account.ACCOUNT_TYPE_ADMIN || isPermissible(account.getDomainId(), domainId) ) {
+                // check if the user's domain == do's domain || user's domain is
+                // a child of so's domain for non-root users
+                sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
+                SearchCriteria<DiskOfferingJoinVO> sc = sb.create();
+                sc.setParameters("domainId", domainId);
+                return _diskOfferingJoinDao.searchAndCount(sc, searchFilter);
+            } else {
+                    throw new PermissionDeniedException("The account:" + account.getAccountName()
+                            + " does not fall in the same domain hierarchy as the disk offering");
+            }
+        }
+
+        sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
+        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+
+
+        boolean includePublicOfferings = false;
+        List<Long> domainIds = null;
+        // For non-root users, only return all offerings for the user's domain, and everything above till root
+        if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)
+                || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+            // find all domain Id up to root domain for this account
+            domainIds = new ArrayList<Long>();
+            DomainVO domainRecord = _domainDao.findById(account.getDomainId());
+            if ( domainRecord == null ){
+                s_logger.error("Could not find the domainId for account:" + account.getAccountName());
+                throw new CloudAuthenticationException("Could not find the domainId for account:" + account.getAccountName());
+            }
+            domainIds.add(domainRecord.getId());
+            while (domainRecord.getParent() != null ){
+                domainRecord = _domainDao.findById(domainRecord.getParent());
+                domainIds.add(domainRecord.getId());
+            }
+            sb.and("domainIdIn", sb.entity().getDomainId(), SearchCriteria.Op.IN);
+
+            // include also public offering if no keyword, name and id specified
+            if ( keyword == null && name == null && id == null ){
+                includePublicOfferings = true;
+            }
+        }
+
+        SearchCriteria<DiskOfferingJoinVO> sc = sb.create();
+        if (keyword != null) {
+            SearchCriteria<DiskOfferingJoinVO> ssc = _diskOfferingJoinDao.createSearchCriteria();
+            ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+            ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+
+            sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+        }
+
+        if (name != null) {
+            sc.setParameters("name", "%" + name + "%");
+        }
+
+        if (id != null) {
+            sc.setParameters("id", id);
+        }
+
+        if (domainIds != null ){
+            sc.setParameters("domainIdIn", domainIds);
+        }
+
+        if (includePublicOfferings){
+            SearchCriteria<DiskOfferingJoinVO> spc = _diskOfferingJoinDao.createSearchCriteria();
+            spc.addAnd("domainId", SearchCriteria.Op.NULL);
+            spc.addAnd("systemUse", SearchCriteria.Op.EQ, false);
+
+            sc.addOr("systemUse", SearchCriteria.Op.SC, spc);
+        }
+
+        // FIXME: disk offerings should search back up the hierarchy for
+        // available disk offerings...
+        /*
+         * sb.addAnd("domainId", sb.entity().getDomainId(),
+         * SearchCriteria.Op.EQ); if (domainId != null) {
+         * SearchBuilder<DomainVO> domainSearch =
+         * _domainDao.createSearchBuilder(); domainSearch.addAnd("path",
+         * domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
+         * sb.join("domainSearch", domainSearch, sb.entity().getDomainId(),
+         * domainSearch.entity().getId()); }
+         */
+
+        // FIXME: disk offerings should search back up the hierarchy for
+        // available disk offerings...
+        /*
+         * if (domainId != null) { sc.setParameters("domainId", domainId); //
+         * //DomainVO domain = _domainDao.findById((Long)domainId); // // I want
+         * to join on user_vm.domain_id = domain.id where domain.path like
+         * 'foo%' //sc.setJoinParameters("domainSearch", "path",
+         * domain.getPath() + "%"); // }
+         */
+
+        return _diskOfferingJoinDao.searchAndCount(sc, searchFilter);
+    }
+
+
+    // This method is used for permissions check for both disk and service
+    // offerings
+    private boolean isPermissible(Long accountDomainId, Long offeringDomainId) {
+
+        if (accountDomainId == offeringDomainId) {
+            return true; // account and service offering in same domain
+        }
+
+        DomainVO domainRecord = _domainDao.findById(accountDomainId);
 
+        if (domainRecord != null) {
+            while (true) {
+                if (domainRecord.getId() == offeringDomainId) {
+                    return true;
+                }
+
+                // try and move on to the next domain
+                if (domainRecord.getParent() != null) {
+                    domainRecord = _domainDao.findById(domainRecord.getParent());
+                } else {
+                    break;
+                }
+            }
+        }
+
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/query/ViewResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/ViewResponseHelper.java b/server/src/com/cloud/api/query/ViewResponseHelper.java
index 39c108e..9c761d4 100644
--- a/server/src/com/cloud/api/query/ViewResponseHelper.java
+++ b/server/src/com/cloud/api/query/ViewResponseHelper.java
@@ -25,6 +25,7 @@ import org.apache.cloudstack.api.ApiConstants.HostDetails;
 import org.apache.cloudstack.api.ApiConstants.VMDetails;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
 import org.apache.cloudstack.api.response.EventResponse;
 import org.apache.cloudstack.api.response.HostResponse;
@@ -43,6 +44,7 @@ import org.apache.log4j.Logger;
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.vo.AccountJoinVO;
 import com.cloud.api.query.vo.AsyncJobJoinVO;
+import com.cloud.api.query.vo.DiskOfferingJoinVO;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
 import com.cloud.api.query.vo.EventJoinVO;
 import com.cloud.api.query.vo.HostJoinVO;
@@ -274,4 +276,12 @@ public class ViewResponseHelper {
         }
         return respList;
     }
+
+    public static List<DiskOfferingResponse> createDiskOfferingResponse(DiskOfferingJoinVO... offerings) {
+        List<DiskOfferingResponse> respList = new ArrayList<DiskOfferingResponse>();
+        for (DiskOfferingJoinVO vt : offerings){
+            respList.add(ApiDBUtils.newDiskOfferingResponse(vt));
+        }
+        return respList;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/query/dao/DiskOfferingJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDao.java b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDao.java
new file mode 100644
index 0000000..30758d1
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDao.java
@@ -0,0 +1,29 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import com.cloud.api.query.vo.DiskOfferingJoinVO;
+import com.cloud.offering.DiskOffering;
+import com.cloud.utils.db.GenericDao;
+
+public interface DiskOfferingJoinDao extends GenericDao<DiskOfferingJoinVO, Long> {
+
+    DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO dof);
+
+    DiskOfferingJoinVO newDiskOfferingView(DiskOffering dof);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
new file mode 100644
index 0000000..d877381
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
@@ -0,0 +1,101 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.query.vo.DiskOfferingJoinVO;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.DiskOfferingVO.Type;
+import com.cloud.utils.db.Attribute;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+
+@Local(value={DiskOfferingJoinDao.class})
+public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO, Long> implements DiskOfferingJoinDao {
+    public static final Logger s_logger = Logger.getLogger(DiskOfferingJoinDaoImpl.class);
+
+
+    private SearchBuilder<DiskOfferingJoinVO> dofIdSearch;
+    private final Attribute _typeAttr;
+
+     protected DiskOfferingJoinDaoImpl() {
+
+        dofIdSearch = createSearchBuilder();
+        dofIdSearch.and("id", dofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+        dofIdSearch.done();
+
+        _typeAttr = _allAttributes.get("type");
+
+        this._count = "select count(distinct id) from disk_offering_view WHERE ";
+    }
+
+
+
+    @Override
+    public DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
+
+        DiskOfferingResponse diskOfferingResponse = new DiskOfferingResponse();
+        diskOfferingResponse.setId(offering.getUuid());
+        diskOfferingResponse.setName(offering.getName());
+        diskOfferingResponse.setDisplayText(offering.getDisplayText());
+        diskOfferingResponse.setCreated(offering.getCreated());
+        diskOfferingResponse.setDiskSize(offering.getDiskSize() / (1024 * 1024 * 1024));
+
+                diskOfferingResponse.setDomain(offering.getDomainName());
+                diskOfferingResponse.setDomainId(offering.getDomainUuid());
+
+        diskOfferingResponse.setTags(offering.getTags());
+        diskOfferingResponse.setCustomized(offering.isCustomized());
+        diskOfferingResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
+        diskOfferingResponse.setObjectName("diskoffering");
+        return diskOfferingResponse;
+    }
+
+
+    @Override
+    public DiskOfferingJoinVO newDiskOfferingView(DiskOffering offering) {
+        SearchCriteria<DiskOfferingJoinVO> sc = dofIdSearch.create();
+        sc.setParameters("id", offering.getId());
+        List<DiskOfferingJoinVO> offerings = searchIncludingRemoved(sc, null, null, false);
+        assert offerings != null && offerings.size() == 1 : "No disk offering found for offering id " + offering.getId();
+        return offerings.get(0);
+    }
+
+    @Override
+    public List<DiskOfferingJoinVO> searchIncludingRemoved(SearchCriteria<DiskOfferingJoinVO> sc, final Filter filter, final Boolean lock, final boolean cache) {
+        sc.addAnd(_typeAttr, Op.EQ, Type.Disk);
+        return super.searchIncludingRemoved(sc, filter, lock, cache);
+    }
+
+    @Override
+    public <K> List<K> customSearchIncludingRemoved(SearchCriteria<K> sc, final Filter filter) {
+        sc.addAnd(_typeAttr, Op.EQ, Type.Disk);
+        return super.customSearchIncludingRemoved(sc, filter);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
new file mode 100644
index 0000000..7785bee
--- /dev/null
+++ b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
@@ -0,0 +1,233 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.vo;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.storage.DiskOfferingVO.Type;
+import com.cloud.utils.db.GenericDao;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="disk_offering_view")
+public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity, Identity {
+
+    @Id
+    @Column(name="id", updatable=false, nullable = false)
+    private long id;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    @Column(name="name")
+    private String name;
+
+    @Column(name="display_text")
+    private String displayText;
+
+    @Column(name="disk_size")
+    long diskSize;
+
+    @Column(name="tags", length=4096)
+    String tags;
+
+    @Column(name="use_local_storage")
+    private boolean useLocalStorage;
+
+    @Column(name="system_use")
+    private boolean systemUse;
+
+    @Column(name="customized")
+    private boolean customized;
+
+    @Column(name="sort_key")
+    int sortKey;
+
+    @Column(name="type")
+    Type type;
+
+    @Column(name=GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name="domain_id")
+    private long domainId;
+
+    @Column(name="domain_uuid")
+    private String domainUuid;
+
+    @Column(name="domain_name")
+    private String domainName = null;
+
+    @Column(name="domain_path")
+    private String domainPath = null;
+
+
+    public DiskOfferingJoinVO() {
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    @Override
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDisplayText() {
+        return displayText;
+    }
+
+    public void setDisplayText(String displayText) {
+        this.displayText = displayText;
+    }
+
+    public long getDiskSize() {
+        return diskSize;
+    }
+
+    public void setDiskSize(long diskSize) {
+        this.diskSize = diskSize;
+    }
+
+    public String getTags() {
+        return tags;
+    }
+
+    public void setTags(String tags) {
+        this.tags = tags;
+    }
+
+    public boolean isUseLocalStorage() {
+        return useLocalStorage;
+    }
+
+    public void setUseLocalStorage(boolean useLocalStorage) {
+        this.useLocalStorage = useLocalStorage;
+    }
+
+    public boolean isSystemUse() {
+        return systemUse;
+    }
+
+    public void setSystemUse(boolean systemUse) {
+        this.systemUse = systemUse;
+    }
+
+    public boolean isCustomized() {
+        return customized;
+    }
+
+    public void setCustomized(boolean customized) {
+        this.customized = customized;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+
+    public long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(long domainId) {
+        this.domainId = domainId;
+    }
+
+    public String getDomainUuid() {
+        return domainUuid;
+    }
+
+    public void setDomainUuid(String domainUuid) {
+        this.domainUuid = domainUuid;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+    }
+
+    public String getDomainPath() {
+        return domainPath;
+    }
+
+    public void setDomainPath(String domainPath) {
+        this.domainPath = domainPath;
+    }
+
+    public int getSortKey() {
+        return sortKey;
+    }
+
+    public void setSortKey(int sortKey) {
+        this.sortKey = sortKey;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index e98946b..5a1b002 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -27,6 +27,7 @@ import com.cloud.alert.dao.AlertDaoImpl;
 import com.cloud.api.query.QueryManagerImpl;
 import com.cloud.api.query.dao.AccountJoinDaoImpl;
 import com.cloud.api.query.dao.AsyncJobJoinDaoImpl;
+import com.cloud.api.query.dao.DiskOfferingJoinDaoImpl;
 import com.cloud.api.query.dao.DomainRouterJoinDaoImpl;
 import com.cloud.api.query.dao.InstanceGroupJoinDaoImpl;
 import com.cloud.api.query.dao.ProjectAccountJoinDaoImpl;
@@ -392,6 +393,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
         addDao("AccountJoinDao", AccountJoinDaoImpl.class);
         addDao("AsyncJobJoinDao", AsyncJobJoinDaoImpl.class);
         addDao("StoragePoolJoinDao", StoragePoolJoinDaoImpl.class);
+        addDao("DiskOfferingJoinDao", DiskOfferingJoinDaoImpl.class);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index bad834d..0684440 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -46,7 +46,6 @@ import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
 import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
 import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
-import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 import org.apache.cloudstack.api.command.admin.systemvm.DestroySystemVmCmd;
 import org.apache.cloudstack.api.command.admin.systemvm.UpgradeSystemVMCmd;
 import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
@@ -55,7 +54,6 @@ import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd;
 import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
 import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
 import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
-import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
 import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
 import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
 import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
@@ -91,9 +89,6 @@ import org.apache.cloudstack.api.command.admin.systemvm.StopSystemVmCmd;
 import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
 import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
 import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
-import com.cloud.api.query.dao.DomainRouterJoinDao;
-import com.cloud.api.query.dao.InstanceGroupJoinDao;
-
 import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
 import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
 import org.apache.cloudstack.api.response.ExtractResponse;
@@ -103,13 +98,11 @@ import com.cloud.async.AsyncJobManager;
 import com.cloud.async.AsyncJobResult;
 import com.cloud.async.AsyncJobVO;
 import com.cloud.async.BaseAsyncJobExecutor;
-import com.cloud.async.dao.AsyncJobDao;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
 import com.cloud.configuration.Config;
-import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Configuration;
 import com.cloud.configuration.ConfigurationVO;
 import com.cloud.configuration.dao.ConfigurationDao;
@@ -139,7 +132,6 @@ import com.cloud.event.EventTypes;
 import com.cloud.event.EventUtils;
 import com.cloud.event.EventVO;
 import com.cloud.event.dao.EventDao;
-import com.cloud.event.dao.EventJoinDao;
 import com.cloud.exception.CloudAuthenticationException;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InvalidParameterValueException;
@@ -179,7 +171,6 @@ import com.cloud.server.ResourceTag.TaggedResourceType;
 import com.cloud.server.auth.UserAuthenticator;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
-import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.GuestOS;
 import com.cloud.storage.GuestOSCategoryVO;
 import com.cloud.storage.GuestOSVO;
@@ -187,7 +178,6 @@ import com.cloud.storage.GuestOsCategory;
 import com.cloud.storage.Storage;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.StorageManager;
-import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolVO;
 import com.cloud.storage.Upload;
 import com.cloud.storage.Upload.Mode;
@@ -195,7 +185,6 @@ import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
-import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.StoragePoolDao;
@@ -220,12 +209,10 @@ import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.SSHKeyPairDao;
 import com.cloud.user.dao.UserDao;
-import com.cloud.uservm.UserVm;
 import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
-import com.cloud.utils.PropertiesUtil;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Adapters;
 import com.cloud.utils.component.ComponentLocator;
@@ -258,7 +245,6 @@ import com.cloud.vm.VirtualMachineProfileImpl;
 import com.cloud.vm.dao.ConsoleProxyDao;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.InstanceGroupDao;
-import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.SecondaryStorageVmDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
@@ -274,12 +260,10 @@ public class ManagementServerImpl implements ManagementServer {
     private final AlertManager _alertMgr;
     private final IPAddressDao _publicIpAddressDao;
     private final DomainRouterDao _routerDao;
-    private final DomainRouterJoinDao _routerJoinDao;
     private final ConsoleProxyDao _consoleProxyDao;
     private final ClusterDao _clusterDao;
     private final SecondaryStorageVmDao _secStorageVmDao;
     private final EventDao _eventDao;
-    private final EventJoinDao _eventJoinDao;
     private final DataCenterDao _dcDao;
     private final VlanDao _vlanDao;
     private final AccountVlanMapDao _accountVlanMapDao;
@@ -294,7 +278,6 @@ public class ManagementServerImpl implements ManagementServer {
     private final SwiftManager _swiftMgr;
     private final S3Manager _s3Mgr;
     private final ServiceOfferingDao _offeringsDao;
-    private final DiskOfferingDao _diskOfferingDao;
     private final VMTemplateDao _templateDao;
     private final DomainDao _domainDao;
     private final AccountDao _accountDao;
@@ -303,25 +286,21 @@ public class ManagementServerImpl implements ManagementServer {
     private final GuestOSDao _guestOSDao;
     private final GuestOSCategoryDao _guestOSCategoryDao;
     private final StoragePoolDao _poolDao;
-    private final NicDao _nicDao;
     private final NetworkDao _networkDao;
     private final StorageManager _storageMgr;
     private final VirtualMachineManager _itMgr;
     private final HostPodDao _hostPodDao;
     private final VMInstanceDao _vmInstanceDao;
     private final VolumeDao _volumeDao;
-    private final AsyncJobDao _jobDao;
     private final AsyncJobManager _asyncMgr;
     private final int _purgeDelay;
     private final InstanceGroupDao _vmGroupDao;
-    private final InstanceGroupJoinDao _vmGroupJoinDao;
     private final UploadMonitor _uploadMonitor;
     private final UploadDao _uploadDao;
     private final SSHKeyPairDao _sshKeyPairDao;
     private final LoadBalancerDao _loadbalancerDao;
     private final HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
     private final Adapters<HostAllocator> _hostAllocators;
-    private final ConfigurationManager _configMgr;
     private final ResourceTagDao _resourceTagDao;
 
     @Inject
@@ -340,6 +319,8 @@ public class ManagementServerImpl implements ManagementServer {
 
     private final Map<String, String> _configs;
 
+    // even though this _statsCollector is never used here, but we create the singleton here to avoid null pointer exception in other places
+    // like ApiDbUtils to reference StatsCollector instance.
     private final StatsCollector _statsCollector;
 
     private final Map<String, Boolean> _availableIdsMap;
@@ -352,9 +333,7 @@ public class ManagementServerImpl implements ManagementServer {
         ComponentLocator locator = ComponentLocator.getLocator(Name);
         _configDao = locator.getDao(ConfigurationDao.class);
         _routerDao = locator.getDao(DomainRouterDao.class);
-        _routerJoinDao = locator.getDao(DomainRouterJoinDao.class);
         _eventDao = locator.getDao(EventDao.class);
-        _eventJoinDao = locator.getDao(EventJoinDao.class);
         _dcDao = locator.getDao(DataCenterDao.class);
         _vlanDao = locator.getDao(VlanDao.class);
         _accountVlanMapDao = locator.getDao(AccountVlanMapDao.class);
@@ -362,9 +341,7 @@ public class ManagementServerImpl implements ManagementServer {
         _hostDao = locator.getDao(HostDao.class);
         _detailsDao = locator.getDao(HostDetailsDao.class);
         _hostPodDao = locator.getDao(HostPodDao.class);
-        _jobDao = locator.getDao(AsyncJobDao.class);
         _clusterDao = locator.getDao(ClusterDao.class);
-        _nicDao = locator.getDao(NicDao.class);
         _networkDao = locator.getDao(NetworkDao.class);
         _loadbalancerDao = locator.getDao(LoadBalancerDao.class);
 
@@ -382,7 +359,6 @@ public class ManagementServerImpl implements ManagementServer {
         _userDao = locator.getDao(UserDao.class);
         _userVmDao = locator.getDao(UserVmDao.class);
         _offeringsDao = locator.getDao(ServiceOfferingDao.class);
-        _diskOfferingDao = locator.getDao(DiskOfferingDao.class);
         _templateDao = locator.getDao(VMTemplateDao.class);
         _domainDao = locator.getDao(DomainDao.class);
         _accountDao = locator.getDao(AccountDao.class);
@@ -392,7 +368,6 @@ public class ManagementServerImpl implements ManagementServer {
         _guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class);
         _poolDao = locator.getDao(StoragePoolDao.class);
         _vmGroupDao = locator.getDao(InstanceGroupDao.class);
-        _vmGroupJoinDao = locator.getDao(InstanceGroupJoinDao.class);
         _uploadDao = locator.getDao(UploadDao.class);
         _configs = _configDao.getConfiguration();
         _vmInstanceDao = locator.getDao(VMInstanceDao.class);
@@ -403,7 +378,6 @@ public class ManagementServerImpl implements ManagementServer {
         _itMgr = locator.getManager(VirtualMachineManager.class);
         _ksMgr = locator.getManager(KeystoreManager.class);
         _resourceMgr = locator.getManager(ResourceManager.class);
-        _configMgr = locator.getManager(ConfigurationManager.class);
         _resourceTagDao = locator.getDao(ResourceTagDao.class);
 
         _hypervisorCapabilitiesDao = locator.getDao(HypervisorCapabilitiesDao.class);
@@ -997,7 +971,7 @@ public class ManagementServerImpl implements ManagementServer {
 
         Pair<List<HostVO>, Integer> allHostsInClusterPair = searchForServers(startIndex, pageSize, null, hostType, null, null, null, cluster, null, null, null, null);
 
-        // filter out the current host        
+        // filter out the current host
         List<HostVO> allHostsInCluster = allHostsInClusterPair.first();
         allHostsInCluster.remove(srcHost);
         Pair<List<? extends Host>, Integer> otherHostsInCluster = new Pair<List <? extends Host>, Integer>(allHostsInCluster, new Integer(allHostsInClusterPair.second().intValue()-1));
@@ -2153,169 +2127,7 @@ public class ManagementServerImpl implements ManagementServer {
                 || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
     }
 
-    private List<DiskOfferingVO> searchDiskOfferingsInternal(Account account, Object name, Object id, Object keyword, Filter searchFilter) {
-        // it was decided to return all offerings for the user's domain, and
-        // everything above till root (for normal user
-        // or
-        // domain admin)
-        // list all offerings belonging to this domain, and all of its parents
-        // check the parent, if not null, add offerings for that parent to list
-        List<DiskOfferingVO> dol = new ArrayList<DiskOfferingVO>();
-        DomainVO domainRecord = _domainDao.findById(account.getDomainId());
-        boolean includePublicOfferings = true;
-        if (domainRecord != null) {
-            while (true) {
-                SearchBuilder<DiskOfferingVO> sb = _diskOfferingDao.createSearchBuilder();
-
-                sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
-                sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
-                sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NULL);
-
-                SearchCriteria<DiskOfferingVO> sc = sb.create();
-                if (keyword != null) {
-                    includePublicOfferings = false;
-                    SearchCriteria<DiskOfferingVO> ssc = _diskOfferingDao.createSearchCriteria();
-                    ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-                    ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-
-                    sc.addAnd("name", SearchCriteria.Op.SC, ssc);
-                }
-
-                if (name != null) {
-                    includePublicOfferings = false;
-                    sc.setParameters("name", "%" + name + "%");
-                }
-
-                if (id != null) {
-                    includePublicOfferings = false;
-                    sc.setParameters("id", id);
-                }
-
-                // for this domain
-                sc.addAnd("domainId", SearchCriteria.Op.EQ, domainRecord.getId());
-
-                // search and add for this domain
-                dol.addAll(_diskOfferingDao.search(sc, searchFilter));
-
-                // try and move on to the next domain
-                if (domainRecord.getParent() != null) {
-                    domainRecord = _domainDao.findById(domainRecord.getParent());
-                } else {
-                    break;// now we got all the offerings for this user/dom adm
-                }
-            }
-        } else {
-            s_logger.error("Could not find the domainId for account:" + account.getAccountName());
-            throw new CloudAuthenticationException("Could not find the domainId for account:" + account.getAccountName());
-        }
-
-        // add all the public offerings to the sol list before returning
-        if (includePublicOfferings) {
-            dol.addAll(_diskOfferingDao.findPublicDiskOfferings());
-        }
-
-        return dol;
-
-    }
-
-    @Override
-    public List<DiskOfferingVO> searchForDiskOfferings(ListDiskOfferingsCmd cmd) {
-        // Note
-        // The list method for offerings is being modified in accordance with
-        // discussion with Will/Kevin
-        // For now, we will be listing the following based on the usertype
-        // 1. For root, we will list all offerings
-        // 2. For domainAdmin and regular users, we will list everything in
-        // their domains+parent domains ... all the way
-        // till
-        // root
 
-        Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
-        isAscending = (isAscending == null ? true : isAscending);
-        Filter searchFilter = new Filter(DiskOfferingVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal());
-        SearchBuilder<DiskOfferingVO> sb = _diskOfferingDao.createSearchBuilder();
-
-        // SearchBuilder and SearchCriteria are now flexible so that the search
-        // builder can be built with all possible
-        // search terms and only those with criteria can be set. The proper SQL
-        // should be generated as a result.
-        Account account = UserContext.current().getCaller();
-        Object name = cmd.getDiskOfferingName();
-        Object id = cmd.getId();
-        Object keyword = cmd.getKeyword();
-        Long domainId = cmd.getDomainId();
-        // Keeping this logic consistent with domain specific zones
-        // if a domainId is provided, we just return the disk offering
-        // associated with this domain
-        if (domainId != null) {
-            if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
-                return _diskOfferingDao.listByDomainId(domainId);// no perm
-                                                                 // check
-            } else {
-                // check if the user's domain == do's domain || user's domain is
-                // a child of so's domain
-                if (isPermissible(account.getDomainId(), domainId)) {
-                    // perm check succeeded
-                    return _diskOfferingDao.listByDomainId(domainId);
-                } else {
-                    throw new PermissionDeniedException("The account:" + account.getAccountName()
-                            + " does not fall in the same domain hierarchy as the disk offering");
-                }
-            }
-        }
-
-        // For non-root users
-        if ((account.getType() == Account.ACCOUNT_TYPE_NORMAL || account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)
-                || account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
-            return searchDiskOfferingsInternal(account, name, id, keyword, searchFilter);
-        }
-
-        // For root users, preserving existing flow
-        sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
-        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
-        sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.NULL);
-
-        // FIXME: disk offerings should search back up the hierarchy for
-        // available disk offerings...
-        /*
-         * sb.addAnd("domainId", sb.entity().getDomainId(),
-         * SearchCriteria.Op.EQ); if (domainId != null) {
-         * SearchBuilder<DomainVO> domainSearch =
-         * _domainDao.createSearchBuilder(); domainSearch.addAnd("path",
-         * domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
-         * sb.join("domainSearch", domainSearch, sb.entity().getDomainId(),
-         * domainSearch.entity().getId()); }
-         */
-
-        SearchCriteria<DiskOfferingVO> sc = sb.create();
-        if (keyword != null) {
-            SearchCriteria<DiskOfferingVO> ssc = _diskOfferingDao.createSearchCriteria();
-            ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-            ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-
-            sc.addAnd("name", SearchCriteria.Op.SC, ssc);
-        }
-
-        if (name != null) {
-            sc.setParameters("name", "%" + name + "%");
-        }
-
-        if (id != null) {
-            sc.setParameters("id", id);
-        }
-
-        // FIXME: disk offerings should search back up the hierarchy for
-        // available disk offerings...
-        /*
-         * if (domainId != null) { sc.setParameters("domainId", domainId); //
-         * //DomainVO domain = _domainDao.findById((Long)domainId); // // I want
-         * to join on user_vm.domain_id = domain.id where domain.path like
-         * 'foo%' //sc.setJoinParameters("domainSearch", "path",
-         * domain.getPath() + "%"); // }
-         */
-
-        return _diskOfferingDao.search(sc, searchFilter);
-    }
 
     @Override
     public List<Class<?>> getCommands() {
@@ -3321,6 +3133,7 @@ public class ManagementServerImpl implements ManagementServer {
 
     }
 
+    @Override
     public void enableAdminUser(String password) {
         String encodedPassword = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/setup/db/create-schema-view.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema-view.sql b/setup/db/create-schema-view.sql
index bf04c1c..63f5998 100644
--- a/setup/db/create-schema-view.sql
+++ b/setup/db/create-schema-view.sql
@@ -818,4 +818,27 @@ left join data_center on storage_pool.data_center_id = data_center.id
 left join host_pod_ref on storage_pool.pod_id = host_pod_ref.id
 left join storage_pool_details on storage_pool_details.pool_id = storage_pool.id and storage_pool_details.value = 'true'
 left join op_host_capacity on storage_pool.id = op_host_capacity.host_id and op_host_capacity.capacity_type = 3
-left join async_job on async_job.instance_id = storage_pool.id and async_job.instance_type = "StoragePool" and async_job.job_status = 0;
\ No newline at end of file
+left join async_job on async_job.instance_id = storage_pool.id and async_job.instance_type = "StoragePool" and async_job.job_status = 0;
+
+DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
+CREATE VIEW disk_offering_view AS
+select 
+disk_offering.id,
+disk_offering.uuid,
+disk_offering.name,
+disk_offering.display_text,
+disk_offering.disk_size,
+disk_offering.created,
+disk_offering.tags,
+disk_offering.customized,
+disk_offering.removed,
+disk_offering.use_local_storage,
+disk_offering.system_use,
+disk_offering.sort_key,
+disk_offering.type,
+domain.id domain_id, 
+domain.uuid domain_uuid,
+domain.name domain_name, 
+domain.path domain_path
+from disk_offering 
+left join domain on disk_offering.domain_id=domain.id;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6db719d5/setup/db/db/schema-40to410.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql
index a9d168d..9513b20 100644
--- a/setup/db/db/schema-40to410.sql
+++ b/setup/db/db/schema-40to410.sql
@@ -945,4 +945,28 @@ left join storage_pool_details on storage_pool_details.pool_id = storage_pool.id
 left join op_host_capacity on storage_pool.id = op_host_capacity.host_id and op_host_capacity.capacity_type = 3
 left join async_job on async_job.instance_id = storage_pool.id and async_job.instance_type = "StoragePool" and async_job.job_status = 0;
 
+DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
+CREATE VIEW disk_offering_view AS
+select 
+disk_offering.id,
+disk_offering.uuid,
+disk_offering.name,
+disk_offering.display_text,
+disk_offering.disk_size,
+disk_offering.created,
+disk_offering.tags,
+disk_offering.customized,
+disk_offering.removed,
+disk_offering.use_local_storage,
+disk_offering.system_use,
+disk_offering.sort_key,
+disk_offering.type,
+domain.id domain_id, 
+domain.uuid domain_uuid,
+domain.name domain_name, 
+domain.path domain_path
+from disk_offering 
+left join domain on disk_offering.domain_id=domain.id;
+
+
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'direct.agent.pool.size', '500', 'Default size for DirectAgentPool');


Mime
View raw message