cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [02/93] [abbrv] [partial] merge master
Date Mon, 13 May 2013 15:53:22 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java
new file mode 100644
index 0000000..f55663f
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java
@@ -0,0 +1,357 @@
+// 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.storage.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.Snapshot.Event;
+import com.cloud.storage.Snapshot.State;
+import com.cloud.storage.Snapshot.Type;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.Volume;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.VolumeDaoImpl.SumCount;
+import com.cloud.tags.dao.ResourceTagDao;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.JoinBuilder.JoinType;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.VMInstanceDao;
+
+@Component
+@Local (value={SnapshotDao.class})
+public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements SnapshotDao {
+    public static final Logger s_logger = Logger.getLogger(SnapshotDaoImpl.class.getName());
+    private static final String GET_LAST_SNAPSHOT = "SELECT id FROM snapshots where volume_id = ? AND id != ? AND path IS NOT NULL ORDER BY created DESC";
+    private static final String UPDATE_SNAPSHOT_VERSION = "UPDATE snapshots SET version = ? WHERE volume_id = ? AND version = ?";
+    private static final String GET_SECHOST_ID = "SELECT sechost_id FROM snapshots where volume_id = ? AND backup_snap_id IS NOT NULL AND sechost_id IS NOT NULL LIMIT 1";
+    private static final String UPDATE_SECHOST_ID = "UPDATE snapshots SET sechost_id = ? WHERE data_center_id = ?";
+
+    private SearchBuilder<SnapshotVO> VolumeIdSearch;
+    private SearchBuilder<SnapshotVO> VolumeIdTypeSearch;
+    private SearchBuilder<SnapshotVO> ParentIdSearch;
+    private SearchBuilder<SnapshotVO> backupUuidSearch;
+    private SearchBuilder<SnapshotVO> VolumeIdVersionSearch;
+    private SearchBuilder<SnapshotVO> HostIdSearch;
+    private SearchBuilder<SnapshotVO> AccountIdSearch;
+    private SearchBuilder<SnapshotVO> InstanceIdSearch;
+    private SearchBuilder<SnapshotVO> StatusSearch;
+    private GenericSearchBuilder<SnapshotVO, Long> CountSnapshotsByAccount;
+    private GenericSearchBuilder<SnapshotVO, SumCount> secondaryStorageSearch;
+    @Inject ResourceTagDao _tagsDao;
+    @Inject protected VMInstanceDao _instanceDao;
+    @Inject protected VolumeDao _volumeDao;
+
+    @Override
+    public SnapshotVO findNextSnapshot(long snapshotId) {
+        SearchCriteria<SnapshotVO> sc = ParentIdSearch.create();
+        sc.setParameters("prevSnapshotId", snapshotId);
+        return findOneIncludingRemovedBy(sc);
+    }
+    
+    @Override
+     public List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid) {
+        SearchCriteria<SnapshotVO> sc = backupUuidSearch.create();
+        sc.setParameters("backupUuid", backupUuid);
+        return listBy(sc, null);
+    }
+    
+    @Override
+    public List<SnapshotVO> listByVolumeIdType(long volumeId, Type type ) {
+        return listByVolumeIdType(null, volumeId, type);
+    }
+    
+    
+    @Override
+    public List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version ) {
+        return listByVolumeIdVersion(null, volumeId, version);
+    }
+
+    @Override
+    public List<SnapshotVO> listByVolumeId(long volumeId) {
+        return listByVolumeId(null, volumeId);
+    }
+    
+    @Override
+    public List<SnapshotVO> listByVolumeId(Filter filter, long volumeId ) {
+        SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        return listBy(sc, filter);
+    }
+    
+    @Override
+    public List<SnapshotVO> listByHostId(long hostId) {
+        return listByHostId(null, hostId);
+    }
+    
+    @Override
+    public List<SnapshotVO> listByHostId(Filter filter, long hostId ) {
+        SearchCriteria<SnapshotVO> sc = HostIdSearch.create();
+        sc.setParameters("hostId", hostId);
+        sc.setParameters("status", Snapshot.State.BackedUp);
+        return listBy(sc, filter);
+    }
+        
+    @Override
+    public List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId) {
+        SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        return listIncludingRemovedBy(sc, null);
+    }
+    
+    public List<SnapshotVO> listByVolumeIdType(Filter filter, long volumeId, Type type ) {
+        SearchCriteria<SnapshotVO> sc = VolumeIdTypeSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("type", type.ordinal());
+        return listBy(sc, filter);
+    }
+    
+    public List<SnapshotVO> listByVolumeIdVersion(Filter filter, long volumeId, String version ) {
+        SearchCriteria<SnapshotVO> sc = VolumeIdVersionSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("version", version);
+        return listBy(sc, filter);
+    }
+
+    public SnapshotDaoImpl() {
+    }
+    
+    @PostConstruct
+    protected void init() {
+        VolumeIdSearch = createSearchBuilder();
+        VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdSearch.done();
+        
+        HostIdSearch = createSearchBuilder();
+        HostIdSearch.and("hostId", HostIdSearch.entity().getSecHostId(), SearchCriteria.Op.EQ);
+        HostIdSearch.and("status", HostIdSearch.entity().getState(), SearchCriteria.Op.EQ);
+        HostIdSearch.done();
+        
+        VolumeIdTypeSearch = createSearchBuilder();
+        VolumeIdTypeSearch.and("volumeId", VolumeIdTypeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdTypeSearch.and("type", VolumeIdTypeSearch.entity().getsnapshotType(), SearchCriteria.Op.EQ);
+        VolumeIdTypeSearch.done();
+        
+        VolumeIdVersionSearch = createSearchBuilder();
+        VolumeIdVersionSearch.and("volumeId", VolumeIdVersionSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdVersionSearch.and("version", VolumeIdVersionSearch.entity().getVersion(), SearchCriteria.Op.EQ);
+        VolumeIdVersionSearch.done();
+        
+        ParentIdSearch = createSearchBuilder();
+        ParentIdSearch.and("prevSnapshotId", ParentIdSearch.entity().getPrevSnapshotId(), SearchCriteria.Op.EQ);
+        ParentIdSearch.done();
+        
+        backupUuidSearch = createSearchBuilder();
+        backupUuidSearch.and("backupUuid", backupUuidSearch.entity().getBackupSnapshotId(), SearchCriteria.Op.EQ);
+        backupUuidSearch.done();
+
+        AccountIdSearch = createSearchBuilder();
+        AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        AccountIdSearch.done();
+        
+        StatusSearch = createSearchBuilder();
+        StatusSearch.and("volumeId", StatusSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        StatusSearch.and("status", StatusSearch.entity().getState(), SearchCriteria.Op.IN);
+        StatusSearch.done();
+        
+        CountSnapshotsByAccount = createSearchBuilder(Long.class);
+        CountSnapshotsByAccount.select(null, Func.COUNT, null);        
+        CountSnapshotsByAccount.and("account", CountSnapshotsByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
+        CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
+        CountSnapshotsByAccount.done();
+        
+        InstanceIdSearch = createSearchBuilder();
+        InstanceIdSearch.and("status", InstanceIdSearch.entity().getState(), SearchCriteria.Op.IN);
+
+        SearchBuilder<VMInstanceVO> instanceSearch = _instanceDao.createSearchBuilder();
+        instanceSearch.and("instanceId", instanceSearch.entity().getId(), SearchCriteria.Op.EQ);
+
+        SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
+        volumeSearch.and("state", volumeSearch.entity().getState(), SearchCriteria.Op.EQ);
+        volumeSearch.join("instanceVolumes", instanceSearch, instanceSearch.entity().getId(), volumeSearch.entity().getInstanceId(), JoinType.INNER);
+
+        InstanceIdSearch.join("instanceSnapshots", volumeSearch, volumeSearch.entity().getId(), InstanceIdSearch.entity().getVolumeId(), JoinType.INNER);
+        InstanceIdSearch.done();
+
+        secondaryStorageSearch = createSearchBuilder(SumCount.class);
+        secondaryStorageSearch.select("sum", Func.SUM, secondaryStorageSearch.entity().getSize());
+        secondaryStorageSearch.and("accountId", secondaryStorageSearch.entity().getAccountId(), Op.EQ);
+        secondaryStorageSearch.and("isRemoved", secondaryStorageSearch.entity().getRemoved(), Op.NULL);
+        secondaryStorageSearch.done();
+    }
+
+    @Override
+    public Long getSecHostId(long volumeId) {
+
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        String sql = GET_SECHOST_ID;
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, volumeId);
+            ResultSet rs = pstmt.executeQuery();
+            if (rs.next()) {
+                return rs.getLong(1);
+            }
+        } catch (Exception ex) {
+        }
+        return null;      
+    }
+    @Override
+    public long getLastSnapshot(long volumeId, long snapId) {
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        String sql = GET_LAST_SNAPSHOT;
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, volumeId);
+            pstmt.setLong(2, snapId);
+            ResultSet rs = pstmt.executeQuery();
+            if (rs.next()) {
+                return rs.getLong(1);
+            }
+        } catch (Exception ex) {
+            s_logger.error("error getting last snapshot", ex);
+        }
+        return 0;
+    }
+
+    @Override
+    public long updateSnapshotVersion(long volumeId, String from, String to) {
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        String sql = UPDATE_SNAPSHOT_VERSION;
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setString(1, to);
+            pstmt.setLong(2, volumeId);
+            pstmt.setString(3, from);
+            pstmt.executeUpdate();
+            return 1;
+        } catch (Exception ex) {
+            s_logger.error("error getting last snapshot", ex);
+        }
+        return 0;
+    }
+    
+    @Override
+    public long updateSnapshotSecHost(long dcId, long secHostId) {
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        String sql = UPDATE_SECHOST_ID;
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, secHostId);
+            pstmt.setLong(2, dcId);
+            pstmt.executeUpdate();
+            return 1;
+        } catch (Exception ex) {
+            s_logger.error("error set secondary storage host id", ex);
+        }
+        return 0;
+    }
+
+    @Override
+    public Long countSnapshotsForAccount(long accountId) {
+    	SearchCriteria<Long> sc = CountSnapshotsByAccount.create();
+        sc.setParameters("account", accountId);
+        return customSearch(sc, null).get(0);
+    }
+    
+    @Override
+	public List<SnapshotVO> listByInstanceId(long instanceId, Snapshot.State... status) {
+    	SearchCriteria<SnapshotVO> sc = this.InstanceIdSearch.create();
+    	
+    	if (status != null && status.length != 0) {
+    	    sc.setParameters("status", (Object[])status);
+    	}
+    	
+    	sc.setJoinParameters("instanceSnapshots", "state", Volume.State.Ready);
+    	sc.setJoinParameters("instanceVolumes", "instanceId", instanceId);
+        return listBy(sc, null);
+    }
+    
+    @Override
+    public List<SnapshotVO> listByStatus(long volumeId, Snapshot.State... status) {
+    	SearchCriteria<SnapshotVO> sc = this.StatusSearch.create();
+    	sc.setParameters("volumeId", volumeId);
+    	sc.setParameters("status", (Object[])status);
+    	return listBy(sc, null);
+    }
+    
+    @Override
+    @DB
+    public boolean remove(Long id) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        SnapshotVO entry = findById(id);
+        if (entry != null) {
+            _tagsDao.removeByIdAndType(id, TaggedResourceType.Snapshot);
+        }
+        boolean result = super.remove(id);
+        txn.commit();
+        return result;
+    }
+    
+    @Override
+    public List<SnapshotVO> listAllByStatus(Snapshot.State... status) {
+        SearchCriteria<SnapshotVO> sc = this.StatusSearch.create();
+        sc.setParameters("status", (Object[])status);
+        return listBy(sc, null);
+    }
+
+    @Override
+    public boolean updateState(State currentState, Event event, State nextState, SnapshotVO snapshot, Object data) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        SnapshotVO snapshotVO = (SnapshotVO)snapshot;
+        snapshotVO.setState(nextState);
+        super.update(snapshotVO.getId(), snapshotVO);
+        txn.commit();
+        return true;
+    }
+
+    @Override
+    public long secondaryStorageUsedForAccount(long accountId) {
+        SearchCriteria<SumCount> sc = secondaryStorageSearch.create();
+        sc.setParameters("accountId", accountId);
+        List<SumCount> storageSpace = customSearch(sc, null);
+        if (storageSpace != null) {
+            return storageSpace.get(0).sum;
+        } else {
+            return 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java
new file mode 100644
index 0000000..467d491
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java
@@ -0,0 +1,38 @@
+// 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.storage.dao;
+
+import java.util.List;
+
+import com.cloud.storage.SnapshotPolicyVO;
+import com.cloud.utils.DateUtil.IntervalType;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDao;
+
+/*
+ * Data Access Object for snapshot_policy table
+ */
+public interface SnapshotPolicyDao extends GenericDao<SnapshotPolicyVO, Long> {
+	List<SnapshotPolicyVO> listByVolumeId(long volumeId);
+	List<SnapshotPolicyVO> listByVolumeId(long volumeId, Filter filter);
+    Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId);
+    Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId, Filter filter);
+	SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType);
+    List<SnapshotPolicyVO> listActivePolicies();
+    SnapshotPolicyVO findOneByVolume(long volumeId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
new file mode 100644
index 0000000..3f894a2
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
@@ -0,0 +1,105 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.storage.dao;
+
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.SnapshotPolicyVO;
+import com.cloud.utils.DateUtil.IntervalType;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local (value={SnapshotPolicyDao.class})
+public class SnapshotPolicyDaoImpl extends GenericDaoBase<SnapshotPolicyVO, Long> implements SnapshotPolicyDao {
+	private final SearchBuilder<SnapshotPolicyVO> VolumeIdSearch;
+	private final SearchBuilder<SnapshotPolicyVO> VolumeIdIntervalSearch;
+	private final SearchBuilder<SnapshotPolicyVO> ActivePolicySearch;
+	
+	@Override
+	public SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType) {
+		SearchCriteria<SnapshotPolicyVO> sc = VolumeIdIntervalSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("interval", intvType.ordinal());
+		return findOneBy(sc);
+	}
+	
+   @Override
+    public SnapshotPolicyVO findOneByVolume(long volumeId) {
+        SearchCriteria<SnapshotPolicyVO> sc = VolumeIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("active", true);
+        return findOneBy(sc);
+    }
+	
+	@Override
+	public List<SnapshotPolicyVO> listByVolumeId(long volumeId) {
+		return listByVolumeId(volumeId, null);
+	}
+	
+    @Override
+    public List<SnapshotPolicyVO> listByVolumeId(long volumeId, Filter filter) {
+        SearchCriteria<SnapshotPolicyVO> sc = VolumeIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("active", true);
+        return listBy(sc, filter);
+    }
+	
+    @Override
+    public Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId) {
+        return listAndCountByVolumeId(volumeId, null);
+    }
+
+    @Override
+    public Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId, Filter filter) {
+        SearchCriteria<SnapshotPolicyVO> sc = VolumeIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("active", true);
+        return searchAndCount(sc, filter);
+    }
+
+    protected SnapshotPolicyDaoImpl() {
+        VolumeIdSearch = createSearchBuilder();
+        VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdSearch.and("active", VolumeIdSearch.entity().isActive(), SearchCriteria.Op.EQ);
+        VolumeIdSearch.done();
+        
+        VolumeIdIntervalSearch = createSearchBuilder();
+        VolumeIdIntervalSearch.and("volumeId", VolumeIdIntervalSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdIntervalSearch.and("interval", VolumeIdIntervalSearch.entity().getInterval(), SearchCriteria.Op.EQ);
+        VolumeIdIntervalSearch.done();
+        
+        ActivePolicySearch = createSearchBuilder();
+        ActivePolicySearch.and("active", ActivePolicySearch.entity().isActive(), SearchCriteria.Op.EQ);
+        ActivePolicySearch.done();
+    }
+
+    @Override
+    public List<SnapshotPolicyVO> listActivePolicies() {
+        SearchCriteria<SnapshotPolicyVO> sc = ActivePolicySearch.create();
+        sc.setParameters("active", true);
+        return listIncludingRemovedBy(sc);
+    }	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java
new file mode 100644
index 0000000..0419e28
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java
@@ -0,0 +1,41 @@
+// 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.storage.dao;
+
+
+import java.util.Date;
+import java.util.List;
+import com.cloud.storage.SnapshotPolicyVO;
+import com.cloud.storage.SnapshotScheduleVO;
+import com.cloud.utils.db.GenericDao;
+
+/*
+ * Data Access Object for snapshot_schedule table
+ */
+public interface SnapshotScheduleDao extends GenericDao<SnapshotScheduleVO, Long> {
+
+	List<SnapshotScheduleVO> getCoincidingSnapshotSchedules(long volumeId, Date date);
+
+    List<SnapshotScheduleVO> getSchedulesToExecute(Date currentTimestamp);
+
+    SnapshotScheduleVO getCurrentSchedule(Long volumeId, Long policyId, boolean executing);
+
+    SnapshotScheduleVO findOneByVolume(long volumeId);
+
+    SnapshotScheduleVO findOneByVolumePolicy(long volumeId, long policyId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java
new file mode 100644
index 0000000..c01644e
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java
@@ -0,0 +1,134 @@
+// 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.storage.dao;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.SnapshotScheduleVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local (value={SnapshotScheduleDao.class})
+public class SnapshotScheduleDaoImpl extends GenericDaoBase<SnapshotScheduleVO, Long> implements SnapshotScheduleDao {
+	protected final SearchBuilder<SnapshotScheduleVO> executableSchedulesSearch;
+	protected final SearchBuilder<SnapshotScheduleVO> coincidingSchedulesSearch;
+    private final SearchBuilder<SnapshotScheduleVO> VolumeIdSearch;
+    private final SearchBuilder<SnapshotScheduleVO> VolumeIdPolicyIdSearch;
+	
+	
+	protected SnapshotScheduleDaoImpl() {
+		
+	    executableSchedulesSearch = createSearchBuilder();
+        executableSchedulesSearch.and("scheduledTimestamp", executableSchedulesSearch.entity().getScheduledTimestamp(), SearchCriteria.Op.LT);
+        executableSchedulesSearch.and("asyncJobId", executableSchedulesSearch.entity().getAsyncJobId(), SearchCriteria.Op.NULL);
+        executableSchedulesSearch.done();
+        
+        coincidingSchedulesSearch = createSearchBuilder();
+        coincidingSchedulesSearch.and("volumeId", coincidingSchedulesSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        coincidingSchedulesSearch.and("scheduledTimestamp", coincidingSchedulesSearch.entity().getScheduledTimestamp(), SearchCriteria.Op.LT);
+        coincidingSchedulesSearch.and("asyncJobId", coincidingSchedulesSearch.entity().getAsyncJobId(), SearchCriteria.Op.NULL);
+        coincidingSchedulesSearch.done();
+        
+        VolumeIdSearch = createSearchBuilder();
+        VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdSearch.done();
+        
+        VolumeIdPolicyIdSearch = createSearchBuilder();
+        VolumeIdPolicyIdSearch.and("volumeId", VolumeIdPolicyIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
+        VolumeIdPolicyIdSearch.and("policyId", VolumeIdPolicyIdSearch.entity().getPolicyId(), SearchCriteria.Op.EQ);
+        VolumeIdPolicyIdSearch.done();
+		
+	}
+	
+	/**
+	 * {@inheritDoc} 
+	 */
+	@Override
+	public List<SnapshotScheduleVO> getCoincidingSnapshotSchedules(long volumeId, Date date) {
+		SearchCriteria<SnapshotScheduleVO> sc = coincidingSchedulesSearch.create();
+	    sc.setParameters("volumeId", volumeId);
+	    sc.setParameters("scheduledTimestamp", date);
+	    // Don't return manual snapshots. They will be executed through another code path.
+        sc.addAnd("policyId", SearchCriteria.Op.NEQ, 1L);
+        return listBy(sc);
+	}
+
+	
+    @Override
+    public SnapshotScheduleVO findOneByVolume(long volumeId) {
+        SearchCriteria<SnapshotScheduleVO> sc = VolumeIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        return findOneBy(sc);
+    }
+    
+    
+    @Override
+    public SnapshotScheduleVO findOneByVolumePolicy(long volumeId, long policyId) {
+        SearchCriteria<SnapshotScheduleVO> sc = VolumeIdPolicyIdSearch.create();
+        sc.setParameters("volumeId", volumeId);
+        sc.setParameters("policyId", policyId);
+        return findOneBy(sc);
+    }
+	/**
+     * {@inheritDoc} 
+     */
+    @Override
+    public List<SnapshotScheduleVO> getSchedulesToExecute(Date currentTimestamp) {
+        SearchCriteria<SnapshotScheduleVO> sc = executableSchedulesSearch.create();
+        sc.setParameters("scheduledTimestamp", currentTimestamp);
+        return listBy(sc);
+    }
+    
+    /**
+     * {@inheritDoc} 
+     */
+    @Override
+    public SnapshotScheduleVO getCurrentSchedule(Long volumeId, Long policyId, boolean executing) {
+        assert volumeId != null;
+        SearchCriteria<SnapshotScheduleVO> sc = createSearchCriteria();
+        SearchCriteria.Op op = executing ? SearchCriteria.Op.NNULL : SearchCriteria.Op.NULL;
+        sc.addAnd("volumeId", SearchCriteria.Op.EQ, volumeId);
+        if (policyId != null) {
+            sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId);
+            if (policyId != Snapshot.MANUAL_POLICY_ID) {
+                // manual policies aren't scheduled by the snapshot poller, so don't look for the jobId here
+                sc.addAnd("asyncJobId", op);
+            }
+        } else {
+            sc.addAnd("asyncJobId", op);
+        }
+
+        List<SnapshotScheduleVO> snapshotSchedules = listBy(sc);
+        // This will return only one schedule because of a DB uniqueness constraint.
+        assert (snapshotSchedules.size() <= 1);
+        if (snapshotSchedules.isEmpty()) {
+            return null;
+        }
+        else {
+            return snapshotSchedules.get(0);
+        }
+    }
+    
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
new file mode 100644
index 0000000..38b5253
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
@@ -0,0 +1,85 @@
+// 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.storage.dao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Component
+@Local(value=StoragePoolDetailsDao.class)
+public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailVO, Long> implements StoragePoolDetailsDao {
+    
+    protected final SearchBuilder<StoragePoolDetailVO> PoolSearch;
+    
+    protected StoragePoolDetailsDaoImpl() {
+        super();
+        PoolSearch = createSearchBuilder();
+        PoolSearch.and("pool", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PoolSearch.and("name", PoolSearch.entity().getName(), SearchCriteria.Op.EQ);
+        PoolSearch.done();
+    }
+    
+    @Override
+    public void update(long poolId, Map<String, String> details) {
+        Transaction txn = Transaction.currentTxn();
+        SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create();
+        sc.setParameters("pool", poolId);
+        
+        txn.start();
+        expunge(sc);
+        for (Map.Entry<String, String> entry : details.entrySet()) {
+            StoragePoolDetailVO detail = new StoragePoolDetailVO(poolId, entry.getKey(), entry.getValue());
+            persist(detail);
+        }
+        txn.commit();
+    }
+    
+    @Override
+    public Map<String, String> getDetails(long poolId) {
+    	SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create();
+    	sc.setParameters("pool", poolId);
+    	
+    	List<StoragePoolDetailVO> details = listBy(sc);
+    	Map<String, String> detailsMap = new HashMap<String, String>();
+    	for (StoragePoolDetailVO detail : details) {
+    		detailsMap.put(detail.getName(), detail.getValue());
+    	}
+    	
+    	return detailsMap;
+    }
+
+    @Override
+    public StoragePoolDetailVO findDetail(long poolId, String name) {
+        SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create();
+        sc.setParameters("pool", poolId);
+        sc.setParameters("name", name);
+
+        return findOneIncludingRemovedBy(sc);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDao.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDao.java
new file mode 100644
index 0000000..8dd10a7
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDao.java
@@ -0,0 +1,42 @@
+// 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.storage.dao;
+
+import java.util.List;
+
+import com.cloud.host.Status;
+import com.cloud.storage.StoragePoolHostVO;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+
+public interface StoragePoolHostDao extends GenericDao<StoragePoolHostVO, Long> {
+    public List<StoragePoolHostVO> listByPoolId(long id);
+
+    public List<StoragePoolHostVO> listByHostIdIncludingRemoved(long hostId);
+
+    public StoragePoolHostVO findByPoolHost(long poolId, long hostId);
+
+    List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus);
+
+    List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly);
+
+    public void deletePrimaryRecordsForHost(long hostId);
+
+    public void deleteStoragePoolHostDetails(long hostId, long poolId);
+
+    List<StoragePoolHostVO> listByHostId(long hostId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java
new file mode 100644
index 0000000..4f509d1
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java
@@ -0,0 +1,184 @@
+// 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.storage.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.host.Status;
+import com.cloud.storage.StoragePoolHostVO;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Component
+@Local(value = { StoragePoolHostDao.class })
+public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Long> implements StoragePoolHostDao {
+    public static final Logger s_logger = Logger.getLogger(StoragePoolHostDaoImpl.class.getName());
+
+    protected final SearchBuilder<StoragePoolHostVO> PoolSearch;
+    protected final SearchBuilder<StoragePoolHostVO> HostSearch;
+    protected final SearchBuilder<StoragePoolHostVO> PoolHostSearch;
+
+    protected static final String HOST_FOR_POOL_SEARCH = "SELECT * FROM storage_pool_host_ref ph,  host h where  ph.host_id = h.id and ph.pool_id=? and h.status=? ";
+
+    protected static final String STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id,  count(ph.host_id) " + " FROM storage_pool p, storage_pool_host_ref ph "
+            + " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + " GROUP by p.data_center_id";
+
+    protected static final String SHARED_STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id,  count(ph.host_id) " + " FROM storage_pool p, storage_pool_host_ref ph "
+            + " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + " AND p.pool_type NOT IN ('LVM', 'Filesystem')" + " GROUP by p.data_center_id";
+
+    protected static final String DELETE_PRIMARY_RECORDS = "DELETE " + "FROM storage_pool_host_ref " + "WHERE host_id = ?";
+
+    public StoragePoolHostDaoImpl() {
+        PoolSearch = createSearchBuilder();
+        PoolSearch.and("pool_id", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PoolSearch.done();
+
+        HostSearch = createSearchBuilder();
+        HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+        HostSearch.done();
+
+        PoolHostSearch = createSearchBuilder();
+        PoolHostSearch.and("pool_id", PoolHostSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PoolHostSearch.and("host_id", PoolHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+        PoolHostSearch.done();
+
+    }
+
+    @Override
+    public List<StoragePoolHostVO> listByPoolId(long id) {
+        SearchCriteria<StoragePoolHostVO> sc = PoolSearch.create();
+        sc.setParameters("pool_id", id);
+        return listIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolHostVO> listByHostIdIncludingRemoved(long hostId) {
+        SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
+        sc.setParameters("host_id", hostId);
+        return listIncludingRemovedBy(sc);
+    }
+    
+    @Override
+    public List<StoragePoolHostVO> listByHostId(long hostId) {
+        SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
+        sc.setParameters("host_id", hostId);
+        return listBy(sc);
+    }
+
+    @Override
+    public StoragePoolHostVO findByPoolHost(long poolId, long hostId) {
+        SearchCriteria<StoragePoolHostVO> sc = PoolHostSearch.create();
+        sc.setParameters("pool_id", poolId);
+        sc.setParameters("host_id", hostId);
+        return findOneIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) {
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        List<StoragePoolHostVO> result = new ArrayList<StoragePoolHostVO>();
+        ResultSet rs = null;
+        try {
+            String sql = HOST_FOR_POOL_SEARCH;
+            pstmt = txn.prepareStatement(sql);
+
+            pstmt.setLong(1, poolId);
+            pstmt.setString(2, hostStatus.toString());
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                // result.add(toEntityBean(rs, false)); TODO: this is buggy in GenericDaoBase for hand constructed queries
+                long id = rs.getLong(1); // ID column
+                result.add(findById(id));
+            }
+        } catch (Exception e) {
+            s_logger.warn("Exception: ", e);
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+        return result;
+
+    }
+
+    @Override
+    public List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly) {
+        ArrayList<Pair<Long, Integer>> l = new ArrayList<Pair<Long, Integer>>();
+        String sql = sharedOnly ? SHARED_STORAGE_POOL_HOST_INFO : STORAGE_POOL_HOST_INFO;
+        Transaction txn = Transaction.currentTxn();
+        ;
+        PreparedStatement pstmt = null;
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, dcId);
+
+            ResultSet rs = pstmt.executeQuery();
+            while (rs.next()) {
+                l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
+            }
+        } catch (SQLException e) {
+        } catch (Throwable e) {
+        }
+        return l;
+    }
+
+    /**
+     * This method deletes the primary records from the host
+     * 
+     * @param hostId
+     *            -- id of the host
+     */
+    @Override
+    public void deletePrimaryRecordsForHost(long hostId) {
+        SearchCriteria<StoragePoolHostVO> sc = HostSearch.create();
+        sc.setParameters("host_id", hostId);
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        remove(sc);
+        txn.commit();
+    }
+
+    @Override
+    public void deleteStoragePoolHostDetails(long hostId, long poolId) {
+        SearchCriteria<StoragePoolHostVO> sc = PoolHostSearch.create();
+        sc.setParameters("host_id", hostId);
+        sc.setParameters("pool_id", poolId);
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        remove(sc);
+        txn.commit();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java
new file mode 100644
index 0000000..c05abf5
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java
@@ -0,0 +1,38 @@
+// 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.storage.dao;
+
+import java.util.List;
+
+import com.cloud.storage.StoragePoolWorkVO;
+import com.cloud.utils.db.GenericDao;
+/**
+ * Data Access Object for storage_pool table
+ */
+public interface StoragePoolWorkDao extends GenericDao<StoragePoolWorkVO, Long> {
+
+    List<StoragePoolWorkVO> listPendingWorkForPrepareForMaintenanceByPoolId(long poolId);
+
+    List<StoragePoolWorkVO> listPendingWorkForCancelMaintenanceByPoolId(long poolId);
+
+    StoragePoolWorkVO findByPoolIdAndVmId(long poolId, long vmId);
+
+    void removePendingJobsOnMsRestart(long msId, long poolId);
+
+    List<Long> searchForPoolIdsForPendingWorkJobs(long msId);
+        
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java
new file mode 100644
index 0000000..360a814
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java
@@ -0,0 +1,136 @@
+// 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.storage.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.StoragePoolWorkVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+@Local(value={StoragePoolWorkDao.class}) @DB(txn=false)
+public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Long>  implements StoragePoolWorkDao {
+
+    protected final SearchBuilder<StoragePoolWorkVO> PendingWorkForPrepareForMaintenanceSearch;
+    protected final SearchBuilder<StoragePoolWorkVO> PendingWorkForCancelMaintenanceSearch;
+    protected final SearchBuilder<StoragePoolWorkVO> PoolAndVmIdSearch;
+    protected final SearchBuilder<StoragePoolWorkVO> PendingJobsForDeadMs;
+    
+    private final String FindPoolIds = "SELECT distinct storage_pool_work.pool_id FROM storage_pool_work WHERE mgmt_server_id = ?";
+    
+    protected StoragePoolWorkDaoImpl() {
+        PendingWorkForPrepareForMaintenanceSearch = createSearchBuilder();
+        PendingWorkForPrepareForMaintenanceSearch.and("poolId", PendingWorkForPrepareForMaintenanceSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PendingWorkForPrepareForMaintenanceSearch.and("stoppedForMaintenance", PendingWorkForPrepareForMaintenanceSearch.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ);
+        PendingWorkForPrepareForMaintenanceSearch.and("startedAfterMaintenance", PendingWorkForPrepareForMaintenanceSearch.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ);
+        PendingWorkForPrepareForMaintenanceSearch.done();
+        
+        PendingWorkForCancelMaintenanceSearch = createSearchBuilder();
+        PendingWorkForCancelMaintenanceSearch.and("poolId", PendingWorkForCancelMaintenanceSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PendingWorkForCancelMaintenanceSearch.and("stoppedForMaintenance", PendingWorkForCancelMaintenanceSearch.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ);
+        PendingWorkForCancelMaintenanceSearch.and("startedAfterMaintenance", PendingWorkForCancelMaintenanceSearch.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ);
+        PendingWorkForCancelMaintenanceSearch.done();
+
+        PoolAndVmIdSearch = createSearchBuilder();
+        PoolAndVmIdSearch.and("poolId", PoolAndVmIdSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PoolAndVmIdSearch.and("vmId", PoolAndVmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+        PoolAndVmIdSearch.done();
+        
+        PendingJobsForDeadMs = createSearchBuilder();
+        PendingJobsForDeadMs.and("managementServerId", PendingJobsForDeadMs.entity().getManagementServerId(), SearchCriteria.Op.EQ);
+        PendingJobsForDeadMs.and("poolId", PendingJobsForDeadMs.entity().getPoolId(), SearchCriteria.Op.EQ);
+        PendingJobsForDeadMs.and("stoppedForMaintenance", PendingJobsForDeadMs.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ);
+        PendingJobsForDeadMs.and("startedAfterMaintenance", PendingJobsForDeadMs.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ);
+        PendingJobsForDeadMs.done();
+        
+    }
+    
+    @Override
+    public List<StoragePoolWorkVO> listPendingWorkForPrepareForMaintenanceByPoolId(long poolId) {
+        SearchCriteria<StoragePoolWorkVO> sc = PendingWorkForPrepareForMaintenanceSearch.create();
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("stoppedForMaintenance", false);
+        sc.setParameters("startedAfterMaintenance", false);
+        return listBy(sc);
+    }
+    
+    @Override
+    public List<StoragePoolWorkVO> listPendingWorkForCancelMaintenanceByPoolId(long poolId) {
+        SearchCriteria<StoragePoolWorkVO> sc = PendingWorkForCancelMaintenanceSearch.create();
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("stoppedForMaintenance", true);
+        sc.setParameters("startedAfterMaintenance", false);
+        return listBy(sc);
+    }
+    
+    @Override
+    public StoragePoolWorkVO findByPoolIdAndVmId(long poolId, long vmId) {
+        SearchCriteria<StoragePoolWorkVO> sc = PoolAndVmIdSearch.create();
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("vmId", vmId);
+        return listBy(sc).get(0);
+    }
+    
+    @Override
+    public void removePendingJobsOnMsRestart(long msId, long poolId) {
+        //hung jobs are those which are stopped, but never started
+        SearchCriteria<StoragePoolWorkVO> sc = PendingJobsForDeadMs.create();
+        sc.setParameters("managementServerId", msId);
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("stoppedForMaintenance", true);
+        sc.setParameters("startedAfterMaintenance", false);        
+        remove(sc);
+    }
+    
+    @Override
+    @DB
+    public List<Long> searchForPoolIdsForPendingWorkJobs(long msId){
+        
+        StringBuilder sql = new StringBuilder(FindPoolIds);
+
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql.toString());
+            pstmt.setLong(1, msId);
+
+            ResultSet rs = pstmt.executeQuery();
+            List<Long> poolIds = new ArrayList<Long>();
+
+            while (rs.next()) {
+                poolIds.add(rs.getLong("pool_id"));
+            }           
+            return poolIds;
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SwiftDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SwiftDao.java b/engine/schema/src/com/cloud/storage/dao/SwiftDao.java
new file mode 100644
index 0000000..72c5219
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SwiftDao.java
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.storage.dao;
+
+import com.cloud.agent.api.to.SwiftTO;
+import com.cloud.storage.SwiftVO;
+import com.cloud.utils.db.GenericDao;
+
+/**
+ * 
+ * 
+ */
+
+public interface SwiftDao extends GenericDao<SwiftVO, Long> {
+
+    SwiftTO getSwiftTO(Long swiftId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java
new file mode 100644
index 0000000..19e5a85
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java
@@ -0,0 +1,58 @@
+// 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.storage.dao;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.agent.api.to.SwiftTO;
+import com.cloud.storage.SwiftVO;
+import com.cloud.utils.db.GenericDaoBase;
+
+/**
+ * 
+ * 
+ */
+@Component
+@Local (value={SwiftDao.class})
+public class SwiftDaoImpl extends GenericDaoBase<SwiftVO, Long> implements SwiftDao {
+    public static final Logger s_logger = Logger.getLogger(SwiftDaoImpl.class.getName());
+
+    @Override
+    public SwiftTO getSwiftTO(Long swiftId) {
+        if (swiftId != null) {
+            SwiftVO swift = findById(swiftId);
+            if (swift != null) {
+                return swift.toSwiftTO();
+            }
+            return null;
+        }
+
+        List<SwiftVO> swiftVOs = listAll();
+        if (swiftVOs == null || swiftVOs.size() < 1) {
+            return null;
+        } else {
+            Collections.shuffle(swiftVOs);
+            return swiftVOs.get(0).toSwiftTO();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/UploadDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/UploadDao.java b/engine/schema/src/com/cloud/storage/dao/UploadDao.java
new file mode 100755
index 0000000..06336ae
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/UploadDao.java
@@ -0,0 +1,36 @@
+// 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.storage.dao;
+
+import java.util.List;
+
+import com.cloud.storage.UploadVO;
+import com.cloud.storage.Upload.Status;
+import com.cloud.storage.Upload.Type;
+import com.cloud.storage.Upload.Mode;
+import com.cloud.utils.db.GenericDao;
+
+public interface UploadDao extends GenericDao<UploadVO, Long> {		
+
+	List<UploadVO> listByTypeUploadStatus(long typeId, Type type,
+			Status uploadState);
+
+	List<UploadVO> listByHostAndUploadStatus(long sserverId, Status uploadInProgress);
+	
+	List<UploadVO> listByModeAndStatus(Mode mode, Status uploadState);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java
new file mode 100755
index 0000000..31fad43
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java
@@ -0,0 +1,92 @@
+// 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.storage.dao;
+import java.util.List;
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.UploadVO;
+import com.cloud.storage.Upload.Status;
+import com.cloud.storage.Upload.Mode;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={UploadDao.class})
+public class UploadDaoImpl extends GenericDaoBase<UploadVO, Long> implements UploadDao {
+	public static final Logger s_logger = Logger.getLogger(UploadDaoImpl.class.getName());
+	protected final SearchBuilder<UploadVO> typeUploadStatusSearch;
+	protected final SearchBuilder<UploadVO> typeHostAndUploadStatusSearch;
+	protected final SearchBuilder<UploadVO> typeModeAndStatusSearch;
+	
+	protected static final String UPDATE_UPLOAD_INFO =
+		"UPDATE upload SET upload_state = ?, upload_pct= ?, last_updated = ? "
+	+   ", upload_error_str = ?, upload_job_id = ? "
+	+   "WHERE host_id = ? and type_id = ? and type = ?";
+	
+	protected static final String UPLOADS_STATE_DC=
+		"SELECT * FROM upload t, host h where t.host_id = h.id and h.data_center_id=? "
+	+	" and t.type_id=? and t.upload_state = ?" ;
+	
+	
+	public UploadDaoImpl() {
+		typeUploadStatusSearch = createSearchBuilder();
+		typeUploadStatusSearch.and("type_id", typeUploadStatusSearch.entity().getTypeId(), SearchCriteria.Op.EQ);
+		typeUploadStatusSearch.and("upload_state", typeUploadStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ);
+		typeUploadStatusSearch.and("type", typeUploadStatusSearch.entity().getType(), SearchCriteria.Op.EQ);
+		typeUploadStatusSearch.done();
+		
+		typeHostAndUploadStatusSearch = createSearchBuilder();
+		typeHostAndUploadStatusSearch.and("host_id", typeHostAndUploadStatusSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+		typeHostAndUploadStatusSearch.and("upload_state", typeHostAndUploadStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ);
+		typeHostAndUploadStatusSearch.done();
+		
+		typeModeAndStatusSearch = createSearchBuilder();
+		typeModeAndStatusSearch.and("mode", typeModeAndStatusSearch.entity().getMode(), SearchCriteria.Op.EQ);
+		typeModeAndStatusSearch.and("upload_state", typeModeAndStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ);
+		typeModeAndStatusSearch.done();
+		
+	}
+	
+	@Override
+	public List<UploadVO> listByTypeUploadStatus(long typeId, UploadVO.Type type, UploadVO.Status uploadState) {
+		SearchCriteria<UploadVO> sc = typeUploadStatusSearch.create();
+		sc.setParameters("type_id", typeId);
+		sc.setParameters("type", type);
+		sc.setParameters("upload_state", uploadState.toString());
+		return listBy(sc);
+	}
+	
+	@Override
+    public List<UploadVO> listByHostAndUploadStatus(long sserverId, Status uploadState){	    
+        SearchCriteria<UploadVO> sc = typeHostAndUploadStatusSearch.create();
+        sc.setParameters("host_id", sserverId);
+        sc.setParameters("upload_state", uploadState.toString());
+        return listBy(sc);
+	}
+	
+	@Override
+	public List<UploadVO> listByModeAndStatus(Mode mode, Status uploadState){
+	    SearchCriteria<UploadVO> sc = typeModeAndStatusSearch.create();
+	    sc.setParameters("mode", mode.toString());
+	    sc.setParameters("upload_state", uploadState.toString());
+	    return listBy(sc);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
new file mode 100755
index 0000000..8520757
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
@@ -0,0 +1,84 @@
+// 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.storage.dao;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
+
+import com.cloud.domain.DomainVO;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.projects.Project.ListProjectResourcesCriteria;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
+import com.cloud.user.Account;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+/*
+ * Data Access Object for vm_templates table
+ */
+public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<TemplateState, TemplateEvent, VMTemplateVO> {
+	
+	
+	public List<VMTemplateVO> listByPublic();
+	public VMTemplateVO findByName(String templateName);
+	public VMTemplateVO findByTemplateName(String templateName);	
+
+	//public void update(VMTemplateVO template);
+
+
+	public List<VMTemplateVO> listAllSystemVMTemplates();
+
+	public List<VMTemplateVO> listDefaultBuiltinTemplates();
+	public String getRoutingTemplateUniqueName();
+	public List<VMTemplateVO> findIsosByIdAndPath(Long domainId, Long accountId, String path);
+	public List<VMTemplateVO> listReadyTemplates();
+	public List<VMTemplateVO> listByAccountId(long accountId);
+	public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso,
+	        List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex, Long zoneId,
+	        HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller,
+	        ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags, String zoneType);
+	
+    public Set<Pair<Long, Long>> searchSwiftTemplates(String name, String keyword, TemplateFilter templateFilter,
+            boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex,
+            Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller, Map<String, String> tags);
+
+    public Set<Pair<Long, Long>> searchS3Templates(String name, String keyword, TemplateFilter templateFilter,
+            boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex,
+            Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller, Map<String, String> tags);
+
+	public long addTemplateToZone(VMTemplateVO tmplt, long zoneId);
+	public List<VMTemplateVO> listAllInZone(long dataCenterId);	
+	
+    public List<VMTemplateVO> listByHypervisorType(List<HypervisorType> hyperTypes);
+	public List<VMTemplateVO> publicIsoSearch(Boolean bootable, boolean listRemoved, Map<String, String> tags);
+	public List<VMTemplateVO> userIsoSearch(boolean listRemoved);
+    VMTemplateVO findSystemVMTemplate(long zoneId);
+    VMTemplateVO findSystemVMTemplate(long zoneId, HypervisorType hType);
+
+    VMTemplateVO findRoutingTemplate(HypervisorType type, String templateName);
+    List<Long> listPrivateTemplatesByHost(Long hostId);
+    public Long countTemplatesForAccount(long accountId);
+	
+    List<VMTemplateVO> findTemplatesToSyncToS3();
+
+}


Mime
View raw message