cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [1/2] git commit: updated refs/heads/object_store to 0cfef3a
Date Wed, 24 Apr 2013 00:52:18 GMT
Updated Branches:
  refs/heads/object_store 7ec0882dc -> 0cfef3aa4


Remove more VMTemplateHostDao references.

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

Branch: refs/heads/object_store
Commit: 7543f314a7c3e0b2492ca5d47c6e075bd5bc4ae2
Parents: 7ec0882
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Apr 23 17:12:21 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Apr 23 17:12:21 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/resource/SimulatorDiscoverer.java    |    3 -
 .../xen/discoverer/XcpServerDiscoverer.java        |  144 +++++++--------
 .../driver/CloudStackImageStoreDriverImpl.java     |   10 +-
 .../datastore/driver/S3ImageStoreDriverImpl.java   |    3 -
 .../driver/SwiftImageStoreDriverImpl.java          |    3 -
 .../allocator/impl/UserConcentratedAllocator.java  |   58 ++++---
 server/src/com/cloud/api/ApiDBUtils.java           |   15 --
 .../consoleproxy/ConsoleProxyManagerImpl.java      |   36 ++---
 .../resourcelimit/ResourceLimitManagerImpl.java    |   12 +-
 .../cloud/storage/upload/UploadMonitorImpl.java    |    5 -
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   19 +-
 11 files changed, 135 insertions(+), 173 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
index a9f6134..4f2be7d 100755
--- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
@@ -52,9 +52,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VMTemplateZoneVO;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
-import org.springframework.stereotype.Component;
 
 @Local(value = Discoverer.class)
 public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
@@ -63,7 +61,6 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
 
     @Inject HostDao _hostDao;
     @Inject VMTemplateDao _vmTemplateDao;
-    @Inject VMTemplateHostDao _vmTemplateHostDao;
     @Inject VMTemplateZoneDao _vmTemplateZoneDao;
     @Inject ClusterDao _clusterDao;
     @Inject AgentManager _agentMgr = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
index 195ab30..83ee150 100755
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
@@ -11,7 +11,7 @@
 // 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 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.hypervisor.xen.discoverer;
@@ -83,7 +83,6 @@ import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.TemplateType;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.user.Account;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.db.SearchCriteria.Op;
@@ -115,14 +114,13 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     @Inject protected AlertManager _alertMgr;
     @Inject protected AgentManager _agentMgr;
     @Inject VMTemplateDao _tmpltDao;
-    @Inject VMTemplateHostDao _vmTemplateHostDao;
     @Inject ResourceManager _resourceMgr;
     @Inject HostPodDao _podDao;
     @Inject DataCenterDao _dcDao;
-    
+
     protected XcpServerDiscoverer() {
     }
-    
+
     void setClusterGuid(ClusterVO cluster, String guid) {
         cluster.setGuid(guid);
         try {
@@ -156,43 +154,43 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
             String msg = "must specify cluster Id when add host";
             s_logger.debug(msg);
             throw new RuntimeException(msg);
-        } 
-        
+        }
+
 		if (podId == null) {
 			String msg = "must specify pod Id when add host";
 			s_logger.debug(msg);
 			throw new RuntimeException(msg);
 		}
-		
+
         ClusterVO cluster = _clusterDao.findById(clusterId);
         if(cluster == null || cluster.getHypervisorType() != HypervisorType.XenServer) {
         	if(s_logger.isInfoEnabled())
                 s_logger.info("invalid cluster id or cluster is not for XenServer hypervisors");
     		return null;
         }
-		
+
         try {
             List<HostVO> eHosts = _resourceMgr.listAllHostsInCluster(clusterId);
             if( eHosts.size() > 0 ) {
             	HostVO eHost = eHosts.get(0);
             	_hostDao.loadDetails(eHost);
-            }         
+            }
             String hostname = url.getHost();
             InetAddress ia = InetAddress.getByName(hostname);
-            String hostIp = ia.getHostAddress(); 
+            String hostIp = ia.getHostAddress();
             Queue<String> pass=new LinkedList<String>();
             pass.add(password);
-            String masterIp = _connPool.getMasterIp(hostIp, username, pass);          
+            String masterIp = _connPool.getMasterIp(hostIp, username, pass);
             conn = _connPool.masterConnect(masterIp, username, pass);
             if (conn == null) {
                 String msg = "Unable to get a connection to " + url;
                 s_logger.debug(msg);
                 throw new DiscoveryException(msg);
             }
-           
+
             Set<Pool> pools = Pool.getAll(conn);
             Pool pool = pools.iterator().next();
-            Pool.Record pr = pool.getRecord(conn);           
+            Pool.Record pr = pool.getRecord(conn);
             String poolUuid = pr.uuid;
             Map<Host, Host.Record> hosts = Host.getAllRecords(conn);
 
@@ -229,22 +227,22 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                 conn.dispose();
                 conn = null;
             }
