cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [7/7] Move view based VO and Dao classes to cloud-server module to hide the details from API client, also extract query related methods into QueryService interface.
Date Fri, 14 Dec 2012 18:48:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index a8241d0..6608987 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -5,7 +5,7 @@
 // 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,
@@ -63,6 +63,9 @@ import com.cloud.agent.api.to.VolumeTO;
 import com.cloud.agent.manager.Commands;
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiDBUtils;
+import com.cloud.api.query.dao.UserVmJoinDao;
+import com.cloud.api.query.vo.UserVmJoinVO;
+
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
 import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
@@ -74,7 +77,6 @@ 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.UpdateVMCmd;
 import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
-import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
 import com.cloud.async.AsyncJobExecutor;
 import com.cloud.async.AsyncJobManager;
 import com.cloud.async.AsyncJobVO;
@@ -230,7 +232,6 @@ import com.cloud.vm.dao.InstanceGroupVMMapDao;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.UserVmDetailsDao;
-import com.cloud.vm.dao.UserVmJoinDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
 @Local(value = { UserVmManager.class, UserVmService.class })
@@ -337,9 +338,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
     protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
     @Inject
     protected SecurityGroupDao _securityGroupDao;
-    @Inject 
+    @Inject
     protected CapacityManager _capacityMgr;;
-    @Inject 
+    @Inject
     protected VMInstanceDao _vmInstanceDao;
     @Inject
     protected ResourceLimitService _resourceLimitMgr;
@@ -349,7 +350,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
     protected ProjectManager _projectMgr;
     @Inject
     protected ResourceManager _resourceMgr;
-    @Inject 
+    @Inject
     protected NetworkServiceMapDao _ntwkSrvcDao;
     @Inject
     SecurityGroupVMMapDao _securityGroupVMMapDao;
@@ -414,7 +415,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 
         if (result) {
             userVm.setPassword(password);
-            //update the password in vm_details table too 
+            //update the password in vm_details table too
             // Check if an SSH key pair was selected for the instance and if so use it to encrypt & save the vm password
             String sshPublicKey = userVm.getDetail("SSH.PublicKey");
             if (sshPublicKey != null && !sshPublicKey.equals("") && password != null && !password.equals("saved_password")) {
@@ -457,7 +458,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 
             UserDataServiceProvider element = _networkMgr.getPasswordResetProvider(defaultNetwork);
             if (element == null) {
-                throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName() + 
+                throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName() +
                         " provider needed for password reset");
             }
 
@@ -473,7 +474,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                     return true;
                 }
 
-                if (rebootVirtualMachine(userId, vmId) == null) { 
+                if (rebootVirtualMachine(userId, vmId) == null) {
                     s_logger.warn("Failed to reboot the vm " + vmInstance);
                     return false;
                 } else {
@@ -688,7 +689,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                         }
 
                         // Check that there is some shared storage.
-                        StoragePoolVO vmRootVolumePool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId());                                           
+                        StoragePoolVO vmRootVolumePool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId());
                         List<StoragePoolVO> sharedVMPools = _storagePoolDao.findPoolsByTags(vmRootVolumePool.getDataCenterId(), vmRootVolumePool.getPodId(), vmRootVolumePool.getClusterId(), null, true);
                         if (sharedVMPools.size() == 0) {
                             throw new CloudRuntimeException("Cannot attach volume since there are no shared storage pools in the VM's cluster to copy the uploaded volume to.");
@@ -1381,7 +1382,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
             }
 
             volume = _volsDao.findById(snapshot.getVolumeId());
-            VolumeVO snapshotVolume = _volsDao.findByIdIncludingRemoved(snapshot.getVolumeId());     
+            VolumeVO snapshotVolume = _volsDao.findByIdIncludingRemoved(snapshot.getVolumeId());
 
             //check permissions
             _accountMgr.checkAccess(caller, null, true, snapshot);
@@ -1390,14 +1391,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                 throw new InvalidParameterValueException("Snapshot id=" + snapshotId + " is not in " + Snapshot.Status.BackedUp + " state yet and can't be used for template creation");
             }
 
-            /*            
+            /*
             // bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT
-            if(snapshot.getHypervisorType() == HypervisorType.VMware && snapshotVolume.getVolumeType() == Type.DATADISK){ 
+            if(snapshot.getHypervisorType() == HypervisorType.VMware && snapshotVolume.getVolumeType() == Type.DATADISK){
                 throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId + " is created from Data Disk");
             }
              */
 
-            hyperType = snapshot.getHypervisorType();            
+            hyperType = snapshot.getHypervisorType();
         }
 
         _resourceLimitMgr.checkResourceLimit(templateOwner, ResourceType.template);
@@ -2190,7 +2191,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                         throw new InvalidParameterValueException("Can't create a vm with multiple networks one of" +
                         		" which is Security Group enabled");
                     }
-                    
+
                     isSecurityGroupEnabledNetworkUsed = true;
                 }
 
@@ -2213,7 +2214,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 
         // if network is security group enabled, and no security group is specified, then add the default security group automatically
         if (isSecurityGroupEnabledNetworkUsed && !isVmWare && _networkMgr.canAddDefaultSecurityGroup()) {
-            
+
           //add the default securityGroup only if no security group is specified
             if(securityGroupIdList == null || securityGroupIdList.isEmpty()){
                 if (securityGroupIdList == null) {
@@ -2276,7 +2277,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                         throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId   + " and tag: " +requiredOfferings.get(0).getTags());
                     }
                     s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process");
-                    Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), 
+                    Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
                             owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
                             null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
                     defaultNetwork = _networkDao.findById(newNetwork.getId());
@@ -2286,7 +2287,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                     defaultNetwork = virtualNetworks.get(0);
                 }
             } else {
-                throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled); 
+                throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
             }
 
             networkList.add(defaultNetwork);
