You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/05/14 22:05:06 UTC

[4/7] Moved VOs into the schema

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
deleted file mode 100644
index 3c34023..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
+++ /dev/null
@@ -1,809 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.persistence.TableGenerator;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.host.HostTagVO;
-import com.cloud.host.Status;
-import com.cloud.info.RunningHostCountInfo;
-import com.cloud.org.Managed;
-import com.cloud.resource.ResourceState;
-import com.cloud.utils.DateUtil;
-import com.cloud.utils.db.Attribute;
-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;
-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.utils.db.UpdateBuilder;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Component(value="EngineHostDao")
-@Local(value = { EngineHostDao.class })
-@DB(txn = false)
-@TableGenerator(name = "host_req_sq", table = "op_host", pkColumnName = "id", valueColumnName = "sequence", allocationSize = 1)
-public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO, Long> implements EngineHostDao {
-    private static final Logger s_logger = Logger.getLogger(EngineHostDaoImpl.class);
-    private static final Logger status_logger = Logger.getLogger(Status.class);
-    private static final Logger state_logger = Logger.getLogger(ResourceState.class);
-
-    protected final SearchBuilder<EngineHostVO> TypePodDcStatusSearch;
-
-    protected final SearchBuilder<EngineHostVO> IdStatusSearch;
-    protected final SearchBuilder<EngineHostVO> TypeDcSearch;
-    protected final SearchBuilder<EngineHostVO> TypeDcStatusSearch;
-    protected final SearchBuilder<EngineHostVO> TypeClusterStatusSearch;
-    protected final SearchBuilder<EngineHostVO> MsStatusSearch;
-    protected final SearchBuilder<EngineHostVO> DcPrivateIpAddressSearch;
-    protected final SearchBuilder<EngineHostVO> DcStorageIpAddressSearch;
-
-    protected final SearchBuilder<EngineHostVO> GuidSearch;
-    protected final SearchBuilder<EngineHostVO> DcSearch;
-    protected final SearchBuilder<EngineHostVO> PodSearch;
-    protected final SearchBuilder<EngineHostVO> TypeSearch;
-    protected final SearchBuilder<EngineHostVO> StatusSearch;
-    protected final SearchBuilder<EngineHostVO> ResourceStateSearch;
-    protected final SearchBuilder<EngineHostVO> NameLikeSearch;
-    protected final SearchBuilder<EngineHostVO> NameSearch;
-    protected final SearchBuilder<EngineHostVO> SequenceSearch;
-    protected final SearchBuilder<EngineHostVO> DirectlyConnectedSearch;
-    protected final SearchBuilder<EngineHostVO> UnmanagedDirectConnectSearch;
-    protected final SearchBuilder<EngineHostVO> UnmanagedApplianceSearch;
-    protected final SearchBuilder<EngineHostVO> MaintenanceCountSearch;
-    protected final SearchBuilder<EngineHostVO> ClusterStatusSearch;
-    protected final SearchBuilder<EngineHostVO> TypeNameZoneSearch;
-    protected final SearchBuilder<EngineHostVO> AvailHypevisorInZone;
-
-    protected final SearchBuilder<EngineHostVO> DirectConnectSearch;
-    protected final SearchBuilder<EngineHostVO> ManagedDirectConnectSearch;
-    protected final SearchBuilder<EngineHostVO> ManagedRoutingServersSearch;
-    protected final SearchBuilder<EngineHostVO> SecondaryStorageVMSearch;
-    protected SearchBuilder<EngineHostVO> StateChangeSearch;
-
-    protected SearchBuilder<EngineHostVO> UUIDSearch;
-
-    protected final GenericSearchBuilder<EngineHostVO, Long> HostsInStatusSearch;
-    protected final GenericSearchBuilder<EngineHostVO, Long> CountRoutingByDc;
-    protected final SearchBuilder<EngineHostVO> RoutingSearch;
-
-    protected final Attribute _statusAttr;
-    protected final Attribute _resourceStateAttr;
-    protected final Attribute _msIdAttr;
-    protected final Attribute _pingTimeAttr;
-
-    @Inject protected HostDetailsDao _detailsDao;
-    @Inject protected HostTagsDao _hostTagsDao;
-    @Inject protected EngineClusterDao _clusterDao;
-
-
-    public EngineHostDaoImpl() {
-
-        MaintenanceCountSearch = createSearchBuilder();
-        MaintenanceCountSearch.and("cluster", MaintenanceCountSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
-        MaintenanceCountSearch.and("resourceState", MaintenanceCountSearch.entity().getResourceState(), SearchCriteria.Op.IN);
-        MaintenanceCountSearch.done();
-
-        TypePodDcStatusSearch = createSearchBuilder();
-        EngineHostVO entity = TypePodDcStatusSearch.entity();
-        TypePodDcStatusSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
-        TypePodDcStatusSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
-        TypePodDcStatusSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
-        TypePodDcStatusSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ);
-        TypePodDcStatusSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ);
-        TypePodDcStatusSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ);
-        TypePodDcStatusSearch.done();
-
-        MsStatusSearch = createSearchBuilder();
-        MsStatusSearch.and("ms", MsStatusSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
-        MsStatusSearch.and("type", MsStatusSearch.entity().getType(), SearchCriteria.Op.EQ);
-        MsStatusSearch.and("resourceState", MsStatusSearch.entity().getResourceState(), SearchCriteria.Op.NIN);
-        MsStatusSearch.done();
-
-        TypeDcSearch = createSearchBuilder();
-        TypeDcSearch.and("type", TypeDcSearch.entity().getType(), SearchCriteria.Op.EQ);
-        TypeDcSearch.and("dc", TypeDcSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        TypeDcSearch.done();
-
-        SecondaryStorageVMSearch = createSearchBuilder();
-        SecondaryStorageVMSearch.and("type", SecondaryStorageVMSearch.entity().getType(), SearchCriteria.Op.EQ);
-        SecondaryStorageVMSearch.and("dc", SecondaryStorageVMSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        SecondaryStorageVMSearch.and("status", SecondaryStorageVMSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        SecondaryStorageVMSearch.done();
-
-        TypeDcStatusSearch = createSearchBuilder();
-        TypeDcStatusSearch.and("type", TypeDcStatusSearch.entity().getType(), SearchCriteria.Op.EQ);
-        TypeDcStatusSearch.and("dc", TypeDcStatusSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        TypeDcStatusSearch.and("status", TypeDcStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        TypeDcStatusSearch.and("resourceState", TypeDcStatusSearch.entity().getResourceState(), SearchCriteria.Op.EQ);
-        TypeDcStatusSearch.done();
-
-        TypeClusterStatusSearch = createSearchBuilder();
-        TypeClusterStatusSearch.and("type", TypeClusterStatusSearch.entity().getType(), SearchCriteria.Op.EQ);
-        TypeClusterStatusSearch.and("cluster", TypeClusterStatusSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
-        TypeClusterStatusSearch.and("status", TypeClusterStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        TypeClusterStatusSearch.and("resourceState", TypeClusterStatusSearch.entity().getResourceState(), SearchCriteria.Op.EQ);
-        TypeClusterStatusSearch.done();
-
-        IdStatusSearch = createSearchBuilder();
-        IdStatusSearch.and("id", IdStatusSearch.entity().getId(), SearchCriteria.Op.EQ);
-        IdStatusSearch.and("states", IdStatusSearch.entity().getStatus(), SearchCriteria.Op.IN);
-        IdStatusSearch.done();
-
-        DcPrivateIpAddressSearch = createSearchBuilder();
-        DcPrivateIpAddressSearch.and("privateIpAddress", DcPrivateIpAddressSearch.entity().getPrivateIpAddress(), SearchCriteria.Op.EQ);
-        DcPrivateIpAddressSearch.and("dc", DcPrivateIpAddressSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        DcPrivateIpAddressSearch.done();
-
-        DcStorageIpAddressSearch = createSearchBuilder();
-        DcStorageIpAddressSearch.and("storageIpAddress", DcStorageIpAddressSearch.entity().getStorageIpAddress(), SearchCriteria.Op.EQ);
-        DcStorageIpAddressSearch.and("dc", DcStorageIpAddressSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        DcStorageIpAddressSearch.done();
-
-        GuidSearch = createSearchBuilder();
-        GuidSearch.and("guid", GuidSearch.entity().getGuid(), SearchCriteria.Op.EQ);
-        GuidSearch.done();
-
-        DcSearch = createSearchBuilder();
-        DcSearch.and("dc", DcSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        DcSearch.done();
-
-        ClusterStatusSearch = createSearchBuilder();
-        ClusterStatusSearch.and("cluster", ClusterStatusSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
-        ClusterStatusSearch.and("status", ClusterStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        ClusterStatusSearch.done();
-
-        TypeNameZoneSearch = createSearchBuilder();
-        TypeNameZoneSearch.and("name", TypeNameZoneSearch.entity().getName(), SearchCriteria.Op.EQ);
-        TypeNameZoneSearch.and("type", TypeNameZoneSearch.entity().getType(), SearchCriteria.Op.EQ);
-        TypeNameZoneSearch.and("zoneId", TypeNameZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        TypeNameZoneSearch.done();
-
-        PodSearch = createSearchBuilder();
-        PodSearch.and("pod", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
-        PodSearch.done();
-
-        TypeSearch = createSearchBuilder();
-        TypeSearch.and("type", TypeSearch.entity().getType(), SearchCriteria.Op.EQ);
-        TypeSearch.done();
-
-        StatusSearch = createSearchBuilder();
-        StatusSearch.and("status", StatusSearch.entity().getStatus(), SearchCriteria.Op.IN);
-        StatusSearch.done();
-
-        ResourceStateSearch = createSearchBuilder();
-        ResourceStateSearch.and("resourceState", ResourceStateSearch.entity().getResourceState(), SearchCriteria.Op.IN);
-        ResourceStateSearch.done();
-
-        NameLikeSearch = createSearchBuilder();
-        NameLikeSearch.and("name", NameLikeSearch.entity().getName(), SearchCriteria.Op.LIKE);
-        NameLikeSearch.done();
-
-        NameSearch = createSearchBuilder();
-        NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
-        NameSearch.done();
-
-        SequenceSearch = createSearchBuilder();
-        SequenceSearch.and("id", SequenceSearch.entity().getId(), SearchCriteria.Op.EQ);
-        // SequenceSearch.addRetrieve("sequence", SequenceSearch.entity().getSequence());
-        SequenceSearch.done();
-
-        DirectlyConnectedSearch = createSearchBuilder();
-        DirectlyConnectedSearch.and("resource", DirectlyConnectedSearch.entity().getResource(), SearchCriteria.Op.NNULL);
-        DirectlyConnectedSearch.and("ms", DirectlyConnectedSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
-        DirectlyConnectedSearch.and("statuses", DirectlyConnectedSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        DirectlyConnectedSearch.and("resourceState", DirectlyConnectedSearch.entity().getResourceState(), SearchCriteria.Op.NOTIN);
-        DirectlyConnectedSearch.done();
-
-        UnmanagedDirectConnectSearch = createSearchBuilder();
-        UnmanagedDirectConnectSearch.and("resource", UnmanagedDirectConnectSearch.entity().getResource(), SearchCriteria.Op.NNULL);
-        UnmanagedDirectConnectSearch.and("server", UnmanagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
-        UnmanagedDirectConnectSearch.and("lastPinged", UnmanagedDirectConnectSearch.entity().getLastPinged(), SearchCriteria.Op.LTEQ);
-        UnmanagedDirectConnectSearch.and("resourceStates", UnmanagedDirectConnectSearch.entity().getResourceState(), SearchCriteria.Op.NIN);
-        /*
-         * UnmanagedDirectConnectSearch.op(SearchCriteria.Op.OR, "managementServerId",
-         * UnmanagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
-         * UnmanagedDirectConnectSearch.and("lastPinged", UnmanagedDirectConnectSearch.entity().getLastPinged(),
-         * SearchCriteria.Op.LTEQ); UnmanagedDirectConnectSearch.cp(); UnmanagedDirectConnectSearch.cp();
-         */
-
-        DirectConnectSearch = createSearchBuilder();
-        DirectConnectSearch.and("resource", DirectConnectSearch.entity().getResource(), SearchCriteria.Op.NNULL);
-        DirectConnectSearch.and("id", DirectConnectSearch.entity().getId(), SearchCriteria.Op.EQ);
-        DirectConnectSearch.and().op("nullserver", DirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
-        DirectConnectSearch.or("server", DirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
-        DirectConnectSearch.cp();
-        DirectConnectSearch.done();
-
-        UnmanagedApplianceSearch = createSearchBuilder();
-        UnmanagedApplianceSearch.and("resource", UnmanagedApplianceSearch.entity().getResource(), SearchCriteria.Op.NNULL);
-        UnmanagedApplianceSearch.and("server", UnmanagedApplianceSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
-        UnmanagedApplianceSearch.and("types", UnmanagedApplianceSearch.entity().getType(), SearchCriteria.Op.IN);
-        UnmanagedApplianceSearch.and("lastPinged", UnmanagedApplianceSearch.entity().getLastPinged(), SearchCriteria.Op.LTEQ);
-        UnmanagedApplianceSearch.done();
-
-        AvailHypevisorInZone = createSearchBuilder();
-        AvailHypevisorInZone.and("zoneId", AvailHypevisorInZone.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        AvailHypevisorInZone.and("hostId", AvailHypevisorInZone.entity().getId(), SearchCriteria.Op.NEQ);
-        AvailHypevisorInZone.and("type", AvailHypevisorInZone.entity().getType(), SearchCriteria.Op.EQ);
-        AvailHypevisorInZone.groupBy(AvailHypevisorInZone.entity().getHypervisorType());
-        AvailHypevisorInZone.done();
-
-        HostsInStatusSearch = createSearchBuilder(Long.class);
-        HostsInStatusSearch.selectField(HostsInStatusSearch.entity().getId());
-        HostsInStatusSearch.and("dc", HostsInStatusSearch.entity().getDataCenterId(), Op.EQ);
-        HostsInStatusSearch.and("pod", HostsInStatusSearch.entity().getPodId(), Op.EQ);
-        HostsInStatusSearch.and("cluster", HostsInStatusSearch.entity().getClusterId(), Op.EQ);
-        HostsInStatusSearch.and("type", HostsInStatusSearch.entity().getType(), Op.EQ);
-        HostsInStatusSearch.and("statuses", HostsInStatusSearch.entity().getStatus(), Op.IN);
-        HostsInStatusSearch.done();
-
-        CountRoutingByDc = createSearchBuilder(Long.class);
-        CountRoutingByDc.select(null, Func.COUNT, null);
-        CountRoutingByDc.and("dc", CountRoutingByDc.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        CountRoutingByDc.and("type", CountRoutingByDc.entity().getType(), SearchCriteria.Op.EQ);
-        CountRoutingByDc.and("status", CountRoutingByDc.entity().getStatus(), SearchCriteria.Op.EQ);
-
-        CountRoutingByDc.done();
-
-        ManagedDirectConnectSearch = createSearchBuilder();
-        ManagedDirectConnectSearch.and("resource", ManagedDirectConnectSearch.entity().getResource(), SearchCriteria.Op.NNULL);
-        ManagedDirectConnectSearch.and("server", ManagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
-        ManagedDirectConnectSearch.done();
-
-        ManagedRoutingServersSearch = createSearchBuilder();
-        ManagedRoutingServersSearch.and("server", ManagedRoutingServersSearch.entity().getManagementServerId(), SearchCriteria.Op.NNULL);
-        ManagedRoutingServersSearch.and("type", ManagedRoutingServersSearch.entity().getType(), SearchCriteria.Op.EQ);
-        ManagedRoutingServersSearch.done();
-
-        RoutingSearch = createSearchBuilder();
-        RoutingSearch.and("type", RoutingSearch.entity().getType(), SearchCriteria.Op.EQ);
-        RoutingSearch.done();
-
-        _statusAttr = _allAttributes.get("status");
-        _msIdAttr = _allAttributes.get("managementServerId");
-        _pingTimeAttr = _allAttributes.get("lastPinged");
-        _resourceStateAttr = _allAttributes.get("resourceState");
-
-        assert (_statusAttr != null && _msIdAttr != null && _pingTimeAttr != null) : "Couldn't find one of these attributes";
-
-        UUIDSearch = createSearchBuilder();
-        UUIDSearch.and("uuid", UUIDSearch.entity().getUuid(), SearchCriteria.Op.EQ);
-        UUIDSearch.done();
-
-        StateChangeSearch = createSearchBuilder();
-        StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
-        StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
-        StateChangeSearch.done();
-    }
-
-    @Override
-    public long countBy(long clusterId, ResourceState... states) {
-        SearchCriteria<EngineHostVO> sc = MaintenanceCountSearch.create();
-
-        sc.setParameters("resourceState", (Object[]) states);
-        sc.setParameters("cluster", clusterId);
-
-        List<EngineHostVO> hosts = listBy(sc);
-        return hosts.size();
-    }
-
-
-    @Override
-    public EngineHostVO findByGuid(String guid) {
-        SearchCriteria<EngineHostVO> sc = GuidSearch.create("guid", guid);
-        return findOneBy(sc);
-    }
-
-    @Override @DB
-    public List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();       
-        SearchCriteria<EngineHostVO> sc = UnmanagedDirectConnectSearch.create();
-        sc.setParameters("lastPinged", lastPingSecondsAfter);
-        //sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.Disabled);
-        sc.setJoinParameters("ClusterManagedSearch", "managed", Managed.ManagedState.Managed);
-        List<EngineHostVO> hosts = lockRows(sc, new Filter(EngineHostVO.class, "clusterId", true, 0L, limit), true);
-
-        for (EngineHostVO host : hosts) {
-            host.setManagementServerId(managementServerId);
-            update(host.getId(), host);
-        }
-
-        txn.commit();
-
-        return hosts;
-    }
-
-    @Override @DB
-    public List<EngineHostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId) {
-        Transaction txn = Transaction.currentTxn();
-
-        txn.start();
-        SearchCriteria<EngineHostVO> sc = UnmanagedApplianceSearch.create();
-        sc.setParameters("lastPinged", lastPingSecondsAfter);
-        sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer, Type.PxeServer, Type.TrafficMonitor, Type.L2Networking);
-        List<EngineHostVO> hosts = lockRows(sc, null, true);
-
-        for (EngineHostVO host : hosts) {
-            host.setManagementServerId(managementServerId);
-            update(host.getId(), host);
-        }
-
-        txn.commit();
-
-        return hosts;
-    }
-
-    @Override
-    public void markHostsAsDisconnected(long msId, long lastPing) {
-        SearchCriteria<EngineHostVO> sc = MsStatusSearch.create();
-        sc.setParameters("ms", msId);
-
-        EngineHostVO host = createForUpdate();
-        host.setLastPinged(lastPing);
-        host.setDisconnectedOn(new Date());
-        UpdateBuilder ub = getUpdateBuilder(host);
-        ub.set(host, "status", Status.Disconnected);
-
-        update(ub, sc, null);
-
-        sc = MsStatusSearch.create();
-        sc.setParameters("ms", msId);
-
-        host = createForUpdate();
-        host.setManagementServerId(null);
-        host.setLastPinged((System.currentTimeMillis() >> 10) - (10 * 60));
-        host.setDisconnectedOn(new Date());
-        ub = getUpdateBuilder(host);
-        update(ub, sc, null);
-    }
-
-    @Override
-    public List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) {
-
-        SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder();
-        HostTagVO tagEntity = hostTagSearch.entity();
-        hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ);
-
-        SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder();
-        EngineHostVO entity = hostSearch.entity();
-        hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
-        hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
-        hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
-        hostSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ);
-        hostSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ);
-        hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ);
-        hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER);
-
-        SearchCriteria<EngineHostVO> sc = hostSearch.create();
-        sc.setJoinParameters("hostTagSearch", "tag", hostTag);
-        sc.setParameters("type", type.toString());
-        if (podId != null) {
-            sc.setParameters("pod", podId);
-        }
-        if (clusterId != null) {
-            sc.setParameters("cluster", clusterId);
-        }
-        sc.setParameters("dc", dcId);
-        sc.setParameters("status", Status.Up.toString());
-        sc.setParameters("resourceState", ResourceState.Enabled.toString());
-
-        return listBy(sc);
-    }
-
-
-    @Override
-    public List<EngineHostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag) {
-        SearchBuilder<HostTagVO> hostTagSearch = null;
-        if (haTag != null && !haTag.isEmpty()) {
-            hostTagSearch = _hostTagsDao.createSearchBuilder();
-            hostTagSearch.and().op("tag", hostTagSearch.entity().getTag(), SearchCriteria.Op.NEQ);
-            hostTagSearch.or("tagNull", hostTagSearch.entity().getTag(), SearchCriteria.Op.NULL);
-            hostTagSearch.cp();
-        }
-
-        SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder();
-
-        hostSearch.and("type", hostSearch.entity().getType(), SearchCriteria.Op.EQ);
-        hostSearch.and("clusterId", hostSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
-        hostSearch.and("podId", hostSearch.entity().getPodId(), SearchCriteria.Op.EQ);
-        hostSearch.and("zoneId", hostSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        hostSearch.and("status", hostSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        hostSearch.and("resourceState", hostSearch.entity().getResourceState(), SearchCriteria.Op.EQ);
-
-        if (haTag != null && !haTag.isEmpty()) {
-            hostSearch.join("hostTagSearch", hostTagSearch, hostSearch.entity().getId(), hostTagSearch.entity().getHostId(), JoinBuilder.JoinType.LEFTOUTER);
-        }
-
-        SearchCriteria<EngineHostVO> sc = hostSearch.create();
-
-        if (haTag != null && !haTag.isEmpty()) {
-            sc.setJoinParameters("hostTagSearch", "tag", haTag);
-        }
-
-        if (type != null) {
-            sc.setParameters("type", type);
-        }
-
-        if (clusterId != null) {
-            sc.setParameters("clusterId", clusterId);
-        }
-
-        if (podId != null) {
-            sc.setParameters("podId", podId);
-        }
-
-        sc.setParameters("zoneId", dcId);
-        sc.setParameters("status", Status.Up);
-        sc.setParameters("resourceState", ResourceState.Enabled);
-
-        return listBy(sc);
-    }
-
-    @Override
-    public void loadDetails(EngineHostVO host) {
-        Map<String, String> details = _detailsDao.findDetails(host.getId());
-        host.setDetails(details);
-    }
-
-    @Override
-    public void loadHostTags(EngineHostVO host) {
-        List<String> hostTags = _hostTagsDao.gethostTags(host.getId());
-        host.setHostTags(hostTags);
-    }
-
-    @DB
-    @Override
-    public List<EngineHostVO> findLostHosts(long timeout) {
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-        List<EngineHostVO> result = new ArrayList<EngineHostVO>();
-        ResultSet rs = null;
-        try {
-            String sql = "select h.id from host h left join  cluster c on h.cluster_id=c.id where h.mgmt_server_id is not null and h.last_ping < ? and h.status in ('Up', 'Updating', 'Disconnected', 'Connecting') and h.type not in ('ExternalFirewall', 'ExternalLoadBalancer', 'TrafficMonitor', 'SecondaryStorage', 'LocalSecondaryStorage', 'L2Networking') and (h.cluster_id is null or c.managed_state = 'Managed') ;" ;
-            pstmt = txn.prepareStatement(sql);
-            pstmt.setLong(1, timeout);
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                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 void saveDetails(EngineHostVO host) {
-        Map<String, String> details = host.getDetails();
-        if (details == null) {
-            return;
-        }
-        _detailsDao.persist(host.getId(), details);
-    }
-
-    protected void saveHostTags(EngineHostVO host) {
-        List<String> hostTags = host.getHostTags();
-        if (hostTags == null || (hostTags != null && hostTags.isEmpty())) {
-            return;
-        }
-        _hostTagsDao.persist(host.getId(), hostTags);
-    }
-
-    @Override
-    @DB
-    public EngineHostVO persist(EngineHostVO host) {
-        final String InsertSequenceSql = "INSERT INTO op_host(id) VALUES(?)";
-
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-
-        EngineHostVO dbHost = super.persist(host);
-
-        try {
-            PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertSequenceSql);
-            pstmt.setLong(1, dbHost.getId());
-            pstmt.executeUpdate();
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable to persist the sequence number for this host");
-        }
-
-        saveDetails(host);
-        loadDetails(dbHost);
-        saveHostTags(host);
-        loadHostTags(dbHost);
-
-        txn.commit();
-
-        return dbHost;
-    }
-
-    @Override
-    @DB
-    public boolean update(Long hostId, EngineHostVO host) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-
-        boolean persisted = super.update(hostId, host);
-        if (!persisted) {
-            return persisted;
-        }
-
-        saveDetails(host);
-        saveHostTags(host);
-
-        txn.commit();
-
-        return persisted;
-    }
-
-    @Override
-    @DB
-    public List<RunningHostCountInfo> getRunningHostCounts(Date cutTime) {
-        String sql = "select * from (" + "select h.data_center_id, h.type, count(*) as count from host as h INNER JOIN mshost as m ON h.mgmt_server_id=m.msid "
-                + "where h.status='Up' and h.type='SecondaryStorage' and m.last_update > ? " + "group by h.data_center_id, h.type " + "UNION ALL "
-                + "select h.data_center_id, h.type, count(*) as count from host as h INNER JOIN mshost as m ON h.mgmt_server_id=m.msid "
-                + "where h.status='Up' and h.type='Routing' and m.last_update > ? " + "group by h.data_center_id, h.type) as t " + "ORDER by t.data_center_id, t.type";
-
-        ArrayList<RunningHostCountInfo> l = new ArrayList<RunningHostCountInfo>();
-
-        Transaction txn = Transaction.currentTxn();
-        ;
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = txn.prepareAutoCloseStatement(sql);
-            String gmtCutTime = DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutTime);
-            pstmt.setString(1, gmtCutTime);
-            pstmt.setString(2, gmtCutTime);
-
-            ResultSet rs = pstmt.executeQuery();
-            while (rs.next()) {
-                RunningHostCountInfo info = new RunningHostCountInfo();
-                info.setDcId(rs.getLong(1));
-                info.setHostType(rs.getString(2));
-                info.setCount(rs.getInt(3));
-
-                l.add(info);
-            }
-        } catch (SQLException e) {
-        } catch (Throwable e) {
-        }
-        return l;
-    }
-
-    @Override
-    public long getNextSequence(long hostId) {
-        if (s_logger.isTraceEnabled()) {
-            s_logger.trace("getNextSequence(), hostId: " + hostId);
-        }
-
-        TableGenerator tg = _tgs.get("host_req_sq");
-        assert tg != null : "how can this be wrong!";
-
-        return s_seqFetcher.getNextSequence(Long.class, tg, hostId);
-    }
-
-    /*TODO: this is used by mycloud, check if it needs resource state Enabled */
-    @Override
-    public long countRoutingHostsByDataCenter(long dcId) {
-        SearchCriteria<Long> sc = CountRoutingByDc.create();
-        sc.setParameters("dc", dcId);
-        sc.setParameters("type", Host.Type.Routing);
-        sc.setParameters("status", Status.Up.toString());
-        return customSearch(sc, null).get(0);
-    }
-
-
-    @Override
-    public boolean updateState(State currentState, DataCenterResourceEntity.State.Event event, State nextState, DataCenterResourceEntity hostEntity, Object data) {
-        EngineHostVO vo = findById(hostEntity.getId());
-        Date oldUpdatedTime = vo.getLastUpdated();
-
-        SearchCriteria<EngineHostVO> sc = StateChangeSearch.create();
-        sc.setParameters("id", hostEntity.getId());
-        sc.setParameters("state", currentState);
-
-        UpdateBuilder builder = getUpdateBuilder(vo);
-        builder.set(vo, "state", nextState);
-        builder.set(vo, "lastUpdated", new Date());
-
-        int rows = update(vo, sc);
-
-        if (rows == 0 && s_logger.isDebugEnabled()) {
-            EngineHostVO dbHost = findByIdIncludingRemoved(vo.getId());
-            if (dbHost != null) {
-                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
-                str.append(": DB Data={id=").append(dbHost.getId()).append("; state=").append(dbHost.getState()).append(";updatedTime=")
-                .append(dbHost.getLastUpdated());
-                str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatedTime=").append(vo.getLastUpdated());
-                str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatedTime=").append(oldUpdatedTime);
-            } else {
-                s_logger.debug("Unable to update dataCenter: id=" + vo.getId() + ", as there is no such dataCenter exists in the database anymore");
-            }
-        }
-        return rows > 0;
-    }
-
-    @Override
-    public boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo) {
-        EngineHostVO host = (EngineHostVO)vo;
-        SearchBuilder<EngineHostVO> sb = createSearchBuilder();
-        sb.and("resource_state", sb.entity().getResourceState(), SearchCriteria.Op.EQ);
-        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
-        sb.done();
-
-        SearchCriteria<EngineHostVO> sc = sb.create();
-
-        sc.setParameters("resource_state", oldState);
-        sc.setParameters("id", host.getId());
-
-        UpdateBuilder ub = getUpdateBuilder(host);
-        ub.set(host, _resourceStateAttr, newState);
-        int result = update(ub, sc, null);
-        assert result <= 1 : "How can this update " + result + " rows? ";
-
-        if (state_logger.isDebugEnabled() && result == 0) {
-            EngineHostVO ho = findById(host.getId());
-            assert ho != null : "How how how? : " + host.getId();
-
-            StringBuilder str = new StringBuilder("Unable to update resource state: [");
-            str.append("m = " + host.getId());
-            str.append("; name = " + host.getName());
-            str.append("; old state = " + oldState);
-            str.append("; event = " + event);
-            str.append("; new state = " + newState + "]");
-            state_logger.debug(str.toString());
-        } else {
-            StringBuilder msg = new StringBuilder("Resource state update: [");
-            msg.append("id = " + host.getId());
-            msg.append("; name = " + host.getName());
-            msg.append("; old state = " + oldState);
-            msg.append("; event = " + event);
-            msg.append("; new state = " + newState + "]");
-            state_logger.debug(msg.toString());
-        }
-
-        return result > 0;
-    }
-
-    @Override
-    public EngineHostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type) {
-        SearchCriteria<EngineHostVO> sc = TypeNameZoneSearch.create();
-        sc.setParameters("type", type);
-        sc.setParameters("name", name);
-        sc.setParameters("zoneId", zoneId);
-        return findOneBy(sc);
-    }
-
-	@Override
-	public List<EngineHostVO> findHypervisorHostInCluster(long clusterId) {
-		 SearchCriteria<EngineHostVO> sc = TypeClusterStatusSearch.create();
-		 sc.setParameters("type", Host.Type.Routing);
-		 sc.setParameters("cluster", clusterId);
-		 sc.setParameters("status", Status.Up);
-		 sc.setParameters("resourceState", ResourceState.Enabled);
-		
-		return listBy(sc);
-	}
-
-	@Override
-	public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> lockRows(
-			SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
-			Filter filter, boolean exclusive) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO lockOneRandomRow(
-			SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
-			boolean exclusive) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-
-	@Override
-	public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> search(
-			SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
-			Filter filter) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> search(
-			SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
-			Filter filter, boolean enable_query_cache) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> searchIncludingRemoved(
-			SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
-			Filter filter, Boolean lock, boolean cache) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public List<EngineHostVO> searchIncludingRemoved(
-			SearchCriteria<EngineHostVO> sc,
-			Filter filter, Boolean lock, boolean cache,
-			boolean enable_query_cache) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-
-	@Override
-	public int remove(
-			SearchCriteria<EngineHostVO> sc) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public int expunge(SearchCriteria<EngineHostVO> sc) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public EngineHostVO findOneBy(SearchCriteria<EngineHostVO> sc) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java
deleted file mode 100644
index 451723e..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDao.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License.  Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
-
-
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-public interface EngineHostPodDao extends GenericDao<EngineHostPodVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
-	public List<EngineHostPodVO> listByDataCenterId(long id);
-
-	public EngineHostPodVO findByName(String name, long dcId);
-
-	public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip);
-
-    public List<Long> listDisabledPods(long zoneId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
deleted file mode 100644
index fee083a..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License.  Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-
-import com.cloud.org.Grouping;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.UpdateBuilder;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-@Component(value="EngineHostPodDao")
-@Local(value={EngineHostPodDao.class})
-public class EngineHostPodDaoImpl extends GenericDaoBase<EngineHostPodVO, Long> implements EngineHostPodDao {
-    private static final Logger s_logger = Logger.getLogger(EngineHostPodDaoImpl.class);
-
-	protected SearchBuilder<EngineHostPodVO> DataCenterAndNameSearch;
-	protected SearchBuilder<EngineHostPodVO> DataCenterIdSearch;
-	protected SearchBuilder<EngineHostPodVO> UUIDSearch;
-    protected SearchBuilder<EngineHostPodVO> StateChangeSearch;
-
-	protected EngineHostPodDaoImpl() {
-	    DataCenterAndNameSearch = createSearchBuilder();
-	    DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-	    DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
-	    DataCenterAndNameSearch.done();
-
-	    DataCenterIdSearch = createSearchBuilder();
-	    DataCenterIdSearch.and("dcId", DataCenterIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-	    DataCenterIdSearch.done();
-
-
-	    UUIDSearch = createSearchBuilder();
-	    UUIDSearch.and("uuid", UUIDSearch.entity().getUuid(), SearchCriteria.Op.EQ);
-	    UUIDSearch.done();
-	    
-        StateChangeSearch = createSearchBuilder();
-        StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
-        StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
-        StateChangeSearch.done();
-
-	}
-
-	@Override
-    public List<EngineHostPodVO> listByDataCenterId(long id) {
-		SearchCriteria<EngineHostPodVO> sc = DataCenterIdSearch.create();
-		sc.setParameters("dcId", id);
-
-	    return listBy(sc);
-	}
-
-	@Override
-    public EngineHostPodVO findByName(String name, long dcId) {
-	    SearchCriteria<EngineHostPodVO> sc = DataCenterAndNameSearch.create();
-	    sc.setParameters("dc", dcId);
-	    sc.setParameters("name", name);
-
-	    return findOneBy(sc);
-	}
-
-	@Override
-	public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip) {
-		HashMap<Long, List<Object>> currentPodCidrSubnets = new HashMap<Long, List<Object>>();
-
-		String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + zoneId +" and removed IS NULL";
-		Transaction txn = Transaction.currentTxn();
-		try {
-		PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
-		ResultSet rs = stmt.executeQuery();
-		while (rs.next()) {
-			Long podId = rs.getLong("id");
-			if (podId.longValue() == podIdToSkip) {
-                    continue;
-                }
-			String cidrAddress = rs.getString("cidr_address");
-			long cidrSize = rs.getLong("cidr_size");
-			List<Object> cidrPair = new ArrayList<Object>();
-			cidrPair.add(0, cidrAddress);
-			cidrPair.add(1, new Long(cidrSize));
-			currentPodCidrSubnets.put(podId, cidrPair);
-		}
-        } catch (SQLException ex) {
-		s_logger.warn("DB exception " + ex.getMessage(), ex);
-            return null;
-        }
-
-        return currentPodCidrSubnets;
-	}
-
-    @Override
-    public boolean remove(Long id) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        EngineHostPodVO pod = createForUpdate();
-        pod.setName(null);
-        
-        update(id, pod);
-
-        boolean result = super.remove(id);
-        txn.commit();
-        return result;
-    }
-
-    @Override
-    public List<Long> listDisabledPods(long zoneId) {
-        GenericSearchBuilder<EngineHostPodVO, Long> podIdSearch = createSearchBuilder(Long.class);
-        podIdSearch.selectField(podIdSearch.entity().getId());
-        podIdSearch.and("dataCenterId", podIdSearch.entity().getDataCenterId(), Op.EQ);
-        podIdSearch.and("allocationState", podIdSearch.entity().getAllocationState(), Op.EQ);
-        podIdSearch.done();
-
-        
-        SearchCriteria<Long> sc = podIdSearch.create();
-        sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
-        sc.addAnd("allocationState", SearchCriteria.Op.EQ, Grouping.AllocationState.Disabled);
-        return customSearch(sc, null);
-    }
-
-
-	@Override
-	public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity podEntity, Object data) {
-		
-		EngineHostPodVO vo = findById(podEntity.getId());
-		
-		Date oldUpdatedTime = vo.getLastUpdated();
-
-		SearchCriteria<EngineHostPodVO> sc = StateChangeSearch.create();
-        sc.setParameters("id", vo.getId());
-        sc.setParameters("state", currentState);
-
-        UpdateBuilder builder = getUpdateBuilder(vo);
-        builder.set(vo, "state", nextState);
-        builder.set(vo, "lastUpdated", new Date());
-
-        int rows = update((EngineHostPodVO) vo, sc);
-        
-        if (rows == 0 && s_logger.isDebugEnabled()) {
-        	EngineHostPodVO dbDC = findByIdIncludingRemoved(vo.getId());
-            if (dbDC != null) {
-                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
-                str.append(": DB Data={id=").append(dbDC.getId()).append("; state=").append(dbDC.getState()).append(";updatedTime=")
-                        .append(dbDC.getLastUpdated());
-                str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatedTime=").append(vo.getLastUpdated());
-                str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatedTime=").append(oldUpdatedTime);
-            } else {
-                s_logger.debug("Unable to update dataCenter: id=" + vo.getId() + ", as there is no such dataCenter exists in the database anymore");
-            }
-        }
-        return rows > 0;
-		
-	}
-
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDao.java
deleted file mode 100644
index d645503..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDao.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.util.Map;
-
-import com.cloud.host.DetailVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface HostDetailsDao extends GenericDao<DetailVO, Long> {
-    Map<String, String> findDetails(long hostId);
-    
-    void persist(long hostId, Map<String, String> details);
-    
-    DetailVO findDetail(long hostId, String name);
-
-	void deleteDetails(long hostId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java
deleted file mode 100644
index 02f8c2c..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostDetailsDaoImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.host.DetailVO;
-import com.cloud.utils.crypt.DBEncryptionUtil;
-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(value="EngineHostDetailsDao")
-@Local(value=HostDetailsDao.class)
-public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implements HostDetailsDao {
-    protected final SearchBuilder<DetailVO> HostSearch;
-    protected final SearchBuilder<DetailVO> DetailSearch;
-    
-    public HostDetailsDaoImpl() {
-        HostSearch = createSearchBuilder();
-        HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
-        HostSearch.done();
-        
-        DetailSearch = createSearchBuilder();
-        DetailSearch.and("hostId", DetailSearch.entity().getHostId(), SearchCriteria.Op.EQ);
-        DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
-        DetailSearch.done();
-    }
-
-    @Override
-    public DetailVO findDetail(long hostId, String name) {
-        SearchCriteria<DetailVO> sc = DetailSearch.create();
-        sc.setParameters("hostId", hostId);
-        sc.setParameters("name", name);
-        
-        DetailVO detail = findOneIncludingRemovedBy(sc);
-        if("password".equals(name) && detail != null){
-        	detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
-        }
-        return detail;
-    }
-
-    @Override
-    public Map<String, String> findDetails(long hostId) {
-        SearchCriteria<DetailVO> sc = HostSearch.create();
-        sc.setParameters("hostId", hostId);
-        
-        List<DetailVO> results = search(sc, null);
-        Map<String, String> details = new HashMap<String, String>(results.size());
-        for (DetailVO result : results) {
-        	if("password".equals(result.getName())){
-        		details.put(result.getName(), DBEncryptionUtil.decrypt(result.getValue()));
-        	} else {
-        		details.put(result.getName(), result.getValue());
-        	}
-        }
-        return details;
-    }
-    
-    @Override
-    public void deleteDetails(long hostId) {
-        SearchCriteria sc = HostSearch.create();
-        sc.setParameters("hostId", hostId);
-        
-        List<DetailVO> results = search(sc, null);
-        for (DetailVO result : results) {
-        	remove(result.getId());
-        }
-    }
-
-    @Override
-    public void persist(long hostId, Map<String, String> details) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        SearchCriteria<DetailVO> sc = HostSearch.create();
-        sc.setParameters("hostId", hostId);
-        expunge(sc);
-        
-        for (Map.Entry<String, String> detail : details.entrySet()) {
-        	String value = detail.getValue();
-        	if("password".equals(detail.getKey())){
-        		value = DBEncryptionUtil.encrypt(value);
-        	}
-            DetailVO vo = new DetailVO(hostId, detail.getKey(), value);
-            persist(vo);
-        }
-        txn.commit();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDao.java
deleted file mode 100644
index 09503d8..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDao.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.util.List;
-import com.cloud.host.HostTagVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
-    
-    void persist(long hostId, List<String> hostTags);
-    
-    List<String> gethostTags(long hostId);
-	
-}
-

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java
deleted file mode 100644
index a70b7d1..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/HostTagsDaoImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.host.HostTagVO;
-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(value="EngineHostTagsDao")
-@Local(value=HostTagsDao.class)
-public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements HostTagsDao {
-    protected final SearchBuilder<HostTagVO> HostSearch;
-    
-    protected HostTagsDaoImpl() {
-        HostSearch = createSearchBuilder();
-        HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
-        HostSearch.done();        
-    }
-
-    @Override
-    public List<String> gethostTags(long hostId) {
-        SearchCriteria<HostTagVO> sc = HostSearch.create();
-        sc.setParameters("hostId", hostId);
-        
-        List<HostTagVO> results = search(sc, null);
-        List<String> hostTags = new ArrayList<String>(results.size());
-        for (HostTagVO result : results) {
-        	hostTags.add(result.getTag());
-        }
-
-        return hostTags;
-    }
-    
-    @Override
-    public void persist(long hostId, List<String> hostTags) {
-        Transaction txn = Transaction.currentTxn();
-
-        txn.start();
-        SearchCriteria<HostTagVO> sc = HostSearch.create();
-        sc.setParameters("hostId", hostId);
-        expunge(sc);
-        
-        for (String tag : hostTags) {
-            tag = tag.trim();
-            if(tag.length() > 0) {
-                HostTagVO vo = new HostTagVO(hostId, tag);
-                persist(vo);
-            }
-        }
-        txn.commit();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java
index 863c181..3c676ff2 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java
@@ -25,16 +25,16 @@ import java.util.Map;
 import javax.inject.Inject;
 import javax.ws.rs.Path;
 
+import org.apache.cloudstack.engine.datacenter.entity.ClusterEntityImpl;
+import org.apache.cloudstack.engine.datacenter.entity.DataCenterResourceManager;
+import org.apache.cloudstack.engine.datacenter.entity.HostEntityImpl;
+import org.apache.cloudstack.engine.datacenter.entity.PodEntityImpl;
+import org.apache.cloudstack.engine.datacenter.entity.ZoneEntityImpl;
 import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntityImpl;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManager;
 import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.HostEntityImpl;
 import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.PodEntityImpl;
 import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
 import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntityImpl;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ChildTestConfiguration.java b/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ChildTestConfiguration.java
index 3b1721f..f6e7988 100644
--- a/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ChildTestConfiguration.java
+++ b/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ChildTestConfiguration.java
@@ -17,10 +17,11 @@
 package org.apache.cloudstack.engine.provisioning.test;
 
 
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineClusterDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineDataCenterDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineHostDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineHostPodDao;
+
 import org.mockito.Mockito;
 import org.springframework.context.annotation.Bean;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java b/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
index 0976f83..53f8ffb 100644
--- a/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
+++ b/engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
@@ -26,15 +26,19 @@ import java.util.UUID;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.datacenter.entity.EngineClusterVO;
+import org.apache.cloudstack.engine.datacenter.entity.EngineDataCenterVO;
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostPodVO;
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostVO;
 import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
 import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity;
 import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
 import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineClusterDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineDataCenterDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineHostDao;
+import org.apache.cloudstack.engine.datacenter.entity.dao.EngineHostPodDao;
 import org.apache.cloudstack.engine.service.api.ProvisioningService;
 import org.junit.Before;
 import org.junit.Test;
@@ -43,10 +47,6 @@ import org.mockito.Mockito;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
 
 import com.cloud.dc.DataCenter.NetworkType;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMComputeTagVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMComputeTagVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMComputeTagVO.java
new file mode 100644
index 0000000..484035c
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMComputeTagVO.java
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.engine.cloud.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "vm_compute_tags")
+public class VMComputeTagVO implements InternalIdentity{
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "vm_id")
+    private long vmId;
+
+    @Column(name = "compute_tag")
+    private String computeTag;
+
+    /**
+     * There should never be a public constructor for this class. Since it's
+     * only here to define the table for the DAO class.
+     */
+    protected VMComputeTagVO() {
+    }
+
+    public VMComputeTagVO(long vmId, String tag) {
+        this.vmId = vmId;
+        this.computeTag = tag;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getVmId() {
+        return vmId;
+    }
+
+    public String getComputeTag() {
+        return computeTag;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMEntityVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMEntityVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMEntityVO.java
new file mode 100644
index 0000000..8e09070
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMEntityVO.java
@@ -0,0 +1,577 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+// 
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.engine.cloud.entity;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.db.Encrypt;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.StateMachine;
+import com.cloud.utils.fsm.FiniteStateObject;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachine.State;
+
+@Entity
+@Table(name="vm_instance")
+@Inheritance(strategy=InheritanceType.JOINED)
+@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
+public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, VirtualMachine.Event> {
+    @Id
+    @TableGenerator(name="vm_instance_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="vm_instance_seq", allocationSize=1)
+    @Column(name="id", updatable=false, nullable = false)
+    protected long id;
+
+    @Column(name="name", updatable=false, nullable=false, length=255)
+    protected String hostName = null;
+
+    @Encrypt
+    @Column(name="vnc_password", updatable=true, nullable=false, length=255)
+    protected String vncPassword;
+
+    @Column(name="proxy_id", updatable=true, nullable=true)
+    protected Long proxyId;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name="proxy_assign_time", updatable=true, nullable=true)
+    protected Date proxyAssignTime;
+
+    /**
+     * Note that state is intentionally missing the setter.  Any updates to
+     * the state machine needs to go through the DAO object because someone
+     * else could be updating it as well.
+     */
+    @Enumerated(value=EnumType.STRING)
+    @StateMachine(state=State.class, event=Event.class)
+    @Column(name="state", updatable=true, nullable=false, length=32)
+    protected State state = null;
+
+    @Column(name="private_ip_address", updatable=true)
+    protected String privateIpAddress;
+
+    @Column(name="instance_name", updatable=true, nullable=false)
+    protected String instanceName;
+
+    @Column(name="vm_template_id", updatable=true, nullable=true, length=17)
+    protected Long templateId = new Long(-1);
+
+    @Column(name="guest_os_id", nullable=false, length=17)
+    protected long guestOSId;
+
+    @Column(name="host_id", updatable=true, nullable=true)
+    protected Long hostId;
+
+    @Column(name="last_host_id", updatable=true, nullable=true)
+    protected Long lastHostId;
+
+    @Column(name="pod_id", updatable=true, nullable=false)
+    protected Long podIdToDeployIn;
+
+    @Column(name="private_mac_address", updatable=true, nullable=true)
+    protected String privateMacAddress;
+
+    @Column(name="data_center_id", updatable=true, nullable=false)
+    protected long dataCenterIdToDeployIn;
+
+    @Column(name="vm_type", updatable=false, nullable=false, length=32)
+    @Enumerated(value=EnumType.STRING)
+    protected Type type;
+
+    @Column(name="ha_enabled", updatable=true, nullable=true)
+    protected boolean haEnabled;
+
+    @Column(name="limit_cpu_use", updatable=true, nullable=true)
+    private boolean limitCpuUse;
+
+    @Column(name="update_count", updatable = true, nullable=false)
+    protected long updated;	// This field should be updated everytime the state is updated.  There's no set method in the vo object because it is done with in the dao code.
+
+    @Column(name=GenericDao.CREATED_COLUMN)
+    protected Date created;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    protected Date removed;
+
+    @Column(name="update_time", updatable=true)
+    @Temporal(value=TemporalType.TIMESTAMP)
+    protected Date updateTime;
+
+    @Column(name="domain_id")
+    protected long domainId;
+
+    @Column(name="account_id")
+    protected long accountId;
+
+    @Column(name="service_offering_id")
+    protected long serviceOfferingId;
+
+    @Column(name="reservation_id")
+    protected String reservationId;
+
+    @Column(name="hypervisor_type")
+    @Enumerated(value=EnumType.STRING)
+    protected HypervisorType hypervisorType;
+
+    @Column(name="ram")
+    protected long ram;
+
+    @Column(name="cpu")
+    protected int cpu;
+
+    @Transient
+    Map<String, String> details;
+
+    @Column(name="uuid")
+    protected String uuid = UUID.randomUUID().toString();
+
+    //orchestration columns
+    @Column(name="owner")
+    private String owner = null;
+
+    @Column(name="speed")
+    private int speed;
+
+    @Transient
+    List<String> computeTags;
+
+    @Transient
+    List<String> rootDiskTags;
+
+    @Column(name="host_name")
+    private String hostname = null;
+
+    @Column(name="display_name")
+    private String displayname = null;
+
+    @Transient
+    List<String> networkIds;
+
+    @Column(name="disk_offering_id")
+    protected Long diskOfferingId;
+    
+    @Transient
+    private VMReservationVO vmReservation;
+    
+
+    public VMEntityVO(long id,
+            long serviceOfferingId,
+            String name,
+            String instanceName,
+            Type type,
+            Long vmTemplateId,
+            HypervisorType hypervisorType,
+            long guestOSId,
+            long domainId,
+            long accountId,
+            boolean haEnabled, Long diskOfferingId) {
+        this.id = id;
+        this.hostName = name != null ? name : this.uuid;
+        if (vmTemplateId != null) {
+            this.templateId = vmTemplateId;
+        }
+        this.instanceName = instanceName;
+        this.type = type;
+        this.guestOSId = guestOSId;
+        this.haEnabled = haEnabled;
+        this.vncPassword = Long.toHexString(new Random().nextLong());
+        this.state = State.Stopped;
+        this.accountId = accountId;
+        this.domainId = domainId;
+        this.serviceOfferingId = serviceOfferingId;
+        this.hypervisorType = hypervisorType;
+        this.limitCpuUse = false;
+        this.diskOfferingId = diskOfferingId;
+    }
+
+    public VMEntityVO(long id,
+            long serviceOfferingId,
+            String name,
+            String instanceName,
+            Type type,
+            Long vmTemplateId,
+            HypervisorType hypervisorType,
+            long guestOSId,
+            long domainId,
+            long accountId,
+            boolean haEnabled,
+            boolean limitResourceUse) {
+        this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled, null);
+        this.limitCpuUse = limitResourceUse;
+    }
+
+
+
+    protected VMEntityVO() {
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    @Override
+    public long getDomainId() {
+        return domainId;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+
+    @Override
+    public Type getType() {
+        return type;
+    }
+
+    public long getUpdated() {
+        return updated;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    @Override
+    public HypervisorType getHypervisorType() {
+        return hypervisorType;
+    }
+
+    @Override
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    @Override
+    public long getDataCenterId() {
+        return dataCenterIdToDeployIn;
+    }
+
+    @Override
+    public String getHostName() {
+        return hostName;
+    }
+
+    @Override
+    public String getInstanceName() {
+        return instanceName;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    // don't use this directly, use VM state machine instead, this method is added for migration tool only
+    @Override
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public String getPrivateIpAddress() {
+        return privateIpAddress;
+    }
+
+    public void setPrivateIpAddress(String address) {
+        privateIpAddress = address;
+    }
+
+    public void setVncPassword(String vncPassword) {
+        this.vncPassword = vncPassword;
+    }
+
+    @Override
+    public String getVncPassword() {
+        return vncPassword;
+    }
+
+    @Override
+    public long getServiceOfferingId() {
+        return serviceOfferingId;
+    }
+
+    public Long getProxyId() {
+        return proxyId;
+    }
+
+    public void setProxyId(Long proxyId) {
+        this.proxyId = proxyId;
+    }
+
+    public Date getProxyAssignTime() {
+        return this.proxyAssignTime;
+    }
+
+    public void setProxyAssignTime(Date time) {
+        this.proxyAssignTime = time;
+    }
+
+    @Override
+    public long getTemplateId() {
+        if (templateId == null) {
+            return -1;
+        } else {
+            return templateId;
+        }
+    }
+
+    public void setTemplateId(Long templateId) {
+        this.templateId = templateId;
+    }
+
+    @Override
+    public long getGuestOSId() {
+        return guestOSId;
+    }
+
+    public void setGuestOSId(long guestOSId) {
+        this.guestOSId = guestOSId;
+    }
+
+    public void incrUpdated() {
+        updated++;
+    }
+
+    public void decrUpdated() {
+        updated--;
+    }
+
+    @Override
+    public Long getHostId() {
+        return hostId;
+    }
+
+    @Override
+    public Long getLastHostId() {
+        return lastHostId;
+    }
+
+    public void setLastHostId(Long lastHostId) {
+        this.lastHostId = lastHostId;
+    }
+
+    public void setHostId(Long hostId) {
+        this.hostId = hostId;
+    }
+
+    @Override
+    public boolean isHaEnabled() {
+        return haEnabled;
+    }
+
+    @Override
+    public boolean limitCpuUse() {
+        return limitCpuUse;
+    }
+
+    public void setLimitCpuUse(boolean value) {
+        limitCpuUse = value;
+    }
+
+    @Override
+    public String getPrivateMacAddress() {
+        return privateMacAddress;
+    }
+
+    @Override
+    public Long getPodIdToDeployIn() {
+        return podIdToDeployIn;
+    }
+
+    public void setPodId(long podId) {
+        this.podIdToDeployIn = podId;
+    }
+
+    public void setPrivateMacAddress(String privateMacAddress) {
+        this.privateMacAddress = privateMacAddress;
+    }
+
+    public void setDataCenterId(long dataCenterId) {
+        this.dataCenterIdToDeployIn = dataCenterId;
+    }
+
+    public boolean isRemoved() {
+        return removed != null;
+    }
+
+    public void setHaEnabled(boolean value) {
+        haEnabled = value;
+    }
+
+    public void setReservationId(String reservationId) {
+        this.reservationId = reservationId;
+    }
+
+    public String getReservationId() {
+        return this.reservationId;
+    }
+
+    @Override
+    public Map<String, String> getDetails() {
+        return details;
+    }
+
+    public void setDetail(String name, String value) {
+        assert (details != null) : "Did you forget to load the details?";
+
+        details.put(name, value);
+    }
+
+    public void setDetails(Map<String, String> details) {
+        this.details = details;
+    }
+
+    transient String toString;
+    @Override
+    public String toString() {
+        if (toString == null) {
+            toString = new StringBuilder("VM[").append(type.toString()).append("|").append(hostName).append("]").toString();
+        }
+        return toString;
+    }
+
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (id ^ (id >>> 32));
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        VMEntityVO other = (VMEntityVO) obj;
+        if (id != other.id)
+            return false;
+        return true;
+    }
+
+
+    public void setServiceOfferingId(long serviceOfferingId) {
+        this.serviceOfferingId = serviceOfferingId;
+    }
+
+    public String getOwner() {
+        return owner;
+    }
+
+    public void setOwner(String owner) {
+        this.owner = owner;
+    }
+
+    public int getSpeed() {
+        return speed;
+    }
+
+    public void setSpeed(int speed) {
+        this.speed = speed;
+    }
+
+    public List<String> getComputeTags() {
+        return computeTags;
+    }
+
+    public void setComputeTags(List<String> computeTags) {
+        this.computeTags = computeTags;
+    }
+
+    public List<String> getRootDiskTags() {
+        return rootDiskTags;
+    }
+
+    public void setRootDiskTags(List<String> rootDiskTags) {
+        this.rootDiskTags = rootDiskTags;
+    }
+
+    public String getHostname() {
+        return hostname;
+    }
+
+    public void setHostname(String hostname) {
+        this.hostname = hostname;
+    }
+
+    public String getDisplayname() {
+        return displayname;
+    }
+
+    public void setDisplayname(String displayname) {
+        this.displayname = displayname;
+    }
+
+    public List<String> getNetworkIds() {
+        return networkIds;
+    }
+
+    public void setNetworkIds(List<String> networkIds) {
+        this.networkIds = networkIds;
+    }
+
+	@Override
+	public Long getDiskOfferingId() {
+		return diskOfferingId;
+	}
+
+    public VMReservationVO getVmReservation() {
+        return vmReservation;
+    }
+
+    public void setVmReservation(VMReservationVO vmReservation) {
+        this.vmReservation = vmReservation;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMNetworkMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMNetworkMapVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMNetworkMapVO.java
new file mode 100644
index 0000000..12095da
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMNetworkMapVO.java
@@ -0,0 +1,71 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.engine.cloud.entity;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.apache.cloudstack.api.InternalIdentity;
+
+
+@Entity
+@Table(name = "vm_network_map")
+public class VMNetworkMapVO implements InternalIdentity{
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "vm_id")
+    private long vmId;
+
+    @Column(name="network_id")
+    private long networkId;
+
+
+    /**
+     * There should never be a public constructor for this class. Since it's
+     * only here to define the table for the DAO class.
+     */
+    protected VMNetworkMapVO() {
+    }
+
+    public VMNetworkMapVO(long vmId, long networkId) {
+        this.vmId = vmId;
+        this.networkId = networkId;
+    }
+
+
+    public long getId() {
+        return id;
+    }
+
+    public long getVmId() {
+        return vmId;
+    }
+
+
+    public long getNetworkId() {
+        return networkId;
+    }
+
+}