-            
+
             poolUuid = clu.getGuid();
             _clusterDao.update(clusterId, clu);
-            
-                    
+
+
             if (_checkHvm) {
                 for (Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
                     Host.Record record = entry.getValue();
-                    
+
                     boolean support_hvm = false;
                     for ( String capability : record.capabilities ) {
                         if(capability.contains("hvm")) {
                            support_hvm = true;
                            break;
                         }
-                    } 
+                    }
                     if( !support_hvm ) {
                         String msg = "Unable to add host " + record.address + " because it doesn't support hvm";
                         _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
@@ -257,7 +255,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
             for (Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
                 Host.Record record = entry.getValue();
                 String hostAddr = record.address;
-                
+
                 String prodVersion = record.softwareVersion.get("product_version");
                 if (prodVersion == null) {
                 	prodVersion = record.softwareVersion.get("platform_version");
@@ -267,18 +265,18 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                 if (hostOS == null) {
                 	hostOS = record.softwareVersion.get("platform_name");
                 }
-                
+
                 String hostOSVer = prodVersion;
                 String hostKernelVer = record.softwareVersion.get("linux");
 
                 if (_resourceMgr.findHostByGuid(record.uuid) != null) {
                     s_logger.debug("Skipping " + record.address + " because " + record.uuid + " is already in the database.");
                     continue;
-                }                
+                }
 
                 CitrixResourceBase resource = createServerResource(dcId, podId, record);
                 s_logger.info("Found host " + record.hostname + " ip=" + record.address + " product version=" + prodVersion);
-                            
+
                 Map<String, String> details = new HashMap<String, String>();
                 Map<String, Object> params = new HashMap<String, Object>();
                 details.put("url", hostAddr);
@@ -292,26 +290,26 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                 params.put("cluster", clusterId.toString());
                 params.put("pool", poolUuid);
                 params.put("ipaddress", record.address);
-                
+
                 details.put(HostInfo.HOST_OS, hostOS);
                 details.put(HostInfo.HOST_OS_VERSION, hostOSVer);
                 details.put(HostInfo.HOST_OS_KERNEL_VERSION, hostKernelVer);
                 details.put(HostInfo.HYPERVISOR_VERSION, xenVersion);
-                
+
                 String privateNetworkLabel = _networkMgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.XenServer);
                 String storageNetworkLabel = _networkMgr.getDefaultStorageTrafficLabel(dcId, HypervisorType.XenServer);
-                
+
                 if (!params.containsKey("private.network.device") && privateNetworkLabel != null) {
                     params.put("private.network.device", privateNetworkLabel);
                     details.put("private.network.device", privateNetworkLabel);
                 }
-                
+
                 if (!params.containsKey("storage.network.device1") && storageNetworkLabel != null) {
                     params.put("storage.network.device1", storageNetworkLabel);
                     details.put("storage.network.device1", storageNetworkLabel);
                 }
 
-                
+
                 params.put("wait", Integer.toString(_wait));
                 details.put("wait", Integer.toString(_wait));
                 params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
@@ -327,8 +325,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                 }
                 resource.start();
                 resources.put(resource, details);
-            }                        
-        } catch (SessionAuthenticationFailed e) {       
+            }
+        } catch (SessionAuthenticationFailed e) {
             throw new DiscoveredWithErrorException("Authentication error");
         } catch (XenAPIException e) {
             s_logger.warn("XenAPI exception", e);
@@ -345,27 +343,27 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
         }
         return resources;
     }
-    
+
     String getPoolUuid(Connection conn) throws XenAPIException, XmlRpcException {
         Map<Pool, Pool.Record> pools = Pool.getAllRecords(conn);
         assert pools.size() == 1 : "Pools size is " + pools.size();
         return pools.values().iterator().next().uuid;
     }
-    
+
     protected void addSamePool(Connection conn, Map<CitrixResourceBase, Map<String, String>> resources) throws XenAPIException, XmlRpcException {
         Map<Pool, Pool.Record> hps = Pool.getAllRecords(conn);
         assert (hps.size() == 1) : "How can it be more than one but it's actually " + hps.size();
-        
+
         // This is the pool.
         String poolUuid = hps.values().iterator().next().uuid;
-        
+
         for (Map<String, String> details : resources.values()) {
             details.put("pool", poolUuid);
         }
     }
-    
+
     protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId) throws XenAPIException, XmlRpcException, DiscoveryException {
-        
+
         List<HostVO> hosts;
         hosts = _resourceMgr.listAllHostsInCluster(clusterId);
 
@@ -400,19 +398,19 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                 hostConn = null;
             }
         }
-        
+
         if (masterIp == null) {
             s_logger.warn("Unable to reach the pool master of the existing cluster");
             throw new CloudRuntimeException("Unable to reach the pool master of the existing cluster");
         }