@@ -2310,10 +2311,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                     }
 
                 }
-                
+
                 _networkMgr.checkNetworkPermissions(owner, network);
 
-                //don't allow to use system networks 
+                //don't allow to use system networks
                 NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
                 if (networkOffering.isSystemOnly()) {
                     throw new InvalidParameterValueException("Network id=" + networkId + " is system only and can't be used for vm deployment");
@@ -2534,7 +2535,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                     ntwkIds.add(network.getId());
                     ntwkDomains.put(ntwkDomain, ntwkIds);
                 }
-            } 
+            }
 
             for (String ntwkDomain : ntwkDomains.keySet()) {
                 for (Long ntwkId : ntwkDomains.get(ntwkDomain)) {
@@ -2543,7 +2544,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                     //* verify that there are no duplicates
                     if (hostNames.contains(hostName)) {
                         throw new InvalidParameterValueException("The vm with hostName " + hostName
-                                + " already exists in the network domain: " + ntwkDomain + "; network=" 
+                                + " already exists in the network domain: " + ntwkDomain + "; network="
                                 + _networkMgr.getNetwork(ntwkId));
                     }
                 }
@@ -2884,7 +2885,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         if (callerAccount != null && callerAccount.getRemoved() != null) {
             throw new InvalidParameterValueException("The account " + callerAccount.getId() + " is removed");
         }
-        
+
         UserVmVO vm = _vmDao.findById(vmId);
         if (vm == null) {
             throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
@@ -2972,12 +2973,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         }
 
         vm = _itMgr.start(vm, params, callerUser, callerAccount, plan);
-           
+
         Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = new Pair(vm, params);
         if (vm != null && vm.isUpdateParameters()) {
          // this value is not being sent to the backend; need only for api display purposes
             if (template.getEnablePassword()) {
-                vm.setPassword((String)vmParamPair.second().get(VirtualMachineProfile.Param.VmPassword));   
+                vm.setPassword((String)vmParamPair.second().get(VirtualMachineProfile.Param.VmPassword));
                 vm.setUpdateParameters(false);
                 _vmDao.update(vm.getId(), vm);
             }
@@ -2997,7 +2998,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
             InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a virtual machine with specified vmId");
             ex.addProxyObject(vm, vmId, "vmId");
             throw ex;
-        } 
+        }
 
         if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) {
             s_logger.trace("Vm id=" + vmId + " is already destroyed");
@@ -3040,61 +3041,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         }
     }
 
-    @Override
-    public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(ListVMsCmd cmd) {
-        Account caller = UserContext.current().getCaller();
-        List<Long> permittedAccounts = new ArrayList<Long>();
-        String hypervisor = cmd.getHypervisor();
-        boolean listAll = cmd.listAll();
-        Long id = cmd.getId();
-        Map<String, String> tags = cmd.getTags();
-
-        Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
-        _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
-        Long domainId = domainIdRecursiveListProject.first();
-        Boolean isRecursive = domainIdRecursiveListProject.second();
-        ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
-
-        // removing order by, orderBy shouold be specified in ListVMsCmd parameters
-        //Criteria c = new Criteria("id", Boolean.TRUE, cmd.getStartIndex(), cmd.getPageSizeVal());
-        Criteria c = new Criteria(null, Boolean.FALSE, cmd.getStartIndex(), cmd.getPageSizeVal());
-        c.addCriteria(Criteria.KEYWORD, cmd.getKeyword());
-        c.addCriteria(Criteria.ID, cmd.getId());
-        c.addCriteria(Criteria.NAME, cmd.getInstanceName());
-        c.addCriteria(Criteria.STATE, cmd.getState());
-        c.addCriteria(Criteria.DATACENTERID, cmd.getZoneId());
-        c.addCriteria(Criteria.GROUPID, cmd.getGroupId());
-        c.addCriteria(Criteria.FOR_VIRTUAL_NETWORK, cmd.getForVirtualNetwork());
-        c.addCriteria(Criteria.NETWORKID, cmd.getNetworkId());
-        c.addCriteria(Criteria.TEMPLATE_ID, cmd.getTemplateId());
-        c.addCriteria(Criteria.ISO_ID, cmd.getIsoId());
-        c.addCriteria(Criteria.VPC_ID, cmd.getVpcId());
-
-        if (domainId != null) {
-            c.addCriteria(Criteria.DOMAINID, domainId);
-        }
-
-        if (HypervisorType.getType(hypervisor) != HypervisorType.None) {
-            c.addCriteria(Criteria.HYPERVISOR, hypervisor);
-        } else if (hypervisor != null) {
-            throw new InvalidParameterValueException("Invalid HypervisorType " + hypervisor);
-        }
-
-        // ignore these search requests if it's not an admin
-        if (_accountMgr.isAdmin(caller.getType())) {
-            c.addCriteria(Criteria.PODID, cmd.getPodId());
-            c.addCriteria(Criteria.HOSTID, cmd.getHostId());
-            c.addCriteria(Criteria.STORAGE_ID, cmd.getStorageId());
-        }
-
-        if (!permittedAccounts.isEmpty()) {
-            c.addCriteria(Criteria.ACCOUNTID, permittedAccounts.toArray());
-        }
-        c.addCriteria(Criteria.ISADMIN, _accountMgr.isAdmin(caller.getType()));
 
-        return searchForUserVMs(c, caller, domainId, isRecursive,
-                permittedAccounts, listAll, listProjectResourcesCriteria, tags);
-    }
 
     @Override
     public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(Criteria c, Account caller, Long domainId, boolean isRecursive,
@@ -3105,7 +3052,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         SearchBuilder<UserVmJoinVO> sb = _vmJoinDao.createSearchBuilder();
         sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids
         _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-        
+
         Object id = c.getCriteria(Criteria.ID);
         Object name = c.getCriteria(Criteria.NAME);
         Object state = c.getCriteria(Criteria.STATE);
@@ -3155,7 +3102,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         if (networkId != null) {
             sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
         }
-        
+
         if(vpcId != null && networkId == null){
             sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
         }
@@ -3208,7 +3155,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         if (networkId != null) {
             sc.setParameters("networkId", networkId);
         }
-        
+
         if(vpcId != null && networkId == null){
             sc.setParameters("vpcId", vpcId);
         }
@@ -3283,7 +3230,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         UserVmVO userVm = _vmDao.findById(vmId);
         if (userVm == null) {
             InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id");
-            ex.addProxyObject(userVm, vmId, "vmId");            
+            ex.addProxyObject(userVm, vmId, "vmId");
             throw ex;
         }
 
@@ -3399,7 +3346,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
             }
             throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate");
         }
