You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2013/01/10 01:48:37 UTC

[21/52] [partial] Summary: Fixes for api_refactoring

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/StorageService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StorageService.java b/api/src/com/cloud/storage/StorageService.java
index 426c4c5..a06f213 100644
--- a/api/src/com/cloud/storage/StorageService.java
+++ b/api/src/com/cloud/storage/StorageService.java
@@ -17,16 +17,13 @@
 package com.cloud.storage;
 
 import java.net.UnknownHostException;
-import java.util.List;
-
-import com.cloud.api.commands.CancelPrimaryStorageMaintenanceCmd;
-import com.cloud.api.commands.CreateStoragePoolCmd;
-import com.cloud.api.commands.CreateVolumeCmd;
-import com.cloud.api.commands.DeletePoolCmd;
-import com.cloud.api.commands.ListVolumesCmd;
-import com.cloud.api.commands.UpdateStoragePoolCmd;
-import com.cloud.api.commands.UploadVolumeCmd;
-import com.cloud.api.commands.ResizeVolumeCmd;
+
+import org.apache.cloudstack.api.command.admin.storage.*;
+import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
+import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
+import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
+import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.PermissionDeniedException;
@@ -34,12 +31,11 @@ import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceInUseException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.user.Account;
-import com.cloud.utils.Pair;
 
 public interface StorageService{
     /**
      * Create StoragePool based on uri
-     * 
+     *
      * @param cmd
      *            the command object that specifies the zone, cluster/pod, URI, details, etc. to use to create the
      *            storage pool.
@@ -50,12 +46,12 @@ public interface StorageService{
      * @throws ResourceUnavailableException
      *             TODO
      */
-    StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException, 
+    StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
     UnknownHostException, ResourceUnavailableException;
 
     /**
      * Creates the database object for a volume based on the given criteria
-     * 
+     *
      * @param cmd
      *            the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
      *            name)
@@ -66,7 +62,7 @@ public interface StorageService{
 
     /**
      * Creates the volume based on the given criteria
-     * 
+     *
      * @param cmd
      *            the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
      *            name)
@@ -86,7 +82,7 @@ public interface StorageService{
 
     /**
      * Delete the storage pool
-     * 
+     *
      * @param cmd
      *            - the command specifying poolId
      * @return success or failure
@@ -95,7 +91,7 @@ public interface StorageService{
 
     /**
      * Enable maintenance for primary storage
-     * 
+     *
      * @param cmd
      *            - the command specifying primaryStorageId
      * @return the primary storage pool
@@ -104,19 +100,19 @@ public interface StorageService{
      * @throws InsufficientCapacityException
      *             TODO
      */
-    public StoragePool preparePrimaryStorageForMaintenance(Long primaryStorageId) throws ResourceUnavailableException, 
+    public StoragePool preparePrimaryStorageForMaintenance(Long primaryStorageId) throws ResourceUnavailableException,
     InsufficientCapacityException;
 
     /**
      * Complete maintenance for primary storage
-     * 
+     *
      * @param cmd
      *            - the command specifying primaryStorageId
      * @return the primary storage pool
      * @throws ResourceUnavailableException
      *             TODO
      */
-    public StoragePool cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd) 
+    public StoragePool cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd)
             throws ResourceUnavailableException;
 
     public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