-        
+
         if( !_connPool.joinPool(conn, hostIp, masterIp, username, pass) ){
             s_logger.warn("Unable to join the pool");
             throw new DiscoveryException("Unable to join the pool");
-        }   
+        }
         return true;
     }
-    
+
     protected CitrixResourceBase createServerResource(long dcId, Long podId, Host.Record record) {
     	String prodBrand = record.softwareVersion.get("product_brand");
     	if (prodBrand == null) {
@@ -430,7 +428,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
         if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") ||  prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6")))
             return new XcpServerResource();
 
-    	if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) 
+    	if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0"))
     		return new XenServer56Resource();
 
     	if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.0"))
@@ -438,7 +436,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
 
     	if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2"))
     		return new XenServer602Resource();
-    	
+
         if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0"))
             return new XenServer610Resource();
 
@@ -450,67 +448,67 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     			return new XenServer56FP1Resource();
     		}
     	}
-    	
+
     	if (prodBrand.equals("XCP_Kronos")) {
     		return new XcpOssResource();
     	}
-    	
+
         String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6,  XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion;
     			_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
     	s_logger.debug(msg);
     	throw new RuntimeException(msg);
 
     }
-    
-    protected void serverConfig() {      
+
+    protected void serverConfig() {
         String value = _params.get(Config.XenSetupMultipath.key());
         _setupMultipath = Boolean.parseBoolean(value);
     }
-    
+
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         super.configure(name, params);
         serverConfig();
-        
+
         _publicNic = _params.get(Config.XenPublicNetwork.key());
         _privateNic = _params.get(Config.XenPrivateNetwork.key());
-        
+
         _storageNic1 = _params.get(Config.XenStorageNetwork1.key());
         _storageNic2 = _params.get(Config.XenStorageNetwork2.key());
-        
+
         _guestNic = _params.get(Config.XenGuestNetwork.key());
-               
+
         String value = _params.get(Config.XapiWait.toString());
         _wait = NumbersUtil.parseInt(value, Integer.parseInt(Config.XapiWait.getDefaultValue()));
-        
+
         _instance = _params.get(Config.InstanceName.key());
-        
+
         value = _params.get(Config.XenSetupMultipath.key());
         Boolean.parseBoolean(value);
 
         value = _params.get("xen.check.hvm");
         _checkHvm = false;
         _connPool = XenServerConnectionPool.getInstance();
-        
+
         _agentMgr.registerForHostEvents(this, true, false, true);
-        
+
         createXsToolsISO();
         _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
         return true;
     }
-    
+
     @Override
 	public boolean matchHypervisor(String hypervisor) {
     	if(hypervisor == null)
     		return true;
     	return Hypervisor.HypervisorType.XenServer.toString().equalsIgnoreCase(hypervisor);
     }
-    
+
     @Override
 	public Hypervisor.HypervisorType getHypervisorType() {
     	return Hypervisor.HypervisorType.XenServer;
     }
-    
+
     @Override
     public void postDiscovery(List<HostVO> hosts, long msId)  throws DiscoveryException{
         //do nothing
@@ -535,7 +533,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     public boolean processCommands(long agentId, long seq, Command[] commands) {
         return false;
     }
-  
+
     private void createXsToolsISO() {
         String isoName = "xs-tools.iso";
         VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
@@ -558,17 +556,17 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     public void processConnect(com.cloud.host.Host agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
         if (!(cmd instanceof StartupRoutingCommand )) {
             return;
-        }       
+        }
         long agentId = agent.getId();
-        
+
         StartupRoutingCommand startup = (StartupRoutingCommand)cmd;
         if (startup.getHypervisorType() != HypervisorType.XenServer) {
             s_logger.debug("Not XenServer so moving on.");
             return;
         }
-        
+
         HostVO host = _hostDao.findById(agentId);
-        
+
         ClusterVO cluster = _clusterDao.findById(host.getClusterId());
         if ( cluster.getGuid() == null) {
             cluster.setGuid(startup.getPool());
@@ -582,7 +580,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
         Map<String, String> details = startup.getHostDetails();
         String prodBrand = details.get("product_brand").trim();
         String prodVersion = details.get("product_version").trim();
-        
+
         if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100")  || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6"))) {
             resource = XcpServerResource.class.getName();
         } else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) {
@@ -603,7 +601,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
         } else if (prodBrand.equals("XCP_Kronos")) {
         	resource = XcpOssResource.class.getName();
         }
-        
+
         if( resource == null ){
             String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion;
             s_logger.debug(msg);
@@ -617,13 +615,13 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
             _hostDao.update(agentId, host);
             throw new HypervisorVersionChangedException(msg);
         }
-        
-        
+
+
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Setting up host " + agentId);
         }
         HostEnvironment env = new HostEnvironment();