-        
+
         //check if migrating to same host
         long srcHostId = vm.getHostId();
         if(destinationHost.getId() == srcHostId){
@@ -3469,11 +3416,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         if (newAccount == null || newAccount.getType() == Account.ACCOUNT_TYPE_PROJECT) {
             throw new InvalidParameterValueException("Invalid accountid=" + cmd.getAccountName() + " in domain " + cmd.getDomainId());
         }
-        
+
         if (newAccount.getState() == Account.State.disabled) {
             throw new InvalidParameterValueException("The new account owner " + cmd.getAccountName() + " is disabled.");
         }
-        
+
         // make sure the accounts are under same domain
         if (oldAccount.getDomainId() != newAccount.getDomainId()){
             throw new InvalidParameterValueException("The account should be under same domain for moving VM between two accounts. Old owner domain =" + oldAccount.getDomainId() +
@@ -3517,7 +3464,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 
         //VV 3: check if volumes are with in resource limits
         _resourceLimitMgr.checkResourceLimit(newAccount, ResourceType.volume, _volsDao.findByInstance(cmd.getVmId()).size());
-        
+
         // VV 4: Check if new owner can use the vm template
         VirtualMachineTemplate template = _templateDao.findById(vm.getTemplateId());
         if (!template.isPublicTemplate()) {
@@ -3532,7 +3479,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         Transaction txn = Transaction.currentTxn();
         txn.start();
         //generate destroy vm event for usage
-        _usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), 
+        _usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(),
                 vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm.getHypervisorType().toString()));
         // update resource counts
         _resourceLimitMgr.decrementResourceCount(oldAccount.getAccountId(), ResourceType.user_vm);
@@ -3561,7 +3508,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 
         _resourceLimitMgr.incrementResourceCount(newAccount.getAccountId(), ResourceType.user_vm);
         //generate usage events to account for this change
-        _usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(), 
+        _usageEventDao.persist(new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterIdToDeployIn(), vm.getId(),
                 vm.getHostName(), vm.getServiceOfferingId(),  vm.getTemplateId(), vm.getHypervisorType().toString()));
 
         txn.commit();
@@ -3572,7 +3519,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         // OS 3: update the network
         List<Long> networkIdList = cmd.getNetworkIds();
         List<Long> securityGroupIdList = cmd.getSecurityGroupIdList();
-        
+
         if (zone.getNetworkType() == NetworkType.Basic) {
              if (networkIdList != null && !networkIdList.isEmpty()) {
                  throw new InvalidParameterValueException("Can't move vm with network Ids; this is a basic zone VM");
@@ -3632,7 +3579,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
             NicProfile profile = new NicProfile();
             profile.setDefaultNic(true);
             networks.add(new Pair<NetworkVO, NicProfile>(networkList.get(0), profile));
-           
+
             VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(), vm.getId());
             VirtualMachineProfileImpl<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vmi);
             _networkMgr.allocate(vmProfile, networks);
@@ -3650,9 +3597,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                  //cleanup the network for the oldOwner
                 _networkMgr.cleanupNics(vmOldProfile);
                 _networkMgr.expungeNics(vmOldProfile);
-                
+
                 Set<NetworkVO> applicableNetworks = new HashSet<NetworkVO>();
-            
+
                 if (networkIdList != null && !networkIdList.isEmpty()){
                     // add any additional networks
                     for (Long networkId : networkIdList) {
@@ -3665,7 +3612,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
 
                         _networkMgr.checkNetworkPermissions(newAccount, network);
 
-                        //don't allow to use system networks 
+                        //don't allow to use system networks
                         NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
                         if (networkOffering.isSystemOnly()) {
                             InvalidParameterValueException ex = new InvalidParameterValueException("Specified Network id is system only and can't be used for vm deployment");
@@ -3693,10 +3640,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                             if (physicalNetwork == null) {
                                 throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId   + " and tag: " +requiredOfferings.get(0).getTags());
                             }
-                            
-                            s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" + 
+
+                            s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
                         requiredOfferings.get(0).getId() + " as a part of deployVM process");
-                            Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), 
+                            Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
                                     newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
                                     null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
                             defaultNetwork = _networkDao.findById(newNetwork.getId());
@@ -3707,7 +3654,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                             defaultNetwork = virtualNetworks.get(0);
                         }
                     } else {
-                        throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled); 
+                        throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled);
                     }
 
                     applicableNetworks.add(defaultNetwork);
@@ -3716,7 +3663,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
                 // add the new nics
                 List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
                 int toggle=0;