@@ -125,13 +121,12 @@ public interface StorageService{
 
     Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
 
-    Pair<List<? extends Volume>, Integer> searchForVolumes(ListVolumesCmd cmd);
 
     /**
      * Uploads the volume to secondary storage
-     * 
-     * @param UploadVolumeCmd cmd 
-     *            
+     *
+     * @param UploadVolumeCmd cmd
+     *
      * @return Volume object
      */
     Volume uploadVolume(UploadVolumeCmd cmd)	throws ResourceAllocationException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/StorageStats.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StorageStats.java b/api/src/com/cloud/storage/StorageStats.java
index fe21c44..c30e1de 100755
--- a/api/src/com/cloud/storage/StorageStats.java
+++ b/api/src/com/cloud/storage/StorageStats.java
@@ -22,7 +22,7 @@ public interface StorageStats {
      */
     public long getByteUsed();
     /**
-     * @return bytes capacity of the storage server 
+     * @return bytes capacity of the storage server
      */
     public long getCapacityBytes();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/Swift.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Swift.java b/api/src/com/cloud/storage/Swift.java
index 54a670c..9cd3a34 100644
--- a/api/src/com/cloud/storage/Swift.java
+++ b/api/src/com/cloud/storage/Swift.java
@@ -17,10 +17,13 @@
 package com.cloud.storage;
 
 import com.cloud.agent.api.to.SwiftTO;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public interface Swift {
+public interface Swift extends InternalIdentity {
     public long getId();
 
+    public String getUuid();
+
     public String getUrl();
 
     public String getAccount();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/Upload.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Upload.java b/api/src/com/cloud/storage/Upload.java
index d73a9d8..a20faf1 100755
--- a/api/src/com/cloud/storage/Upload.java
+++ b/api/src/com/cloud/storage/Upload.java
@@ -16,9 +16,12 @@
 // under the License.
 package com.cloud.storage;
 
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
 import java.util.Date;
 
-public interface Upload {
+public interface Upload extends InternalIdentity, Identity {
 
     public static enum Status {
         UNKNOWN, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS, NOT_COPIED, COPY_IN_PROGRESS, COPY_ERROR, COPY_COMPLETE, DOWNLOAD_URL_CREATED, DOWNLOAD_URL_NOT_CREATED, ERROR
@@ -34,8 +37,6 @@ public interface Upload {
 
     long getHostId();
 
-    long getId();
-
     Date getCreated();
 
     Date getLastUpdated();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java b/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
index 49fbc6d..97baa4b 100644
--- a/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
+++ b/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
@@ -16,9 +16,12 @@
 // under the License.
 package com.cloud.storage;
 
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
 import java.util.Date;
 
-public interface VMTemplateStorageResourceAssoc {
+public interface VMTemplateStorageResourceAssoc extends InternalIdentity {
     public static enum Status {
         UNKNOWN, DOWNLOAD_ERROR, NOT_DOWNLOADED, DOWNLOAD_IN_PROGRESS, DOWNLOADED, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS
     }
@@ -35,8 +38,6 @@ public interface VMTemplateStorageResourceAssoc {
 
     void setDownloadState(Status downloadState);
 
-    long getId();
-
     Date getCreated();
 
     Date getLastUpdated();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/Volume.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java
index e7e9476..38ba2d4 100755
--- a/api/src/com/cloud/storage/Volume.java
+++ b/api/src/com/cloud/storage/Volume.java
@@ -18,12 +18,14 @@ package com.cloud.storage;
 
 import java.util.Date;
 
-import com.cloud.acl.ControlledEntity;
+import org.apache.cloudstack.acl.ControlledEntity;
 import com.cloud.template.BasedOn;
 import com.cloud.utils.fsm.StateMachine2;
 import com.cloud.utils.fsm.StateObject;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.State> {
+public interface Volume extends ControlledEntity, Identity, InternalIdentity, BasedOn, StateObject<Volume.State> {
     enum Type {
         UNKNOWN, ROOT, SWAP, DATADISK, ISO
     };
@@ -36,8 +38,8 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
         Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
         Resizing("The volume is being resized"),
         Expunging("The volume is being expunging"),
-        Destroy("The volume is destroyed, and can't be recovered."),        
-        UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");            
+        Destroy("The volume is destroyed, and can't be recovered."),
+        UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
 
         String _description;
 
@@ -66,9 +68,9 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
             s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);
             s_fsm.addTransition(Resizing, Event.OperationFailed, Ready);          
             s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
-            s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage            
+            s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
             s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
-            s_fsm.addTransition(Creating, Event.CopyFailed, UploadOp);// Copying volume from sec to primary failed.  
+            s_fsm.addTransition(Creating, Event.CopyFailed, UploadOp);// Copying volume from sec to primary failed.
             s_fsm.addTransition(UploadOp, Event.DestroyRequested, Destroy);
             s_fsm.addTransition(Ready, Event.DestroyRequested, Destroy);
             s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
@@ -98,8 +100,6 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
         ResizeRequested;
     }
 
-    long getId();
-
     /**
      * @return the volume name
      */

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/snapshot/SnapshotPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/snapshot/SnapshotPolicy.java b/api/src/com/cloud/storage/snapshot/SnapshotPolicy.java
index 7c05e36..37ce6fd 100644
--- a/api/src/com/cloud/storage/snapshot/SnapshotPolicy.java
+++ b/api/src/com/cloud/storage/snapshot/SnapshotPolicy.java
@@ -16,8 +16,10 @@
 // under the License.
 package com.cloud.storage.snapshot;
 
-public interface SnapshotPolicy {
-    long getId();
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface SnapshotPolicy extends Identity, InternalIdentity {
 
     long getVolumeId();
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/snapshot/SnapshotSchedule.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/snapshot/SnapshotSchedule.java b/api/src/com/cloud/storage/snapshot/SnapshotSchedule.java
index 75469de..12c1445 100644
--- a/api/src/com/cloud/storage/snapshot/SnapshotSchedule.java
+++ b/api/src/com/cloud/storage/snapshot/SnapshotSchedule.java
@@ -21,6 +21,8 @@ import java.util.Date;
 public interface SnapshotSchedule {
     long getId();
 
+    String getUuid();
+
     Long getVolumeId();
 
     Long getPolicyId();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/storage/snapshot/SnapshotService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/snapshot/SnapshotService.java b/api/src/com/cloud/storage/snapshot/SnapshotService.java
index 84388e9..79041c4 100644
--- a/api/src/com/cloud/storage/snapshot/SnapshotService.java
+++ b/api/src/com/cloud/storage/snapshot/SnapshotService.java
@@ -18,11 +18,11 @@ package com.cloud.storage.snapshot;
 
 import java.util.List;
 
-import com.cloud.api.commands.CreateSnapshotPolicyCmd;
-import com.cloud.api.commands.DeleteSnapshotPoliciesCmd;
+import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
+import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd;
+import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
 import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
-import com.cloud.api.commands.ListSnapshotPoliciesCmd;
-import com.cloud.api.commands.ListSnapshotsCmd;
+import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.storage.Snapshot;
@@ -34,7 +34,7 @@ public interface SnapshotService {
 
     /**
      * List all snapshots of a disk volume. Optionally lists snapshots created by specified interval
-     * 
+     *
      * @param cmd
      *            the command containing the search criteria (order by, limit, etc.)
      * @return list of snapshots
@@ -46,7 +46,7 @@ public interface SnapshotService {
      * Delete specified snapshot from the specified. If no other policies are assigned it calls destroy snapshot. This
      * will be
      * used for manual snapshots too.
-     * 
+     *
      * @param snapshotId
      *            TODO
      */
@@ -56,7 +56,7 @@ public interface SnapshotService {
      * Creates a policy with specified schedule. maxSnaps specifies the number of most recent snapshots that are to be
      * retained.
      * If the number of snapshots go beyond maxSnaps the oldest snapshot is deleted
-     * 
+     *
      * @param cmd
      *            the command that
      * @param policyOwner
@@ -67,7 +67,7 @@ public interface SnapshotService {
 
     /**
      * Get the recurring snapshots scheduled for this volume currently along with the time at which they are scheduled
-     * 
+     *
      * @param cmd
      *            the command wrapping the volumeId (volume for which the snapshots are required) and policyId (to show
      *            snapshots for only this policy).
@@ -77,7 +77,7 @@ public interface SnapshotService {
 
     /**
      * list all snapshot policies assigned to the specified volume
-     * 
+     *
      * @param cmd
      *            the command that specifies the volume criteria
      * @return list of snapshot policies
@@ -90,12 +90,12 @@ public interface SnapshotService {
 
     /**
      * Create a snapshot of a volume
-     * 
+     *
      * @param snapshotOwner
      *            TODO
      * @param cmd
      *            the API command wrapping the parameters for creating the snapshot (mainly volumeId)
-     * 
+     *
      * @return the Snapshot that was created
      */
     Snapshot createSnapshot(Long volumeId, Long policyId, Long snapshotId, Account snapshotOwner);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/template/BasedOn.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/BasedOn.java b/api/src/com/cloud/template/BasedOn.java
index 25d409e..a95c697 100644
--- a/api/src/com/cloud/template/BasedOn.java
+++ b/api/src/com/cloud/template/BasedOn.java
@@ -20,7 +20,7 @@ package com.cloud.template;
  * BasedOn is implemented by all objects that are based on a certain template.
  */
 public interface BasedOn {
-    
+
     /**
      * @return the template id that the volume is based on.
      */

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/template/TemplateService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/TemplateService.java b/api/src/com/cloud/template/TemplateService.java
index e45f43d..93e8a25 100755
--- a/api/src/com/cloud/template/TemplateService.java
+++ b/api/src/com/cloud/template/TemplateService.java
@@ -19,15 +19,15 @@ package com.cloud.template;
 import java.net.URISyntaxException;
 import java.util.List;
 
-import com.cloud.api.commands.CopyTemplateCmd;
-import com.cloud.api.commands.DeleteIsoCmd;
-import com.cloud.api.commands.DeleteTemplateCmd;
-import com.cloud.api.commands.ExtractIsoCmd;
-import com.cloud.api.commands.ExtractTemplateCmd;
-import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
-import com.cloud.api.commands.UpdateTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
+import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
+import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
+import org.apache.cloudstack.api.command.user.template.*;
+import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
+import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
+import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
 import com.cloud.exception.InternalErrorException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.StorageUnavailableException;
@@ -48,7 +48,7 @@ public interface TemplateService {
 
     /**
      * Deletes a template
-     * 
+     *
      * @param cmd
      *            - the command specifying templateId
      */
@@ -56,7 +56,7 @@ public interface TemplateService {
 
     /**
      * Deletes a template
-     * 
+     *
      * @param cmd
      *            - the command specifying isoId
      * @return true if deletion is successful, false otherwise
@@ -65,7 +65,7 @@ public interface TemplateService {
 
     /**
      * Extracts an ISO
-     * 
+     *
      * @param cmd
      *            - the command specifying the mode and id of the ISO
      * @return extractId.
@@ -74,7 +74,7 @@ public interface TemplateService {
 
     /**
      * Extracts a Template
-     * 
+     *
      * @param cmd
      *            - the command specifying the mode and id of the template
      * @return extractId
@@ -83,7 +83,7 @@ public interface TemplateService {
 
     VirtualMachineTemplate getTemplate(long templateId);
 
-    List<String> listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd);
+    List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
 
-    boolean updateTemplateOrIsoPermissions(UpdateTemplateOrIsoPermissionsCmd cmd);
+    boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/template/VirtualMachineTemplate.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/VirtualMachineTemplate.java b/api/src/com/cloud/template/VirtualMachineTemplate.java
index 27f5871..274b7b6 100755
--- a/api/src/com/cloud/template/VirtualMachineTemplate.java
+++ b/api/src/com/cloud/template/VirtualMachineTemplate.java
@@ -19,12 +19,14 @@ package com.cloud.template;
 import java.util.Date;
 import java.util.Map;
 
-import com.cloud.acl.ControlledEntity;
+import org.apache.cloudstack.acl.ControlledEntity;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.TemplateType;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public interface VirtualMachineTemplate extends ControlledEntity {
+public interface VirtualMachineTemplate extends ControlledEntity, Identity, InternalIdentity {
 
     public static enum BootloaderType {
         PyGrub, HVM, External, CD
@@ -40,11 +42,6 @@ public interface VirtualMachineTemplate extends ControlledEntity {
         all // all templates (only usable by admins)
     }
 
-    /**
-     * @return id.
-     */
-    long getId();
-
     boolean isFeatured();
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/Account.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java
index 18f585b..a5b3e87 100755
--- a/api/src/com/cloud/user/Account.java
+++ b/api/src/com/cloud/user/Account.java
@@ -18,9 +18,11 @@ package com.cloud.user;
 
 import java.util.Date;
 
-import com.cloud.acl.ControlledEntity;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public interface Account extends ControlledEntity {
+public interface Account extends ControlledEntity, InternalIdentity, Identity {
     public enum Type {
         Normal,
         Admin,
@@ -35,6 +37,7 @@ public interface Account extends ControlledEntity {
         locked
     }
 
+
     public static final short ACCOUNT_TYPE_NORMAL = 0;
     public static final short ACCOUNT_TYPE_ADMIN = 1;
     public static final short ACCOUNT_TYPE_DOMAIN_ADMIN = 2;
@@ -48,8 +51,6 @@ public interface Account extends ControlledEntity {
 
     public static final long ACCOUNT_ID_SYSTEM = 1;
 
-    public long getId();
-
     public String getAccountName();
 
     public short getType();
@@ -59,6 +60,7 @@ public interface Account extends ControlledEntity {
     public Date getRemoved();
 
     public String getNetworkDomain();
-    
+
     public Long getDefaultZoneId();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index 90e3551..ce16f5e 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -19,14 +19,14 @@ package com.cloud.user;
 import java.util.List;
 import java.util.Map;
 
-import com.cloud.acl.ControlledEntity;
-import com.cloud.acl.SecurityChecker.AccessType;
-import com.cloud.api.commands.DeleteUserCmd;
-import com.cloud.api.commands.ListAccountsCmd;
-import com.cloud.api.commands.ListUsersCmd;
-import com.cloud.api.commands.RegisterCmd;
-import com.cloud.api.commands.UpdateAccountCmd;
-import com.cloud.api.commands.UpdateUserCmd;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+
+import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
+import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
+import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
+import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
+
 import com.cloud.domain.Domain;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.PermissionDeniedException;
@@ -37,7 +37,7 @@ public interface AccountService {
 
     /**
      * Creates a new user and account, stores the password as is so encrypted passwords are recommended.
-     * 
+     *
      * @param userName
      *            TODO
      * @param password
@@ -58,7 +58,7 @@ public interface AccountService {
      *            TODO
      * @param networkDomain
      *            TODO
-     * 
+     *
      * @return the user if created successfully, null otherwise
      */
     UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
@@ -66,17 +66,17 @@ public interface AccountService {
 
     /**
      * Deletes a user by userId
-     * 
+     *
      * @param accountId
      *            - id of the account do delete
-     * 
+     *
      * @return true if delete was successful, false otherwise
      */
     boolean deleteUserAccount(long accountId);
 
     /**
      * Disables a user by userId
-     * 
+     *
      * @param userId
      *            - the userId
      * @return UserAccount object
@@ -85,7 +85,7 @@ public interface AccountService {
 
     /**
      * Enables a user
-     * 
+     *
      * @param userId
      *            - the userId
      * @return UserAccount object
@@ -95,7 +95,7 @@ public interface AccountService {
     /**
      * Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
      * allocated/etc.
-     * 
+     *
      * @param userId
      * @return UserAccount object
      */
@@ -103,7 +103,7 @@ public interface AccountService {
 
     /**
      * Update a user by userId
-     * 
+     *
      * @param userId
      * @return UserAccount object
      */
@@ -111,7 +111,7 @@ public interface AccountService {
 
     /**
      * Disables an account by accountName and domainId
-     * 
+     *
      * @param accountName
      *            TODO
      * @param domainId
@@ -125,7 +125,7 @@ public interface AccountService {
 
     /**
      * Enables an account by accountId
-     * 
+     *
      * @param accountName
      *            - the enableAccount command defining the accountId to be deleted.
      * @param domainId
@@ -139,7 +139,7 @@ public interface AccountService {
      * Locks an account by accountId. A locked account cannot access the API, but will still have running VMs/IP
      * addresses
      * allocated/etc.
-     * 
+     *
      * @param accountName
      *            - the LockAccount command defining the accountId to be locked.
      * @param domainId
@@ -151,7 +151,7 @@ public interface AccountService {
 
     /**
      * Updates an account name
-     * 
+     *
      * @param cmd
      *            - the parameter containing accountId
      * @return updated account object
@@ -191,13 +191,8 @@ public interface AccountService {
 
     public String[] createApiKeyAndSecretKey(RegisterCmd cmd);
 
-    Pair<List<? extends Account>, Integer> searchForAccounts(ListAccountsCmd cmd);
-
-    Pair<List<? extends UserAccount>, Integer> searchForUsers(ListUsersCmd cmd)
-            throws PermissionDeniedException;
-
     UserAccount getUserByApiKey(String apiKey);
-    
+
     void checkAccess(Account account, Domain domain) throws PermissionDeniedException;
 
     void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/DomainService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/DomainService.java b/api/src/com/cloud/user/DomainService.java
index 83f3622..6fbe1b9 100644
--- a/api/src/com/cloud/user/DomainService.java
+++ b/api/src/com/cloud/user/DomainService.java
@@ -18,8 +18,8 @@ package com.cloud.user;
 
 import java.util.List;
 
-import com.cloud.api.commands.ListDomainChildrenCmd;
-import com.cloud.api.commands.ListDomainsCmd;
+import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd;
+import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
 import com.cloud.domain.Domain;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.utils.Pair;
@@ -32,7 +32,7 @@ public interface DomainService {
 
     /**
      * Return whether a domain is a child domain of a given domain.
-     * 
+     *
      * @param parentId
      * @param childId
      */

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/ResourceLimitService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/ResourceLimitService.java b/api/src/com/cloud/user/ResourceLimitService.java
index 98dfc11..bec65d5 100644
--- a/api/src/com/cloud/user/ResourceLimitService.java
+++ b/api/src/com/cloud/user/ResourceLimitService.java
@@ -28,7 +28,7 @@ public interface ResourceLimitService {
 
     /**
      * Updates an existing resource limit with the specified details. If a limit doesn't exist, will create one.
-     * 
+     *
      * @param accountId
      *            TODO
      * @param domainId
@@ -37,14 +37,14 @@ public interface ResourceLimitService {
      *            TODO
      * @param max
      *            TODO
-     * 
+     *
      * @return the updated/created resource limit
      */
     ResourceLimit updateResourceLimit(Long accountId, Long domainId, Integer resourceType, Long max);
 
     /**
      * Updates an existing resource count details for the account/domain
-     * 
+     *
      * @param accountId
      *            TODO
      * @param domainId
@@ -57,7 +57,7 @@ public interface ResourceLimitService {
 
     /**
      * Search for resource limits for the given id and/or account and/or type and/or domain.
-     * 
+     *
      * @param id
      *            TODO
      * @param accountId
@@ -73,7 +73,7 @@ public interface ResourceLimitService {
     /**
      * Finds the resource limit for a specified account and type. If the account has an infinite limit, will check
      * the account's parent domain, and if that limit is also infinite, will return the ROOT domain's limit.
-     * 
+     *
      * @param account
      * @param type
      * @return resource limit
@@ -81,9 +81,19 @@ public interface ResourceLimitService {
     public long findCorrectResourceLimitForAccount(Account account, ResourceType type);
 
     /**
+     * This call should be used when we have already queried resource limit for an account. This is to handle
+     * some corner cases where queried limit may be null.
+     * @param accountType
+     * @param limit
+     * @param type
+     * @return
+     */
+    public long findCorrectResourceLimitForAccount(short accountType, Long limit, ResourceType type);
+
+    /**
      * Finds the resource limit for a specified domain and type. If the domain has an infinite limit, will check
      * up the domain hierarchy
-     * 
+     *
      * @param account
      * @param type
      * @return resource limit
@@ -92,7 +102,7 @@ public interface ResourceLimitService {
 
     /**
      * Increments the resource count
-     * 
+     *
      * @param accountId
      * @param type
      * @param delta
@@ -101,7 +111,7 @@ public interface ResourceLimitService {
 
     /**
      * Decrements the resource count
-     * 
+     *
      * @param accountId
      * @param type
      * @param delta
@@ -110,7 +120,7 @@ public interface ResourceLimitService {
 
     /**
      * Checks if a limit has been exceeded for an account
-     * 
+     *
      * @param account
      * @param type
      * @param count
@@ -122,7 +132,7 @@ public interface ResourceLimitService {
 
     /**
      * Gets the count of resources for a resource type and account
-     * 
+     *
      * @param account
      * @param type
      * @return count of resources

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/SSHKeyPair.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/SSHKeyPair.java b/api/src/com/cloud/user/SSHKeyPair.java
index 494f74f..aa20c17 100644
--- a/api/src/com/cloud/user/SSHKeyPair.java
+++ b/api/src/com/cloud/user/SSHKeyPair.java
@@ -16,14 +16,10 @@
 // under the License.
 package com.cloud.user;
 
-import com.cloud.acl.ControlledEntity;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public interface SSHKeyPair extends ControlledEntity {
-
-    /**
-     * @return The id of the key pair.
-     */
-    public long getId();
+public interface SSHKeyPair extends ControlledEntity, InternalIdentity {
 
     /**
      * @return The given name of the key pair.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/User.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/User.java b/api/src/com/cloud/user/User.java
index c625c16..36a7c65 100644
--- a/api/src/com/cloud/user/User.java
+++ b/api/src/com/cloud/user/User.java
@@ -16,13 +16,17 @@
 // under the License.
 package com.cloud.user;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 import java.util.Date;
 
-public interface User extends OwnedBy {
+public interface User extends OwnedBy, InternalIdentity {
     public static final long UID_SYSTEM = 1;
 
     public long getId();
 
+    public String getUuid();
+
     public Date getCreated();
 
     public Date getRemoved();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/user/UserAccount.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/UserAccount.java b/api/src/com/cloud/user/UserAccount.java
index 2a6bd4f..c09b5c0 100644
--- a/api/src/com/cloud/user/UserAccount.java
+++ b/api/src/com/cloud/user/UserAccount.java
@@ -16,10 +16,12 @@
 // under the License.
 package com.cloud.user;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 import java.util.Date;
 
-public interface UserAccount {
-    Long getId();
+public interface UserAccount extends InternalIdentity {
+    long getId();
 
     String getUsername();
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/uservm/UserVm.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/uservm/UserVm.java b/api/src/com/cloud/uservm/UserVm.java
index 866d849..a587666 100755
--- a/api/src/com/cloud/uservm/UserVm.java
+++ b/api/src/com/cloud/uservm/UserVm.java
@@ -16,7 +16,7 @@
 // under the License.
 package com.cloud.uservm;
 
-import com.cloud.acl.ControlledEntity;
+import org.apache.cloudstack.acl.ControlledEntity;
 import com.cloud.vm.VirtualMachine;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/InstanceGroup.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/InstanceGroup.java b/api/src/com/cloud/vm/InstanceGroup.java
index 98fac59..6560b4a 100644
--- a/api/src/com/cloud/vm/InstanceGroup.java
+++ b/api/src/com/cloud/vm/InstanceGroup.java
@@ -18,10 +18,11 @@ package com.cloud.vm;
 
 import java.util.Date;
 
-import com.cloud.acl.ControlledEntity;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public interface InstanceGroup extends ControlledEntity {
-    long getId();
+public interface InstanceGroup extends ControlledEntity, Identity, InternalIdentity {
 
     String getName();
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/Nic.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/Nic.java b/api/src/com/cloud/vm/Nic.java
index 3beff0a..84c0034 100644
--- a/api/src/com/cloud/vm/Nic.java
+++ b/api/src/com/cloud/vm/Nic.java
@@ -25,17 +25,19 @@ import com.cloud.network.Networks.AddressFormat;
 import com.cloud.network.Networks.Mode;
 import com.cloud.utils.fsm.FiniteState;
 import com.cloud.utils.fsm.StateMachine;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
 
 /**
  * Nic represents one nic on the VM.
  */
-public interface Nic {
+public interface Nic extends Identity, InternalIdentity {
     enum Event {
         ReservationRequested, ReleaseRequested, CancelRequested, OperationCompleted, OperationFailed,
     }
 
     public enum State implements FiniteState<State, Event> {
-        Allocated("Resource is allocated but not reserved"), Reserving("Resource is being reserved right now"), 
+        Allocated("Resource is allocated but not reserved"), Reserving("Resource is being reserved right now"),
         Reserved("Resource has been reserved."), Releasing("Resource is being released"), Deallocating(
                 "Resource is being deallocated");
 
@@ -87,11 +89,6 @@ public interface Nic {
     }
 
     /**
-     * @return id in the CloudStack database
-     */
-    long getId();
-
-    /**
      * @return reservation id returned by the allocation source. This can be the String version of the database id if
      *         the
      *         allocation source does not need it's own implementation of the reservation id. This is passed back to the

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/NicProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/NicProfile.java b/api/src/com/cloud/vm/NicProfile.java
index c5ffbea..32e3f21 100644
--- a/api/src/com/cloud/vm/NicProfile.java
+++ b/api/src/com/cloud/vm/NicProfile.java
@@ -24,8 +24,9 @@ import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.vm.Nic.ReservationStrategy;
+import org.apache.cloudstack.api.InternalIdentity;
 
-public class NicProfile {
+public class NicProfile implements InternalIdentity {
     long id;
     long networkId;
     BroadcastDomainType broadcastType;
@@ -207,7 +208,7 @@ public class NicProfile {
         return strategy;
     }
 
-    public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate, 
+    public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate,
             boolean isSecurityGroupEnabled, String name) {
         this.id = nic.getId();
         this.networkId = network.getId();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/RunningOn.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/RunningOn.java b/api/src/com/cloud/vm/RunningOn.java
index a04e28e..cb64293 100644
--- a/api/src/com/cloud/vm/RunningOn.java
+++ b/api/src/com/cloud/vm/RunningOn.java
@@ -17,7 +17,7 @@
 package com.cloud.vm;
 
 /**
- * 
+ *
  */
 public interface RunningOn {
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/UserVmService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index 98d02db..b1ebe10 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -21,22 +21,21 @@ import java.util.Map;
 
 import javax.naming.InsufficientResourcesException;
 
-import com.cloud.api.commands.AssignVMCmd;
-import com.cloud.api.commands.AttachVolumeCmd;
-import com.cloud.api.commands.CreateTemplateCmd;
-import com.cloud.api.commands.CreateVMGroupCmd;
-import com.cloud.api.commands.DeleteVMGroupCmd;
-import com.cloud.api.commands.DeployVMCmd;
-import com.cloud.api.commands.DestroyVMCmd;
-import com.cloud.api.commands.DetachVolumeCmd;
-import com.cloud.api.commands.ListVMsCmd;
-import com.cloud.api.commands.RebootVMCmd;
-import com.cloud.api.commands.RecoverVMCmd;
-import com.cloud.api.commands.ResetVMPasswordCmd;
-import com.cloud.api.commands.RestoreVMCmd;
-import com.cloud.api.commands.StartVMCmd;
-import com.cloud.api.commands.UpdateVMCmd;
-import com.cloud.api.commands.UpgradeVMCmd;
+import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
+import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
+import org.apache.cloudstack.api.command.user.vm.*;
+import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
+import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
+import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
+import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
+import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
+import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
+import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
+import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
+import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
+import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
+import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
+
 import com.cloud.dc.DataCenter;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -53,13 +52,12 @@ import com.cloud.storage.Volume;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 import com.cloud.uservm.UserVm;
-import com.cloud.utils.Pair;
 import com.cloud.utils.exception.ExecutionException;
 
 public interface UserVmService {
     /**
      * Destroys one virtual machine
-     * 
+     *
      * @param userId
      *            the id of the user performing the action
      * @param vmId
@@ -71,7 +69,7 @@ public interface UserVmService {
 
     /**
      * Destroys one virtual machine
-     * 
+     *
      * @param userId
      *            the id of the user performing the action
      * @param vmId
@@ -83,7 +81,7 @@ public interface UserVmService {
 
     /**
      * Resets the password of a virtual machine.
-     * 
+     *
      * @param cmd
      *            - the command specifying vmId, password
      * @return the VM if reset worked successfully, null otherwise
@@ -92,7 +90,7 @@ public interface UserVmService {
 
     /**
      * Attaches the specified volume to the specified VM
-     * 
+     *
      * @param cmd
      *            - the command specifying volumeId and vmId
      * @return the Volume object if attach worked successfully.
@@ -101,7 +99,7 @@ public interface UserVmService {
 
     /**
      * Detaches the specified volume from the VM it is currently attached to.
-     * 
+     *
      * @param cmd
      *            - the command specifying volumeId
      * @return the Volume object if detach worked successfully.
@@ -119,7 +117,7 @@ public interface UserVmService {
 
     /**
      * Create a template database record in preparation for creating a private template.
-     * 
+     *
      * @param cmd
      *            the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
      *            for the
@@ -133,7 +131,7 @@ public interface UserVmService {
 
     /**
      * Creates a private template from a snapshot of a VM
-     * 
+     *
      * @param cmd
      *            - the command specifying snapshotId, name, description
      * @return a template if successfully created, null otherwise
@@ -142,7 +140,7 @@ public interface UserVmService {
 
     /**
      * Creates a Basic Zone User VM in the database and returns the VM to the caller.
-     * 
+     *
      * @param zone
      *            - availability zone for the virtual machine
      * @param serviceOffering
@@ -189,7 +187,7 @@ public interface UserVmService {
      *            - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
      *            be used
      * @return UserVm object if successful.
-     * 
+     *
      * @throws InsufficientCapacityException
      *             if there is insufficient capacity to deploy the VM.
      * @throws ConcurrentOperationException
@@ -205,7 +203,7 @@ public interface UserVmService {
     /**
      * Creates a User VM in Advanced Zone (Security Group feature is enabled) in the database and returns the VM to the
      * caller.
-     * 
+     *
      * @param zone
      *            - availability zone for the virtual machine
      * @param serviceOffering
@@ -254,7 +252,7 @@ public interface UserVmService {
      *            - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
      *            be used
      * @return UserVm object if successful.
-     * 
+     *
      * @throws InsufficientCapacityException
      *             if there is insufficient capacity to deploy the VM.
      * @throws ConcurrentOperationException
@@ -271,7 +269,7 @@ public interface UserVmService {
     /**
      * Creates a User VM in Advanced Zone (Security Group feature is disabled) in the database and returns the VM to the
      * caller.
-     * 
+     *
      * @param zone
      *            - availability zone for the virtual machine
      * @param serviceOffering
@@ -318,7 +316,7 @@ public interface UserVmService {
      *            - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
      *            be used
      * @return UserVm object if successful.
-     * 
+     *
      * @throws InsufficientCapacityException
      *             if there is insufficient capacity to deploy the VM.
      * @throws ConcurrentOperationException
@@ -333,7 +331,7 @@ public interface UserVmService {
 
     /**
      * Starts the virtual machine created from createVirtualMachine.
-     * 
+     *
      * @param cmd
      *            Command to deploy.
      * @return UserVm object if successful.
@@ -348,7 +346,7 @@ public interface UserVmService {
 
     /**
      * Creates a vm group.
-     * 
+     *
      * @param name
      *            - name of the group
      * @param accountId
@@ -360,7 +358,7 @@ public interface UserVmService {
 
     /**
      * upgrade the service offering of the virtual machine
-     * 
+     *
      * @param cmd
      *            - the command specifying vmId and new serviceOfferingId
      * @return the vm
@@ -371,15 +369,6 @@ public interface UserVmService {
 
     void deletePrivateTemplateRecord(Long templateId);
 
-    /**
-     * Obtains a list of virtual machines by the specified search criteria. Can search by: "userId", "name", "state",
-     * "dataCenterId", "podId", "hostId"
-     * 
-     * @param cmd
-     *            the API command that wraps the search criteria
-     * @return List of UserVMs.
-     */
-    Pair<List<? extends UserVm>, Integer> searchForUserVMs(ListVMsCmd cmd);
 
     HypervisorType getHypervisorTypeOfUserVM(long vmid);
 
@@ -392,7 +381,7 @@ public interface UserVmService {
      * Migrate the given VM to the destination host provided. The API returns the migrated VM if migration succeeds.
      * Only Root
      * Admin can migrate a VM.
-     * 
+     *
      * @param destinationStorage
      *            TODO
      * @param Long
@@ -400,7 +389,7 @@ public interface UserVmService {
      *            vmId of The VM to migrate
      * @param Host
      *            destinationHost to migrate the VM
-     * 
+     *
      * @return VirtualMachine migrated VM
      * @throws ManagementServerException
      *             in case we get error finding the VM or host or access errors or other internal errors.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index 1fa16c3..cd30579 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -19,17 +19,18 @@ package com.cloud.vm;
 import java.util.Date;
 import java.util.Map;
 
-import com.cloud.acl.ControlledEntity;
-import com.cloud.api.Identity;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Identity;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.fsm.StateMachine2;
 import com.cloud.utils.fsm.StateObject;
+import org.apache.cloudstack.api.InternalIdentity;
 
 /**
  * VirtualMachine describes the properties held by a virtual machine
- * 
+ *
  */
-public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, StateObject<VirtualMachine.State> {
+public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, InternalIdentity, StateObject<VirtualMachine.State> {
 
     public enum State {
         Starting(true, "VM is being started.  At this state, you should find host id filled which means it's being started on that host."),
@@ -207,11 +208,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
     public String getInstanceName();
 
     /**
-     * @return the id of this virtual machine. null means the id has not been set.
-     */
-    public long getId();
-
-    /**
      * @return the host name of the virtual machine. If the user did not
      *         specify the host name when creating the virtual machine then it is
      *         defaults to the instance name.
@@ -245,7 +241,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
 
     /**
      * returns the guest OS ID
-     * 
+     *
      * @return guestOSId
      */
     public long getGuestOSId();
@@ -290,6 +286,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
     HypervisorType getHypervisorType();
 
     public Map<String, String> getDetails();
-    
+
     boolean canPlugNics();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/com/cloud/vm/VirtualMachineProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VirtualMachineProfile.java b/api/src/com/cloud/vm/VirtualMachineProfile.java
index 57277db..0fab443 100644
--- a/api/src/com/cloud/vm/VirtualMachineProfile.java
+++ b/api/src/com/cloud/vm/VirtualMachineProfile.java
@@ -30,7 +30,7 @@ import com.cloud.user.Account;
  * VirtualMachineProfile describes one virtual machine. This object
  * on what the virtual machine profile should look like before it is
  * actually started on the hypervisor.
- * 
+ *
  * @param <T>
  *            a VirtualMachine
  */

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/acl/APIAccessChecker.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/APIAccessChecker.java b/api/src/org/apache/cloudstack/acl/APIAccessChecker.java
new file mode 100644
index 0000000..3194bd1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/APIAccessChecker.java
@@ -0,0 +1,32 @@
+// 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.acl;
+
+import java.util.Properties;
+
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.utils.component.Adapter;
+
+/**
+ * APIAccessChecker checks the ownership and access control to API requests
+ */
+public interface APIAccessChecker extends Adapter {
+    // Interface for checking access to an API for an user
+    boolean canAccessAPI(User user, String apiCommandName) throws PermissionDeniedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/acl/ControlledEntity.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/ControlledEntity.java b/api/src/org/apache/cloudstack/acl/ControlledEntity.java
new file mode 100644
index 0000000..3e04126
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/ControlledEntity.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 org.apache.cloudstack.acl;
+
+import com.cloud.domain.PartOf;
+import com.cloud.user.OwnedBy;
+
+/**
+ * ControlledEntity defines an object for which the access from an
+ * access must inherit this interface.
+ *
+ */
+public interface ControlledEntity extends OwnedBy, PartOf {
+    public enum ACLType {
+        Account,
+        Domain
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/acl/InfrastructureEntity.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/InfrastructureEntity.java b/api/src/org/apache/cloudstack/acl/InfrastructureEntity.java
new file mode 100644
index 0000000..451c0c8
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/InfrastructureEntity.java
@@ -0,0 +1,20 @@
+// 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.acl;
+
+public interface InfrastructureEntity {
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/acl/Role.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/Role.java b/api/src/org/apache/cloudstack/acl/Role.java
new file mode 100644
index 0000000..d039a6f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/Role.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 org.apache.cloudstack.acl;
+
+//metadata - consists of default dynamic roles in CS + any custom roles added by user
+public interface Role {
+
+    public static final short ROOT_ADMIN = 0;
+    public static final short DOMAIN_ADMIN = 1;
+    public static final short DOMAIN_USER = 2;
+    public static final short OWNER = 3;
+    public static final short PARENT_DOMAIN_ADMIN = 4;
+    public static final short PARENT_DOMAIN_USER = 5;
+    public static final short CHILD_DOMAIN_ADMIN = 6;
+    public static final short CHILD_DOMAIN_USER = 7;
+
+    public long getId();
+    public short getRoleType();
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/acl/SecurityChecker.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/SecurityChecker.java b/api/src/org/apache/cloudstack/acl/SecurityChecker.java
new file mode 100644
index 0000000..3a721fe
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/SecurityChecker.java
@@ -0,0 +1,99 @@
+// 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.acl;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.domain.Domain;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.utils.component.Adapter;
+
+/**
+ * SecurityChecker checks the ownership and access control to objects within
+ */
+public interface SecurityChecker extends Adapter {
+
+    public enum AccessType {
+        ListEntry,
+        ModifyEntry,
+        ModifyProject,
+        UseNetwork
+    }
+
+    /**
+     * Checks if the account owns the object.
+     *
+     * @param caller
+     *            account to check against.
+     * @param object
+     *            object that the account is trying to access.
+     * @return true if access allowed. false if this adapter cannot authenticate ownership.
+     * @throws PermissionDeniedException
+     *             if this adapter is suppose to authenticate ownership and the check failed.
+     */
+    boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException;
+
+    /**
+     * Checks if the user belongs to an account that owns the object.
+     *
+     * @param user
+     *            user to check against.
+     * @param object
+     *            object that the account is trying to access.
+     * @return true if access allowed. false if this adapter cannot authenticate ownership.
+     * @throws PermissionDeniedException
+     *             if this adapter is suppose to authenticate ownership and the check failed.
+     */
+    boolean checkAccess(User user, Domain domain) throws PermissionDeniedException;
+
+    /**
+     * Checks if the account can access the object.
+     *
+     * @param caller
+     *            account to check against.
+     * @param entity
+     *            object that the account is trying to access.
+     * @param accessType
+     *            TODO
+     * @return true if access allowed. false if this adapter cannot provide permission.
+     * @throws PermissionDeniedException
+     *             if this adapter is suppose to authenticate ownership and the check failed.
+     */
+    boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType) throws PermissionDeniedException;
+
+    /**
+     * Checks if the user belongs to an account that can access the object.
+     *
+     * @param user
+     *            user to check against.
+     * @param entity
+     *            object that the account is trying to access.
+     * @return true if access allowed. false if this adapter cannot authenticate ownership.
+     * @throws PermissionDeniedException
+     *             if this adapter is suppose to authenticate ownership and the check failed.
+     */
+    boolean checkAccess(User user, ControlledEntity entity) throws PermissionDeniedException;
+
+    boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException;
+
+    public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException;
+
+    boolean checkAccess(Account account, DiskOffering dof) throws PermissionDeniedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/ACL.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ACL.java b/api/src/org/apache/cloudstack/api/ACL.java
new file mode 100644
index 0000000..3623d1a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/ACL.java
@@ -0,0 +1,31 @@
+// 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.api;
+
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ FIELD })
+public @interface ACL {
+
+    boolean checkKeyAccess() default false;
+    boolean checkValueAccess() default false;
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c4c9d2d8/api/src/org/apache/cloudstack/api/APICommand.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/APICommand.java b/api/src/org/apache/cloudstack/api/APICommand.java
new file mode 100644
index 0000000..4d024c1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/APICommand.java
@@ -0,0 +1,39 @@
+// 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.api;
+
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ TYPE })
+public @interface APICommand {
+    Class<? extends BaseResponse> responseObject();
+
+    String name() default "";
+
+    String description() default "";
+
+    String usage() default "";
+
+    boolean includeInApiDoc() default true;
+
+    String since() default "";
+}