-        
+
         SetupCommand setup = new SetupCommand(env);
         if (_setupMultipath) {
             setup.setMultipathOn();
@@ -631,7 +629,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
         if (!host.isSetup()) {
             setup.setNeedSetup(true);
         }
-        
+
         try {
             SetupAnswer answer = (SetupAnswer)_agentMgr.send(agentId, setup);
             if (answer != null && answer.getResult()) {
@@ -699,7 +697,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
 		if (host.getType() != com.cloud.host.Host.Type.Routing || host.getHypervisorType() != HypervisorType.XenServer) {
 			return null;
 		}
-		
+
 		_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
 		if (host.getClusterId() != null) {
 			List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(com.cloud.host.Host.Type.Routing, host.getClusterId(), host.getPodId(), host.getDataCenterId());
@@ -708,7 +706,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
 				if (thost.getId() == host.getId()) {
 					continue;
 				}
-				
+
 				long thostId = thost.getId();
 				PoolEjectCommand eject = new PoolEjectCommand(host.getGuid());
 				Answer answer = _agentMgr.easySend(thostId, eject);
@@ -728,10 +726,10 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
 				_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to eject host " + host.getGuid(), msg);
 			}
 		}
-		
+
 		return new DeleteHostAnswer(true);
     }
-	
+
     @Override
     public boolean stop() {
     	_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
index 4debdc3..aca8afc 100644
--- a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
@@ -33,7 +33,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.framework.async.AsyncRpcConext;
@@ -42,7 +41,6 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.image.ImageStoreDriver;
 import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
 import org.apache.cloudstack.storage.image.store.TemplateObject;
-import org.apache.cloudstack.storage.to.ImageStoreTO;
 import org.apache.cloudstack.storage.volume.VolumeObject;
 import org.apache.log4j.Logger;
 
@@ -56,7 +54,6 @@ import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.NfsTO;
 import com.cloud.agent.api.to.S3TO;
 import com.cloud.agent.api.to.SwiftTO;
-import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.event.EventTypes;
 import com.cloud.event.UsageEventUtils;
 import com.cloud.host.HostVO;
@@ -64,9 +61,7 @@ import com.cloud.host.dao.HostDao;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.RegisterVolumePayload;
 import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.storage.SnapshotVO;
-import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateStorageResourceAssoc;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VMTemplateZoneVO;
@@ -74,7 +69,6 @@ import com.cloud.storage.VolumeHostVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.dao.VolumeHostDao;
@@ -97,8 +91,6 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
     @Inject
     VMTemplateDao templateDao;
     @Inject DownloadMonitor _downloadMonitor;
-    @Inject
-    VMTemplateHostDao _vmTemplateHostDao;
     @Inject VolumeDao volumeDao;
     @Inject VolumeHostDao volumeHostDao;
     @Inject HostDao hostDao;
@@ -176,7 +168,7 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
         		AsyncCallbackDispatcher.create(this);
         caller.setContext(context);
         caller.setCallback(caller.getTarget().createAsyncCallback(null, null));
-        
+
 
         if (data.getType() == DataObjectType.TEMPLATE) {
             TemplateObject tData = (TemplateObject)data;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
index 366d2e5..c7d2475 100644
--- a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
@@ -67,7 +67,6 @@ import com.cloud.storage.VolumeHostVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.dao.VolumeHostDao;
@@ -91,8 +90,6 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
     VMTemplateDao templateDao;
     @Inject DownloadMonitor _downloadMonitor;
     @Inject
-    VMTemplateHostDao _vmTemplateHostDao;
-    @Inject
     ImageStoreDetailsDao _imageStoreDetailsDao;
     @Inject VolumeDao volumeDao;
     @Inject VolumeHostDao volumeHostDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
index 1493616..4c664d9 100644
--- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
@@ -67,7 +67,6 @@ import com.cloud.storage.VolumeHostVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.dao.VolumeHostDao;
@@ -91,8 +90,6 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
     VMTemplateDao templateDao;
     @Inject DownloadMonitor _downloadMonitor;
     @Inject
-    VMTemplateHostDao _vmTemplateHostDao;
-    @Inject
     ImageStoreDetailsDao _imageStoreDetailsDao;
     @Inject VolumeDao volumeDao;
     @Inject VolumeHostDao volumeHostDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
index 29e1be9..af4e411 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
@@ -70,8 +70,6 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
     @Inject
     HostPodDao _podDao;
     @Inject
-    VMTemplateHostDao _templateHostDao;
-    @Inject
     VMTemplatePoolDao _templatePoolDao;
     @Inject
     ServiceOfferingDao _offeringDao;
@@ -87,7 +85,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
     private int _secondsToSkipDestroyedVMs = 0;
 
     @Override
-    public Pair<HostPodVO, Long> allocateTo(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO zone, long accountId, Set<Long> avoids) {
+    public Pair<HostPodVO, Long> allocateTo(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO zone, long accountId,
+            Set<Long> avoids) {
         long zoneId = zone.getId();
         List<HostPodVO> podsInZone = _podDao.listByDataCenterId(zoneId);
 
@@ -107,23 +106,28 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
                 }
 
                 if (offering != null) {
-                    // test for enough memory in the pod (make sure to check for enough memory for the service offering, plus
+                    // test for enough memory in the pod (make sure to check for
+                    // enough memory for the service offering, plus
                     // some extra padding for xen overhead
                     long[] hostCandiates = new long[1];
-                    boolean enoughCapacity = dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getRamSize()) * 1024L * 1024L, CapacityVO.CAPACITY_TYPE_MEMORY, hostCandiates);
+                    boolean enoughCapacity = dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getRamSize()) * 1024L * 1024L,
+                            CapacityVO.CAPACITY_TYPE_MEMORY, hostCandiates);
 
                     if (!enoughCapacity) {
                         if (s_logger.isDebugEnabled()) {
-                            s_logger.debug("Not enough RAM available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")");
+                            s_logger.debug("Not enough RAM available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: "
+                                    + podId + ")");
                         }
                         continue;
                     }
 
                     // test for enough CPU in the pod
-                    enoughCapacity = dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getCpu() * offering.getSpeed()), CapacityVO.CAPACITY_TYPE_CPU, hostCandiates);
+                    enoughCapacity = dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getCpu() * offering.getSpeed()),
+                            CapacityVO.CAPACITY_TYPE_CPU, hostCandiates);
                     if (!enoughCapacity) {
                         if (s_logger.isDebugEnabled()) {
-                            s_logger.debug("Not enough cpu available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")");
+                            s_logger.debug("Not enough cpu available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: "
+                                    + podId + ")");
                         }
                         continue;
                     }