-                for (NetworkVO appNet: applicableNetworks){                    
+                for (NetworkVO appNet: applicableNetworks){
                     NicProfile defaultNic = new NicProfile();
                     if (toggle==0){
                         defaultNic.setDefaultNic(true);
@@ -3821,7 +3768,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         s_logger.debug("Restore VM " + vmId + " with template " + root.getTemplateId() + " successfully");
         return vm;
     }
-    
+
     @Override
     public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
             ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException,
@@ -3841,5 +3788,5 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
     @Override
     public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/dao/DomainRouterJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/DomainRouterJoinDao.java b/server/src/com/cloud/vm/dao/DomainRouterJoinDao.java
deleted file mode 100644
index 9bb03be..0000000
--- a/server/src/com/cloud/vm/dao/DomainRouterJoinDao.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.vm.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.DomainRouterResponse;
-import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-import com.cloud.utils.db.GenericDao;
-
-public interface DomainRouterJoinDao extends GenericDao<DomainRouterJoinVO, Long> {
-
-    DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO uvo, Account caller);
-
-    DomainRouterResponse setDomainRouterResponse(DomainRouterResponse userVmData, DomainRouterJoinVO uvo);
-
-    List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr);
-
-    List<DomainRouterJoinVO> searchByIds(Long... ids);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/dao/DomainRouterJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterJoinDaoImpl.java
deleted file mode 100644
index 38839e3..0000000
--- a/server/src/com/cloud/vm/dao/DomainRouterJoinDaoImpl.java
+++ /dev/null
@@ -1,202 +0,0 @@
-// 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.vm.dao;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiResponseHelper;
-import org.apache.cloudstack.api.response.DomainRouterResponse;
-import org.apache.cloudstack.api.response.NicResponse;
-import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-
-@Local(value={DomainRouterJoinDao.class})
-public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO, Long> implements DomainRouterJoinDao {
-    public static final Logger s_logger = Logger.getLogger(DomainRouterJoinDaoImpl.class);
-
-    private SearchBuilder<DomainRouterJoinVO> vrSearch;
-
-    private SearchBuilder<DomainRouterJoinVO> vrIdSearch;
-
-    protected DomainRouterJoinDaoImpl() {
-
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
-
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
-
-        this._count = "select count(distinct id) from domain_router_view WHERE ";
-    }
-
-
-    @Override
-    public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, Account caller) {
-        DomainRouterResponse routerResponse = new DomainRouterResponse();
-        routerResponse.setId(router.getUuid());
-        routerResponse.setZoneId(router.getDataCenterUuid());
-        routerResponse.setName(router.getHostName());
-        routerResponse.setTemplateId(router.getTemplateUuid());
-        routerResponse.setCreated(router.getCreated());
-        routerResponse.setState(router.getState());
-        routerResponse.setIsRedundantRouter(router.isRedundantRouter());
-        routerResponse.setRedundantState(router.getRedundantState().toString());
-
-        if (caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN
-                || caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
-            if (router.getHostId() != null) {
-                routerResponse.setHostId(router.getHostUuid());
-                routerResponse.setHostName(router.getHostName());
-            }
-            routerResponse.setPodId(router.getPodUuid());
-            long nic_id = router.getNicId();
-            if (nic_id > 0) {
-                TrafficType ty = router.getTrafficType();
-                if (ty != null) {
-                    // legacy code, public/control/guest nic info is kept in
-                    // nics response object
-                    if (ty == TrafficType.Public) {
-                        routerResponse.setPublicIp(router.getIpAddress());
-                        routerResponse.setPublicMacAddress(router.getMacAddress());
-                        routerResponse.setPublicNetmask(router.getNetmask());
-                        routerResponse.setGateway(router.getGateway());
-                        routerResponse.setPublicNetworkId(router.getNetworkUuid());
-                    } else if (ty == TrafficType.Control) {
-                        routerResponse.setLinkLocalIp(router.getIpAddress());
-                        routerResponse.setLinkLocalMacAddress(router.getMacAddress());
-                        routerResponse.setLinkLocalNetmask(router.getNetmask());
-                        routerResponse.setLinkLocalNetworkId(router.getNetworkUuid());
-                    } else if (ty == TrafficType.Guest) {
-                        routerResponse.setGuestIpAddress(router.getIpAddress());
-                        routerResponse.setGuestMacAddress(router.getMacAddress());
-                        routerResponse.setGuestNetmask(router.getNetmask());
-                        routerResponse.setGuestNetworkId(router.getNetworkUuid());
-                        routerResponse.setNetworkDomain(router.getNetworkDomain());
-                    }
-                }
-
-                NicResponse nicResponse = new NicResponse();
-                nicResponse.setId(router.getNicUuid());
-                nicResponse.setIpaddress(router.getIpAddress());
-                nicResponse.setGateway(router.getGateway());
-                nicResponse.setNetmask(router.getNetmask());
-                nicResponse.setNetworkid(router.getNetworkUuid());
-                nicResponse.setNetworkName(router.getNetworkName());
-                nicResponse.setMacAddress(router.getMacAddress());
-                if (router.getBroadcastUri() != null) {
-                    nicResponse.setBroadcastUri(router.getBroadcastUri().toString());
-                }
-                if (router.getIsolationUri() != null) {
-                    nicResponse.setIsolationUri(router.getIsolationUri().toString());
-                }
-                if (router.getTrafficType() != null) {
-                    nicResponse.setTrafficType(router.getTrafficType().toString());
-                }
-                if (router.getGuestType() != null) {
-                    nicResponse.setType(router.getGuestType().toString());
-                }
-                nicResponse.setIsDefault(router.isDefaultNic());
-                nicResponse.setObjectName("nic");
-                routerResponse.addNic(nicResponse);
-            }
-        }
-
-        routerResponse.setServiceOfferingId(router.getServiceOfferingUuid());
-        routerResponse.setServiceOfferingName(router.getServiceOfferingName());
-
-        // populate owner.
-        ApiResponseHelper.populateOwner(routerResponse, router);
-
-
-        routerResponse.setDomainId(router.getDomainUuid());
-        routerResponse.setDomainName(router.getDomainName());
-
-        routerResponse.setZoneName(router.getDataCenterName());
-        routerResponse.setDns1(router.getDns1());
-        routerResponse.setDns2(router.getDns2());
-
-        routerResponse.setVpcId(router.getVpcUuid());
-
-        routerResponse.setObjectName("router");
-
-        return routerResponse;
-    }
-
-
-    @Override
-    public DomainRouterResponse setDomainRouterResponse(DomainRouterResponse vrData, DomainRouterJoinVO vr) {
-        long nic_id = vr.getNicId();
-        if (nic_id > 0) {
-            NicResponse nicResponse = new NicResponse();
-            nicResponse.setId(vr.getNicUuid());
-            nicResponse.setIpaddress(vr.getIpAddress());
-            nicResponse.setGateway(vr.getGateway());
-            nicResponse.setNetmask(vr.getNetmask());
-            nicResponse.setNetworkid(vr.getNetworkUuid());
-            nicResponse.setMacAddress(vr.getMacAddress());
-            if (vr.getBroadcastUri() != null) {
-                nicResponse.setBroadcastUri(vr.getBroadcastUri().toString());
-            }
-            if (vr.getIsolationUri() != null) {
-                nicResponse.setIsolationUri(vr.getIsolationUri().toString());
-            }
-            if (vr.getTrafficType() != null) {
-                nicResponse.setTrafficType(vr.getTrafficType().toString());
-            }
-            if (vr.getGuestType() != null) {
-                nicResponse.setType(vr.getGuestType().toString());
-            }
-            nicResponse.setIsDefault(vr.isDefaultNic());
-            nicResponse.setObjectName("nic");
-            vrData.addNic(nicResponse);
-        }
-        return vrData;
-    }
-
-
-
-
-    @Override
-    public List<DomainRouterJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<DomainRouterJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
-    @Override
-    public List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr) {
-
-        SearchCriteria<DomainRouterJoinVO> sc = vrIdSearch.create();
-        sc.setParameters("id", vr.getId());
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/dao/InstanceGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/InstanceGroupJoinDao.java b/server/src/com/cloud/vm/dao/InstanceGroupJoinDao.java
deleted file mode 100644
index 64599be..0000000
--- a/server/src/com/cloud/vm/dao/InstanceGroupJoinDao.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.vm.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.InstanceGroupResponse;
-import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
-
-import com.cloud.utils.db.GenericDao;
-import com.cloud.vm.InstanceGroup;
-
-public interface InstanceGroupJoinDao extends GenericDao<InstanceGroupJoinVO, Long> {
-
-    InstanceGroupResponse newInstanceGroupResponse(InstanceGroupJoinVO group);
-
-    InstanceGroupJoinVO newInstanceGroupView(InstanceGroup group);
-
-    List<InstanceGroupJoinVO> searchByIds(Long... ids);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/dao/InstanceGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/InstanceGroupJoinDaoImpl.java b/server/src/com/cloud/vm/dao/InstanceGroupJoinDaoImpl.java
deleted file mode 100644
index aa20b77..0000000
--- a/server/src/com/cloud/vm/dao/InstanceGroupJoinDaoImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-// 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.vm.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiResponseHelper;
-import org.apache.cloudstack.api.response.InstanceGroupResponse;
-import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.InstanceGroup;
-
-
-@Local(value={InstanceGroupJoinDao.class})
-public class InstanceGroupJoinDaoImpl extends GenericDaoBase<InstanceGroupJoinVO, Long> implements InstanceGroupJoinDao {
-    public static final Logger s_logger = Logger.getLogger(InstanceGroupJoinDaoImpl.class);
-
-    private SearchBuilder<InstanceGroupJoinVO> vrSearch;
-
-    private SearchBuilder<InstanceGroupJoinVO> vrIdSearch;
-
-
-    protected InstanceGroupJoinDaoImpl() {
-
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
-
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
-
-        this._count = "select count(distinct id) from instance_group_view WHERE ";
-    }
-
-
-
-    @Override
-    public InstanceGroupResponse newInstanceGroupResponse(InstanceGroupJoinVO group) {
-        InstanceGroupResponse groupResponse = new InstanceGroupResponse();
-        groupResponse.setId(group.getUuid());
-        groupResponse.setName(group.getName());
-        groupResponse.setCreated(group.getCreated());
-
-        ApiResponseHelper.populateOwner(groupResponse, group);
-
-        groupResponse.setObjectName("instancegroup");
-        return groupResponse;
-    }
-
-
-
-    @Override
-    public InstanceGroupJoinVO newInstanceGroupView(InstanceGroup group) {
-        SearchCriteria<InstanceGroupJoinVO> sc = vrIdSearch.create();
-        sc.setParameters("id", group.getId());
-        List<InstanceGroupJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
-        assert grps != null && grps.size() == 1 : "No vm group found for group id " + group.getId();
-        return grps.get(0);
-
-    }
-
-
-
-    @Override
-    public List<InstanceGroupJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<InstanceGroupJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/dao/UserVmJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/UserVmJoinDao.java b/server/src/com/cloud/vm/dao/UserVmJoinDao.java
deleted file mode 100644
index 7788a62..0000000
--- a/server/src/com/cloud/vm/dao/UserVmJoinDao.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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.vm.dao;
-
-import java.util.EnumSet;
-import java.util.List;
-
-import org.apache.cloudstack.api.ApiConstants.VMDetails;
-import org.apache.cloudstack.api.response.UserVmResponse;
-import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
-import com.cloud.user.Account;
-import com.cloud.uservm.UserVm;
-import com.cloud.utils.db.GenericDao;
-
-public interface UserVmJoinDao extends GenericDao<UserVmJoinVO, Long> {
-
-    UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller);
-
-    UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo);
-
-    List<UserVmJoinVO> newUserVmView(UserVm... userVms);
-
-    List<UserVmJoinVO> searchByIds(Long... ids);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmJoinDaoImpl.java
deleted file mode 100644
index b20e53f..0000000
--- a/server/src/com/cloud/vm/dao/UserVmJoinDaoImpl.java
+++ /dev/null
@@ -1,327 +0,0 @@
-// 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.vm.dao;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.Hashtable;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiDBUtils;
-import org.apache.cloudstack.api.ApiConstants.VMDetails;
-import org.apache.cloudstack.api.response.NicResponse;
-import org.apache.cloudstack.api.response.SecurityGroupResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
-import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
-import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
-import com.cloud.user.Account;
-import com.cloud.uservm.UserVm;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.VmStats;
-
-
-@Local(value={UserVmJoinDao.class})
-public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implements UserVmJoinDao {
-    public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
-
-    private static final int VM_DETAILS_BATCH_SIZE=100;
-
-    private SearchBuilder<UserVmJoinVO> VmDetailSearch;
-
-    protected UserVmJoinDaoImpl() {
-
-        VmDetailSearch = createSearchBuilder();
-        VmDetailSearch.and("idIN", VmDetailSearch.entity().getId(), SearchCriteria.Op.IN);
-        VmDetailSearch.done();
-
-        this._count = "select count(distinct id) from user_vm_view WHERE ";
-    }
-
-    public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
-        UserVmResponse userVmResponse = new UserVmResponse();
-
-        if (userVm.getHypervisorType() != null){
-            userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
-        }
-        userVmResponse.setId(userVm.getUuid());
-        userVmResponse.setName(userVm.getName());
-
-        userVmResponse.setDisplayName(userVm.getDisplayName());
-
-        if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
-            userVmResponse.setProjectId(userVm.getProjectUuid());
-            userVmResponse.setProjectName(userVm.getProjectName());
-        } else {
-            userVmResponse.setAccountName(userVm.getAccountName());
-        }
-
-        userVmResponse.setDomainId(userVm.getDomainUuid());
-        userVmResponse.setDomainName(userVm.getDomainName());
-
-        userVmResponse.setCreated(userVm.getCreated());
-
-        if (userVm.getState() != null) {
-            userVmResponse.setState(userVm.getState().toString());
-        }
-        userVmResponse.setHaEnable(userVm.isHaEnabled());
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.group)) {
-            userVmResponse.setGroupId(userVm.getInstanceGroupUuid());
-            userVmResponse.setGroup(userVm.getInstanceGroupName());
-        }
-        userVmResponse.setZoneId(userVm.getDataCenterUuid());
-        userVmResponse.setZoneName(userVm.getDataCenterName());
-        if ((caller == null) || (caller.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
-            userVmResponse.setInstanceName(userVm.getInstanceName());
-            userVmResponse.setHostId(userVm.getHostUuid());
-            userVmResponse.setHostName(userVm.getHostName());
-        }
-
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.tmpl)) {
-            userVmResponse.setTemplateId(userVm.getTemplateUuid());
-            userVmResponse.setTemplateName(userVm.getTemplateName());
-            userVmResponse.setTemplateDisplayText(userVm.getTemplateDisplayText());
-            userVmResponse.setPasswordEnabled(userVm.isPasswordEnabled());
-        }
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)) {
-            userVmResponse.setIsoId(userVm.getIsoUuid());
-            userVmResponse.setIsoName(userVm.getIsoName());
-            userVmResponse.setIsoDisplayText(userVm.getIsoDisplayText());
-        }
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff)) {
-            userVmResponse.setServiceOfferingId(userVm.getServiceOfferingUuid());
-            userVmResponse.setServiceOfferingName(userVm.getServiceOfferingName());
-            userVmResponse.setCpuNumber(userVm.getCpu());
-            userVmResponse.setCpuSpeed(userVm.getSpeed());
-            userVmResponse.setMemory(userVm.getRamSize());
-        }
-        userVmResponse.setGuestOsId(userVm.getGuestOsUuid());
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.volume)) {
-            userVmResponse.setRootDeviceId(userVm.getVolumeDeviceId());
-            if (userVm.getVolumeType() != null) {
-                userVmResponse.setRootDeviceType(userVm.getVolumeType().toString());
-            }
-        }
-        userVmResponse.setPassword(userVm.getPassword());
-        userVmResponse.setJobUuid(userVm.getJobUuid());
-        userVmResponse.setJobStatus(userVm.getJobStatus());
-        //userVmResponse.setForVirtualNetwork(userVm.getForVirtualNetwork());
-
-        userVmResponse.setPublicIpId(userVm.getPublicIpUuid());
-        userVmResponse.setPublicIp(userVm.getPublicIpAddress());
-        userVmResponse.setKeyPairName(userVm.getKeypairName());
-
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
-            DecimalFormat decimalFormat = new DecimalFormat("#.##");
-            // stats calculation
-            String cpuUsed = null;
-            VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
-            if (vmStats != null) {
-                float cpuUtil = (float) vmStats.getCPUUtilization();
-                cpuUsed = decimalFormat.format(cpuUtil) + "%";
-                userVmResponse.setCpuUsed(cpuUsed);
-
-                Double networkKbRead = Double.valueOf(vmStats.getNetworkReadKBs());
-                userVmResponse.setNetworkKbsRead(networkKbRead.longValue());
-
-                Double networkKbWrite = Double.valueOf(vmStats.getNetworkWriteKBs());
-                userVmResponse.setNetworkKbsWrite(networkKbWrite.longValue());
-            }
-        }
-
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)) {
-            Long securityGroupId = userVm.getSecurityGroupId();
-            if (securityGroupId != null && securityGroupId.longValue() != 0) {
-                SecurityGroupResponse resp = new SecurityGroupResponse();
-                resp.setId(userVm.getSecurityGroupUuid());
-                resp.setName(userVm.getSecurityGroupName());
-                resp.setDescription(userVm.getSecurityGroupDescription());
-                resp.setObjectName("securitygroup");
-                if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
-                    resp.setProjectId(userVm.getProjectUuid());
-                    resp.setProjectName(userVm.getProjectName());
-                } else {
-                    resp.setAccountName(userVm.getAccountName());
-                }
-                userVmResponse.addSecurityGroup(resp);
-            }
-        }
-
-        if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)) {
-            long nic_id = userVm.getNicId();
-            if (nic_id > 0) {
-                NicResponse nicResponse = new NicResponse();
-                nicResponse.setId(userVm.getNicUuid());
-                nicResponse.setIpaddress(userVm.getIpAddress());
-                nicResponse.setGateway(userVm.getGateway());
-                nicResponse.setNetmask(userVm.getNetmask());
-                nicResponse.setNetworkid(userVm.getNetworkUuid());
-                nicResponse.setMacAddress(userVm.getMacAddress());
-                if (userVm.getBroadcastUri() != null) {
-                    nicResponse.setBroadcastUri(userVm.getBroadcastUri().toString());
-                }
-                if (userVm.getIsolationUri() != null) {
-                    nicResponse.setIsolationUri(userVm.getIsolationUri().toString());
-                }
-                if (userVm.getTrafficType() != null) {
-                    nicResponse.setTrafficType(userVm.getTrafficType().toString());
-                }
-                if (userVm.getGuestType() != null) {
-                    nicResponse.setType(userVm.getGuestType().toString());
-                }
-                nicResponse.setIsDefault(userVm.isDefaultNic());
-                nicResponse.setObjectName("nic");
-                userVmResponse.addNic(nicResponse);
-            }
-        }
-
-        // update tag information
-        long tag_id = userVm.getTagId();
-        if (tag_id > 0) {
-            ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
-            if ( vtag != null ){
-                userVmResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
-            }
-        }
-        userVmResponse.setObjectName(objectName);
-
-        return userVmResponse;
-       }
-
-    public UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo) {
-        Long securityGroupId = uvo.getSecurityGroupId();
-        if (securityGroupId != null && securityGroupId.longValue() != 0) {
-            SecurityGroupResponse resp = new SecurityGroupResponse();
-            resp.setId(uvo.getSecurityGroupUuid());
-            resp.setName(uvo.getSecurityGroupName());
-            resp.setDescription(uvo.getSecurityGroupDescription());
-            resp.setObjectName("securitygroup");
-            if (uvo.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
-                resp.setProjectId(uvo.getProjectUuid());
-                resp.setProjectName(uvo.getProjectName());
-            } else {
-                resp.setAccountName(uvo.getAccountName());
-            }
-            userVmData.addSecurityGroup(resp);
-        }
-
-        long nic_id = uvo.getNicId();
-        if (nic_id > 0) {
-            NicResponse nicResponse = new NicResponse();
-            nicResponse.setId(uvo.getNicUuid());
-            nicResponse.setIpaddress(uvo.getIpAddress());
-            nicResponse.setGateway(uvo.getGateway());
-            nicResponse.setNetmask(uvo.getNetmask());
-            nicResponse.setNetworkid(uvo.getNetworkUuid());
-            nicResponse.setMacAddress(uvo.getMacAddress());
-            if (uvo.getBroadcastUri() != null) {
-                nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
-            }
-            if (uvo.getIsolationUri() != null) {
-                nicResponse.setIsolationUri(uvo.getIsolationUri().toString());
-            }
-            if (uvo.getTrafficType() != null) {
-                nicResponse.setTrafficType(uvo.getTrafficType().toString());
-            }
-            if (uvo.getGuestType() != null) {
-                nicResponse.setType(uvo.getGuestType().toString());
-            }
-            nicResponse.setIsDefault(uvo.isDefaultNic());
-            nicResponse.setObjectName("nic");
-            userVmData.addNic(nicResponse);
-        }
-
-        long tag_id = uvo.getTagId();
-        if (tag_id > 0) {
-            ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
-            if ( vtag != null ){
-                userVmData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
-            }
-        }
-        return userVmData;
-    }
-
-
-    @Override
-    public List<UserVmJoinVO> searchByIds(Long... vmIds) {
-        SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
-        sc.setParameters("idIN", vmIds);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-    @Override
-    public List<UserVmJoinVO> newUserVmView(UserVm... userVms) {
-
-        int curr_index = 0;
-
-        Hashtable<Long, UserVm> userVmDataHash = new Hashtable<Long, UserVm>();
-        for (UserVm vm : userVms){
-            if ( !userVmDataHash.containsKey(vm.getId())){
-                userVmDataHash.put(vm.getId(), vm);
-            }
-        }
-
-        List<UserVmJoinVO> uvList = new ArrayList<UserVmJoinVO>();
-        List<Long> userVmIdList = new ArrayList(userVmDataHash.keySet());
-         if (userVmIdList.size() > VM_DETAILS_BATCH_SIZE) {
-            while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmIdList.size()) {
-                // set current ids
-                Long[] vmIds = new Long[VM_DETAILS_BATCH_SIZE];
-                for (int k = 0, j = curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
-                    vmIds[k] = userVmIdList.get(j);
-                }
-                SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
-                sc.setParameters("idIN", vmIds);
-                List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
-                if (vms != null) {
-                    for (UserVmJoinVO uvm : vms) {
-                        uvList.add(uvm);
-                    }
-                }
-                curr_index += VM_DETAILS_BATCH_SIZE;
-            }
-        }
-
-        if (curr_index < userVmIdList.size()) {
-            int batch_size = (userVmIdList.size() - curr_index);
-            // set the ids value
-            Long[] vmIds = new Long[batch_size];
-            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
-                vmIds[k] = userVmIdList.get(j);
-            }
-            SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
-            sc.setParameters("idIN", vmIds);
-            List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
-            if (vms != null) {
-                for (UserVmJoinVO uvm : vms) {
-                    UserVm vm = userVmDataHash.get(uvm.getId());
-                    assert vm != null : "We should not find details of vm not in the passed UserVm list";
-                    uvList.add(uvm);
-                }
-            }
-        }
-        return uvList;
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/test/com/cloud/network/security/SecurityGroupManagerImpl2Test.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/security/SecurityGroupManagerImpl2Test.java b/server/test/com/cloud/network/security/SecurityGroupManagerImpl2Test.java
index 46b7018..461bde0 100644
--- a/server/test/com/cloud/network/security/SecurityGroupManagerImpl2Test.java
+++ b/server/test/com/cloud/network/security/SecurityGroupManagerImpl2Test.java
@@ -28,13 +28,13 @@ import org.junit.Before;
 import org.junit.Ignore;
 
 import com.cloud.agent.MockAgentManagerImpl;
