cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [37/50] git commit: ConsoleProxyManagerImpl: Get rid of IdentityDao
Date Mon, 14 Jan 2013 16:15:58 GMT
ConsoleProxyManagerImpl: Get rid of IdentityDao

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>


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

Branch: refs/heads/cloud-agent-with-openvswitch
Commit: 83e7214b02adf1facc8aed0f61206248de698c42
Parents: 8eba0ee
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Fri Jan 11 16:45:35 2013 -0800
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Fri Jan 11 18:44:20 2013 -0800

----------------------------------------------------------------------
 .../consoleproxy/ConsoleProxyManagerImpl.java      |   35 ++++++--------
 1 files changed, 15 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/83e7214b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 4994f4f..5bc5d27 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -31,6 +31,8 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 import javax.persistence.Table;
 
+import com.cloud.offering.DiskOffering;
+import com.cloud.storage.dao.DiskOfferingDao;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
@@ -107,7 +109,6 @@ import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.servlet.ConsoleProxyServlet;
-import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.StoragePoolVO;
@@ -138,7 +139,6 @@ import com.cloud.utils.db.Transaction;
 import com.cloud.utils.events.SubscriptionMgr;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
-import com.cloud.uuididentity.dao.IdentityDao;
 import com.cloud.vm.ConsoleProxyVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
@@ -216,6 +216,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
     @Inject
     ServiceOfferingDao _offeringDao;
     @Inject
+    DiskOfferingDao _diskOfferingDao;
+    @Inject
     NetworkOfferingDao _networkOfferingDao;
     @Inject
     StoragePoolDao _storagePoolDao;
@@ -224,8 +226,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
     @Inject
     ResourceManager _resourceMgr;
     @Inject
-    IdentityDao _identityDao;
-    @Inject
     NetworkDao _networkDao;
     @Inject
     RulesManager _rulesMgr;
@@ -928,14 +928,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager,
ConsoleProx
             return new ConsoleAccessAuthenticationAnswer(cmd, false);
         }
 
-        vmId = _identityDao.getIdentityId("vm_instance", cmd.getVmId());
-        if (vmId == null) {
-            s_logger.error("Invalid vm id " + cmd.getVmId() + " sent from console access
authentication");
-            return new ConsoleAccessAuthenticationAnswer(cmd, false);
+        VirtualMachine vm = _instanceDao.findByUuid(cmd.getVmId());
+        if (vm == null) {
+            vm = _instanceDao.findById(Long.parseLong(cmd.getVmId()));
         }
-
-        VMInstanceVO vm = _instanceDao.findById(vmId);
         if (vm == null) {
+            s_logger.error("Invalid vm id " + cmd.getVmId() + " sent from console access
authentication");
             return new ConsoleAccessAuthenticationAnswer(cmd, false);
         }
 
@@ -1525,16 +1523,13 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager,
ConsoleProx
         //check if there is a default service offering configured
         String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());

         if (cpvmSrvcOffIdStr != null) {
-            
-            Long cpvmSrvcOffId = null;
-            try {
-                cpvmSrvcOffId = _identityDao.getIdentityId(DiskOfferingVO.class.getAnnotation(Table.class).name(),cpvmSrvcOffIdStr);
-            } catch (Exception e) {
-                String msg = "Can't find system service offering specified by global config,
uuid=" + cpvmSrvcOffIdStr + " for console proxy vm";
-                s_logger.warn(msg);
-            }
-            if(cpvmSrvcOffId != null){
-                _serviceOffering = _offeringDao.findById(cpvmSrvcOffId);
+            DiskOffering diskOffering = _diskOfferingDao.findByUuid(cpvmSrvcOffIdStr);
+            if (diskOffering == null)
+                diskOffering = _diskOfferingDao.findById(Long.parseLong(cpvmSrvcOffIdStr));
+            if (diskOffering != null) {
+                _serviceOffering = _offeringDao.findById(diskOffering.getId());
+            } else {
+                s_logger.warn("Can't find system service offering specified by global config,
uuid=" + cpvmSrvcOffIdStr + " for console proxy vm");
             }
         } 
 


Mime
View raw message