@@ -207,7 +211,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
         }
 
         if (vm.getState() == State.Stopped || vm.getState() == State.Destroyed) {
-            // for Stopped/Destroyed VMs, we will skip counting it if it hasn't been used for a while
+            // for Stopped/Destroyed VMs, we will skip counting it if it hasn't
+            // been used for a while
             int secondsToSkipVMs = _secondsToSkipStoppedVMs;
 
             if (vm.getState() == State.Destroyed) {
@@ -217,8 +222,9 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
             long millisecondsSinceLastUpdate = DateUtil.currentGMTTime().getTime() - vm.getUpdateTime().getTime();
             if (millisecondsSinceLastUpdate > secondsToSkipVMs * 1000L) {
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Skip counting " + vm.getState().toString() + " vm " + vm.getInstanceName() + " in capacity allocation as it has been " + vm.getState().toString().toLowerCase()
-                            + " for " + millisecondsSinceLastUpdate / 60000 + " minutes");
+                    s_logger.debug("Skip counting " + vm.getState().toString() + " vm " + vm.getInstanceName()
+                            + " in capacity allocation as it has been " + vm.getState().toString().toLowerCase() + " for "
+                            + millisecondsSinceLastUpdate / 60000 + " minutes");
                 }
                 return true;
             }
@@ -228,11 +234,12 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
     }
 
     /**
-     * 
+     *
      * @param hostId
      *            Host id to calculate against
      * @param capacityType
-     *            CapacityVO.CAPACITY_TYPE_MEMORY or CapacityVO.CAPACITY_TYPE_CPU
+     *            CapacityVO.CAPACITY_TYPE_MEMORY or
+     *            CapacityVO.CAPACITY_TYPE_CPU
      * @return
      */
     private long calcHostAllocatedCpuMemoryCapacity(long hostId, short capacityType) {
@@ -253,21 +260,23 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
                 if (userVm == null) {
                     continue;
                 }
-            } 
-            
+            }
+
             so = _offeringDao.findById(vm.getServiceOfferingId());
 
             if (capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
                 usedCapacity += so.getRamSize() * 1024L * 1024L;
 
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId + ", currently counted: " + usedCapacity + " Bytes");
+                    s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId
+                            + ", currently counted: " + usedCapacity + " Bytes");
                 }
             } else if (capacityType == CapacityVO.CAPACITY_TYPE_CPU) {
                 usedCapacity += so.getCpu() * so.getSpeed();
 
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed() + ", currently counted: " + usedCapacity + " Bytes");
+                    s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed()
+                            + ", currently counted: " + usedCapacity + " Bytes");
                 }
             }
         }
@@ -281,7 +290,7 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
          * List<VMTemplateHostVO> thvoList = _templateHostDao.listByTemplateStatus(templateId, dcId, podId, Status.DOWNLOADED);
          * List<VMTemplateStoragePoolVO> tpvoList = _templatePoolDao.listByTemplateStatus(templateId, dcId, podId,
          * Status.DOWNLOADED);