+import com.cloud.api.query.dao.SecurityGroupJoinDaoImpl;
 import com.cloud.configuration.DefaultInterceptorLibrary;
 import com.cloud.configuration.dao.ConfigurationDaoImpl;
 import com.cloud.domain.dao.DomainDaoImpl;
 import com.cloud.event.dao.UsageEventDaoImpl;
 import com.cloud.network.MockNetworkManagerImpl;
 import com.cloud.network.security.dao.SecurityGroupDaoImpl;
-import com.cloud.network.security.dao.SecurityGroupJoinDaoImpl;
 import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
 import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
 import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/test/com/cloud/projects/MockProjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/projects/MockProjectManagerImpl.java b/server/test/com/cloud/projects/MockProjectManagerImpl.java
index 3911ceb..309fa45 100644
--- a/server/test/com/cloud/projects/MockProjectManagerImpl.java
+++ b/server/test/com/cloud/projects/MockProjectManagerImpl.java
@@ -22,10 +22,10 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
-import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
-import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
-import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
 
+import com.cloud.api.query.vo.ProjectAccountJoinVO;
+import com.cloud.api.query.vo.ProjectInvitationJoinVO;
+import com.cloud.api.query.vo.ProjectJoinVO;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
@@ -109,21 +109,6 @@ public class MockProjectManagerImpl implements ProjectManager, Manager {
         return false;
     }
 
