cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject [33/50] [abbrv] git commit: updated refs/heads/vmware-datamodel to 6a8c2bd
Date Fri, 31 May 2013 07:49:31 GMT
CLOUDSTACK-681: Dedicated Resources - Explicit Dedication, Private zone, pod, cluster or host. <Patch1>

This feature allows a user to deploy VMs only in the resources dedicated to his account or domain.

1. Resources(Zones, Pods, Clusters or hosts) can be dedicated to an account or domain.
   Implemented 12 new APIs to dedicate/list/release resources:
   - dedicateZone, listDedicatedZones, releaseDedicatedZone for a Zone.
   - dedicatePod, listDedicatedPods, releaseDedicatedPod for a Pod.
   - dedicateCluster, listDedicatedClusters, releaseDedicatedCluster for a Cluster
   - dedicateHost, listDedicatedHosts, releaseDedicatedHost for a Host.
2. Once a resource(eg. pod) is dedicated to an account, other resources(eg. clusters/hosts) inside that cannot be further dedicated.
3. Once a resource is dedicated to a domain, other resources inside that can be further dedicated to its sub-domain or account.
4. If any resource (eg.cluster) is dedicated to a account/domain, then resources(eg. Pod) above that cannot be dedicated to different accounts/domain (not belonging to the same domain)
5. To use Explicit dedication, user needs to create an Affinity Group of type 'ExplicitDedication'
6. A VM can be deployed with the above affinity group parameter as an input.
7. A new ExplicitDedicationProcessor has been added which will process the affinity group of type 'Explicit Dedication' for a deployment of a VM that demands dedicated resources.
   This processor implements the AffinityGroupProcessor adapter. This processor will update the avoid list.
8. A VM requesting dedication will be deployed on dedicatd resources if available with the user account.
9. A VM requesting dedication can also be deployed on the dedicated resources available with the parent domains iff no dedicated resources are available with the current user's account or
   domain.
10. A VM (without dedication) can be deployed on shared host but not on dedicated hosts.
11. To modify the dedication, the resource has to be released first.
12. Existing Private zone functionality has been redirected to Explicit dedication of zones.
13. Updated the db upgrade schema script. A new table "dedicated_resources" has been added.
14. Added the right permissions in commands.properties
15. Unit tests:  For the new APIs and Service, added unit tests under : plugins/dedicated-resources/test/org/apache/cloudstack/dedicated/DedicatedApiUnitTest.java
16. Marvin Test: To dedicate host, create affinity group, deploy-vm, check if vm is deployed on the dedicated host.


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

Branch: refs/heads/vmware-datamodel
Commit: 17267794adb2bab923fb20515a7b943780d61921
Parents: 4989f73
Author: Saksham Srivastava <saksham.srivastava@citrix.com>
Authored: Thu May 30 11:00:03 2013 +0530
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu May 30 01:07:01 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/dc/DedicatedResources.java       |   33 +
 api/src/com/cloud/event/EventTypes.java            |    4 +
 client/pom.xml                                     |   10 +
 client/tomcatconf/applicationContext.xml.in        |   14 +-
 client/tomcatconf/commands.properties.in           |   13 +
 client/tomcatconf/componentContext.xml.in          |   32 +-
 .../platform/orchestration/CloudOrchestrator.java  |    3 +-
 engine/schema/src/com/cloud/dc/dao/ClusterDao.java |    1 +
 .../src/com/cloud/dc/dao/ClusterDaoImpl.java       |   14 +-
 .../src/com/cloud/domain/dao/DomainDaoImpl.java    |    2 +-
 engine/schema/src/com/cloud/host/dao/HostDao.java  |    6 +
 .../schema/src/com/cloud/host/dao/HostDaoImpl.java |   37 +-
 .../explicit-dedication/pom.xml                    |   33 +
 .../affinity/ExplicitDedicationProcessor.java      |  383 +++++++
 plugins/dedicated-resources/pom.xml                |   29 +
 .../dedicated/api/commands/DedicateClusterCmd.java |  115 ++
 .../dedicated/api/commands/DedicateHostCmd.java    |  118 +++
 .../dedicated/api/commands/DedicatePodCmd.java     |  120 +++
 .../dedicated/api/commands/DedicateZoneCmd.java    |  120 +++
 .../api/commands/ListDedicatedClustersCmd.java     |  105 ++
 .../api/commands/ListDedicatedHostsCmd.java        |  105 ++
 .../api/commands/ListDedicatedPodsCmd.java         |  105 ++
 .../api/commands/ListDedicatedZonesCmd.java        |  105 ++
 .../api/commands/ReleaseDedicatedClusterCmd.java   |   91 ++
 .../api/commands/ReleaseDedicatedHostCmd.java      |   91 ++
 .../api/commands/ReleaseDedicatedPodCmd.java       |   91 ++
 .../api/commands/ReleaseDedicatedZoneCmd.java      |   91 ++
 .../api/response/DedicateClusterResponse.java      |   79 ++
 .../api/response/DedicateHostResponse.java         |   79 ++
 .../api/response/DedicatePodResponse.java          |   82 ++
 .../api/response/DedicateZoneResponse.java         |   83 ++
 .../manager/DedicatedResourceManagerImpl.java      |  816 +++++++++++++++
 .../dedicated/services/DedicatedService.java       |   63 ++
 .../dedicated/manager/DedicatedApiUnitTest.java    |  324 ++++++
 .../test/resource/dedicatedContext.xml             |   45 +
 plugins/pom.xml                                    |    4 +-
 .../src/com/cloud/api/query/QueryManagerImpl.java  |   33 +-
 .../configuration/ConfigurationManagerImpl.java    |   23 +-
 server/src/com/cloud/dc/DedicatedResourceVO.java   |  136 +++
 .../src/com/cloud/dc/dao/DedicatedResourceDao.java |   49 +
 .../com/cloud/dc/dao/DedicatedResourceDaoImpl.java |  304 ++++++
 .../com/cloud/resource/ResourceManagerImpl.java    |   22 +-
 server/src/com/cloud/user/AccountManagerImpl.java  |   26 +-
 server/src/com/cloud/user/DomainManagerImpl.java   |   26 +
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   50 +-
 .../networkoffering/ChildTestConfiguration.java    |   11 +-
 setup/db/create-schema.sql                         |    1 -
 setup/db/db/schema-410to420.sql                    |   27 +-
 .../component/test_explicit_dedication.py          |  231 ++++
 tools/apidoc/gen_toc.py                            |    4 +-
 50 files changed, 4348 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/api/src/com/cloud/dc/DedicatedResources.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/dc/DedicatedResources.java b/api/src/com/cloud/dc/DedicatedResources.java