-         * 
+         *
          * if (thvoList != null && thvoList.size() > 0) { if (s_logger.isDebugEnabled()) { s_logger.debug("Found " +
          * thvoList.size() + " storage hosts in pod " + podId + " with template " + templateId); } return true; } else if
          * (tpvoList != null && tpvoList.size() > 0) { if (s_logger.isDebugEnabled()) { s_logger.debug("Found " +
@@ -304,7 +313,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         Map<String, String> configs = _configDao.getConfiguration("management-server", params);
         String stoppedValue = configs.get("vm.resource.release.interval");
-        // String destroyedValue = configs.get("capacity.skipcounting.destroyed.hours");
+        // String destroyedValue =
+        // configs.get("capacity.skipcounting.destroyed.hours");
         String destroyedValue = null;
         _secondsToSkipStoppedVMs = NumbersUtil.parseInt(stoppedValue, 86400);
         _secondsToSkipDestroyedVMs = NumbersUtil.parseInt(destroyedValue, 0);
@@ -312,19 +322,19 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
         /*
          * ComponentLocator locator = ComponentLocator.getCurrentLocator(); _vmDao = locator.getDao(UserVmDao.class); if (_vmDao
          * == null) { throw new ConfigurationException("Unable to find UserVMDao."); }
-         * 
+         *
          * _volumeDao = locator.getDao(VolumeDao.class); if (_volumeDao == null) { throw new
          * ConfigurationException("Unable to find VolumeDao."); }
-         * 
+         *
          * _templateHostDao = locator.getDao(VMTemplateHostDao.class); if (_templateHostDao == null) { throw new
          * ConfigurationException("Unable to get template host dao."); }
-         * 
+         *
          * _templatePoolDao = locator.getDao(VMTemplatePoolDao.class); if (_templatePoolDao == null) { throw new
          * ConfigurationException("Unable to get template pool dao."); }
-         * 
+         *
          * _podDao = locator.getDao(HostPodDao.class); if (_podDao == null) { throw new
          * ConfigurationException("Unable to find HostPodDao."); }
-         * 
+         *
          * _capacityDao = locator.getDao(CapacityDao.class); if (_capacityDao == null) { throw new
          * ConfigurationException("Unable to retrieve " + CapacityDao.class); }
          */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 41082b7..ecac9dd 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -320,7 +320,6 @@ public class ApiDBUtils {
     static PrimaryDataStoreDao _storagePoolDao;
     static VMTemplateDao _templateDao;
     static VMTemplateDetailsDao _templateDetailsDao;
-    static VMTemplateHostDao _templateHostDao;
     static VMTemplateSwiftDao _templateSwiftDao;
     static VMTemplateS3Dao _templateS3Dao;
     static UploadDao _uploadDao;
@@ -426,7 +425,6 @@ public class ApiDBUtils {
     @Inject private PrimaryDataStoreDao storagePoolDao;
     @Inject private VMTemplateDao templateDao;
     @Inject private VMTemplateDetailsDao templateDetailsDao;
-    @Inject private VMTemplateHostDao templateHostDao;
     @Inject private VMTemplateSwiftDao templateSwiftDao;
     @Inject private VMTemplateS3Dao templateS3Dao;
     @Inject private UploadDao uploadDao;
@@ -530,7 +528,6 @@ public class ApiDBUtils {
         _storagePoolDao = storagePoolDao;
         _templateDao = templateDao;
         _templateDetailsDao = templateDetailsDao;
-        _templateHostDao = templateHostDao;
         _templateSwiftDao = templateSwiftDao;
         _templateS3Dao = templateS3Dao;
         _uploadDao = uploadDao;
@@ -933,18 +930,6 @@ public class ApiDBUtils {
         return _storageMgr.getHypervisorTypeFromFormat(format);
     }
 
-    public static List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId, boolean readyOnly) {
-        if (zoneId != null) {
-            VMTemplateVO vmTemplate = findTemplateById(templateId);
-            if (vmTemplate.getHypervisorType() == HypervisorType.BareMetal) {
-                return _templateHostDao.listByTemplateId(templateId);
-            } else {
-                return _templateHostDao.listByZoneTemplate(zoneId, templateId, readyOnly);
-            }
-        } else {
-            return _templateHostDao.listByOnlyTemplateId(templateId);
-        }
-    }
 
     public static List<UserStatisticsVO> listUserStatsBy(Long accountId) {
         return _userStatsDao.listBy(accountId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/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 fa489ff..1687f1b 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.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,
@@ -33,6 +33,8 @@ import javax.naming.ConfigurationException;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
@@ -112,12 +114,10 @@ import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.servlet.ConsoleProxyServlet;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePoolStatus;
-import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.template.TemplateManager;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
@@ -127,7 +127,6 @@ import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
-import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GlobalLock;
@@ -203,7 +202,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
     @Inject
     private VMInstanceDao _instanceDao;
     @Inject
-    private VMTemplateHostDao _vmTemplateHostDao;
+    private TemplateDataStoreDao _vmTemplateStoreDao;
     @Inject
     private AgentManager _agentMgr;
     @Inject
@@ -287,7 +286,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
      * "PWpfKR3ISI5yXB0vRNAL6Vet5zbTcUZhKDVtNSbis3UEsGYH8NorEC2z2cpjGQJANhJi9Ow6c5Mh\n"
      * + "/DURBUn+1l5pyCKrZnDbvaALSLATLvjmFTuGjoHszy2OeKnOZmEqExWnKKE/VYuPyhy6V7i3TwJA\n" +
      * "f8skDgtPK0OsBCa6IljPaHoWBjPc4kFkSTSS1d56hUcWSikTmiuKdLyBb85AADSZYsvHWrte4opN\n" + "dhNukMJuRA==\n";
-     * 
+     *
      * private final String certContent = "-----BEGIN CERTIFICATE-----\n" +
      * "MIIE3jCCA8agAwIBAgIFAqv56tIwDQYJKoZIhvcNAQEFBQAwgcoxCzAJBgNVBAYT\n"
      * + "AlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYD\n" +
@@ -668,7 +667,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
                 if(proxy.getActiveSession() >= _capacityPerProxy){
                     it.remove();
                 }
-            }            
+            }
             if (s_logger.isTraceEnabled()) {
                 s_logger.trace("Running proxy pool size : " + runningList.size());
                 for (ConsoleProxyVO proxy : runningList) {
@@ -961,7 +960,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
             authenticationAnswer.setReauthenticating(true);
 
             s_logger.info("Re-authentication request, ask host " + vm.getHostId() + " for new console info");
-            GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new 
+            GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new
                     GetVncPortCommand(vm.getId(), vm.getInstanceName()));
 
             if (answer != null && answer.getResult()) {
@@ -1175,15 +1174,10 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
         ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId);
         if (zoneHostInfo != null && isZoneHostReady(zoneHostInfo)) {
             VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId);
-            HostVO secondaryStorageHost = this.templateMgr.getSecondaryStorageHost(dataCenterId);
-            boolean templateReady = false;
-
-            if (template != null && secondaryStorageHost != null) {
-                VMTemplateHostVO templateHostRef = _vmTemplateHostDao.findByHostTemplate(secondaryStorageHost.getId(), template.getId());
-                templateReady = (templateHostRef != null) && (templateHostRef.getDownloadState() == Status.DOWNLOADED);
-            }
+            TemplateDataStoreVO templateHostRef = this._vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId,
+                    Status.DOWNLOADED);
 
-            if (templateReady) {
+            if (templateHostRef != null) {
                 List<Pair<Long, Integer>> l = _consoleProxyDao.getDatacenterStoragePoolHostInfo(dataCenterId, _use_lvm);
                 if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {
                     return true;
@@ -1196,11 +1190,9 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
                 if (s_logger.isDebugEnabled()) {
                     if (template == null) {
                         s_logger.debug("Zone host is ready, but console proxy template is null");
-                    } else if (secondaryStorageHost != null) {
-			s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() +  " is not ready on secondary storage: " + secondaryStorageHost.getId());
-		    } else {
-			s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() +  " is not ready on secondary storage.");
-		    }
+                    } else {
+                        s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage.");
+                    }
                 }
             }
         }
@@ -1397,7 +1389,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
             //expunge the vm
             boolean result = _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
             if (result) {
-                HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(), 
+                HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(),
                         Host.Type.ConsoleProxy);
                 if (host != null) {
                     s_logger.debug("Removing host entry for proxy id=" + vmId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index e8805ae..49c3af1 100755
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -30,6 +30,8 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -140,9 +142,9 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
     @Inject
     private ServiceOfferingDao _serviceOfferingDao;
     @Inject
-    private VMTemplateHostDao _vmTemplateHostDao;
+    private TemplateDataStoreDao _vmTemplateStoreDao;
 
-    protected GenericSearchBuilder<VMTemplateHostVO, SumCount> templateSizeSearch;
+    protected GenericSearchBuilder<TemplateDataStoreVO, SumCount> templateSizeSearch;
 
     protected SearchBuilder<ResourceCountVO> ResourceCountSearch;
     ScheduledExecutorService _rcExecutor;
@@ -172,7 +174,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
         ResourceCountSearch.and("domainId", ResourceCountSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
         ResourceCountSearch.done();
 
-        templateSizeSearch = _vmTemplateHostDao.createSearchBuilder(SumCount.class);
+        templateSizeSearch = _vmTemplateStoreDao.createSearchBuilder(SumCount.class);
         templateSizeSearch.select("sum", Func.SUM, templateSizeSearch.entity().getSize());
         templateSizeSearch.and("downloadState", templateSizeSearch.entity().getDownloadState(), Op.EQ);
         templateSizeSearch.and("destroyed", templateSizeSearch.entity().getDestroyed(), Op.EQ);
@@ -198,7 +200,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
             projectResourceLimitMap.put(Resource.ResourceType.memory, Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectMemory.key())));
             projectResourceLimitMap.put(Resource.ResourceType.primary_storage, Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectPrimaryStorage.key())));
             projectResourceLimitMap.put(Resource.ResourceType.secondary_storage, Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectSecondaryStorage.key())));