-    @Override
-    public Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccounts(long projectId,
-            String accountName, String role, Long startIndex, Long pageSizeVal) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id,
-            Long projectId, String accountName, Long domainId, String state,
-            boolean activeOnly, Long startIndex, Long pageSizeVal,
-            boolean isRecursive, boolean listAll) {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
     @Override
     public boolean updateInvitation(long projectId, String accountName,
@@ -225,16 +210,16 @@ public class MockProjectManagerImpl implements ProjectManager, Manager {
         return false;
     }
 
-    /* (non-Javadoc)
-     * @see com.cloud.projects.ProjectService#listProjects(java.lang.Long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, java.lang.Long, java.lang.Long, boolean, boolean, java.util.Map)
-     */
+
+
     @Override
-    public Pair<List<ProjectJoinVO>, Integer> listProjects(Long id, String name, String displayText, String state, String accountName, Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll,
-            boolean isRecursive, Map<String, String> tags) {
+    public long getInvitationTimeout() {
         // TODO Auto-generated method stub
-        return null;
+        return 0;
     }
 
+
+
     @Override
     public Project findByProjectAccountIdIncludingRemoved(long projectAccountId) {
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/test/com/cloud/user/MockAccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java
index dbe6169..29c9f6f 100644
--- a/server/test/com/cloud/user/MockAccountManagerImpl.java
+++ b/server/test/com/cloud/user/MockAccountManagerImpl.java
@@ -24,14 +24,15 @@ import javax.naming.ConfigurationException;
 
 import com.cloud.acl.ControlledEntity;
 import com.cloud.acl.SecurityChecker.AccessType;
+import com.cloud.api.query.vo.ControlledViewEntity;
+import com.cloud.api.query.vo.UserAccountJoinVO;
+
 import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
 import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
 import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
 import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
 import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
 import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
-import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
-import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
 
 import com.cloud.domain.Domain;
 import com.cloud.exception.ConcurrentOperationException;
@@ -306,11 +307,6 @@ public class MockAccountManagerImpl implements Manager, AccountManager, AccountS
         return null;
     }
 
-    @Override
-    public Pair<List<UserAccountJoinVO>, Integer> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
 	@Override
 	public boolean enableAccount(long accountId) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/test/com/cloud/vm/MockUserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java
index 08e7ee2..27508b1 100644
--- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java
+++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java
@@ -28,6 +28,8 @@ import com.cloud.agent.api.VmStatsEntry;
 import com.cloud.agent.api.to.NicTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.agent.manager.Commands;
+import com.cloud.api.query.vo.UserVmJoinVO;
+
 import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
 import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
 import org.apache.cloudstack.api.command.user.vm.*;
@@ -44,7 +46,6 @@ import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
 import org.apache.cloudstack.api.command.user.vm.StartVMCmd;
 import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
 import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
-import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
 import com.cloud.dc.DataCenter;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
@@ -401,11 +402,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
 		return null;
 	}
 
-    @Override
-    public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(ListVMsCmd cmd) {
-        // TODO Auto-generated method stub
-        return null;
-    }
+
 
     @Override
     public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
@@ -416,7 +413,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
 	@Override
 	public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
 		// TODO Auto-generated method stub
-		
+
 	}
 
     /* (non-Javadoc)


Mime
View raw message