new file mode 100755
index 0000000..e8e5ab3
--- /dev/null
+++ b/api/src/com/cloud/dc/DedicatedResources.java
@@ -0,0 +1,33 @@
+// 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.dc;
+
+import org.apache.cloudstack.acl.InfrastructureEntity;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface DedicatedResources extends InfrastructureEntity, InternalIdentity, Identity{
+    long getId();
+    Long getDataCenterId();
+    Long getPodId();
+    Long getClusterId();
+    Long getHostId();
+    Long getDomainId();
+    Long getAccountId();
+    String getUuid();
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 6dfb1ab..ed4ba12 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -438,6 +438,10 @@ public class EventTypes {
     public static final String EVENT_PORTABLE_IP_RANGE_DELETE = "PORTABLE.IP.RANGE.DELETE";
     public static final String EVENT_PORTABLE_IP_TRANSFER = "PORTABLE.IP.TRANSFER";
 
+    // Dedicated Resources
+    public static final String EVENT_DEDICATE_RESOURCE = "DEDICATE.RESOURCE";
+    public static final String EVENT_DEDICATE_RESOURCE_RELEASE = "DEDICATE.RESOURCE.RELEASE";
+
     static {
 
         // TODO: need a way to force author adding event types to declare the entity details as well, with out braking

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 0c38ecb..ab758eb 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -30,6 +30,11 @@
       <artifactId>cloud-plugin-acl-static-role-based</artifactId>
       <version>${project.version}</version>
     </dependency>
+     <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-dedicated-resources</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-api-limit-account-based</artifactId>
@@ -138,6 +143,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-explicit-dedication</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-host-allocator-random</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index edf83a9..26b698a 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -93,7 +93,7 @@
         <entry key="cache.size" value="50" />
         <entry key="cache.time.to.live" value="600" />
       </map>
-    </property>  
+    </property>
   </bean>
 
   <bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
@@ -156,9 +156,17 @@
         <entry key="cache.size" value="100" />
         <entry key="cache.time.to.live" value="600" />
       </map>
-    </property>  
+    </property>
   </bean>
-  
+  <bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="30" />
+        <entry key="cache.time.to.live" value="3600" />
+      </map>
+    </property>
+  </bean>
+
   <!--
     DAOs with default configuration
   -->

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index fd5479f..f0ae7bf 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -641,3 +641,16 @@ listInternalLoadBalancerVMs=1
 ### Network Isolation methods listing
 listNetworkIsolationMethods=1
 
+#### Dedicated Resource commands
+dedicateZone=1
+dedicatePod=1
+dedicateCluster=1
+dedicateHost=1
+releaseDedicatedZone=1
+releaseDedicatedPod=1
+releaseDedicatedCluster=1
+releaseDedicatedHost=1
+listDedicatedZones=1
+listDedicatedPods=1
+listDedicatedClusters=1
+listDedicatedHosts=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index e946f44..fcbcc1b 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -24,28 +24,27 @@
   xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
                       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-                      http://www.springframework.org/schema/tx 
+                      http://www.springframework.org/schema/tx
                       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                       http://www.springframework.org/schema/aop
                       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                       http://www.springframework.org/schema/context
-                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">                     
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
 
 <!--
- 
+
   OSS deployment configuration
-      
+
   OSS/non-OSS counter-exclusive components and related configurations should be put here
   for example, configurationDaoImpl component, it has exclusive configuration settings in OSS and non-OSS deployment,
   its component declaration should be put in both componentContext.xml.in and nonossComponentContext.xml.in, each with
   independent configuration
-    
+
 -->
   
   <bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
   <bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl" />
-  
   <bean id="GlobalLoadBalancingRulesServiceImpl" class ="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
 
   <!--
@@ -70,13 +69,13 @@
   <bean id="MidoNetElement" class="com.cloud.network.element.MidoNetElement">
     <property name="name" value="MidoNetElement"/>
   </bean>
-  
+
 <!--
 
   Deployment configurations of various adapters
-    
+
   It determines whether or not a adapter is activated or how it is loaded in order in its managing provider,
-     
+
 --> 
 
   <!-- Security adapters -->
@@ -171,7 +170,7 @@
       </list>
     </property>
   </bean>
-  
+
   <bean id="hostAllocators" class="com.cloud.utils.component.AdapterList">
     <property name="Adapters">
       <list>
@@ -260,13 +259,22 @@
    	<property name="name" value="HostAntiAffinityProcessor"/>
    	<property name="type" value="host anti-affinity"/>
   </bean>
-  
+
   <bean id="affinityProcessors" class="com.cloud.utils.component.AdapterList">
     <property name="Adapters">
       <list>
           <ref bean="HostAntiAffinityProcessor" />
+          <ref bean="ExplicitDedicationProcessor"/>
       </list>
     </property>
   </bean>
-  
+
+  <!--
+    Dedicated Resources components
+  -->
+  <bean id="DedicatedResourceManagerImpl" class="org.apache.cloudstack.dedicated.manager.DedicatedResourceManagerImpl"/>
+  <bean id="ExplicitDedicationProcessor" class="org.apache.cloudstack.affinity.ExplicitDedicationProcessor">
+  <property name="name" value="ExplicitDedicationProcessor"/>
+  <property name="type" value="ExplicitDedication"/>
+  </bean>
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
index 963e4d7..ca299ea 100755
--- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
@@ -89,10 +89,9 @@ public class CloudOrchestrator implements OrchestrationService {
 
 	public CloudOrchestrator() {
 	}
-	
+
     public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks, List<String> computeTags,
             Map<String, String> details, String owner) {
-        // TODO Auto-generated method stub
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ClusterDao.java b/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
index 3ce0798..673888b 100644
--- a/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/ClusterDao.java
@@ -34,4 +34,5 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
     Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
     List<Long> listDisabledClusters(long zoneId, Long podId);
     List<Long> listClustersWithDisabledPods(long zoneId);
+    List<ClusterVO> listClustersByDcId(long zoneId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
index 86dc65e..ba2686a 100644
--- a/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
@@ -52,6 +52,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
     protected final SearchBuilder<ClusterVO> AvailHyperSearch;
     protected final SearchBuilder<ClusterVO> ZoneSearch;
     protected final SearchBuilder<ClusterVO> ZoneHyTypeSearch;
+    protected final SearchBuilder<ClusterVO> ZoneClusterSearch;
 
     private static final String GET_POD_CLUSTER_MAP_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( ";
     private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
@@ -85,12 +86,16 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
         AvailHyperSearch.and("zoneId", AvailHyperSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
         AvailHyperSearch.select(null, Func.DISTINCT, AvailHyperSearch.entity().getHypervisorType());
         AvailHyperSearch.done();
+
+        ZoneClusterSearch = createSearchBuilder();
+        ZoneClusterSearch.and("dataCenterId", ZoneClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        ZoneClusterSearch.done();
     }
 
     @Override
     public List<ClusterVO> listByZoneId(long zoneId) {
         SearchCriteria<ClusterVO> sc = ZoneSearch.create();
-        sc.setParameters("dataCenterId", zoneId);        
+        sc.setParameters("dataCenterId", zoneId);
         return listBy(sc);
     }
 
@@ -224,6 +229,13 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
     }
 
     @Override
+    public List<ClusterVO> listClustersByDcId(long zoneId) {
+        SearchCriteria<ClusterVO> sc = ZoneClusterSearch.create();
+        sc.setParameters("dataCenterId", zoneId);
+        return listBy(sc);
+    }
+
+    @Override
     public boolean remove(Long id) {
         Transaction txn = Transaction.currentTxn();
         txn.start();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java b/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
index 9460a73..c84aa60 100644
--- a/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
+++ b/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
@@ -288,5 +288,5 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
         
         return parentDomains;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/engine/schema/src/com/cloud/host/dao/HostDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDao.java b/engine/schema/src/com/cloud/host/dao/HostDao.java
index 98bdcb4..8ceb8f2 100755
--- a/engine/schema/src/com/cloud/host/dao/HostDao.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDao.java
@@ -80,4 +80,10 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
      * @return
      */
     List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
+
+    List<HostVO> findByPodId(Long podId);
+
+    List<HostVO> findByClusterId(Long clusterId);
+
+    List<HostVO> listByDataCenterId(long id);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
index 07a4232..810b973 100755
--- a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
@@ -37,6 +37,7 @@ import com.cloud.cluster.agentlb.HostTransferMapVO;
 import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
 import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
 import com.cloud.dc.ClusterVO;
+import com.cloud.dc.HostPodVO;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.ClusterDaoImpl;
 import com.cloud.host.Host;
@@ -86,6 +87,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
     protected SearchBuilder<HostVO> GuidSearch;
     protected SearchBuilder<HostVO> DcSearch;
     protected SearchBuilder<HostVO> PodSearch;
+    protected SearchBuilder<HostVO> ClusterSearch;
     protected SearchBuilder<HostVO> TypeSearch;
     protected SearchBuilder<HostVO> StatusSearch;
     protected SearchBuilder<HostVO> ResourceStateSearch;
@@ -201,6 +203,9 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
 
         DcSearch = createSearchBuilder();
         DcSearch.and("dc", DcSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        DcSearch.and("type", DcSearch.entity().getType(), Op.EQ);
+        DcSearch.and("status", DcSearch.entity().getStatus(), Op.EQ);
+        DcSearch.and("resourceState", DcSearch.entity().getResourceState(), Op.EQ);
         DcSearch.done();
 
         ClusterStatusSearch = createSearchBuilder();
@@ -215,9 +220,13 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
         TypeNameZoneSearch.done();
 
         PodSearch = createSearchBuilder();
-        PodSearch.and("pod", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
+        PodSearch.and("podId", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
         PodSearch.done();
 
+        ClusterSearch = createSearchBuilder();
+        ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+        ClusterSearch.done();
+
         TypeSearch = createSearchBuilder();
         TypeSearch.and("type", TypeSearch.entity().getType(), SearchCriteria.Op.EQ);
         TypeSearch.done();
@@ -373,7 +382,17 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
         List<HostVO> hosts = listBy(sc);
         return hosts.size();
     }
-    
+
+    @Override
+    public List<HostVO> listByDataCenterId(long id) {
+        SearchCriteria<HostVO> sc = DcSearch.create();
+        sc.setParameters("dcId", id);
+        sc.setParameters("status", Status.Up);
+        sc.setParameters("type", Host.Type.Routing);
+        sc.setParameters("resourceState", ResourceState.Enabled);
+
+        return listBy(sc);
+    }
 
     @Override
     public HostVO findByGuid(String guid) {
@@ -907,6 +926,20 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
     }
 
     @Override
+    public List<HostVO> findByPodId(Long podId) {
+        SearchCriteria<HostVO> sc = PodSearch.create();
+        sc.setParameters("podId", podId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<HostVO> findByClusterId(Long clusterId) {
+        SearchCriteria<HostVO> sc = ClusterSearch.create();
+        sc.setParameters("clusterId", clusterId);
+        return listBy(sc);
+    }
+
+    @Override
     public List<HostVO> findHypervisorHostInCluster(long clusterId) {
         SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
         sc.setParameters("type", Host.Type.Routing);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/affinity-group-processors/explicit-dedication/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/affinity-group-processors/explicit-dedication/pom.xml b/plugins/affinity-group-processors/explicit-dedication/pom.xml
new file mode 100644
index 0000000..bb3c595
--- /dev/null
+++ b/plugins/affinity-group-processors/explicit-dedication/pom.xml
@@ -0,0 +1,33 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-explicit-dedication</artifactId>
+  <name>Apache CloudStack Plugin - Explicit Dedication Processor</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.2.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <sourceDirectory>src</sourceDirectory>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
new file mode 100644
index 0000000..a0eb56c
--- /dev/null
+++ b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java
@@ -0,0 +1,383 @@
+// 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 org.apache.cloudstack.affinity;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
+import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.ClusterVO;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.DedicatedResourceVO;
+import com.cloud.dc.HostPodVO;
+import com.cloud.dc.dao.ClusterDao;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.dc.dao.DedicatedResourceDao;
+import com.cloud.dc.dao.HostPodDao;
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.domain.DomainVO;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.exception.AffinityConflictException;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.dao.VMInstanceDao;
+
+@Local(value = AffinityGroupProcessor.class)
+public class ExplicitDedicationProcessor extends AffinityProcessorBase implements AffinityGroupProcessor {
+
+    private static final Logger s_logger = Logger.getLogger(ExplicitDedicationProcessor.class);
+    @Inject
+    protected UserVmDao _vmDao;
+    @Inject
+    protected VMInstanceDao _vmInstanceDao;
+    @Inject
+    protected DataCenterDao _dcDao;
+    @Inject
+    protected DedicatedResourceDao _dedicatedDao;
+    @Inject
+    protected HostPodDao _podDao;
+    @Inject
+    protected ClusterDao _clusterDao;
+    @Inject
+    protected HostDao _hostDao;
+    @Inject
+    protected DomainDao _domainDao;
+    @Inject
+    protected AffinityGroupDao _affinityGroupDao;
+    @Inject
+    protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
+
+    /**
+     * This method will process the affinity group of type 'Explicit Dedication' for a deployment of a VM that demands dedicated resources.
+     * For ExplicitDedicationProcessor we need to add dedicated resources into the IncludeList based on the level we have dedicated resources available.
+     * For eg. if admin dedicates a pod to a domain, then all the user in that domain can use the resources of that pod.
+     * We need to take care of the situation when dedicated resources further have resources dedicated to sub-domain/account.
+     * This IncludeList is then used to update the avoid list for a given data center.
+     */
+    @Override
+    public void process(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan,
+            ExcludeList avoid) throws AffinityConflictException {
+        VirtualMachine vm = vmProfile.getVirtualMachine();
+        List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
+        DataCenter dc = _dcDao.findById(vm.getDataCenterId());
+        long domainId = vm.getDomainId();
+        long accountId = vm.getAccountId();
+
+        for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
+            if (vmGroupMapping != null) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Processing affinity group of type 'ExplicitDedication' for VM Id: " + vm.getId());
+                }
+
+                List<DedicatedResourceVO> dr = _dedicatedDao.listByAccountId(accountId);
+                List<DedicatedResourceVO> drOfDomain = searchInDomainResources(domainId);
+                List<DedicatedResourceVO> drOfParentDomain = searchInParentDomainResources(domainId);
+                List<DedicatedResourceVO> resourceList = new ArrayList<DedicatedResourceVO>();
+                resourceList.addAll(dr);
+                resourceList.addAll(drOfDomain);
+                resourceList.addAll(drOfParentDomain);
+                boolean canUse = false;
+
+                if (plan.getHostId() != null) {
+                    HostVO host = _hostDao.findById(plan.getHostId());
+                    ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
+                    HostPodVO podOfHost = _podDao.findById(host.getPodId());
+                    DataCenterVO zoneOfHost = _dcDao.findById(host.getDataCenterId());
+                    if (resourceList != null && resourceList.size() != 0) {
+                        for(DedicatedResourceVO resource : resourceList){
+                            if ((resource.getHostId() != null && resource.getHostId() == plan.getHostId()) ||
+                                    (resource.getClusterId() != null && resource.getClusterId() == clusterofHost.getId()) ||
+                                    (resource.getPodId() != null && resource.getPodId() == podOfHost.getId()) ||
+                                    (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfHost.getId())){
+                               canUse = true;
+                            }
+                        }
+                    }
+                    if (!canUse) {
+                        throw new CloudRuntimeException("Cannot use this host " + host.getName() + " for explicit dedication");
+                    }
+                } else if (plan.getClusterId() != null) {
+                    ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
+                    HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
+                    DataCenterVO zoneOfCluster = _dcDao.findById(cluster.getDataCenterId());
+                    List<HostVO> hostToUse = new ArrayList<HostVO>();
+                    // check whether this cluster or its pod is dedicated
+                    if (resourceList != null && resourceList.size() != 0) {
+                        for(DedicatedResourceVO resource : resourceList){
+                            if ((resource.getClusterId() != null && resource.getClusterId() == cluster.getId()) ||
+                                    (resource.getPodId() != null && resource.getPodId() == podOfCluster.getId()) ||
+                                    (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfCluster.getId())){
+                                canUse = true;
+                            }
+
+                            // check for all dedicated host; if it belongs to this cluster
+                            if (!canUse){
+                                if (resource.getHostId() != null) {
+                                    HostVO dHost = _hostDao.findById(resource.getHostId());
+                                    if (dHost.getClusterId() == cluster.getId()) {
+                                        hostToUse.add(dHost);
+                                    }
+                                }
+                            }
+
+                        }
+                    }
+
+                    if (hostToUse.isEmpty() && !canUse) {
+                        throw new CloudRuntimeException("Cannot use this cluster " + cluster.getName() + " for explicit dedication");
+                    }
+
+                    if (hostToUse != null && hostToUse.size() != 0) {
+                        // add other non-dedicated hosts to avoid list
+                        List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
+                        for (HostVO host : hostList){
+                            if (!hostToUse.contains(host)) {
+                                avoid.addHost(host.getId());
+                            }
+                        }
+                    }
+
+                } else if (plan.getPodId() != null) {
+                    HostPodVO pod = _podDao.findById(plan.getPodId());
+                    DataCenterVO zoneOfPod = _dcDao.findById(pod.getDataCenterId());
+                    List<ClusterVO> clustersToUse = new ArrayList<ClusterVO>();
+                    List<HostVO> hostsToUse = new ArrayList<HostVO>();
+                    // check whether this cluster or its pod is dedicated
+                    if (resourceList != null && resourceList.size() != 0) {
+                        for(DedicatedResourceVO resource : resourceList){
+                            if ((resource.getPodId() != null && resource.getPodId() == pod.getId()) ||
+                                    (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfPod.getId())){
+                                canUse = true;
+                            }
+
+                            // check for all dedicated cluster/host; if it belongs to this pod
+                            if (!canUse){
+                                if (resource.getClusterId() != null) {
+                                    ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
+                                    if (dCluster.getPodId() == pod.getId()) {
+                                        clustersToUse.add(dCluster);
+                                    }
+                                }
+                                if (resource.getHostId() != null) {
+                                    HostVO dHost = _hostDao.findById(resource.getHostId());
+                                    if (dHost.getPodId() == pod.getId()) {
+                                        hostsToUse.add(dHost);
+                                    }
+                                }
+                            }
+
+                        }
+                    }
+
+                    if (hostsToUse.isEmpty() && clustersToUse.isEmpty() && !canUse) {
+                        throw new CloudRuntimeException("Cannot use this pod " + pod.getName() + " for explicit dedication");
+                    }
+
+                    if (clustersToUse != null && clustersToUse.size() != 0) {
+                        // add other non-dedicated clusters to avoid list
+                        List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
+                        for (ClusterVO cluster : clusterList){
+                            if (!clustersToUse.contains(cluster)) {
+                                avoid.addCluster(cluster.getId());
+                            }
+                        }
+                    }
+
+                    if (hostsToUse != null && hostsToUse.size() != 0) {
+                        // add other non-dedicated hosts to avoid list
+                        List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
+                        for (HostVO host : hostList){
+                            if (!hostsToUse.contains(host)) {
+                                avoid.addHost(host.getId());
+                            }
+                        }
+                    }
+
+                } else {
+                    //check all resources under this zone
+                    if (dr != null && dr.size() != 0) {
+                        avoid = updateAvoidList(dr, avoid, dc);
+                    } else if(drOfDomain != null && drOfDomain.size() != 0){
+                        avoid = updateAvoidList(drOfDomain, avoid, dc);
+                    } else if(drOfParentDomain != null && drOfParentDomain.size() != 0){
+                        avoid = updateAvoidList(drOfParentDomain, avoid, dc);
+                    } else {
+                        avoid.addDataCenter(dc.getId());
+                        if (s_logger.isDebugEnabled()) {
+                            s_logger.debug("No dedicated resources available for this domain or account");
+                        }
+                    }
+
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: Deploy avoids pods: " + avoid.getPodsToAvoid() + ", clusters: "
+                                + avoid.getClustersToAvoid() + ", hosts: " + avoid.getHostsToAvoid());
+                    }
+                }
+            }
+        }
+    }
+
+    private ExcludeList updateAvoidList(List<DedicatedResourceVO> dedicatedResources, ExcludeList avoidList, DataCenter dc) {
+        ExcludeList includeList = new ExcludeList();
+        for (DedicatedResourceVO dr : dedicatedResources) {
+            if (dr.getHostId() != null){
+                includeList.addHost(dr.getHostId());
+                HostVO dedicatedHost = _hostDao.findById(dr.getHostId());
+                includeList.addCluster(dedicatedHost.getClusterId());
+                includeList.addPod(dedicatedHost.getPodId());
+            }
+
+            if (dr.getClusterId() != null) {
+                includeList.addCluster(dr.getClusterId());
+                //add all hosts inside this in includeList
+                List<HostVO> hostList = _hostDao.findByClusterId(dr.getClusterId());
+                for (HostVO host : hostList) {
+                    DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
+                    if (dHost != null) {
+                        avoidList.addHost(host.getId());
+                    } else {
+                        includeList.addHost(host.getId());
+                    }
+                }
+                ClusterVO dedicatedCluster = _clusterDao.findById(dr.getClusterId());
+                includeList.addPod(dedicatedCluster.getPodId());
+            }
+
+            if (dr.getPodId() != null) {
+                includeList.addPod(dr.getPodId());
+                //add all cluster under this pod in includeList
+                List<ClusterVO> clusterList = _clusterDao.listByPodId(dr.getPodId());
+                for (ClusterVO cluster : clusterList) {
+                    if (_dedicatedDao.findByClusterId(cluster.getId()) != null) {
+                        avoidList.addCluster(cluster.getId());
+                    } else {
+                        includeList.addCluster(cluster.getId());
+                    }
+                }
+                //add all hosts inside this pod in includeList
+                List<HostVO> hostList = _hostDao.findByPodId(dr.getPodId());
+                for (HostVO host : hostList) {
+                    if (_dedicatedDao.findByHostId(host.getId()) != null) {
+                        avoidList.addHost(host.getId());
+                    } else {
+                        includeList.addHost(host.getId());
+                    }
+                }
+            }
+
+            if (dr.getDataCenterId() != null) {
+                includeList.addDataCenter(dr.getDataCenterId());
+                //add all Pod under this data center in includeList
+                List<HostPodVO> podList = _podDao.listByDataCenterId(dr.getDataCenterId());
+                for (HostPodVO pod : podList) {
+                    if (_dedicatedDao.findByPodId(pod.getId()) != null) {
+                        avoidList.addPod(pod.getId());
+                    } else {
+                        includeList.addPod(pod.getId());
+                    }
+                }
+                List<ClusterVO> clusterList = _clusterDao.listClustersByDcId(dr.getDataCenterId());
+                for (ClusterVO cluster : clusterList) {
+                    if (_dedicatedDao.findByClusterId(cluster.getId()) != null) {
+                        avoidList.addCluster(cluster.getId());
+                    } else {
+                        includeList.addCluster(cluster.getId());
+                    }
+                }
+                //add all hosts inside this in includeList
+                List<HostVO> hostList = _hostDao.listByDataCenterId(dr.getDataCenterId());
+                for (HostVO host : hostList) {
+                    if (_dedicatedDao.findByHostId(host.getId()) != null) {
+                        avoidList.addHost(host.getId());
+                    } else {
+                        includeList.addHost(host.getId());
+                    }
+                }
+            }
+        }
+        //Update avoid list using includeList.
+        //add resources in avoid list which are not in include list.
+
+        List<HostPodVO> pods = _podDao.listByDataCenterId(dc.getId());
+        List<ClusterVO> clusters = _clusterDao.listClustersByDcId(dc.getId());
+        List<HostVO> hosts = _hostDao.listByDataCenterId(dc.getId());
+        Set<Long> podsInIncludeList = includeList.getPodsToAvoid();
+        Set<Long> clustersInIncludeList = includeList.getClustersToAvoid();
+        Set<Long> hostsInIncludeList = includeList.getHostsToAvoid();
+
+        for (HostPodVO pod : pods){
+            if (podsInIncludeList != null && !podsInIncludeList.contains(pod.getId())) {
+                avoidList.addPod(pod.getId());
+            }
+        }
+
+        for (ClusterVO cluster : clusters) {
+            if (clustersInIncludeList != null && !clustersInIncludeList.contains(cluster.getId())) {
+                avoidList.addCluster(cluster.getId());
+            }
+        }
+
+        for (HostVO host : hosts) {
+            if (hostsInIncludeList != null && !hostsInIncludeList.contains(host.getId())) {
+                avoidList.addHost(host.getId());
+            }
+        }
+        return avoidList;
+    }
+
+    private List<DedicatedResourceVO> searchInParentDomainResources(long domainId) {
+        List<Long> domainIds = getDomainParentIds(domainId);
+        List<DedicatedResourceVO> dr = new ArrayList<DedicatedResourceVO>();
+        for (Long id : domainIds) {
+            List<DedicatedResourceVO> resource = _dedicatedDao.listByDomainId(id);
+            if(resource != null) {
+                dr.addAll(resource);
+            }
+        }
+        return dr;
+    }
+
+    private List<DedicatedResourceVO> searchInDomainResources(long domainId) {
+        List<DedicatedResourceVO> dr = _dedicatedDao.listByDomainId(domainId);
+        return dr;
+    }
+
+    private List<Long> getDomainParentIds(long domainId) {
+        DomainVO domainRecord = _domainDao.findById(domainId);
+        List<Long> domainIds = new ArrayList<Long>();
+        domainIds.add(domainRecord.getId());
+        while (domainRecord.getParent() != null ){
+            domainRecord = _domainDao.findById(domainRecord.getParent());
+            domainIds.add(domainRecord.getId());
+        }
+        return domainIds;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/pom.xml b/plugins/dedicated-resources/pom.xml
new file mode 100644
index 0000000..4c908f4
--- /dev/null
+++ b/plugins/dedicated-resources/pom.xml
@@ -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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-dedicated-resources</artifactId>
+  <name>Apache CloudStack Plugin - Dedicated Resources</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.2.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateClusterCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateClusterCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateClusterCmd.java
new file mode 100644
index 0000000..58e20de
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateClusterCmd.java
@@ -0,0 +1,115 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicateClusterResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResources;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+
+@APICommand(name = "dedicateCluster", description= "Dedicate an existing cluster", responseObject = DedicateClusterResponse.class )
+public class DedicateClusterCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DedicateClusterCmd.class.getName());
+
+    private static final String s_name = "dedicateclusterresponse";
+    @Inject DedicatedService dedicatedService;
+
+    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType=ClusterResponse.class,
+            required=true, description="the ID of the Cluster")
+    private Long clusterId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_DEDICATE_RESOURCE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "dedicating a cluster";
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName());
+        ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
+        List<DedicateClusterResponse> clusterResponseList = new ArrayList<DedicateClusterResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result) {
+                DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
+                clusterResponseList.add(clusterResponse);
+            }
+            response.setResponses(clusterResponseList);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster");
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateHostCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateHostCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateHostCmd.java
new file mode 100644
index 0000000..f0269b1
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateHostCmd.java
@@ -0,0 +1,118 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicateHostResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResources;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+
+@APICommand(name = "dedicateHost", description = "Dedicates a host.", responseObject = DedicateHostResponse.class)
+public class DedicateHostCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DedicateHostCmd.class.getName());
+    private static final String s_name = "dedicatehostresponse";
+    @Inject DedicatedService dedicatedService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType = HostResponse.class,
+            required=true, description="the ID of the host to update")
+    private Long hostId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        List<? extends DedicatedResources> result = dedicatedService.dedicateHost(getHostId(), getDomainId(), getAccountName());
+        ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
+        List<DedicateHostResponse> hostResponseList = new ArrayList<DedicateHostResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result) {
+                DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
+                hostResponseList.add(hostResponse);
+            }
+            response.setResponses(hostResponseList);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate host");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_DEDICATE_RESOURCE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "dedicating a host";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicatePodCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicatePodCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicatePodCmd.java
new file mode 100644
index 0000000..be5eac2
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicatePodCmd.java
@@ -0,0 +1,120 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicatePodResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResources;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+
+@APICommand(name = "dedicatePod", description ="Dedicates a Pod.", responseObject = DedicatePodResponse.class)
+public class DedicatePodCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DedicatePodCmd.class.getName());
+
+    private static final String s_name = "dedicatepodresponse";
+    @Inject public DedicatedService dedicatedService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+            required=true, description="the ID of the Pod")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        List<? extends DedicatedResources> result = dedicatedService.dedicatePod(getPodId(), getDomainId(), getAccountName());
+        ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
+        List<DedicatePodResponse> podResponseList = new ArrayList<DedicatePodResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result) {
+                DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
+                podResponseList.add(podresponse);
+            }
+            response.setResponses(podResponseList);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate pod");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_DEDICATE_RESOURCE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "dedicating a pod";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateZoneCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateZoneCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateZoneCmd.java
new file mode 100644
index 0000000..134fb97
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/DedicateZoneCmd.java
@@ -0,0 +1,120 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicateZoneResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResources;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+
+@APICommand(name = "dedicateZone", description ="Dedicates a zones.", responseObject = DedicateZoneResponse.class)
+public class DedicateZoneCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DedicateZoneCmd.class.getName());
+
+    private static final String s_name = "dedicatezoneresponse";
+    @Inject public DedicatedService dedicatedService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+            required=true, description="the ID of the zone")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description="the ID of the containing domain")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the name of the account which needs dedication. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        List<? extends DedicatedResources> result = dedicatedService.dedicateZone(getZoneId(), getDomainId(), getAccountName());
+        ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
+        List<DedicateZoneResponse> zoneResponseList = new ArrayList<DedicateZoneResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result) {
+                DedicateZoneResponse zoneresponse = dedicatedService.createDedicateZoneResponse(resource);
+                zoneResponseList.add(zoneresponse);
+            }
+            response.setResponses(zoneResponseList);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate zone");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_DEDICATE_RESOURCE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "dedicating a zone";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedClustersCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedClustersCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedClustersCmd.java
new file mode 100644
index 0000000..c60c524
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedClustersCmd.java
@@ -0,0 +1,105 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicateClusterResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResourceVO;
+import com.cloud.dc.DedicatedResources;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listDedicatedClusters", description = "Lists dedicated clusters.", responseObject = DedicateClusterResponse.class)
+public class ListDedicatedClustersCmd extends BaseListCmd {
+	public static final Logger s_logger = Logger.getLogger(ListDedicatedClustersCmd.class.getName());
+
+    private static final String s_name = "listdedicatedclustersresponse";
+    @Inject DedicatedService dedicatedService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType=ClusterResponse.class,
+            description="the ID of the cluster")
+    private Long clusterId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+            description="the ID of the domain associated with the cluster")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING,
+            description = "the name of the account associated with the cluster. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public Long getDomainId(){
+        return domainId;
+    }
+
+    public String getAccountName(){
+        return accountName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedClusters(this);
+        ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
+        List<DedicateClusterResponse> Responses = new ArrayList<DedicateClusterResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result.first()) {
+                DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
+                Responses.add(clusterResponse);
+            }
+            response.setResponses(Responses, result.second());
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated clusters");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedHostsCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedHostsCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedHostsCmd.java
new file mode 100644
index 0000000..2c1ad00
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedHostsCmd.java
@@ -0,0 +1,105 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicateHostResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResourceVO;
+import com.cloud.dc.DedicatedResources;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listDedicatedHosts", description = "Lists dedicated hosts.", responseObject = DedicateHostResponse.class)
+public class ListDedicatedHostsCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListDedicatedHostsCmd.class.getName());
+
+    private static final String s_name = "listdedicatedhostsresponse";
+    @Inject DedicatedService dedicatedService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
+            description="the ID of the host")
+    private Long hostId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+            description="the ID of the domain associated with the host")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING,
+            description = "the name of the account associated with the host. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public Long getDomainId(){
+        return domainId;
+    }
+
+    public String getAccountName(){
+        return accountName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////l
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
+        ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
+        List<DedicateHostResponse> Responses = new ArrayList<DedicateHostResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result.first()) {
+                DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
+                Responses.add(hostResponse);
+            }
+            response.setResponses(Responses, result.second());
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated hosts");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17267794/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedPodsCmd.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedPodsCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedPodsCmd.java
new file mode 100644
index 0000000..31b1ecf
--- /dev/null
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/api/commands/ListDedicatedPodsCmd.java
@@ -0,0 +1,105 @@
+// 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 org.apache.cloudstack.dedicated.api.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.dedicated.api.response.DedicatePodResponse;
+import org.apache.cloudstack.dedicated.services.DedicatedService;
+import org.apache.log4j.Logger;
+
+import com.cloud.dc.DedicatedResourceVO;
+import com.cloud.dc.DedicatedResources;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listDedicatedPods", description = "Lists dedicated pods.", responseObject = DedicatePodResponse.class)
+public class ListDedicatedPodsCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListDedicatedPodsCmd.class.getName());
+
+    private static final String s_name = "listdedicatedpodsresponse";
+    @Inject DedicatedService dedicatedService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+            description="the ID of the pod")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+            description="the ID of the domain associated with the pod")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING,
+            description = "the name of the account associated with the pod. Must be used with domainId.")
+    private String accountName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public Long getDomainId(){
+        return domainId;
+    }
+
+    public String getAccountName(){
+        return accountName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
+        ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
+        List<DedicatePodResponse> Responses = new ArrayList<DedicatePodResponse>();
+        if (result != null) {
+            for (DedicatedResources resource : result.first()) {
+                DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
+                Responses.add(podresponse);
+            }
+            response.setResponses(Responses, result.second());
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated pods");
+        }
+    }
+}


Mime
View raw message