-    
+
             accountResourceLimitMap.put(Resource.ResourceType.public_ip, Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountPublicIPs.key())));
             accountResourceLimitMap.put(Resource.ResourceType.snapshot, Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountSnapshots.key())));
             accountResourceLimitMap.put(Resource.ResourceType.template, Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountTemplates.key())));
@@ -898,7 +900,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
         sc.setParameters("downloadState", Status.DOWNLOADED);
         sc.setParameters("destroyed", false);
         sc.setJoinParameters("templates", "accountId", accountId);
-        List<SumCount> templates = _vmTemplateHostDao.customSearch(sc, null);
+        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc, null);
         if (templates != null) {
             totalTemplatesSize = templates.get(0).sum;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
index 0495255..3f07cba 100755
--- a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
+++ b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
@@ -47,7 +47,6 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.storage.CreateEntityDownloadURLCommand;
 import com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand;
-import com.cloud.agent.api.storage.ListTemplateAnswer;
 import com.cloud.agent.api.storage.UploadCommand;
 import com.cloud.agent.api.storage.UploadProgressCommand.RequestType;
 import com.cloud.agent.manager.Commands;
@@ -66,12 +65,10 @@ import com.cloud.storage.Upload.Status;
 import com.cloud.storage.Upload.Type;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.UploadVO;
-import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.UploadDao;
 import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.component.ManagerBase;
@@ -93,8 +90,6 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
 	static final Logger s_logger = Logger.getLogger(UploadMonitorImpl.class);
 
     @Inject
-    VMTemplateHostDao _vmTemplateHostDao;
-    @Inject
     UploadDao _uploadDao;
     @Inject
     SecondaryStorageVmDao _secStorageVmDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7543f314/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 24bce8b..f1b32ed 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -173,7 +173,6 @@ import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.dao.VolumeHostDao;
@@ -249,8 +248,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
     @Inject
     protected VMTemplateDetailsDao _templateDetailsDao = null;
     @Inject
-    protected VMTemplateHostDao _templateHostDao = null;
-    @Inject
     protected VMTemplateZoneDao _templateZoneDao = null;
     @Inject
     protected DomainDao _domainDao = null;
@@ -367,7 +364,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
     VpcManager _vpcMgr;
     @Inject
     TemplateManager templateMgr;
-    @Inject 
+    @Inject
     protected GuestOSCategoryDao _guestOSCategoryDao;
     @Inject
     UsageEventDao _usageEventDao;
@@ -682,7 +679,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
 
         try {
             VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
-            status = vmEntity.stop(new Long(userId).toString());            
+            status = vmEntity.stop(new Long(userId).toString());
         } catch (ResourceUnavailableException e) {
             s_logger.debug("Unable to stop due to ", e);
             status = false;
@@ -2032,7 +2029,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
             isSecurityGroupEnabledNetworkUsed = true;
 
         } else {
-            // Verify that all the networks are Shared/Guest; can't create combination of SG enabled and disabled networks 
+            // Verify that all the networks are Shared/Guest; can't create combination of SG enabled and disabled networks
             for (Long networkId : networkIdList) {
                 NetworkVO network = _networkDao.findById(networkId);
 
@@ -2048,7 +2045,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
                     }
 
                     isSecurityGroupEnabledNetworkUsed = true;
-                }            
+                }
 
                 if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) {
                     throw new InvalidParameterValueException("Can specify only Shared Guest networks when" +
@@ -2452,7 +2449,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
                     // * 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="
                                 + _networkModel.getNetwork(ntwkId));
                     }
                 }
@@ -2515,7 +2512,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
         List<String> computeTags = new ArrayList<String>();
         computeTags.add(offering.getHostTag());
 
-        List<String> rootDiskTags =	new ArrayList<String>();    	
+        List<String> rootDiskTags =	new ArrayList<String>();
         rootDiskTags.add(offering.getTags());
 
         if(isIso){
@@ -2834,7 +2831,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
 
         try {
             VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
-            vmEntity.stop(new Long(userId).toString());            
+            vmEntity.stop(new Long(userId).toString());
         } catch (ResourceUnavailableException e) {
             throw new CloudRuntimeException(
                     "Unable to contact the agent to stop the virtual machine "
@@ -3049,7 +3046,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
 
         try {
             VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
-            status = vmEntity.destroy(new Long(userId).toString());    
+            status = vmEntity.destroy(new Long(userId).toString());
         } catch (CloudException e) {
             CloudRuntimeException ex = new CloudRuntimeException(
                     "Unable to destroy with specified vmId", e);


Mime
View raw message