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:03 UTC
[1/7] Moved VOs into the schema
Updated Branches:
refs/heads/vmsync 3dd26e85d -> 2fa361209
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
new file mode 100644
index 0000000..99ecd1f
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
@@ -0,0 +1,809 @@
+// 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.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.EngineHostVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
+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.EngineHostVO> lockRows(
+ SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> sc,
+ Filter filter, boolean exclusive) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public org.apache.cloudstack.engine.datacenter.entity.EngineHostVO lockOneRandomRow(
+ SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> sc,
+ boolean exclusive) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public List<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> search(
+ SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> sc,
+ Filter filter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> search(
+ SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> sc,
+ Filter filter, boolean enable_query_cache) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<org.apache.cloudstack.engine.datacenter.entity.EngineHostVO> searchIncludingRemoved(
+ SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDao.java
new file mode 100644
index 0000000..8fecf3b
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDao.java
@@ -0,0 +1,33 @@
+// 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.dao;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostPodVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
+
+
+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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDaoImpl.java
new file mode 100644
index 0000000..3daf356
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostPodDaoImpl.java
@@ -0,0 +1,184 @@
+// 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.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.EngineHostPodVO;
+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.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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDao.java
new file mode 100644
index 0000000..7a91a90
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDao.java
@@ -0,0 +1,32 @@
+// 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.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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDaoImpl.java
new file mode 100644
index 0000000..6c2db46
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostDetailsDaoImpl.java
@@ -0,0 +1,110 @@
+// 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.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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDao.java
new file mode 100644
index 0000000..73ffe01
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDao.java
@@ -0,0 +1,30 @@
+// 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.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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDaoImpl.java
new file mode 100644
index 0000000..a157bb7
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/HostTagsDaoImpl.java
@@ -0,0 +1,75 @@
+// 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.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();
+ }
+}
[7/7] git commit: updated refs/heads/vmsync to 2fa3612
Posted by ah...@apache.org.
Moved VOs into the schema
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2fa36120
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2fa36120
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2fa36120
Branch: refs/heads/vmsync
Commit: 2fa361209eeeebfd9b6cb2610a5bf41b5ad890c1
Parents: 3dd26e8
Author: Alex Huang <al...@gmail.com>
Authored: Tue May 14 13:06:48 2013 -0700
Committer: Alex Huang <al...@gmail.com>
Committed: Tue May 14 13:06:48 2013 -0700
----------------------------------------------------------------------
.../entity/api/DataCenterResourceEntity.java | 13 +-
.../engine/cloud/entity/api/VMEntityManager.java | 2 +-
.../cloud/entity/api/VMEntityManagerImpl.java | 8 +-
.../cloud/entity/api/VirtualMachineEntityImpl.java | 3 +-
.../engine/cloud/entity/api/db/VMComputeTagVO.java | 67 --
.../engine/cloud/entity/api/db/VMEntityVO.java | 577 ----------
.../engine/cloud/entity/api/db/VMNetworkMapVO.java | 71 --
.../cloud/entity/api/db/VMReservationVO.java | 127 ---
.../cloud/entity/api/db/VMRootDiskTagVO.java | 67 --
.../cloud/entity/api/db/VolumeReservationVO.java | 100 --
.../cloud/entity/api/db/dao/VMComputeTagDao.java | 31 -
.../entity/api/db/dao/VMComputeTagDaoImpl.java | 89 --
.../cloud/entity/api/db/dao/VMEntityDao.java | 41 -
.../cloud/entity/api/db/dao/VMEntityDaoImpl.java | 169 ---
.../cloud/entity/api/db/dao/VMNetworkMapDao.java | 31 -
.../entity/api/db/dao/VMNetworkMapDaoImpl.java | 85 --
.../cloud/entity/api/db/dao/VMReservationDao.java | 34 -
.../entity/api/db/dao/VMReservationDaoImpl.java | 111 --
.../cloud/entity/api/db/dao/VMRootDiskTagDao.java | 31 -
.../entity/api/db/dao/VMRootDiskTagDaoImpl.java | 88 --
.../entity/api/db/dao/VolumeReservationDao.java | 31 -
.../api/db/dao/VolumeReservationDaoImpl.java | 68 --
.../datacenter/entity/ClusterEntityImpl.java | 210 ++++
.../entity/DataCenterResourceManager.java | 51 +
.../entity/DataCenterResourceManagerImpl.java | 126 +++
.../engine/datacenter/entity/HostEntityImpl.java | 216 ++++
.../engine/datacenter/entity/PodEntityImpl.java | 212 ++++
.../engine/datacenter/entity/ZoneEntityImpl.java | 205 ++++
.../datacenter/entity/api/ClusterEntityImpl.java | 209 ----
.../entity/api/DataCenterResourceManager.java | 50 -
.../entity/api/DataCenterResourceManagerImpl.java | 129 ---
.../datacenter/entity/api/HostEntityImpl.java | 215 ----
.../datacenter/entity/api/PodEntityImpl.java | 211 ----
.../datacenter/entity/api/ZoneEntityImpl.java | 201 ----
.../datacenter/entity/api/db/ClusterDetailsVO.java | 68 --
.../datacenter/entity/api/db/DcDetailVO.java | 67 --
.../datacenter/entity/api/db/EngineCluster.java | 23 -
.../datacenter/entity/api/db/EngineClusterVO.java | 243 -----
.../datacenter/entity/api/db/EngineDataCenter.java | 23 -
.../entity/api/db/EngineDataCenterVO.java | 504 ---------
.../datacenter/entity/api/db/EngineHost.java | 24 -
.../datacenter/entity/api/db/EngineHostPodVO.java | 245 -----
.../datacenter/entity/api/db/EngineHostVO.java | 778 --------------
.../engine/datacenter/entity/api/db/EnginePod.java | 23 -
.../datacenter/entity/api/db/dao/DcDetailsDao.java | 29 -
.../entity/api/db/dao/DcDetailsDaoImpl.java | 94 --
.../entity/api/db/dao/EngineClusterDao.java | 37 -
.../entity/api/db/dao/EngineClusterDaoImpl.java | 288 -----
.../entity/api/db/dao/EngineDataCenterDao.java | 54 -
.../entity/api/db/dao/EngineDataCenterDaoImpl.java | 327 ------
.../entity/api/db/dao/EngineHostDao.java | 85 --
.../entity/api/db/dao/EngineHostDaoImpl.java | 809 ---------------
.../entity/api/db/dao/EngineHostPodDao.java | 33 -
.../entity/api/db/dao/EngineHostPodDaoImpl.java | 184 ----
.../entity/api/db/dao/HostDetailsDao.java | 32 -
.../entity/api/db/dao/HostDetailsDaoImpl.java | 110 --
.../datacenter/entity/api/db/dao/HostTagsDao.java | 30 -
.../entity/api/db/dao/HostTagsDaoImpl.java | 75 --
.../service/api/ProvisioningServiceImpl.java | 10 +-
.../provisioning/test/ChildTestConfiguration.java | 9 +-
.../engine/provisioning/test/ProvisioningTest.java | 16 +-
.../engine/cloud/entity/VMComputeTagVO.java | 67 ++
.../cloudstack/engine/cloud/entity/VMEntityVO.java | 577 ++++++++++
.../engine/cloud/entity/VMNetworkMapVO.java | 71 ++
.../engine/cloud/entity/VMReservationVO.java | 127 +++
.../engine/cloud/entity/VMRootDiskTagVO.java | 67 ++
.../engine/cloud/entity/VolumeReservationVO.java | 100 ++
.../engine/cloud/entity/dao/VMComputeTagDao.java | 31 +
.../cloud/entity/dao/VMComputeTagDaoImpl.java | 89 ++
.../engine/cloud/entity/dao/VMEntityDao.java | 41 +
.../engine/cloud/entity/dao/VMEntityDaoImpl.java | 170 +++
.../engine/cloud/entity/dao/VMNetworkMapDao.java | 31 +
.../cloud/entity/dao/VMNetworkMapDaoImpl.java | 87 ++
.../engine/cloud/entity/dao/VMReservationDao.java | 34 +
.../cloud/entity/dao/VMReservationDaoImpl.java | 112 ++
.../engine/cloud/entity/dao/VMRootDiskTagDao.java | 31 +
.../cloud/entity/dao/VMRootDiskTagDaoImpl.java | 88 ++
.../cloud/entity/dao/VolumeReservationDao.java | 31 +
.../cloud/entity/dao/VolumeReservationDaoImpl.java | 69 ++
.../engine/datacenter/entity/ClusterDetailsVO.java | 68 ++
.../engine/datacenter/entity/DcDetailVO.java | 67 ++
.../engine/datacenter/entity/EngineCluster.java | 23 +
.../engine/datacenter/entity/EngineClusterVO.java | 243 +++++
.../engine/datacenter/entity/EngineDataCenter.java | 23 +
.../datacenter/entity/EngineDataCenterVO.java | 504 +++++++++
.../engine/datacenter/entity/EngineHost.java | 24 +
.../engine/datacenter/entity/EngineHostPodVO.java | 245 +++++
.../engine/datacenter/entity/EngineHostVO.java | 778 ++++++++++++++
.../engine/datacenter/entity/EnginePod.java | 23 +
.../engine/datacenter/entity/dao/DcDetailsDao.java | 29 +
.../datacenter/entity/dao/DcDetailsDaoImpl.java | 95 ++
.../datacenter/entity/dao/EngineClusterDao.java | 37 +
.../entity/dao/EngineClusterDaoImpl.java | 288 +++++
.../datacenter/entity/dao/EngineDataCenterDao.java | 54 +
.../entity/dao/EngineDataCenterDaoImpl.java | 327 ++++++
.../datacenter/entity/dao/EngineHostDao.java | 85 ++
.../datacenter/entity/dao/EngineHostDaoImpl.java | 809 +++++++++++++++
.../datacenter/entity/dao/EngineHostPodDao.java | 33 +
.../entity/dao/EngineHostPodDaoImpl.java | 184 ++++
.../datacenter/entity/dao/HostDetailsDao.java | 32 +
.../datacenter/entity/dao/HostDetailsDaoImpl.java | 110 ++
.../engine/datacenter/entity/dao/HostTagsDao.java | 30 +
.../datacenter/entity/dao/HostTagsDaoImpl.java | 75 ++
103 files changed, 7061 insertions(+), 7047 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceEntity.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceEntity.java b/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceEntity.java
index 0817553..5ad4d0f 100755
--- a/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceEntity.java
+++ b/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceEntity.java
@@ -19,8 +19,6 @@
package org.apache.cloudstack.engine.datacenter.entity.api;
import javax.ws.rs.GET;
-
-
import javax.ws.rs.POST;
import javax.ws.rs.Produces;
@@ -30,14 +28,14 @@ import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.fsm.StateObject;
/**
- * This interface specifies the states and operations all physical
- * and virtual resources in the data center must implement.
+ * This interface specifies the states and operations all physical
+ * and virtual resources in the data center must implement.
*/
@Produces({"application/json", "application/xml"})
public interface DataCenterResourceEntity extends CloudStackEntity, StateObject<DataCenterResourceEntity.State> {
/**
- * This is the state machine for how CloudStack should interact with
+ * This is the state machine for how CloudStack should interact with
*
*/
public enum State {
@@ -66,12 +64,15 @@ public interface DataCenterResourceEntity extends CloudStackEntity, StateObject<
s_fsm.addTransition(Deactivated, Event.ActivatedRequest, Enabled);
}
+ public static StateMachine2<State, Event, DataCenterResourceEntity> getStateMachine() {
+ return s_fsm;
+ }
}
/**
* Prepare the resource to take new on new demands.
*/
- @POST
+ @POST
boolean enable();
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
index ca0a777..92d4401 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
@@ -16,7 +16,7 @@
// under the License.
package org.apache.cloudstack.engine.cloud.entity.api;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
+import org.apache.cloudstack.engine.cloud.entity.VMEntityVO;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
index 25e7423..2292fac 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
@@ -24,10 +24,10 @@ import java.util.UUID;
import javax.inject.Inject;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
-import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao;
-import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
+import org.apache.cloudstack.engine.cloud.entity.VMEntityVO;
+import org.apache.cloudstack.engine.cloud.entity.VMReservationVO;
+import org.apache.cloudstack.engine.cloud.entity.dao.VMEntityDao;
+import org.apache.cloudstack.engine.cloud.entity.dao.VMReservationDao;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.springframework.stereotype.Component;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
index dd57f9a..9dc0262 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
@@ -23,7 +23,8 @@ import java.util.Map;
import javax.inject.Inject;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
+import org.apache.cloudstack.engine.cloud.entity.VMEntityVO;
+
import org.springframework.stereotype.Component;
import com.cloud.deploy.DeploymentPlan;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java
deleted file mode 100644
index e4fc228..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMComputeTagVO.java
+++ /dev/null
@@ -1,67 +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.cloud.entity.api.db;
-
-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/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
deleted file mode 100644
index 4748215..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
+++ /dev/null
@@ -1,577 +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.cloud.entity.api.db;
-
-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/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMNetworkMapVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMNetworkMapVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMNetworkMapVO.java
deleted file mode 100644
index f29b19f..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMNetworkMapVO.java
+++ /dev/null
@@ -1,71 +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.cloud.entity.api.db;
-
-
-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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
deleted file mode 100644
index 5a69ec8..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
+++ /dev/null
@@ -1,127 +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.cloud.entity.api.db;
-
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
-
-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 javax.persistence.Transient;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name = "vm_reservation")
-public class VMReservationVO implements Identity, InternalIdentity{
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- private long id;
-
- @Column(name = "vm_id")
- private long vmId;
-
- @Column(name="uuid")
- private String uuid;
-
- @Column(name="data_center_id")
- private long dataCenterId;
-
- @Column(name="pod_id")
- private long podId;
-
- @Column(name="cluster_id")
- private long clusterId;
-
- @Column(name="host_id")
- private long hostId;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- private Date created;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- // VolumeId -> poolId
- @Transient
- Map<Long,Long> volumeReservationMap;
-
- /**
- * There should never be a public constructor for this class. Since it's
- * only here to define the table for the DAO class.
- */
- protected VMReservationVO() {
- }
-
- public VMReservationVO(long vmId, long dataCenterId, long podId, long clusterId, long hostId) {
- this.vmId = vmId;
- this.dataCenterId = dataCenterId;
- this.podId = podId;
- this.clusterId = clusterId;
- this.hostId = hostId;
- this.uuid = UUID.randomUUID().toString();
- }
-
-
- public long getId() {
- return id;
- }
-
- public long getVmId() {
- return vmId;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- public Long getPodId() {
- return podId;
- }
-
- public Long getClusterId() {
- return clusterId;
- }
-
- public Long getHostId() {
- return hostId;
- }
-
- public Map<Long,Long> getVolumeReservation(){
- return volumeReservationMap;
- }
-
- public void setVolumeReservation(Map<Long,Long> volumeReservationMap){
- this.volumeReservationMap = volumeReservationMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java
deleted file mode 100644
index 3c09e93..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMRootDiskTagVO.java
+++ /dev/null
@@ -1,67 +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.cloud.entity.api.db;
-
-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_root_disk_tags")
-public class VMRootDiskTagVO implements InternalIdentity {
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- private long id;
-
- @Column(name = "vm_id")
- private long vmId;
-
- @Column(name = "root_disk_tag")
- private String rootDiskTag;
-
- /**
- * There should never be a public constructor for this class. Since it's
- * only here to define the table for the DAO class.
- */
- protected VMRootDiskTagVO() {
- }
-
- public VMRootDiskTagVO(long vmId, String rootDiskTag) {
- this.vmId = vmId;
- this.rootDiskTag = rootDiskTag;
- }
-
- public long getId() {
- return id;
- }
-
- public long getVmId() {
- return vmId;
- }
-
- public String getRootDiskTag() {
- return rootDiskTag;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java
deleted file mode 100644
index f064623..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java
+++ /dev/null
@@ -1,100 +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.cloud.entity.api.db;
-
-import java.util.Date;
-import java.util.Map;
-
-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 javax.persistence.Transient;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name = "volume_reservation")
-public class VolumeReservationVO implements InternalIdentity{
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- private long id;
-
- @Column(name = "vm_reservation_id")
- private Long vmReservationId;
-
- @Column(name = "vm_id")
- private long vmId;
-
- @Column(name="volume_id")
- private long volumeId;
-
- @Column(name="pool_id")
- private long poolId;
-
- // VolumeId -> poolId
- @Transient
- Map<String, String> volumeReservationMap;
-
- /**
- * There should never be a public constructor for this class. Since it's
- * only here to define the table for the DAO class.
- */
- protected VolumeReservationVO() {
- }
-
- public VolumeReservationVO(long vmId, long volumeId, long poolId, Long vmReservationId) {
- this.vmId = vmId;
- this.volumeId = volumeId;
- this.poolId = poolId;
- this.vmReservationId = vmReservationId;
- }
-
-
- public long getId() {
- return id;
- }
-
- public long getVmId() {
- return vmId;
- }
-
- public Long geVmReservationId() {
- return vmReservationId;
- }
-
- public long getVolumeId() {
- return volumeId;
- }
-
- public Long getPoolId() {
- return poolId;
- }
-
-
- public Map<String,String> getVolumeReservation(){
- return volumeReservationMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java
deleted file mode 100644
index d8178d4..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDao.java
+++ /dev/null
@@ -1,31 +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.cloud.entity.api.db.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface VMComputeTagDao extends GenericDao<VMComputeTagVO, Long>{
-
- void persist(long vmId, List<String> computeTags);
-
- List<String> getComputeTags(long vmId);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java
deleted file mode 100644
index 6f70b35..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMComputeTagDaoImpl.java
+++ /dev/null
@@ -1,89 +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.cloud.entity.api.db.dao;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO;
-
-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 = { VMComputeTagDao.class })
-public class VMComputeTagDaoImpl extends GenericDaoBase<VMComputeTagVO, Long> implements VMComputeTagDao {
-
- protected SearchBuilder<VMComputeTagVO> VmIdSearch;
-
- public VMComputeTagDaoImpl() {
- }
-
- @PostConstruct
- public void init() {
- VmIdSearch = createSearchBuilder();
- VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
- VmIdSearch.done();
-
- }
-
- @Override
- public void persist(long vmId, List<String> computeTags) {
- Transaction txn = Transaction.currentTxn();
-
- txn.start();
- SearchCriteria<VMComputeTagVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
- expunge(sc);
-
- for (String tag : computeTags) {
- if(tag != null){
- tag = tag.trim();
- if(tag.length() > 0) {
- VMComputeTagVO vo = new VMComputeTagVO(vmId, tag);
- persist(vo);
- }
- }
- }
- txn.commit();
- }
-
- @Override
- public List<String> getComputeTags(long vmId) {
-
- SearchCriteria<VMComputeTagVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
-
- List<VMComputeTagVO> results = search(sc, null);
- List<String> computeTags = new ArrayList<String>(results.size());
- for (VMComputeTagVO result : results) {
- computeTags.add(result.getComputeTag());
- }
-
- return computeTags;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDao.java
deleted file mode 100644
index aa063dc..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDao.java
+++ /dev/null
@@ -1,41 +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.cloud.entity.api.db.dao;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
-
-import com.cloud.utils.Pair;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachine.State;
-import com.cloud.vm.VirtualMachine.Type;
-
-
-/*
- * Data Access Object for vm_instance table
- */
-public interface VMEntityDao extends GenericDao<VMEntityVO, Long> {
-
- void loadVmReservation(VMEntityVO vm);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java
deleted file mode 100644
index 3082d21..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMEntityDaoImpl.java
+++ /dev/null
@@ -1,169 +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.cloud.entity.api.db.dao;
-
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkVO;
-import com.cloud.utils.Pair;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.Transaction;
-import com.cloud.vm.NicProfile;
-
-
-
-@Component
-@Local(value = { VMEntityDao.class })
-public class VMEntityDaoImpl extends GenericDaoBase<VMEntityVO, Long> implements VMEntityDao {
-
- public static final Logger s_logger = Logger.getLogger(VMEntityDaoImpl.class);
-
-
- @Inject protected VMReservationDao _vmReservationDao;
-
- @Inject protected VMComputeTagDao _vmComputeTagDao;
-
- @Inject protected VMRootDiskTagDao _vmRootDiskTagsDao;
-
- @Inject protected VMNetworkMapDao _vmNetworkMapDao;
-
-
- @Inject
- protected NetworkDao _networkDao;
-
- public VMEntityDaoImpl() {
- }
-
- @PostConstruct
- protected void init() {
-
- }
-
- @Override
- public void loadVmReservation(VMEntityVO vm) {
- VMReservationVO vmReservation = _vmReservationDao.findByVmId(vm.getId());
- vm.setVmReservation(vmReservation);
- }
-
- @Override
- @DB
- public VMEntityVO persist(VMEntityVO vm) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
-
- VMEntityVO dbVO = super.persist(vm);
-
- saveVmNetworks(vm);
- loadVmNetworks(dbVO);
- saveVmReservation(vm);
- loadVmReservation(dbVO);
- saveComputeTags(vm.getId(), vm.getComputeTags());
- loadComputeTags(dbVO);
- saveRootDiskTags(vm.getId(), vm.getRootDiskTags());
- loadRootDiskTags(dbVO);
-
- txn.commit();
-
- return dbVO;
- }
-
- private void loadVmNetworks(VMEntityVO dbVO) {
- List<Long> networksIds = _vmNetworkMapDao.getNetworks(dbVO.getId());
-
- List<String> networks = new ArrayList<String>();
- for(Long networkId : networksIds){
- NetworkVO network = _networkDao.findById(networkId);
- if(network != null){
- networks.add(network.getUuid());
- }
- }
-
- dbVO.setNetworkIds(networks);
-
- }
-
- private void saveVmNetworks(VMEntityVO vm) {
- List<Long> networks = new ArrayList<Long>();
-
- List<String> networksIds = vm.getNetworkIds();
-
- if (networksIds == null || (networksIds != null && networksIds.isEmpty())) {
- return;
- }
-
-
- for(String uuid : networksIds){
- NetworkVO network = _networkDao.findByUuid(uuid);
- if(network != null){
- networks.add(network.getId());
- }
- }
- _vmNetworkMapDao.persist(vm.getId(), networks);
-
- }
-
- private void loadRootDiskTags(VMEntityVO dbVO) {
- List<String> rootDiskTags = _vmRootDiskTagsDao.getRootDiskTags(dbVO.getId());
- dbVO.setRootDiskTags(rootDiskTags);
-
- }
-
- private void loadComputeTags(VMEntityVO dbVO) {
- List<String> computeTags = _vmComputeTagDao.getComputeTags(dbVO.getId());
- dbVO.setComputeTags(computeTags);
-
- }
-
- private void saveRootDiskTags(long vmId, List<String> rootDiskTags) {
- if (rootDiskTags == null || (rootDiskTags != null && rootDiskTags.isEmpty())) {
- return;
- }
- _vmRootDiskTagsDao.persist(vmId, rootDiskTags);
-
- }
-
- private void saveComputeTags(long vmId, List<String> computeTags) {
- if (computeTags == null || (computeTags != null && computeTags.isEmpty())) {
- return;
- }
-
- _vmComputeTagDao.persist(vmId, computeTags);
- }
-
- private void saveVmReservation(VMEntityVO vm) {
- if(vm.getVmReservation() != null){
- _vmReservationDao.persist(vm.getVmReservation());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java
deleted file mode 100644
index 59c41c2..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDao.java
+++ /dev/null
@@ -1,31 +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.cloud.entity.api.db.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface VMNetworkMapDao extends GenericDao<VMNetworkMapVO, Long>{
-
- void persist(long vmId, List<Long> networks);
-
- List<Long> getNetworks(long vmId);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java
deleted file mode 100644
index 0f2c4cc..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMNetworkMapDaoImpl.java
+++ /dev/null
@@ -1,85 +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.cloud.entity.api.db.dao;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.inject.Inject;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO;
-import org.springframework.stereotype.Component;
-import com.cloud.network.dao.NetworkDao;
-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 = { VMNetworkMapDao.class })
-public class VMNetworkMapDaoImpl extends GenericDaoBase<VMNetworkMapVO, Long> implements VMNetworkMapDao {
-
- protected SearchBuilder<VMNetworkMapVO> VmIdSearch;
-
- @Inject
- protected NetworkDao _networkDao;
-
- public VMNetworkMapDaoImpl() {
- }
-
- @PostConstruct
- public void init() {
- VmIdSearch = createSearchBuilder();
- VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
- VmIdSearch.done();
-
- }
-
- @Override
- public void persist(long vmId, List<Long> networks) {
- Transaction txn = Transaction.currentTxn();
-
- txn.start();
- SearchCriteria<VMNetworkMapVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
- expunge(sc);
-
- for (Long networkId : networks) {
- VMNetworkMapVO vo = new VMNetworkMapVO(vmId, networkId);
- persist(vo);
- }
-
- txn.commit();
- }
-
- @Override
- public List<Long> getNetworks(long vmId) {
-
- SearchCriteria<VMNetworkMapVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
-
- List<VMNetworkMapVO> results = search(sc, null);
- List<Long> networks = new ArrayList<Long>(results.size());
- for (VMNetworkMapVO result : results) {
- networks.add(result.getNetworkId());
- }
-
- return networks;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java
deleted file mode 100644
index 721a8c4..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDao.java
+++ /dev/null
@@ -1,34 +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.cloud.entity.api.db.dao;
-
-
-import java.util.Map;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface VMReservationDao extends GenericDao<VMReservationVO, Long>{
-
- VMReservationVO findByVmId(long vmId);
-
- void loadVolumeReservation(VMReservationVO reservation);
-
- VMReservationVO findByReservationId(String reservationId);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java
deleted file mode 100644
index 73b4dd2..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMReservationDaoImpl.java
+++ /dev/null
@@ -1,111 +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.cloud.entity.api.db.dao;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO;
-import org.springframework.stereotype.Component;
-
-import com.cloud.host.dao.HostTagsDaoImpl;
-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;
-
-@Component
-@Local(value = { VMReservationDao.class })
-public class VMReservationDaoImpl extends GenericDaoBase<VMReservationVO, Long> implements VMReservationDao {
-
- protected SearchBuilder<VMReservationVO> VmIdSearch;
-
- @Inject protected VolumeReservationDao _volumeReservationDao;
-
- public VMReservationDaoImpl() {
- }
-
- @PostConstruct
- public void init() {
- VmIdSearch = createSearchBuilder();
- VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
- VmIdSearch.done();
- }
-
- @Override
- public VMReservationVO findByVmId(long vmId) {
- SearchCriteria<VMReservationVO> sc = VmIdSearch.create("vmId", vmId);
- VMReservationVO vmRes = findOneBy(sc);
- loadVolumeReservation(vmRes);
- return vmRes;
- }
-
-
- @Override
- public void loadVolumeReservation(VMReservationVO reservation){
- if(reservation != null){
- List<VolumeReservationVO> volumeResList = _volumeReservationDao.listVolumeReservation(reservation.getId());
- Map<Long, Long> volumeReservationMap = new HashMap<Long,Long>();
-
- for(VolumeReservationVO res : volumeResList){
- volumeReservationMap.put(res.getVolumeId(), res.getPoolId());
- }
- reservation.setVolumeReservation(volumeReservationMap);
- }
- }
-
- @Override
- @DB
- public VMReservationVO persist(VMReservationVO reservation) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
-
- VMReservationVO dbVO = super.persist(reservation);
-
- saveVolumeReservation(reservation);
- loadVolumeReservation(dbVO);
-
- txn.commit();
-
- return dbVO;
- }
-
- private void saveVolumeReservation(VMReservationVO reservation) {
- if(reservation.getVolumeReservation() != null){
- for(Long volumeId : reservation.getVolumeReservation().keySet()){
- VolumeReservationVO volumeReservation = new VolumeReservationVO(reservation.getVmId(), volumeId, reservation.getVolumeReservation().get(volumeId), reservation.getId());
- _volumeReservationDao.persist(volumeReservation);
- }
- }
- }
-
- @Override
- public VMReservationVO findByReservationId(String reservationId) {
- VMReservationVO vmRes = super.findByUuid(reservationId);
- loadVolumeReservation(vmRes);
- return vmRes;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java
deleted file mode 100644
index dc00880..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDao.java
+++ /dev/null
@@ -1,31 +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.cloud.entity.api.db.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface VMRootDiskTagDao extends GenericDao<VMRootDiskTagVO, Long>{
-
- void persist(long vmId, List<String> diskTags);
-
- List<String> getRootDiskTags(long vmId);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java
deleted file mode 100644
index be194bb..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VMRootDiskTagDaoImpl.java
+++ /dev/null
@@ -1,88 +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.cloud.entity.api.db.dao;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO;
-
-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 = { VMRootDiskTagDao.class })
-public class VMRootDiskTagDaoImpl extends GenericDaoBase<VMRootDiskTagVO, Long> implements VMRootDiskTagDao {
-
- protected SearchBuilder<VMRootDiskTagVO> VmIdSearch;
-
- public VMRootDiskTagDaoImpl() {
- }
-
- @PostConstruct
- public void init() {
- VmIdSearch = createSearchBuilder();
- VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
- VmIdSearch.done();
-
- }
-
- @Override
- public void persist(long vmId, List<String> rootDiskTags) {
- Transaction txn = Transaction.currentTxn();
-
- txn.start();
- SearchCriteria<VMRootDiskTagVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
- expunge(sc);
-
- for (String tag : rootDiskTags) {
- if(tag != null){
- tag = tag.trim();
- if(tag.length() > 0) {
- VMRootDiskTagVO vo = new VMRootDiskTagVO(vmId, tag);
- persist(vo);
- }
- }
- }
- txn.commit();
- }
-
-
- @Override
- public List<String> getRootDiskTags(long vmId) {
- SearchCriteria<VMRootDiskTagVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
-
- List<VMRootDiskTagVO> results = search(sc, null);
- List<String> computeTags = new ArrayList<String>(results.size());
- for (VMRootDiskTagVO result : results) {
- computeTags.add(result.getRootDiskTag());
- }
- return computeTags;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java
deleted file mode 100644
index fd709b0..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDao.java
+++ /dev/null
@@ -1,31 +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.cloud.entity.api.db.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface VolumeReservationDao extends GenericDao<VolumeReservationVO, Long>{
-
- VolumeReservationVO findByVmId(long vmId);
-
- List<VolumeReservationVO> listVolumeReservation(long vmReservationId);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java
deleted file mode 100644
index 26bc65f..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java
+++ /dev/null
@@ -1,68 +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.cloud.entity.api.db.dao;
-
-
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
-import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO;
-import org.springframework.stereotype.Component;
-
-import com.cloud.host.dao.HostTagsDaoImpl;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Component
-@Local(value = { VolumeReservationDao.class })
-public class VolumeReservationDaoImpl extends GenericDaoBase<VolumeReservationVO, Long> implements VolumeReservationDao {
-
- protected SearchBuilder<VolumeReservationVO> VmIdSearch;
- protected SearchBuilder<VolumeReservationVO> VmReservationIdSearch;
-
- public VolumeReservationDaoImpl() {
- }
-
- @PostConstruct
- public void init() {
- VmIdSearch = createSearchBuilder();
- VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
- VmIdSearch.done();
-
- VmReservationIdSearch = createSearchBuilder();
- VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().geVmReservationId(), SearchCriteria.Op.EQ);
- VmReservationIdSearch.done();
- }
-
- @Override
- public VolumeReservationVO findByVmId(long vmId) {
- SearchCriteria<VolumeReservationVO> sc = VmIdSearch.create("vmId", vmId);
- return findOneBy(sc);
- }
-
- @Override
- public List<VolumeReservationVO> listVolumeReservation(long vmReservationId) {
- SearchCriteria<VolumeReservationVO> sc = VmReservationIdSearch.create("vmReservationId", vmReservationId);
- return listBy(sc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
new file mode 100644
index 0000000..041fa12
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
@@ -0,0 +1,210 @@
+// 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;
+
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineClusterVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.org.Cluster.ClusterType;
+import com.cloud.org.Grouping.AllocationState;
+import com.cloud.org.Managed.ManagedState;
+import com.cloud.utils.fsm.NoTransitionException;
+
+
+public class ClusterEntityImpl implements ClusterEntity {
+
+
+ private DataCenterResourceManager manager;
+
+ private EngineClusterVO clusterVO;
+
+
+ public ClusterEntityImpl(String clusterId, DataCenterResourceManager manager) {
+ this.manager = manager;
+ this.clusterVO = this.manager.loadCluster(clusterId);
+ }
+
+ @Override
+ public boolean enable() {
+ try {
+ manager.changeState(this, Event.EnableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean disable() {
+ try {
+ manager.changeState(this, Event.DisableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean deactivate() {
+ try {
+ manager.changeState(this, Event.DeactivateRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public boolean reactivate() {
+ try {
+ manager.changeState(this, Event.ActivatedRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public State getState() {
+ return clusterVO.getState();
+ }
+
+ @Override
+ public void persist() {
+ manager.saveCluster(clusterVO);
+ }
+
+ @Override
+ public String getUuid() {
+ return clusterVO.getUuid();
+ }
+
+ @Override
+ public long getId() {
+ return clusterVO.getId();
+ }
+
+ @Override
+ public String getCurrentState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getDesiredState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getCreatedTime() {
+ return clusterVO.getCreated();
+ }
+
+ @Override
+ public Date getLastUpdatedTime() {
+ return clusterVO.getLastUpdated();
+ }
+
+ @Override
+ public String getOwner() {
+ return clusterVO.getOwner();
+ }
+
+ @Override
+ public Map<String, String> getDetails() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void addDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void delDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Method> getApplicableActions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return clusterVO.getName();
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return clusterVO.getDataCenterId();
+ }
+
+ @Override
+ public long getPodId() {
+ return clusterVO.getPodId();
+ }
+
+ @Override
+ public HypervisorType getHypervisorType() {
+ return clusterVO.getHypervisorType();
+ }
+
+ @Override
+ public ClusterType getClusterType() {
+ return clusterVO.getClusterType();
+ }
+
+ @Override
+ public AllocationState getAllocationState() {
+ return clusterVO.getAllocationState();
+ }
+
+ @Override
+ public ManagedState getManagedState() {
+ return clusterVO.getManagedState();
+ }
+
+ public void setOwner(String owner) {
+ clusterVO.setOwner(owner);
+ }
+
+ public void setName(String name) {
+ clusterVO.setName(name);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManager.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManager.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManager.java
new file mode 100644
index 0000000..65f3c93
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManager.java
@@ -0,0 +1,51 @@
+// 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;
+
+
+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.DataCenterResourceEntity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+import com.cloud.utils.fsm.NoTransitionException;
+
+
+
+public interface DataCenterResourceManager {
+
+ EngineDataCenterVO loadDataCenter(String dataCenterId);
+
+ void saveDataCenter(EngineDataCenterVO dc);
+
+ void savePod(EngineHostPodVO dc);
+
+ void saveCluster(EngineClusterVO cluster);
+
+ boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException;
+
+ EngineHostPodVO loadPod(String uuid);
+
+ EngineClusterVO loadCluster(String uuid);
+
+ EngineHostVO loadHost(String uuid);
+
+ void saveHost(EngineHostVO hostVO);
+
+}
[5/7] Moved VOs into the schema
Posted by ah...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java
deleted file mode 100644
index 4b4a560..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java
+++ /dev/null
@@ -1,778 +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;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-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.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-
-import com.cloud.host.Status;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.resource.ResourceState;
-import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.StateMachine;
-
-@Entity
-@Table(name="host")
-@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
-@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
-public class EngineHostVO implements EngineHost, Identity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="disconnected")
- @Temporal(value=TemporalType.TIMESTAMP)
- private Date disconnectedOn;
-
- @Column(name="name", nullable=false)
- private String name = null;
-
- /**
- * Note: There is no setter for status because it has to be set in the dao code.
- */
- @Column(name="status", nullable=false)
- private Status status = null;
-
- @Column(name="type", updatable = true, nullable=false)
- @Enumerated(value=EnumType.STRING)
- private Type type;
-
- @Column(name="private_ip_address", nullable=false)
- private String privateIpAddress;
-
- @Column(name="private_mac_address", nullable=false)
- private String privateMacAddress;
-
- @Column(name="private_netmask", nullable=false)
- private String privateNetmask;
-
- @Column(name="public_netmask")
- private String publicNetmask;
-
- @Column(name="public_ip_address")
- private String publicIpAddress;
-
- @Column(name="public_mac_address")
- private String publicMacAddress;
-
- @Column(name="storage_ip_address")
- private String storageIpAddress;
-
- @Column(name="cluster_id")
- private Long clusterId;
-
- @Column(name="storage_netmask")
- private String storageNetmask;
-
- @Column(name="storage_mac_address")
- private String storageMacAddress;
-
- @Column(name="storage_ip_address_2")
- private String storageIpAddressDeux;
-
- @Column(name="storage_netmask_2")
- private String storageNetmaskDeux;
-
- @Column(name="storage_mac_address_2")
- private String storageMacAddressDeux;
-
- @Column(name="hypervisor_type", updatable = true, nullable=false)
- @Enumerated(value=EnumType.STRING)
- private HypervisorType hypervisorType;
-
- @Column(name="proxy_port")
- private Integer proxyPort;
-
- @Column(name="resource")
- private String resource;
-
- @Column(name="fs_type")
- private StoragePoolType fsType;
-
- @Column(name="available")
- private boolean available = true;
-
- @Column(name="setup")
- private boolean setup = false;
-
- @Column(name="resource_state", nullable=false)
- @Enumerated(value=EnumType.STRING)
- private ResourceState resourceState;
-
- @Column(name="hypervisor_version")
- private String hypervisorVersion;
-
- @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="uuid")
- private String uuid;
-
- // This is a delayed load value. If the value is null,
- // then this field has not been loaded yet.
- // Call host dao to load it.
- @Transient
- Map<String, String> details;
-
- // This is a delayed load value. If the value is null,
- // then this field has not been loaded yet.
- // Call host dao to load it.
- @Transient
- List<String> hostTags;
-
- @Override
- public String getStorageIpAddressDeux() {
- return storageIpAddressDeux;
- }
-
- public void setStorageIpAddressDeux(String deuxStorageIpAddress) {
- this.storageIpAddressDeux = deuxStorageIpAddress;
- }
-
- @Override
- public String getStorageNetmaskDeux() {
- return storageNetmaskDeux;
- }
-
- @Override
- public Long getClusterId() {
- return clusterId;
- }
-
- public void setClusterId(Long clusterId) {
- this.clusterId = clusterId;
- }
-
- public void setStorageNetmaskDeux(String deuxStorageNetmask) {
- this.storageNetmaskDeux = deuxStorageNetmask;
- }
-
- @Override
- public String getStorageMacAddressDeux() {
- return storageMacAddressDeux;
- }
-
- public void setStorageMacAddressDeux(String duexStorageMacAddress) {
- this.storageMacAddressDeux = duexStorageMacAddress;
- }
-
- @Override
- public String getPrivateMacAddress() {
- return privateMacAddress;
- }
-
- public void setPrivateMacAddress(String privateMacAddress) {
- this.privateMacAddress = privateMacAddress;
- }
-
- public boolean isAvailable() {
- return available;
- }
-
- public void setAvailable(boolean available) {
- this.available = available;
- }
-
- @Override
- public String getPrivateNetmask() {
- return privateNetmask;
- }
-
- public void setPrivateNetmask(String privateNetmask) {
- this.privateNetmask = privateNetmask;
- }
-
- @Override
- public String getPublicNetmask() {
- return publicNetmask;
- }
-
- public void setPublicNetmask(String publicNetmask) {
- this.publicNetmask = publicNetmask;
- }
-
- @Override
- public String getPublicIpAddress() {
- return publicIpAddress;
- }
-
- public void setPublicIpAddress(String publicIpAddress) {
- this.publicIpAddress = publicIpAddress;
- }
-
- @Override
- public String getPublicMacAddress() {
- return publicMacAddress;
- }
-
- public void setPublicMacAddress(String publicMacAddress) {
- this.publicMacAddress = publicMacAddress;
- }
-
- @Override
- public String getStorageIpAddress() {
- return storageIpAddress;
- }
-
- public void setStorageIpAddress(String storageIpAddress) {
- this.storageIpAddress = storageIpAddress;
- }
-
- @Override
- public String getStorageNetmask() {
- return storageNetmask;
- }
-
- public void setStorageNetmask(String storageNetmask) {
- this.storageNetmask = storageNetmask;
- }
-
- @Override
- public String getStorageMacAddress() {
- return storageMacAddress;
- }
-
- public boolean isSetup() {
- return setup;
- }
-
- public void setSetup(boolean setup) {
- this.setup = setup;
- }
-
- public void setStorageMacAddress(String storageMacAddress) {
- this.storageMacAddress = storageMacAddress;
- }
-
- public String getResource() {
- return resource;
- }
-
- public void setResource(String resource) {
- this.resource = resource;
- }
-
- public Map<String, String> getDetails() {
- return details;
- }
-
- public String getDetail(String name) {
- assert (details != null) : "Did you forget to load the details?";
-
- return details != null ? details.get(name) : null;
- }
-
- 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;
- }
-
- public List<String> getHostTags() {
- return hostTags;
- }
-
- public void setHostTags(List<String> hostTags) {
- this.hostTags = hostTags;
- }
-
- @Column(name="data_center_id", nullable=false)
- private long dataCenterId;
-
- @Column(name="pod_id")
- private Long podId;
-
- @Column(name="cpus")
- private Integer cpus;
-
- @Column(name="url")
- private String storageUrl;
-
- @Column(name="speed")
- private Long speed;
-
- @Column(name="ram")
- private long totalMemory;
-
- @Column(name="parent", nullable=false)
- private String parent;
-
- @Column(name="guid", updatable=true, nullable=false)
- private String guid;
-
- @Column(name="capabilities")
- private String caps;
-
- @Column(name="total_size")
- private Long totalSize;
-
- @Column(name="last_ping")
- private long lastPinged;
-
- @Column(name="mgmt_server_id")
- private Long managementServerId;
-
- @Column(name="dom0_memory")
- private long dom0MinMemory;
-
- @Column(name="version")
- private String version;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- private Date created;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- //orchestration
- @Column(name="owner")
- private String owner = null;
-
- @Column(name="lastUpdated", updatable=true)
- @Temporal(value=TemporalType.TIMESTAMP)
- protected Date lastUpdated;
-
- /**
- * 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="engine_state", updatable=true, nullable=false, length=32)
- protected State engineState = null;
-
-
- public EngineHostVO(String guid) {
- this.guid = guid;
- this.status = Status.Creating;
- this.totalMemory = 0;
- this.dom0MinMemory = 0;
- this.resourceState = ResourceState.Creating;
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- protected EngineHostVO() {
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- public EngineHostVO(long id,
- String name,
- Type type,
- String privateIpAddress,
- String privateNetmask,
- String privateMacAddress,
- String publicIpAddress,
- String publicNetmask,
- String publicMacAddress,
- String storageIpAddress,
- String storageNetmask,
- String storageMacAddress,
- String deuxStorageIpAddress,
- String duxStorageNetmask,
- String deuxStorageMacAddress,
- String guid,
- Status status,
- String version,
- String iqn,
- Date disconnectedOn,
- long dcId,
- Long podId,
- long serverId,
- long ping,
- String parent,
- long totalSize,
- StoragePoolType fsType) {
- this(id, name, type, privateIpAddress, privateNetmask, privateMacAddress, publicIpAddress, publicNetmask, publicMacAddress, storageIpAddress, storageNetmask, storageMacAddress, guid, status, version, iqn, disconnectedOn, dcId, podId, serverId, ping, null, null, null, 0, null);
- this.parent = parent;
- this.totalSize = totalSize;
- this.fsType = fsType;
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- public EngineHostVO(long id,
- String name,
- Type type,
- String privateIpAddress,
- String privateNetmask,
- String privateMacAddress,
- String publicIpAddress,
- String publicNetmask,
- String publicMacAddress,
- String storageIpAddress,
- String storageNetmask,
- String storageMacAddress,
- String guid,
- Status status,
- String version,
- String url,
- Date disconnectedOn,
- long dcId,
- Long podId,
- long serverId,
- long ping,
- Integer cpus,
- Long speed,
- Long totalMemory,
- long dom0MinMemory,
- String caps) {
- this.id = id;
- this.name = name;
- this.status = status;
- this.type = type;
- this.privateIpAddress = privateIpAddress;
- this.privateNetmask = privateNetmask;
- this.privateMacAddress = privateMacAddress;
- this.publicIpAddress = publicIpAddress;
- this.publicNetmask = publicNetmask;
- this.publicMacAddress = publicMacAddress;
- this.storageIpAddress = storageIpAddress;
- this.storageNetmask = storageNetmask;
- this.storageMacAddress = storageMacAddress;
- this.dataCenterId = dcId;
- this.podId = podId;
- this.cpus = cpus;
- this.version = version;
- this.speed = speed;
- this.totalMemory = totalMemory != null ? totalMemory : 0;
- this.guid = guid;
- this.parent = null;
- this.totalSize = null;
- this.fsType = null;
- this.managementServerId = serverId;
- this.lastPinged = ping;
- this.caps = caps;
- this.disconnectedOn = disconnectedOn;
- this.dom0MinMemory = dom0MinMemory;
- this.storageUrl = url;
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- public void setPodId(Long podId) {
-
- this.podId = podId;
- }
-
- public void setDataCenterId(long dcId) {
- this.dataCenterId = dcId;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public void setStorageUrl(String url) {
- this.storageUrl = url;
- }
-
- public void setDisconnectedOn(Date disconnectedOn) {
- this.disconnectedOn = disconnectedOn;
- }
-
- public String getStorageUrl() {
- return storageUrl;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setPrivateIpAddress(String ipAddress) {
- this.privateIpAddress = ipAddress;
- }
-
- public void setCpus(Integer cpus) {
- this.cpus = cpus;
- }
-
- public void setSpeed(Long speed) {
- this.speed = speed;
- }
-
- public void setTotalMemory(long totalMemory) {
- this.totalMemory = totalMemory;
- }
-
- public void setParent(String parent) {
- this.parent = parent;
- }
-
- public void setCaps(String caps) {
- this.caps = caps;
- }
-
- public void setTotalSize(Long totalSize) {
- this.totalSize = totalSize;
- }
-
- public void setLastPinged(long lastPinged) {
- this.lastPinged = lastPinged;
- }
-
- public void setManagementServerId(Long managementServerId) {
- this.managementServerId = managementServerId;
- }
-
- @Override
- public long getLastPinged() {
- return lastPinged;
- }
-
- @Override
- public String getParent() {
- return parent;
- }
-
- @Override
- public long getTotalSize() {
- return totalSize;
- }
-
- @Override
- public String getCapabilities() {
- return caps;
- }
-
- @Override
- public Date getCreated() {
- return created;
- }
-
- @Override
- public Date getRemoved() {
- return removed;
- }
-
- @Override
- public String getVersion() {
- return version;
- }
-
- public void setType(Type type) {
- this.type = type;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public Status getStatus() {
- return status;
- }
-
- @Override
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- @Override
- public Long getPodId() {
- return podId;
- }
-
- @Override
- public Long getManagementServerId() {
- return managementServerId;
- }
-
- @Override
- public Date getDisconnectedOn() {
- return disconnectedOn;
- }
-
- @Override
- public String getPrivateIpAddress() {
- return privateIpAddress;
- }
-
- @Override
- public String getGuid() {
- return guid;
- }
-
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- @Override
- public Integer getCpus() {
- return cpus;
- }
-
- @Override
- public Long getSpeed() {
- return speed;
- }
-
- @Override
- public Long getTotalMemory() {
- return totalMemory;
- }
-
- @Override
- public Integer getProxyPort() {
- return proxyPort;
- }
-
- public void setProxyPort(Integer port) {
- proxyPort = port;
- }
-
- public StoragePoolType getFsType() {
- return fsType;
- }
-
- @Override
- public Type getType() {
- return type;
- }
-
- @Override
- public int hashCode() {
- return NumbersUtil.hash(id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EngineHostVO) {
- return ((EngineHostVO)obj).getId() == this.getId();
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return new StringBuilder("Host[").append("-").append(id).append("-").append(type).append("]").toString();
- }
-
- public void setHypervisorType(HypervisorType hypervisorType) {
- this.hypervisorType = hypervisorType;
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return hypervisorType;
- }
-
- public void setHypervisorVersion(String hypervisorVersion) {
- this.hypervisorVersion = hypervisorVersion;
- }
-
- @Override
- public String getHypervisorVersion() {
- return hypervisorVersion;
- }
-
- @Override
-
- // TODO, I tempoerary disable it as it breaks GenericSearchBuild when @Transient is applied
- // @Transient
- public Status getState() {
- return status;
- }
-
- @Override
- public ResourceState getResourceState() {
- return resourceState;
- }
-
- public void setResourceState(ResourceState state) {
- resourceState = state;
- }
-
- @Override
- public boolean isInMaintenanceStates() {
- return (getResourceState() == ResourceState.Maintenance || getResourceState() == ResourceState.ErrorInMaintenance
- || getResourceState() == ResourceState.PrepareForMaintenance);
- }
-
- public long getUpdated() {
- return updated;
- }
-
- public long incrUpdated() {
- updated++;
- return updated;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public State getOrchestrationState() {
- return engineState;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java
deleted file mode 100644
index 2adbca3..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EnginePod.java
+++ /dev/null
@@ -1,23 +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;
-
-import com.cloud.dc.Pod;
-
-public interface EnginePod extends Pod {
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDao.java
deleted file mode 100644
index ef1b3a0..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDao.java
+++ /dev/null
@@ -1,29 +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.Map;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.db.DcDetailVO;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface DcDetailsDao extends GenericDao<DcDetailVO, Long> {
- Map<String, String> findDetails(long dcId);
-
- void persist(long dcId, Map<String, String> details);
-
- DcDetailVO findDetail(long dcId, String name);
-
- void deleteDetails(long dcId);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java
deleted file mode 100644
index 60eec4c..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/DcDetailsDaoImpl.java
+++ /dev/null
@@ -1,94 +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 java.util.Map;
-
-import javax.ejb.Local;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.db.DcDetailVO;
-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(value="EngineDcDetailsDao")
-@Local(value=DcDetailsDao.class)
-public class DcDetailsDaoImpl extends GenericDaoBase<DcDetailVO, Long> implements DcDetailsDao {
- protected final SearchBuilder<DcDetailVO> DcSearch;
- protected final SearchBuilder<DcDetailVO> DetailSearch;
-
- protected DcDetailsDaoImpl() {
- DcSearch = createSearchBuilder();
- DcSearch.and("dcId", DcSearch.entity().getDcId(), SearchCriteria.Op.EQ);
- DcSearch.done();
-
- DetailSearch = createSearchBuilder();
- DetailSearch.and("dcId", DetailSearch.entity().getDcId(), SearchCriteria.Op.EQ);
- DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
- DetailSearch.done();
- }
-
- @Override
- public DcDetailVO findDetail(long dcId, String name) {
- SearchCriteria<DcDetailVO> sc = DetailSearch.create();
- sc.setParameters("dcId", dcId);
- sc.setParameters("name", name);
-
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public Map<String, String> findDetails(long dcId) {
- SearchCriteria<DcDetailVO> sc = DcSearch.create();
- sc.setParameters("dcId", dcId);
-
- List<DcDetailVO> results = search(sc, null);
- Map<String, String> details = new HashMap<String, String>(results.size());
- for (DcDetailVO result : results) {
- details.put(result.getName(), result.getValue());
- }
- return details;
- }
-
- @Override
- public void deleteDetails(long dcId) {
- SearchCriteria sc = DcSearch.create();
- sc.setParameters("dcId", dcId);
-
- List<DcDetailVO> results = search(sc, null);
- for (DcDetailVO result : results) {
- remove(result.getId());
- }
- }
-
- @Override
- public void persist(long dcId, Map<String, String> details) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- SearchCriteria<DcDetailVO> sc = DcSearch.create();
- sc.setParameters("dcId", dcId);
- expunge(sc);
-
- for (Map.Entry<String, String> detail : details.entrySet()) {
- DcDetailVO vo = new DcDetailVO(dcId, detail.getKey(), detail.getValue());
- 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/EngineClusterDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDao.java
deleted file mode 100644
index af1b153..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDao.java
+++ /dev/null
@@ -1,37 +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.List;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
-
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-public interface EngineClusterDao extends GenericDao<EngineClusterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
- List<EngineClusterVO> listByPodId(long podId);
- EngineClusterVO findBy(String name, long podId);
- List<EngineClusterVO> listByHyTypeWithoutGuid(String hyType);
- List<EngineClusterVO> listByZoneId(long zoneId);
-
- List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
- List<EngineClusterVO> listByDcHyType(long dcId, String hyType);
- Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
- List<Long> listDisabledClusters(long zoneId, Long podId);
- List<Long> listClustersWithDisabledPods(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/EngineClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java
deleted file mode 100644
index 1f0bd4d..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java
+++ /dev/null
@@ -1,288 +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 java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-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.EngineClusterVO;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.org.Grouping;
-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="EngineClusterDao")
-@Local(value=EngineClusterDao.class)
-public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> implements EngineClusterDao {
- private static final Logger s_logger = Logger.getLogger(EngineClusterDaoImpl.class);
-
- protected final SearchBuilder<EngineClusterVO> PodSearch;
- protected final SearchBuilder<EngineClusterVO> HyTypeWithoutGuidSearch;
- protected final SearchBuilder<EngineClusterVO> AvailHyperSearch;
- protected final SearchBuilder<EngineClusterVO> ZoneSearch;
- protected final SearchBuilder<EngineClusterVO> ZoneHyTypeSearch;
- protected SearchBuilder<EngineClusterVO> StateChangeSearch;
- protected SearchBuilder<EngineClusterVO> UUIDSearch;
-
- private static final String GET_POD_CLUSTER_MAP_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( ";
- private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
-
- @Inject protected EngineHostPodDao _hostPodDao;
-
- protected EngineClusterDaoImpl() {
- super();
-
- HyTypeWithoutGuidSearch = createSearchBuilder();
- HyTypeWithoutGuidSearch.and("hypervisorType", HyTypeWithoutGuidSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
- HyTypeWithoutGuidSearch.and("guid", HyTypeWithoutGuidSearch.entity().getGuid(), SearchCriteria.Op.NULL);
- HyTypeWithoutGuidSearch.done();
-
- ZoneHyTypeSearch = createSearchBuilder();
- ZoneHyTypeSearch.and("hypervisorType", ZoneHyTypeSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
- ZoneHyTypeSearch.and("dataCenterId", ZoneHyTypeSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneHyTypeSearch.done();
-
- PodSearch = createSearchBuilder();
- PodSearch.and("pod", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
- PodSearch.and("name", PodSearch.entity().getName(), SearchCriteria.Op.EQ);
- PodSearch.done();
-
- ZoneSearch = createSearchBuilder();
- ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- ZoneSearch.groupBy(ZoneSearch.entity().getHypervisorType());
- ZoneSearch.done();
-
- AvailHyperSearch = createSearchBuilder();
- AvailHyperSearch.and("zoneId", AvailHyperSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- AvailHyperSearch.select(null, Func.DISTINCT, AvailHyperSearch.entity().getHypervisorType());
- AvailHyperSearch.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<EngineClusterVO> listByZoneId(long zoneId) {
- SearchCriteria<EngineClusterVO> sc = ZoneSearch.create();
- sc.setParameters("dataCenterId", zoneId);
- return listBy(sc);
- }
-
- @Override
- public List<EngineClusterVO> listByPodId(long podId) {
- SearchCriteria<EngineClusterVO> sc = PodSearch.create();
- sc.setParameters("pod", podId);
-
- return listBy(sc);
- }
-
- @Override
- public EngineClusterVO findBy(String name, long podId) {
- SearchCriteria<EngineClusterVO> sc = PodSearch.create();
- sc.setParameters("pod", podId);
- sc.setParameters("name", name);
-
- return findOneBy(sc);
- }
-
- @Override
- public List<EngineClusterVO> listByHyTypeWithoutGuid(String hyType) {
- SearchCriteria<EngineClusterVO> sc = HyTypeWithoutGuidSearch.create();
- sc.setParameters("hypervisorType", hyType);
-
- return listBy(sc);
- }
-
- @Override
- public List<EngineClusterVO> listByDcHyType(long dcId, String hyType) {
- SearchCriteria<EngineClusterVO> sc = ZoneHyTypeSearch.create();
- sc.setParameters("dataCenterId", dcId);
- sc.setParameters("hypervisorType", hyType);
- return listBy(sc);
- }
-
- @Override
- public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
- SearchCriteria<EngineClusterVO> sc = AvailHyperSearch.create();
- if (zoneId != null) {
- sc.setParameters("zoneId", zoneId);
- }
- List<EngineClusterVO> clusters = listBy(sc);
- List<HypervisorType> hypers = new ArrayList<HypervisorType>(4);
- for (EngineClusterVO cluster : clusters) {
- hypers.add(cluster.getHypervisorType());
- }
-
- return hypers;
- }
-
- @Override
- public Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds){
- Transaction txn = Transaction.currentTxn();
- PreparedStatement pstmt = null;
- Map<Long, List<Long>> result = new HashMap<Long, List<Long>>();
-
- try {
- StringBuilder sql = new StringBuilder(GET_POD_CLUSTER_MAP_PREFIX);
- if (clusterIds.size() > 0) {
- for (Long clusterId : clusterIds) {
- sql.append(clusterId).append(",");
- }
- sql.delete(sql.length()-1, sql.length());
- sql.append(GET_POD_CLUSTER_MAP_SUFFIX);
- }
-
- pstmt = txn.prepareAutoCloseStatement(sql.toString());
- ResultSet rs = pstmt.executeQuery();
- while (rs.next()) {
- Long podId = rs.getLong(1);
- Long clusterIdInPod = rs.getLong(2);
- if(result.containsKey(podId)){
- List<Long> clusterList = result.get(podId);
- clusterList.add(clusterIdInPod);
- result.put(podId, clusterList);
- }else{
- List<Long> clusterList = new ArrayList<Long>();
- clusterList.add(clusterIdInPod);
- result.put(podId, clusterList);
- }
- }
- return result;
- } catch (SQLException e) {
- throw new CloudRuntimeException("DB Exception on: " + GET_POD_CLUSTER_MAP_PREFIX, e);
- } catch (Throwable e) {
- throw new CloudRuntimeException("Caught: " + GET_POD_CLUSTER_MAP_PREFIX, e);
- }
- }
-
- @Override
- public List<Long> listDisabledClusters(long zoneId, Long podId) {
- GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
- clusterIdSearch.selectField(clusterIdSearch.entity().getId());
- clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
- if(podId != null){
- clusterIdSearch.and("podId", clusterIdSearch.entity().getPodId(), Op.EQ);
- }
- clusterIdSearch.and("allocationState", clusterIdSearch.entity().getAllocationState(), Op.EQ);
- clusterIdSearch.done();
-
-
- SearchCriteria<Long> sc = clusterIdSearch.create();
- sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
- if (podId != null) {
- sc.addAnd("podId", SearchCriteria.Op.EQ, podId);
- }
- sc.addAnd("allocationState", SearchCriteria.Op.EQ, Grouping.AllocationState.Disabled);
- return customSearch(sc, null);
- }
-
- @Override
- public List<Long> listClustersWithDisabledPods(long zoneId) {
-
- GenericSearchBuilder<EngineHostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
- disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
- disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
- disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
-
- GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
- clusterIdSearch.selectField(clusterIdSearch.entity().getId());
- clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
- clusterIdSearch.done();
-
-
- SearchCriteria<Long> sc = clusterIdSearch.create();
- sc.setJoinParameters("disabledPodIdSearch", "dataCenterId", zoneId);
- sc.setJoinParameters("disabledPodIdSearch", "allocationState", Grouping.AllocationState.Disabled);
-
- return customSearch(sc, null);
- }
-
- @Override
- public boolean remove(Long id) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- EngineClusterVO cluster = createForUpdate();
- cluster.setName(null);
- cluster.setGuid(null);
-
- update(id, cluster);
-
- boolean result = super.remove(id);
- txn.commit();
- return result;
- }
-
- @Override
- public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
-
- EngineClusterVO vo = findById(clusterEntity.getId());
-
- Date oldUpdatedTime = vo.getLastUpdated();
-
- SearchCriteria<EngineClusterVO> 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(vo, sc);
-
- if (rows == 0 && s_logger.isDebugEnabled()) {
- EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
- if (dbCluster != null) {
- StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
- str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=")
- .append(dbCluster.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/EngineDataCenterDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDao.java
deleted file mode 100644
index 83060cf..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDao.java
+++ /dev/null
@@ -1,54 +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.List;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
-
-
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-
-public interface EngineDataCenterDao extends GenericDao<EngineDataCenterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
- EngineDataCenterVO findByName(String name);
-
- /**
- * @param id data center id
- * @return a pair of mac address strings. The first one is private and second is public.
- */
- String[] getNextAvailableMacAddressPair(long id);
- String[] getNextAvailableMacAddressPair(long id, long mask);
- List<EngineDataCenterVO> findZonesByDomainId(Long domainId);
-
- List<EngineDataCenterVO> listPublicZones(String keyword);
-
- List<EngineDataCenterVO> findChildZones(Object[] ids, String keyword);
-
- void loadDetails(EngineDataCenterVO zone);
- void saveDetails(EngineDataCenterVO zone);
-
- List<EngineDataCenterVO> listDisabledZones();
- List<EngineDataCenterVO> listEnabledZones();
- EngineDataCenterVO findByToken(String zoneToken);
- EngineDataCenterVO findByTokenOrIdOrName(String tokenIdOrName);
-
-
-
- List<EngineDataCenterVO> findZonesByDomainId(Long domainId, String keyword);
-
- List<EngineDataCenterVO> findByKeyword(String keyword);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDaoImpl.java
deleted file mode 100644
index f99bc6c..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDaoImpl.java
+++ /dev/null
@@ -1,327 +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.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-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.DataCenterResourceEntity.State.Event;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.org.Grouping;
-import com.cloud.utils.NumbersUtil;
-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.SequenceFetcher;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.UpdateBuilder;
-import com.cloud.utils.net.NetUtils;
-
-/**
- * @config
- * {@table
- * || Param Name | Description | Values | Default ||
- * || mac.address.prefix | prefix to attach to all public and private mac addresses | number | 06 ||
- * }
- **/
-@Component(value="EngineDataCenterDao")
-@Local(value={EngineDataCenterDao.class})
-public class EngineDataCenterDaoImpl extends GenericDaoBase<EngineDataCenterVO, Long> implements EngineDataCenterDao {
- private static final Logger s_logger = Logger.getLogger(EngineDataCenterDaoImpl.class);
-
- protected SearchBuilder<EngineDataCenterVO> NameSearch;
- protected SearchBuilder<EngineDataCenterVO> ListZonesByDomainIdSearch;
- protected SearchBuilder<EngineDataCenterVO> PublicZonesSearch;
- protected SearchBuilder<EngineDataCenterVO> ChildZonesSearch;
- protected SearchBuilder<EngineDataCenterVO> DisabledZonesSearch;
- protected SearchBuilder<EngineDataCenterVO> TokenSearch;
- protected SearchBuilder<EngineDataCenterVO> StateChangeSearch;
- protected SearchBuilder<EngineDataCenterVO> UUIDSearch;
-
- protected long _prefix;
- protected Random _rand = new Random(System.currentTimeMillis());
- protected TableGenerator _tgMacAddress;
-
- @Inject protected DcDetailsDao _detailsDao;
-
-
- @Override
- public EngineDataCenterVO findByName(String name) {
- SearchCriteria<EngineDataCenterVO> sc = NameSearch.create();
- sc.setParameters("name", name);
- return findOneBy(sc);
- }
-
-
- @Override
- public EngineDataCenterVO findByToken(String zoneToken){
- SearchCriteria<EngineDataCenterVO> sc = TokenSearch.create();
- sc.setParameters("zoneToken", zoneToken);
- return findOneBy(sc);
- }
-
- @Override
- public List<EngineDataCenterVO> findZonesByDomainId(Long domainId){
- SearchCriteria<EngineDataCenterVO> sc = ListZonesByDomainIdSearch.create();
- sc.setParameters("domainId", domainId);
- return listBy(sc);
- }
-
- @Override
- public List<EngineDataCenterVO> findZonesByDomainId(Long domainId, String keyword){
- SearchCriteria<EngineDataCenterVO> sc = ListZonesByDomainIdSearch.create();
- sc.setParameters("domainId", domainId);
- if (keyword != null) {
- SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- }
- return listBy(sc);
- }
-
- @Override
- public List<EngineDataCenterVO> findChildZones(Object[] ids, String keyword){
- SearchCriteria<EngineDataCenterVO> sc = ChildZonesSearch.create();
- sc.setParameters("domainid", ids);
- if (keyword != null) {
- SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- }
- return listBy(sc);
- }
-
- @Override
- public List<EngineDataCenterVO> listPublicZones(String keyword){
- SearchCriteria<EngineDataCenterVO> sc = PublicZonesSearch.create();
- if (keyword != null) {
- SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- }
- //sc.setParameters("domainId", domainId);
- return listBy(sc);
- }
-
- @Override
- public List<EngineDataCenterVO> findByKeyword(String keyword){
- SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- return listBy(ssc);
- }
-
-
- @Override
- public String[] getNextAvailableMacAddressPair(long id) {
- return getNextAvailableMacAddressPair(id, 0);
- }
-
- @Override
- public String[] getNextAvailableMacAddressPair(long id, long mask) {
- SequenceFetcher fetch = SequenceFetcher.getInstance();
-
- long seq = fetch.getNextSequence(Long.class, _tgMacAddress, id);
- seq = seq | _prefix | ((id & 0x7f) << 32);
- seq |= mask;
- seq |= ((_rand.nextInt(Short.MAX_VALUE) << 16) & 0x00000000ffff0000l);
- String[] pair = new String[2];
- pair[0] = NetUtils.long2Mac(seq);
- pair[1] = NetUtils.long2Mac(seq | 0x1l << 39);
- return pair;
- }
-
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- if (!super.configure(name, params)) {
- return false;
- }
-
- String value = (String)params.get("mac.address.prefix");
- _prefix = (long)NumbersUtil.parseInt(value, 06) << 40;
-
- return true;
- }
-
- protected EngineDataCenterDaoImpl() {
- super();
- NameSearch = createSearchBuilder();
- NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
- NameSearch.done();
-
- ListZonesByDomainIdSearch = createSearchBuilder();
- ListZonesByDomainIdSearch.and("domainId", ListZonesByDomainIdSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
- ListZonesByDomainIdSearch.done();
-
- PublicZonesSearch = createSearchBuilder();
- PublicZonesSearch.and("domainId", PublicZonesSearch.entity().getDomainId(), SearchCriteria.Op.NULL);
- PublicZonesSearch.done();
-
- ChildZonesSearch = createSearchBuilder();
- ChildZonesSearch.and("domainid", ChildZonesSearch.entity().getDomainId(), SearchCriteria.Op.IN);
- ChildZonesSearch.done();
-
- DisabledZonesSearch = createSearchBuilder();
- DisabledZonesSearch.and("allocationState", DisabledZonesSearch.entity().getAllocationState(), SearchCriteria.Op.EQ);
- DisabledZonesSearch.done();
-
- TokenSearch = createSearchBuilder();
- TokenSearch.and("zoneToken", TokenSearch.entity().getZoneToken(), SearchCriteria.Op.EQ);
- TokenSearch.done();
-
- StateChangeSearch = createSearchBuilder();
- StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
- StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
- StateChangeSearch.done();
-
- UUIDSearch = createSearchBuilder();
- UUIDSearch.and("uuid", UUIDSearch.entity().getUuid(), SearchCriteria.Op.EQ);
- UUIDSearch.done();
-
-
- _tgMacAddress = _tgs.get("macAddress");
- assert _tgMacAddress != null : "Couldn't get mac address table generator";
- }
-
- @Override @DB
- public boolean update(Long zoneId, EngineDataCenterVO zone) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- boolean persisted = super.update(zoneId, zone);
- if (!persisted) {
- return persisted;
- }
- saveDetails(zone);
- txn.commit();
- return persisted;
- }
-
- @Override
- public void loadDetails(EngineDataCenterVO zone) {
- Map<String, String> details =_detailsDao.findDetails(zone.getId());
- zone.setDetails(details);
- }
-
- @Override
- public void saveDetails(EngineDataCenterVO zone) {
- Map<String, String> details = zone.getDetails();
- if (details == null) {
- return;
- }
- _detailsDao.persist(zone.getId(), details);
- }
-
- @Override
- public List<EngineDataCenterVO> listDisabledZones(){
- SearchCriteria<EngineDataCenterVO> sc = DisabledZonesSearch.create();
- sc.setParameters("allocationState", Grouping.AllocationState.Disabled);
-
- List<EngineDataCenterVO> dcs = listBy(sc);
-
- return dcs;
- }
-
- @Override
- public List<EngineDataCenterVO> listEnabledZones(){
- SearchCriteria<EngineDataCenterVO> sc = DisabledZonesSearch.create();
- sc.setParameters("allocationState", Grouping.AllocationState.Enabled);
-
- List<EngineDataCenterVO> dcs = listBy(sc);
-
- return dcs;
- }
-
- @Override
- public EngineDataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
- EngineDataCenterVO result = findByToken(tokenOrIdOrName);
- if (result == null) {
- result = findByName(tokenOrIdOrName);
- if (result == null) {
- try {
- Long dcId = Long.parseLong(tokenOrIdOrName);
- return findById(dcId);
- } catch (NumberFormatException nfe) {
-
- }
- }
- }
- return result;
- }
-
- @Override
- public boolean remove(Long id) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- EngineDataCenterVO zone = createForUpdate();
- zone.setName(null);
-
- update(id, zone);
-
- boolean result = super.remove(id);
- txn.commit();
- return result;
- }
-
-
- @Override
- public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity zoneEntity, Object data) {
-
- EngineDataCenterVO vo = findById(zoneEntity.getId());
-
- Date oldUpdatedTime = vo.getLastUpdated();
-
- SearchCriteria<EngineDataCenterVO> 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(vo, sc);
-
- if (rows == 0 && s_logger.isDebugEnabled()) {
- EngineDataCenterVO 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/EngineHostDao.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java
deleted file mode 100644
index 3a71fe2..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDao.java
+++ /dev/null
@@ -1,85 +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.Date;
-import java.util.List;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
-
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.host.Status;
-import com.cloud.info.RunningHostCountInfo;
-import com.cloud.resource.ResourceState;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-/**
- * Data Access Object for server
- *
- */
-public interface EngineHostDao extends GenericDao<EngineHostVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
- long countBy(long clusterId, ResourceState... states);
-
- /**
- * Mark all hosts associated with a certain management server
- * as disconnected.
- *
- * @param msId management server id.
- */
- void markHostsAsDisconnected(long msId, long lastPing);
-
- List<EngineHostVO> findLostHosts(long timeout);
-
- List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId);
-
- List<RunningHostCountInfo> getRunningHostCounts(Date cutTime);
-
- long getNextSequence(long hostId);
-
- void loadDetails(EngineHostVO host);
-
- void saveDetails(EngineHostVO host);
-
- void loadHostTags(EngineHostVO host);
-
- List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
-
- long countRoutingHostsByDataCenter(long dcId);
-
- List<EngineHostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId);
-
- boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
-
- EngineHostVO findByGuid(String guid);
-
- EngineHostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type);
- List<EngineHostVO> findHypervisorHostInCluster(long clusterId);
-
-
- /**
- * @param type
- * @param clusterId
- * @param podId
- * @param dcId
- * @param haTag TODO
- * @return
- */
- List<EngineHostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
-}
[3/7] Moved VOs into the schema
Posted by ah...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMReservationVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMReservationVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMReservationVO.java
new file mode 100644
index 0000000..5c4b870
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMReservationVO.java
@@ -0,0 +1,127 @@
+// 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.Map;
+import java.util.UUID;
+
+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 javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "vm_reservation")
+public class VMReservationVO implements Identity, InternalIdentity{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "vm_id")
+ private long vmId;
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Column(name="data_center_id")
+ private long dataCenterId;
+
+ @Column(name="pod_id")
+ private long podId;
+
+ @Column(name="cluster_id")
+ private long clusterId;
+
+ @Column(name="host_id")
+ private long hostId;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ // VolumeId -> poolId
+ @Transient
+ Map<Long,Long> volumeReservationMap;
+
+ /**
+ * There should never be a public constructor for this class. Since it's
+ * only here to define the table for the DAO class.
+ */
+ protected VMReservationVO() {
+ }
+
+ public VMReservationVO(long vmId, long dataCenterId, long podId, long clusterId, long hostId) {
+ this.vmId = vmId;
+ this.dataCenterId = dataCenterId;
+ this.podId = podId;
+ this.clusterId = clusterId;
+ this.hostId = hostId;
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+
+ public long getId() {
+ return id;
+ }
+
+ public long getVmId() {
+ return vmId;
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public Long getHostId() {
+ return hostId;
+ }
+
+ public Map<Long,Long> getVolumeReservation(){
+ return volumeReservationMap;
+ }
+
+ public void setVolumeReservation(Map<Long,Long> volumeReservationMap){
+ this.volumeReservationMap = volumeReservationMap;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMRootDiskTagVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMRootDiskTagVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMRootDiskTagVO.java
new file mode 100644
index 0000000..396aafb
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VMRootDiskTagVO.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_root_disk_tags")
+public class VMRootDiskTagVO implements InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "vm_id")
+ private long vmId;
+
+ @Column(name = "root_disk_tag")
+ private String rootDiskTag;
+
+ /**
+ * There should never be a public constructor for this class. Since it's
+ * only here to define the table for the DAO class.
+ */
+ protected VMRootDiskTagVO() {
+ }
+
+ public VMRootDiskTagVO(long vmId, String rootDiskTag) {
+ this.vmId = vmId;
+ this.rootDiskTag = rootDiskTag;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getVmId() {
+ return vmId;
+ }
+
+ public String getRootDiskTag() {
+ return rootDiskTag;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VolumeReservationVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VolumeReservationVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VolumeReservationVO.java
new file mode 100644
index 0000000..ecb0e68
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/VolumeReservationVO.java
@@ -0,0 +1,100 @@
+// 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.Map;
+
+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 javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "volume_reservation")
+public class VolumeReservationVO implements InternalIdentity{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "vm_reservation_id")
+ private Long vmReservationId;
+
+ @Column(name = "vm_id")
+ private long vmId;
+
+ @Column(name="volume_id")
+ private long volumeId;
+
+ @Column(name="pool_id")
+ private long poolId;
+
+ // VolumeId -> poolId
+ @Transient
+ Map<String, String> volumeReservationMap;
+
+ /**
+ * There should never be a public constructor for this class. Since it's
+ * only here to define the table for the DAO class.
+ */
+ protected VolumeReservationVO() {
+ }
+
+ public VolumeReservationVO(long vmId, long volumeId, long poolId, Long vmReservationId) {
+ this.vmId = vmId;
+ this.volumeId = volumeId;
+ this.poolId = poolId;
+ this.vmReservationId = vmReservationId;
+ }
+
+
+ public long getId() {
+ return id;
+ }
+
+ public long getVmId() {
+ return vmId;
+ }
+
+ public Long geVmReservationId() {
+ return vmReservationId;
+ }
+
+ public long getVolumeId() {
+ return volumeId;
+ }
+
+ public Long getPoolId() {
+ return poolId;
+ }
+
+
+ public Map<String,String> getVolumeReservation(){
+ return volumeReservationMap;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDao.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDao.java
new file mode 100644
index 0000000..0123160
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDao.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 org.apache.cloudstack.engine.cloud.entity.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.cloud.entity.VMComputeTagVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface VMComputeTagDao extends GenericDao<VMComputeTagVO, Long>{
+
+ void persist(long vmId, List<String> computeTags);
+
+ List<String> getComputeTags(long vmId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDaoImpl.java
new file mode 100644
index 0000000..9535926
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMComputeTagDaoImpl.java
@@ -0,0 +1,89 @@
+// 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.dao;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+
+
+import org.apache.cloudstack.engine.cloud.entity.VMComputeTagVO;
+
+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 = { VMComputeTagDao.class })
+public class VMComputeTagDaoImpl extends GenericDaoBase<VMComputeTagVO, Long> implements VMComputeTagDao {
+
+ protected SearchBuilder<VMComputeTagVO> VmIdSearch;
+
+ public VMComputeTagDaoImpl() {
+ }
+
+ @PostConstruct
+ public void init() {
+ VmIdSearch = createSearchBuilder();
+ VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+ VmIdSearch.done();
+
+ }
+
+ @Override
+ public void persist(long vmId, List<String> computeTags) {
+ Transaction txn = Transaction.currentTxn();
+
+ txn.start();
+ SearchCriteria<VMComputeTagVO> sc = VmIdSearch.create();
+ sc.setParameters("vmId", vmId);
+ expunge(sc);
+
+ for (String tag : computeTags) {
+ if(tag != null){
+ tag = tag.trim();
+ if(tag.length() > 0) {
+ VMComputeTagVO vo = new VMComputeTagVO(vmId, tag);
+ persist(vo);
+ }
+ }
+ }
+ txn.commit();
+ }
+
+ @Override
+ public List<String> getComputeTags(long vmId) {
+
+ SearchCriteria<VMComputeTagVO> sc = VmIdSearch.create();
+ sc.setParameters("vmId", vmId);
+
+ List<VMComputeTagVO> results = search(sc, null);
+ List<String> computeTags = new ArrayList<String>(results.size());
+ for (VMComputeTagVO result : results) {
+ computeTags.add(result.getComputeTag());
+ }
+
+ return computeTags;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDao.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDao.java
new file mode 100644
index 0000000..7f6b3c6
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDao.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 org.apache.cloudstack.engine.cloud.entity.dao;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.cloud.entity.VMEntityVO;
+
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachine.State;
+import com.cloud.vm.VirtualMachine.Type;
+
+
+/*
+ * Data Access Object for vm_instance table
+ */
+public interface VMEntityDao extends GenericDao<VMEntityVO, Long> {
+
+ void loadVmReservation(VMEntityVO vm);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDaoImpl.java
new file mode 100644
index 0000000..bf153bc
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMEntityDaoImpl.java
@@ -0,0 +1,170 @@
+// 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.dao;
+
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.cloud.entity.VMEntityVO;
+import org.apache.cloudstack.engine.cloud.entity.VMReservationVO;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.Transaction;
+import com.cloud.vm.NicProfile;
+
+
+
+@Component
+@Local(value = { VMEntityDao.class })
+public class VMEntityDaoImpl extends GenericDaoBase<VMEntityVO, Long> implements VMEntityDao {
+
+ public static final Logger s_logger = Logger.getLogger(VMEntityDaoImpl.class);
+
+
+ @Inject protected VMReservationDao _vmReservationDao;
+
+ @Inject protected VMComputeTagDao _vmComputeTagDao;
+
+ @Inject protected VMRootDiskTagDao _vmRootDiskTagsDao;
+
+ @Inject protected VMNetworkMapDao _vmNetworkMapDao;
+
+
+ @Inject
+ protected NetworkDao _networkDao;
+
+ public VMEntityDaoImpl() {
+ }
+
+ @PostConstruct
+ protected void init() {
+
+ }
+
+ @Override
+ public void loadVmReservation(VMEntityVO vm) {
+ VMReservationVO vmReservation = _vmReservationDao.findByVmId(vm.getId());
+ vm.setVmReservation(vmReservation);
+ }
+
+ @Override
+ @DB
+ public VMEntityVO persist(VMEntityVO vm) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+
+ VMEntityVO dbVO = super.persist(vm);
+
+ saveVmNetworks(vm);
+ loadVmNetworks(dbVO);
+ saveVmReservation(vm);
+ loadVmReservation(dbVO);
+ saveComputeTags(vm.getId(), vm.getComputeTags());
+ loadComputeTags(dbVO);
+ saveRootDiskTags(vm.getId(), vm.getRootDiskTags());
+ loadRootDiskTags(dbVO);
+
+ txn.commit();
+
+ return dbVO;
+ }
+
+ private void loadVmNetworks(VMEntityVO dbVO) {
+ List<Long> networksIds = _vmNetworkMapDao.getNetworks(dbVO.getId());
+
+ List<String> networks = new ArrayList<String>();
+ for(Long networkId : networksIds){
+ NetworkVO network = _networkDao.findById(networkId);
+ if(network != null){
+ networks.add(network.getUuid());
+ }
+ }
+
+ dbVO.setNetworkIds(networks);
+
+ }
+
+ private void saveVmNetworks(VMEntityVO vm) {
+ List<Long> networks = new ArrayList<Long>();
+
+ List<String> networksIds = vm.getNetworkIds();
+
+ if (networksIds == null || (networksIds != null && networksIds.isEmpty())) {
+ return;
+ }
+
+
+ for(String uuid : networksIds){
+ NetworkVO network = _networkDao.findByUuid(uuid);
+ if(network != null){
+ networks.add(network.getId());
+ }
+ }
+ _vmNetworkMapDao.persist(vm.getId(), networks);
+
+ }
+
+ private void loadRootDiskTags(VMEntityVO dbVO) {
+ List<String> rootDiskTags = _vmRootDiskTagsDao.getRootDiskTags(dbVO.getId());
+ dbVO.setRootDiskTags(rootDiskTags);
+
+ }
+
+ private void loadComputeTags(VMEntityVO dbVO) {
+ List<String> computeTags = _vmComputeTagDao.getComputeTags(dbVO.getId());
+ dbVO.setComputeTags(computeTags);
+
+ }
+
+ private void saveRootDiskTags(long vmId, List<String> rootDiskTags) {
+ if (rootDiskTags == null || (rootDiskTags != null && rootDiskTags.isEmpty())) {
+ return;
+ }
+ _vmRootDiskTagsDao.persist(vmId, rootDiskTags);
+
+ }
+
+ private void saveComputeTags(long vmId, List<String> computeTags) {
+ if (computeTags == null || (computeTags != null && computeTags.isEmpty())) {
+ return;
+ }
+
+ _vmComputeTagDao.persist(vmId, computeTags);
+ }
+
+ private void saveVmReservation(VMEntityVO vm) {
+ if(vm.getVmReservation() != null){
+ _vmReservationDao.persist(vm.getVmReservation());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDao.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDao.java
new file mode 100644
index 0000000..102339f
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDao.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 org.apache.cloudstack.engine.cloud.entity.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.cloud.entity.VMNetworkMapVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface VMNetworkMapDao extends GenericDao<VMNetworkMapVO, Long>{
+
+ void persist(long vmId, List<Long> networks);
+
+ List<Long> getNetworks(long vmId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDaoImpl.java
new file mode 100644
index 0000000..f5d7036
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMNetworkMapDaoImpl.java
@@ -0,0 +1,87 @@
+// 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.dao;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.cloud.entity.VMNetworkMapVO;
+
+import org.springframework.stereotype.Component;
+import com.cloud.network.dao.NetworkDao;
+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 = { VMNetworkMapDao.class })
+public class VMNetworkMapDaoImpl extends GenericDaoBase<VMNetworkMapVO, Long> implements VMNetworkMapDao {
+
+ protected SearchBuilder<VMNetworkMapVO> VmIdSearch;
+
+ @Inject
+ protected NetworkDao _networkDao;
+
+ public VMNetworkMapDaoImpl() {
+ }
+
+ @PostConstruct
+ public void init() {
+ VmIdSearch = createSearchBuilder();
+ VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+ VmIdSearch.done();
+
+ }
+
+ @Override
+ public void persist(long vmId, List<Long> networks) {
+ Transaction txn = Transaction.currentTxn();
+
+ txn.start();
+ SearchCriteria<VMNetworkMapVO> sc = VmIdSearch.create();
+ sc.setParameters("vmId", vmId);
+ expunge(sc);
+
+ for (Long networkId : networks) {
+ VMNetworkMapVO vo = new VMNetworkMapVO(vmId, networkId);
+ persist(vo);
+ }
+
+ txn.commit();
+ }
+
+ @Override
+ public List<Long> getNetworks(long vmId) {
+
+ SearchCriteria<VMNetworkMapVO> sc = VmIdSearch.create();
+ sc.setParameters("vmId", vmId);
+
+ List<VMNetworkMapVO> results = search(sc, null);
+ List<Long> networks = new ArrayList<Long>(results.size());
+ for (VMNetworkMapVO result : results) {
+ networks.add(result.getNetworkId());
+ }
+
+ return networks;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDao.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDao.java
new file mode 100644
index 0000000..364d70c
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDao.java
@@ -0,0 +1,34 @@
+// 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.dao;
+
+
+import java.util.Map;
+
+import org.apache.cloudstack.engine.cloud.entity.VMReservationVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface VMReservationDao extends GenericDao<VMReservationVO, Long>{
+
+ VMReservationVO findByVmId(long vmId);
+
+ void loadVolumeReservation(VMReservationVO reservation);
+
+ VMReservationVO findByReservationId(String reservationId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDaoImpl.java
new file mode 100644
index 0000000..d6723ed
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMReservationDaoImpl.java
@@ -0,0 +1,112 @@
+// 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.dao;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.cloud.entity.VMEntityVO;
+import org.apache.cloudstack.engine.cloud.entity.VMReservationVO;
+import org.apache.cloudstack.engine.cloud.entity.VolumeReservationVO;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.host.dao.HostTagsDaoImpl;
+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;
+
+@Component
+@Local(value = { VMReservationDao.class })
+public class VMReservationDaoImpl extends GenericDaoBase<VMReservationVO, Long> implements VMReservationDao {
+
+ protected SearchBuilder<VMReservationVO> VmIdSearch;
+
+ @Inject protected VolumeReservationDao _volumeReservationDao;
+
+ public VMReservationDaoImpl() {
+ }
+
+ @PostConstruct
+ public void init() {
+ VmIdSearch = createSearchBuilder();
+ VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+ VmIdSearch.done();
+ }
+
+ @Override
+ public VMReservationVO findByVmId(long vmId) {
+ SearchCriteria<VMReservationVO> sc = VmIdSearch.create("vmId", vmId);
+ VMReservationVO vmRes = findOneBy(sc);
+ loadVolumeReservation(vmRes);
+ return vmRes;
+ }
+
+
+ @Override
+ public void loadVolumeReservation(VMReservationVO reservation){
+ if(reservation != null){
+ List<VolumeReservationVO> volumeResList = _volumeReservationDao.listVolumeReservation(reservation.getId());
+ Map<Long, Long> volumeReservationMap = new HashMap<Long,Long>();
+
+ for(VolumeReservationVO res : volumeResList){
+ volumeReservationMap.put(res.getVolumeId(), res.getPoolId());
+ }
+ reservation.setVolumeReservation(volumeReservationMap);
+ }
+ }
+
+ @Override
+ @DB
+ public VMReservationVO persist(VMReservationVO reservation) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+
+ VMReservationVO dbVO = super.persist(reservation);
+
+ saveVolumeReservation(reservation);
+ loadVolumeReservation(dbVO);
+
+ txn.commit();
+
+ return dbVO;
+ }
+
+ private void saveVolumeReservation(VMReservationVO reservation) {
+ if(reservation.getVolumeReservation() != null){
+ for(Long volumeId : reservation.getVolumeReservation().keySet()){
+ VolumeReservationVO volumeReservation = new VolumeReservationVO(reservation.getVmId(), volumeId, reservation.getVolumeReservation().get(volumeId), reservation.getId());
+ _volumeReservationDao.persist(volumeReservation);
+ }
+ }
+ }
+
+ @Override
+ public VMReservationVO findByReservationId(String reservationId) {
+ VMReservationVO vmRes = super.findByUuid(reservationId);
+ loadVolumeReservation(vmRes);
+ return vmRes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDao.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDao.java
new file mode 100644
index 0000000..44d9036
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDao.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 org.apache.cloudstack.engine.cloud.entity.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.cloud.entity.VMRootDiskTagVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface VMRootDiskTagDao extends GenericDao<VMRootDiskTagVO, Long>{
+
+ void persist(long vmId, List<String> diskTags);
+
+ List<String> getRootDiskTags(long vmId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDaoImpl.java
new file mode 100644
index 0000000..3f395ab
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VMRootDiskTagDaoImpl.java
@@ -0,0 +1,88 @@
+// 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.dao;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+
+
+import org.apache.cloudstack.engine.cloud.entity.VMRootDiskTagVO;
+
+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 = { VMRootDiskTagDao.class })
+public class VMRootDiskTagDaoImpl extends GenericDaoBase<VMRootDiskTagVO, Long> implements VMRootDiskTagDao {
+
+ protected SearchBuilder<VMRootDiskTagVO> VmIdSearch;
+
+ public VMRootDiskTagDaoImpl() {
+ }
+
+ @PostConstruct
+ public void init() {
+ VmIdSearch = createSearchBuilder();
+ VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+ VmIdSearch.done();
+
+ }
+
+ @Override
+ public void persist(long vmId, List<String> rootDiskTags) {
+ Transaction txn = Transaction.currentTxn();
+
+ txn.start();
+ SearchCriteria<VMRootDiskTagVO> sc = VmIdSearch.create();
+ sc.setParameters("vmId", vmId);
+ expunge(sc);
+
+ for (String tag : rootDiskTags) {
+ if(tag != null){
+ tag = tag.trim();
+ if(tag.length() > 0) {
+ VMRootDiskTagVO vo = new VMRootDiskTagVO(vmId, tag);
+ persist(vo);
+ }
+ }
+ }
+ txn.commit();
+ }
+
+
+ @Override
+ public List<String> getRootDiskTags(long vmId) {
+ SearchCriteria<VMRootDiskTagVO> sc = VmIdSearch.create();
+ sc.setParameters("vmId", vmId);
+
+ List<VMRootDiskTagVO> results = search(sc, null);
+ List<String> computeTags = new ArrayList<String>(results.size());
+ for (VMRootDiskTagVO result : results) {
+ computeTags.add(result.getRootDiskTag());
+ }
+ return computeTags;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDao.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDao.java
new file mode 100644
index 0000000..80534d9
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDao.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 org.apache.cloudstack.engine.cloud.entity.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.cloud.entity.VolumeReservationVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface VolumeReservationDao extends GenericDao<VolumeReservationVO, Long>{
+
+ VolumeReservationVO findByVmId(long vmId);
+
+ List<VolumeReservationVO> listVolumeReservation(long vmReservationId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDaoImpl.java
new file mode 100644
index 0000000..689628e
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/dao/VolumeReservationDaoImpl.java
@@ -0,0 +1,69 @@
+// 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.dao;
+
+
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.cloud.entity.VMReservationVO;
+import org.apache.cloudstack.engine.cloud.entity.VolumeReservationVO;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.host.dao.HostTagsDaoImpl;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = { VolumeReservationDao.class })
+public class VolumeReservationDaoImpl extends GenericDaoBase<VolumeReservationVO, Long> implements VolumeReservationDao {
+
+ protected SearchBuilder<VolumeReservationVO> VmIdSearch;
+ protected SearchBuilder<VolumeReservationVO> VmReservationIdSearch;
+
+ public VolumeReservationDaoImpl() {
+ }
+
+ @PostConstruct
+ public void init() {
+ VmIdSearch = createSearchBuilder();
+ VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+ VmIdSearch.done();
+
+ VmReservationIdSearch = createSearchBuilder();
+ VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().geVmReservationId(), SearchCriteria.Op.EQ);
+ VmReservationIdSearch.done();
+ }
+
+ @Override
+ public VolumeReservationVO findByVmId(long vmId) {
+ SearchCriteria<VolumeReservationVO> sc = VmIdSearch.create("vmId", vmId);
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<VolumeReservationVO> listVolumeReservation(long vmReservationId) {
+ SearchCriteria<VolumeReservationVO> sc = VmReservationIdSearch.create("vmReservationId", vmReservationId);
+ return listBy(sc);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/ClusterDetailsVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/ClusterDetailsVO.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/ClusterDetailsVO.java
new file mode 100644
index 0000000..720a3fc
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/ClusterDetailsVO.java
@@ -0,0 +1,68 @@
+// 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;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="cluster_details")
+public class ClusterDetailsVO {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="cluster_id")
+ private long clusterId;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="value")
+ private String value;
+
+ protected ClusterDetailsVO() {
+ }
+
+ public ClusterDetailsVO(long clusterId, String name, String value) {
+ this.clusterId = clusterId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getClusterId() {
+ return clusterId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/DcDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/DcDetailVO.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/DcDetailVO.java
new file mode 100644
index 0000000..c67c8eb
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/DcDetailVO.java
@@ -0,0 +1,67 @@
+// 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;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="data_center_details")
+public class DcDetailVO {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="dc_id")
+ private long dcId;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="value")
+ private String value;
+
+ protected DcDetailVO() {
+ }
+
+ public DcDetailVO(long dcId, String name, String value) {
+ this.dcId = dcId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getDcId() {
+ return dcId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineCluster.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineCluster.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineCluster.java
new file mode 100644
index 0000000..b95e131
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineCluster.java
@@ -0,0 +1,23 @@
+// 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;
+
+import com.cloud.org.Cluster;
+
+public interface EngineCluster extends Cluster {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
new file mode 100644
index 0000000..c64fdf8
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
@@ -0,0 +1,243 @@
+// 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;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.org.Cluster;
+import com.cloud.org.Grouping;
+import com.cloud.org.Managed.ManagedState;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.StateMachine;
+
+@Entity
+@Table(name="cluster")
+public class EngineClusterVO implements EngineCluster, Identity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name="id")
+ long id;
+
+ @Column(name="name")
+ String name;
+
+ @Column(name="guid")
+ String guid;
+
+ @Column(name="data_center_id")
+ long dataCenterId;
+
+ @Column(name="pod_id")
+ long podId;
+
+ @Column(name="hypervisor_type")
+ String hypervisorType;
+
+ @Column(name="cluster_type")
+ @Enumerated(value=EnumType.STRING)
+ Cluster.ClusterType clusterType;
+
+ @Column(name="allocation_state")
+ @Enumerated(value=EnumType.STRING)
+ AllocationState allocationState;
+
+ @Column(name="managed_state")
+ @Enumerated(value=EnumType.STRING)
+ ManagedState managedState;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name="uuid")
+ String uuid;
+
+ //orchestration
+
+ @Column(name="owner")
+ private String owner = null;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ @Column(name="lastUpdated", updatable=true)
+ @Temporal(value=TemporalType.TIMESTAMP)
+ protected Date lastUpdated;
+
+ /**
+ * 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="engine_state", updatable=true, nullable=false, length=32)
+ protected State engineState = null;
+
+
+ public EngineClusterVO() {
+ clusterType = Cluster.ClusterType.CloudManaged;
+ allocationState = Grouping.AllocationState.Enabled;
+
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ public EngineClusterVO(long dataCenterId, long podId, String name) {
+ this.dataCenterId = dataCenterId;
+ this.podId = podId;
+ this.name = name;
+ this.clusterType = Cluster.ClusterType.CloudManaged;
+ this.allocationState = Grouping.AllocationState.Enabled;
+ this.managedState = ManagedState.Managed;
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ @Override
+ public long getPodId() {
+ return podId;
+ }
+
+ @Override
+ public Cluster.ClusterType getClusterType() {
+ return clusterType;
+ }
+
+ public void setClusterType(Cluster.ClusterType clusterType) {
+ this.clusterType = clusterType;
+ }
+
+ @Override
+ public AllocationState getAllocationState() {
+ return allocationState;
+ }
+
+ public void setAllocationState(AllocationState allocationState) {
+ this.allocationState = allocationState;
+ }
+
+ @Override
+ public ManagedState getManagedState() {
+ return managedState;
+ }
+
+ public void setManagedState(ManagedState managedState) {
+ this.managedState = managedState;
+ }
+
+ public EngineClusterVO(long clusterId) {
+ this.id = clusterId;
+ }
+
+ @Override
+ public int hashCode() {
+ return NumbersUtil.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof EngineClusterVO)) {
+ return false;
+ }
+ EngineClusterVO that = (EngineClusterVO)obj;
+ return this.id == that.id;
+ }
+
+ @Override
+ public HypervisorType getHypervisorType() {
+ return HypervisorType.getType(hypervisorType);
+ }
+
+ public void setHypervisorType(String hy) {
+ hypervisorType = hy;
+ }
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public State getState() {
+ return engineState;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenter.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenter.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenter.java
new file mode 100644
index 0000000..027b0e6
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenter.java
@@ -0,0 +1,23 @@
+// 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;
+
+import com.cloud.dc.DataCenter;
+
+public interface EngineDataCenter extends DataCenter {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
new file mode 100644
index 0000000..08d3085
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
@@ -0,0 +1,504 @@
+// 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;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+
+import com.cloud.network.Network.Provider;
+import com.cloud.org.Grouping;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.StateMachine;
+
+@Entity
+@Table(name="data_center")
+public class EngineDataCenterVO implements EngineDataCenter, Identity {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="name")
+ private String name = null;
+
+ @Column(name="description")
+ private String description = null;
+
+ @Column(name="dns1")
+ private String dns1 = null;
+
+ @Column(name="dns2")
+ private String dns2 = null;
+
+ @Column(name="ip6Dns1")
+ private String ip6Dns1 = null;
+
+ @Column(name="ip6Dns2")
+ private String ip6Dns2 = null;
+
+ @Column(name="internal_dns1")
+ private String internalDns1 = null;
+
+ @Column(name="internal_dns2")
+ private String internalDns2 = null;
+
+ @Column(name="router_mac_address", updatable = false, nullable=false)
+ private String routerMacAddress = "02:00:00:00:00:01";
+
+ @Column(name="guest_network_cidr")
+ private String guestNetworkCidr = null;
+
+ @Column(name="domain_id")
+ private Long domainId = null;
+
+ @Column(name="domain")
+ private String domain;
+
+ @Column(name="networktype")
+ @Enumerated(EnumType.STRING)
+ NetworkType networkType;
+
+ @Column(name="dns_provider")
+ private String dnsProvider;
+
+ @Column(name="dhcp_provider")
+ private String dhcpProvider;
+
+ @Column(name="gateway_provider")
+ private String gatewayProvider;
+
+ @Column(name="vpn_provider")
+ private String vpnProvider;
+
+ @Column(name="userdata_provider")
+ private String userDataProvider;
+
+ @Column(name="lb_provider")
+ private String loadBalancerProvider;
+
+ @Column(name="firewall_provider")
+ private String firewallProvider;
+
+ @Column(name="mac_address", nullable=false)
+ @TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
+ private long macAddress = 1;
+
+ @Column(name="zone_token")
+ private String zoneToken;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ // This is a delayed load value. If the value is null,
+ // then this field has not been loaded yet.
+ // Call the dao to load it.
+ @Transient
+ Map<String, String> details;
+
+ @Column(name="allocation_state")
+ @Enumerated(value=EnumType.STRING)
+ AllocationState allocationState;
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Column(name="is_security_group_enabled")
+ boolean securityGroupEnabled;
+
+ @Column(name="is_local_storage_enabled")
+ boolean localStorageEnabled;
+
+ //orchestration
+ @Column(name="owner")
+ private String owner = null;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ @Column(name="lastUpdated", updatable=true)
+ @Temporal(value=TemporalType.TIMESTAMP)
+ protected Date lastUpdated;
+
+ /**
+ * 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="engine_state", updatable=true, nullable=false, length=32)
+ protected State engineState = null;
+
+
+ @Override
+ public String getDnsProvider() {
+ return dnsProvider;
+ }
+
+ public void setDnsProvider(String dnsProvider) {
+ this.dnsProvider = dnsProvider;
+ }
+
+ @Override
+ public String getDhcpProvider() {
+ return dhcpProvider;
+ }
+
+ public void setDhcpProvider(String dhcpProvider) {
+ this.dhcpProvider = dhcpProvider;
+ }
+
+ @Override
+ public String getGatewayProvider() {
+ return gatewayProvider;
+ }
+
+ public void setGatewayProvider(String gatewayProvider) {
+ this.gatewayProvider = gatewayProvider;
+ }
+
+ @Override
+ public String getLoadBalancerProvider() {
+ return loadBalancerProvider;
+ }
+
+ public void setLoadBalancerProvider(String loadBalancerProvider) {
+ this.loadBalancerProvider = loadBalancerProvider;
+ }
+
+ @Override
+ public String getFirewallProvider() {
+ return firewallProvider;
+ }
+
+ public void setFirewallProvider(String firewallProvider) {
+ this.firewallProvider = firewallProvider;
+ }
+
+ public EngineDataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
+ this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
+ this.id = id;
+ this.allocationState = Grouping.AllocationState.Enabled;
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) {
+ this.name = name;
+ this.description = description;
+ this.dns1 = dns1;
+ this.dns2 = dns2;
+ this.internalDns1 = dns3;
+ this.internalDns2 = dns4;
+ this.guestNetworkCidr = guestCidr;
+ this.domain = domain;
+ this.domainId = domainId;
+ this.networkType = zoneType;
+ this.allocationState = Grouping.AllocationState.Enabled;
+ this.securityGroupEnabled = securityGroupEnabled;
+ this.localStorageEnabled = localStorageEnabled;
+
+ if (zoneType == NetworkType.Advanced) {
+ loadBalancerProvider = Provider.VirtualRouter.getName();
+ firewallProvider = Provider.VirtualRouter.getName();
+ dhcpProvider = Provider.VirtualRouter.getName();
+ dnsProvider = Provider.VirtualRouter.getName();
+ gatewayProvider = Provider.VirtualRouter.getName();
+ vpnProvider = Provider.VirtualRouter.getName();
+ userDataProvider = Provider.VirtualRouter.getName();
+ } else if (zoneType == NetworkType.Basic){
+ dhcpProvider = Provider.VirtualRouter.getName();
+ dnsProvider = Provider.VirtualRouter.getName();
+ userDataProvider = Provider.VirtualRouter.getName();
+ loadBalancerProvider = Provider.ElasticLoadBalancerVm.getName();
+ }
+
+ this.zoneToken = zoneToken;
+ this.domain = domainSuffix;
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ @Override
+ public String getVpnProvider() {
+ return vpnProvider;
+ }
+
+ public void setVpnProvider(String vpnProvider) {
+ this.vpnProvider = vpnProvider;
+ }
+
+ @Override
+ public String getUserDataProvider() {
+ return userDataProvider;
+ }
+
+ public void setUserDataProvider(String userDataProvider) {
+ this.userDataProvider = userDataProvider;
+ }
+
+ @Override
+ public String getGuestNetworkCidr()
+ {
+ return guestNetworkCidr;
+ }
+
+ public void setGuestNetworkCidr(String guestNetworkCidr)
+ {
+ this.guestNetworkCidr = guestNetworkCidr;
+ }
+
+ @Override
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public void setDomainId(Long domainId) {
+ this.domainId = domainId;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public String getRouterMacAddress() {
+ return routerMacAddress;
+ }
+
+ @Override
+ public String getDns1() {
+ return dns1;
+ }
+
+ @Override
+ public String getDns2() {
+ return dns2;
+ }
+
+ @Override
+ public String getInternalDns1() {
+ return internalDns1;
+ }
+
+ @Override
+ public String getInternalDns2() {
+ return internalDns2;
+ }
+
+ protected EngineDataCenterVO() {
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setDns1(String dns1) {
+ this.dns1 = dns1;
+ }
+
+ public void setDns2(String dns2) {
+ this.dns2 = dns2;
+ }
+
+ public void setInternalDns1(String dns3) {
+ this.internalDns1 = dns3;
+ }
+
+ public void setInternalDns2(String dns4) {
+ this.internalDns2 = dns4;
+ }
+
+ public void setRouterMacAddress(String routerMacAddress) {
+ this.routerMacAddress = routerMacAddress;
+ }
+
+ @Override
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ public void setNetworkType(NetworkType zoneNetworkType) {
+ this.networkType = zoneNetworkType;
+ }
+
+ @Override
+ public NetworkType getNetworkType() {
+ return networkType;
+ }
+
+ @Override
+ public boolean isSecurityGroupEnabled() {
+ return securityGroupEnabled;
+ }
+
+ public void setSecurityGroupEnabled(boolean enabled) {
+ this.securityGroupEnabled = enabled;
+ }
+
+ @Override
+ public boolean isLocalStorageEnabled() {
+ return localStorageEnabled;
+ }
+
+ public void setLocalStorageEnabled(boolean enabled) {
+ this.localStorageEnabled = enabled;
+ }
+
+ @Override
+ public Map<String, String> getDetails() {
+ return details;
+ }
+
+ @Override
+ public void setDetails(Map<String, String> details2) {
+ details = details2;
+ }
+
+ public String getDetail(String name) {
+ assert (details != null) : "Did you forget to load the details?";
+
+ return details != null ? details.get(name) : null;
+ }
+
+ public void setDetail(String name, String value) {
+ assert (details != null) : "Did you forget to load the details?";
+
+ details.put(name, value);
+ }
+
+ @Override
+ public AllocationState getAllocationState() {
+ return allocationState;
+ }
+
+ public void setAllocationState(AllocationState allocationState) {
+ this.allocationState = allocationState;
+ }
+
+ @Override
+ public int hashCode() {
+ return NumbersUtil.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof EngineDataCenterVO)) {
+ return false;
+ }
+ EngineDataCenterVO that = (EngineDataCenterVO)obj;
+ return this.id == that.id;
+ }
+
+ @Override
+ public String getZoneToken() {
+ return zoneToken;
+ }
+
+ public void setZoneToken(String zoneToken) {
+ this.zoneToken = zoneToken;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public long getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(long macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public State getState() {
+ return engineState;
+ }
+
+ @Override
+ public String getIp6Dns1() {
+ return ip6Dns1;
+ }
+
+ public void setIp6Dns1(String ip6Dns1) {
+ this.ip6Dns1 = ip6Dns1;
+ }
+
+ @Override
+ public String getIp6Dns2() {
+ return ip6Dns2;
+ }
+
+ public void setIp6Dns2(String ip6Dns2) {
+ this.ip6Dns2 = ip6Dns2;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHost.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHost.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHost.java
new file mode 100644
index 0000000..82ab1f5
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHost.java
@@ -0,0 +1,24 @@
+// 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;
+
+import com.cloud.host.Host;
+
+public interface EngineHost extends Host {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
new file mode 100644
index 0000000..3b78b85
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
@@ -0,0 +1,245 @@
+// 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;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+import com.cloud.org.Grouping;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.StateMachine;
+
+@Entity
+@Table(name = "host_pod_ref")
+public class EngineHostPodVO implements EnginePod, Identity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ long id;
+
+ @Column(name = "name")
+ private String name = null;
+
+ @Column(name = "data_center_id")
+ private long dataCenterId;
+
+ @Column(name = "gateway")
+ private String gateway;
+
+ @Column(name = "cidr_address")
+ private String cidrAddress;
+
+ @Column(name = "cidr_size")
+ private int cidrSize;
+
+ @Column(name = "description")
+ private String description;
+
+ @Column(name="allocation_state")
+ @Enumerated(value=EnumType.STRING)
+ AllocationState allocationState;
+
+ @Column(name = "external_dhcp")
+ private Boolean externalDhcp;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ //orchestration
+ @Column(name="owner")
+ private String owner = null;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ @Column(name="lastUpdated", updatable=true)
+ @Temporal(value=TemporalType.TIMESTAMP)
+ protected Date lastUpdated;
+
+ /**
+ * 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="engine_state", updatable=true, nullable=false, length=32)
+ protected State engineState = null;
+
+ public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
+ this.name = name;
+ this.dataCenterId = dcId;
+ this.gateway = gateway;
+ this.cidrAddress = cidrAddress;
+ this.cidrSize = cidrSize;
+ this.description = description;
+ this.allocationState = Grouping.AllocationState.Enabled;
+ this.externalDhcp = false;
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ /*
+ * public HostPodVO(String name, long dcId) { this(null, name, dcId); }
+ */
+ protected EngineHostPodVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ public void setDataCenterId(long dataCenterId) {
+ this.dataCenterId = dataCenterId;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getCidrAddress() {
+ return cidrAddress;
+ }
+
+ public void setCidrAddress(String cidrAddress) {
+ this.cidrAddress = cidrAddress;
+ }
+
+ @Override
+ public int getCidrSize() {
+ return cidrSize;
+ }
+
+ public void setCidrSize(int cidrSize) {
+ this.cidrSize = cidrSize;
+ }
+
+ @Override
+ public String getGateway() {
+ return gateway;
+ }
+
+ public void setGateway(String gateway) {
+ this.gateway = gateway;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public AllocationState getAllocationState() {
+ return allocationState;
+ }
+
+ public void setAllocationState(AllocationState allocationState) {
+ this.allocationState = allocationState;
+ }
+
+ // Use for comparisons only.
+ public EngineHostPodVO(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ return NumbersUtil.hash(id);
+ }
+
+ @Override
+ public boolean getExternalDhcp() {
+ return externalDhcp;
+ }
+
+ public void setExternalDhcp(boolean use) {
+ externalDhcp = use;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof EngineHostPodVO) {
+ return id == ((EngineHostPodVO)obj).id;
+ } else {
+ return false;
+ }
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public State getState() {
+ return engineState;
+ }
+}
[4/7] Moved VOs into the schema
Posted by ah...@apache.org.
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;
+ }
+
+}
[6/7] Moved VOs into the schema
Posted by ah...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManagerImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManagerImpl.java
new file mode 100644
index 0000000..dfbaed5
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/DataCenterResourceManagerImpl.java
@@ -0,0 +1,126 @@
+// 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;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
+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.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.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 com.cloud.exception.InvalidParameterValueException;
+import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.utils.fsm.StateMachine2;
+
+public class DataCenterResourceManagerImpl implements DataCenterResourceManager {
+
+ @Inject
+ EngineDataCenterDao _dataCenterDao;
+
+ @Inject
+ EngineHostPodDao _podDao;
+
+ @Inject
+ EngineClusterDao _clusterDao;
+
+ @Inject
+ EngineHostDao _hostDao;
+
+
+ protected StateMachine2<State, Event, DataCenterResourceEntity> _stateMachine = DataCenterResourceEntity.State.getStateMachine();
+
+ @Override
+ public EngineDataCenterVO loadDataCenter(String dataCenterId) {
+ EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
+ if(dataCenterVO == null){
+ throw new InvalidParameterValueException("Zone does not exist");
+ }
+ return dataCenterVO;
+ }
+
+ @Override
+ public void saveDataCenter(EngineDataCenterVO dc) {
+ _dataCenterDao.persist(dc);
+
+ }
+
+ @Override
+ public boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException {
+
+ if(entity instanceof ZoneEntity){
+ return _stateMachine.transitTo(entity, event, null, _dataCenterDao);
+ }else if(entity instanceof PodEntity){
+ return _stateMachine.transitTo(entity, event, null, _podDao);
+ }else if(entity instanceof ClusterEntity){
+ return _stateMachine.transitTo(entity, event, null, _clusterDao);
+ }else if(entity instanceof HostEntity){
+ return _stateMachine.transitTo(entity, event, null, _hostDao);
+ }
+
+ return false;
+ }
+
+ @Override
+ public EngineHostPodVO loadPod(String uuid) {
+ EngineHostPodVO pod = _podDao.findByUuid(uuid);
+ if(pod == null){
+ throw new InvalidParameterValueException("Pod does not exist");
+ }
+ return pod;
+ }
+
+ @Override
+ public EngineClusterVO loadCluster(String uuid) {
+ EngineClusterVO cluster = _clusterDao.findByUuid(uuid);
+ if(cluster == null){
+ throw new InvalidParameterValueException("Pod does not exist");
+ }
+ return cluster;
+ }
+
+ @Override
+ public void savePod(EngineHostPodVO pod) {
+ _podDao.persist(pod);
+ }
+
+ @Override
+ public void saveCluster(EngineClusterVO cluster) {
+ _clusterDao.persist(cluster);
+ }
+
+ @Override
+ public EngineHostVO loadHost(String uuid) {
+ EngineHostVO host = _hostDao.findByUuid(uuid);
+ if(host == null){
+ throw new InvalidParameterValueException("Host does not exist");
+ }
+ return host;
+ }
+
+ @Override
+ public void saveHost(EngineHostVO hostVO) {
+ _hostDao.persist(hostVO);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/HostEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/HostEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/HostEntityImpl.java
new file mode 100644
index 0000000..dd8dcd3
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/HostEntityImpl.java
@@ -0,0 +1,216 @@
+// 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;
+
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.fsm.NoTransitionException;
+
+public class HostEntityImpl implements HostEntity {
+
+ private DataCenterResourceManager manager;
+
+ private EngineHostVO hostVO;
+
+ public HostEntityImpl(String uuid, DataCenterResourceManager manager) {
+ this.manager = manager;
+ hostVO = manager.loadHost(uuid);
+ }
+
+ @Override
+ public boolean enable() {
+ try {
+ manager.changeState(this, Event.EnableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean disable() {
+ try {
+ manager.changeState(this, Event.DisableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean deactivate() {
+ try {
+ manager.changeState(this, Event.DeactivateRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean reactivate() {
+ try {
+ manager.changeState(this, Event.ActivatedRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public State getState() {
+ return hostVO.getOrchestrationState();
+ }
+
+ @Override
+ public void persist() {
+ manager.saveHost(hostVO);
+ }
+
+ @Override
+ public String getName() {
+ return hostVO.getName();
+ }
+
+ @Override
+ public String getUuid() {
+ return hostVO.getUuid();
+ }
+
+ @Override
+ public long getId() {
+ return hostVO.getId();
+ }
+
+ @Override
+ public String getCurrentState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getDesiredState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getCreatedTime() {
+ return hostVO.getCreated();
+ }
+
+ @Override
+ public Date getLastUpdatedTime() {
+ return hostVO.getLastUpdated();
+ }
+
+ @Override
+ public String getOwner() {
+ // TODO Auto-generated method stub
+ return hostVO.getOwner();
+ }
+
+
+ public void setDetails(Map<String,String> details) {
+ hostVO.setDetails(details);
+ }
+
+ @Override
+ public Map<String, String> getDetails() {
+ return hostVO.getDetails();
+ }
+
+ @Override
+ public void addDetail(String name, String value) {
+ hostVO.setDetail(name, value);
+ }
+
+ @Override
+ public void delDetail(String name, String value) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void updateDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Method> getApplicableActions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Long getTotalMemory() {
+ return hostVO.getTotalMemory();
+ }
+
+ @Override
+ public Integer getCpus() {
+ return hostVO.getCpus();
+ }
+
+ @Override
+ public Long getSpeed() {
+ return hostVO.getSpeed();
+ }
+
+ @Override
+ public Long getPodId() {
+ return hostVO.getPodId();
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return hostVO.getDataCenterId();
+ }
+
+ @Override
+ public HypervisorType getHypervisorType() {
+ return hostVO.getHypervisorType();
+ }
+
+ @Override
+ public String getGuid() {
+ return hostVO.getGuid();
+ }
+
+ @Override
+ public Long getClusterId() {
+ return hostVO.getClusterId();
+ }
+
+ public void setOwner(String owner) {
+ hostVO.setOwner(owner);
+ }
+
+ public void setName(String name) {
+ hostVO.setName(name);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/PodEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/PodEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/PodEntityImpl.java
new file mode 100755
index 0000000..696c3e0
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/PodEntityImpl.java
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostPodVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+import com.cloud.org.Cluster;
+import com.cloud.org.Grouping.AllocationState;
+import com.cloud.utils.fsm.NoTransitionException;
+
+public class PodEntityImpl implements PodEntity {
+
+
+ private DataCenterResourceManager manager;
+
+ private EngineHostPodVO podVO;
+
+ public PodEntityImpl(String uuid, DataCenterResourceManager manager) {
+ this.manager = manager;
+ podVO = manager.loadPod(uuid);
+ }
+
+ @Override
+ public boolean enable() {
+ try {
+ manager.changeState(this, Event.EnableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean disable() {
+ try {
+ manager.changeState(this, Event.DisableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean deactivate() {
+ try {
+ manager.changeState(this, Event.DeactivateRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean reactivate() {
+ try {
+ manager.changeState(this, Event.ActivatedRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public State getState() {
+ return podVO.getState();
+ }
+
+ @Override
+ public String getUuid() {
+ return podVO.getUuid();
+ }
+
+ @Override
+ public long getId() {
+ return podVO.getId();
+ }
+
+ @Override
+ public String getCurrentState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getDesiredState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getCreatedTime() {
+ return podVO.getCreated();
+ }
+
+ @Override
+ public Date getLastUpdatedTime() {
+ return podVO.getLastUpdated();
+ }
+
+ @Override
+ public String getOwner() {
+ return podVO.getOwner();
+ }
+
+
+ @Override
+ public List<Method> getApplicableActions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getCidrAddress() {
+ return podVO.getCidrAddress();
+ }
+
+ @Override
+ public int getCidrSize() {
+ return podVO.getCidrSize();
+ }
+
+ @Override
+ public String getGateway() {
+ return podVO.getGateway();
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return podVO.getDataCenterId();
+ }
+
+ @Override
+ public String getName() {
+ return podVO.getName();
+ }
+
+ @Override
+ public AllocationState getAllocationState() {
+ return podVO.getAllocationState();
+ }
+
+ @Override
+ public boolean getExternalDhcp() {
+ return podVO.getExternalDhcp();
+ }
+
+ @Override
+ public List<Cluster> listClusters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void persist() {
+ manager.savePod(podVO);
+
+ }
+
+ @Override
+ public Map<String, String> getDetails() {
+ return null;
+ }
+
+ @Override
+ public void addDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void delDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDetail(String name, String value) {
+
+ }
+
+ public void setOwner(String owner) {
+ podVO.setOwner(owner);
+ }
+
+ public void setName(String name) {
+ podVO.setName(name);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ZoneEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ZoneEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ZoneEntityImpl.java
new file mode 100644
index 0000000..043b632
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ZoneEntityImpl.java
@@ -0,0 +1,205 @@
+/*
+ * 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;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineDataCenterVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
+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.DataCenterResourceEntity.State.Event;
+import com.cloud.utils.fsm.FiniteStateObject;
+import com.cloud.utils.fsm.NoTransitionException;
+
+
+@Path("/zone/{id}")
+public class ZoneEntityImpl implements ZoneEntity, FiniteStateObject<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event> {
+
+
+ private DataCenterResourceManager manager;
+
+ private EngineDataCenterVO dataCenterVO;
+
+
+ public ZoneEntityImpl(String dataCenterId, DataCenterResourceManager manager) {
+ this.manager = manager;
+ this.dataCenterVO = this.manager.loadDataCenter(dataCenterId);
+ }
+
+ @Override
+ @GET
+ public String getUuid() {
+ return dataCenterVO.getUuid();
+ }
+
+ @Override
+ public long getId() {
+ return dataCenterVO.getId();
+ }
+
+ @Override
+ public boolean enable() {
+ try {
+ manager.changeState(this, Event.EnableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean disable() {
+ try {
+ manager.changeState(this, Event.DisableRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean deactivate() {
+ try {
+ manager.changeState(this, Event.DeactivateRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean reactivate() {
+ try {
+ manager.changeState(this, Event.ActivatedRequest);
+ } catch (NoTransitionException e) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String getCurrentState() {
+ // TODO Auto-generated method stub
+ return "state";
+ }
+
+ @Override
+ public String getDesiredState() {
+ // TODO Auto-generated method stub
+ return "desired_state";
+ }
+
+ @Override
+ public Date getCreatedTime() {
+ return dataCenterVO.getCreated();
+ }
+
+ @Override
+ public Date getLastUpdatedTime() {
+ return dataCenterVO.getLastUpdated();
+ }
+
+ @Override
+ public String getOwner() {
+ return dataCenterVO.getOwner();
+ }
+
+
+ public void setOwner(String owner) {
+ dataCenterVO.setOwner(owner);
+ }
+
+ @Override
+ public Map<String, String> getDetails() {
+ return dataCenterVO.getDetails();
+ }
+
+ public void setDetails(Map<String,String> details) {
+ dataCenterVO.setDetails(details);
+ }
+
+
+ @Override
+ public void addDetail(String name, String value) {
+ dataCenterVO.setDetail(name, value);
+ }
+
+ @Override
+ public void delDetail(String name, String value) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void updateDetail(String name, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Method> getApplicableActions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public State getState() {
+ return dataCenterVO.getState();
+ }
+
+
+ @Override
+ public List<PodEntity> listPods() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setState(State state) {
+ //use FSM to set state.
+ }
+
+ @Override
+ public void persist() {
+ manager.saveDataCenter(dataCenterVO);
+ }
+
+ @Override
+ public String getName() {
+ return dataCenterVO.getName();
+ }
+
+ @Override
+ public List<String> listPodIds() {
+ List<String> podIds = new ArrayList<String>();
+ podIds.add("pod-uuid-1");
+ podIds.add("pod-uuid-2");
+ return podIds;
+ }
+
+ public void setName(String name) {
+ dataCenterVO.setName(name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java
deleted file mode 100644
index 46dd21d..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ClusterEntityImpl.java
+++ /dev/null
@@ -1,209 +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;
-
-import java.lang.reflect.Method;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.org.Cluster.ClusterType;
-import com.cloud.org.Grouping.AllocationState;
-import com.cloud.org.Managed.ManagedState;
-import com.cloud.utils.fsm.NoTransitionException;
-
-
-public class ClusterEntityImpl implements ClusterEntity {
-
-
- private DataCenterResourceManager manager;
-
- private EngineClusterVO clusterVO;
-
-
- public ClusterEntityImpl(String clusterId, DataCenterResourceManager manager) {
- this.manager = manager;
- this.clusterVO = this.manager.loadCluster(clusterId);
- }
-
- @Override
- public boolean enable() {
- try {
- manager.changeState(this, Event.EnableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean disable() {
- try {
- manager.changeState(this, Event.DisableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean deactivate() {
- try {
- manager.changeState(this, Event.DeactivateRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
-
- @Override
- public boolean reactivate() {
- try {
- manager.changeState(this, Event.ActivatedRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
-
- @Override
- public State getState() {
- return clusterVO.getState();
- }
-
- @Override
- public void persist() {
- manager.saveCluster(clusterVO);
- }
-
- @Override
- public String getUuid() {
- return clusterVO.getUuid();
- }
-
- @Override
- public long getId() {
- return clusterVO.getId();
- }
-
- @Override
- public String getCurrentState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getDesiredState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Date getCreatedTime() {
- return clusterVO.getCreated();
- }
-
- @Override
- public Date getLastUpdatedTime() {
- return clusterVO.getLastUpdated();
- }
-
- @Override
- public String getOwner() {
- return clusterVO.getOwner();
- }
-
- @Override
- public Map<String, String> getDetails() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void addDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void delDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void updateDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public List<Method> getApplicableActions() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getName() {
- return clusterVO.getName();
- }
-
- @Override
- public long getDataCenterId() {
- return clusterVO.getDataCenterId();
- }
-
- @Override
- public long getPodId() {
- return clusterVO.getPodId();
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return clusterVO.getHypervisorType();
- }
-
- @Override
- public ClusterType getClusterType() {
- return clusterVO.getClusterType();
- }
-
- @Override
- public AllocationState getAllocationState() {
- return clusterVO.getAllocationState();
- }
-
- @Override
- public ManagedState getManagedState() {
- return clusterVO.getManagedState();
- }
-
- public void setOwner(String owner) {
- clusterVO.setOwner(owner);
- }
-
- public void setName(String name) {
- clusterVO.setName(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java
deleted file mode 100644
index a5f6d5e..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManager.java
+++ /dev/null
@@ -1,50 +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;
-
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-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.utils.fsm.NoTransitionException;
-
-
-
-public interface DataCenterResourceManager {
-
- EngineDataCenterVO loadDataCenter(String dataCenterId);
-
- void saveDataCenter(EngineDataCenterVO dc);
-
- void savePod(EngineHostPodVO dc);
-
- void saveCluster(EngineClusterVO cluster);
-
- boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException;
-
- EngineHostPodVO loadPod(String uuid);
-
- EngineClusterVO loadCluster(String uuid);
-
- EngineHostVO loadHost(String uuid);
-
- void saveHost(EngineHostVO hostVO);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java
deleted file mode 100644
index c267e55..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceManagerImpl.java
+++ /dev/null
@@ -1,129 +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;
-
-import javax.inject.Inject;
-
-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.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 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.springframework.stereotype.Component;
-
-
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.utils.fsm.NoTransitionException;
-import com.cloud.utils.fsm.StateMachine2;
-
-@Component
-public class DataCenterResourceManagerImpl implements DataCenterResourceManager {
-
- @Inject
- EngineDataCenterDao _dataCenterDao;
-
- @Inject
- EngineHostPodDao _podDao;
-
- @Inject
- EngineClusterDao _clusterDao;
-
- @Inject
- EngineHostDao _hostDao;
-
-
- protected StateMachine2<State, Event, DataCenterResourceEntity> _stateMachine = DataCenterResourceEntity.State.s_fsm;
-
- @Override
- public EngineDataCenterVO loadDataCenter(String dataCenterId) {
- EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
- if(dataCenterVO == null){
- throw new InvalidParameterValueException("Zone does not exist");
- }
- return dataCenterVO;
- }
-
- @Override
- public void saveDataCenter(EngineDataCenterVO dc) {
- _dataCenterDao.persist(dc);
-
- }
-
- @Override
- public boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException {
-
- if(entity instanceof ZoneEntity){
- return _stateMachine.transitTo(entity, event, null, _dataCenterDao);
- }else if(entity instanceof PodEntity){
- return _stateMachine.transitTo(entity, event, null, _podDao);
- }else if(entity instanceof ClusterEntity){
- return _stateMachine.transitTo(entity, event, null, _clusterDao);
- }else if(entity instanceof HostEntity){
- return _stateMachine.transitTo(entity, event, null, _hostDao);
- }
-
- return false;
- }
-
- @Override
- public EngineHostPodVO loadPod(String uuid) {
- EngineHostPodVO pod = _podDao.findByUuid(uuid);
- if(pod == null){
- throw new InvalidParameterValueException("Pod does not exist");
- }
- return pod;
- }
-
- @Override
- public EngineClusterVO loadCluster(String uuid) {
- EngineClusterVO cluster = _clusterDao.findByUuid(uuid);
- if(cluster == null){
- throw new InvalidParameterValueException("Pod does not exist");
- }
- return cluster;
- }
-
- @Override
- public void savePod(EngineHostPodVO pod) {
- _podDao.persist(pod);
- }
-
- @Override
- public void saveCluster(EngineClusterVO cluster) {
- _clusterDao.persist(cluster);
- }
-
- @Override
- public EngineHostVO loadHost(String uuid) {
- EngineHostVO host = _hostDao.findByUuid(uuid);
- if(host == null){
- throw new InvalidParameterValueException("Host does not exist");
- }
- return host;
- }
-
- @Override
- public void saveHost(EngineHostVO hostVO) {
- _hostDao.persist(hostVO);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java
deleted file mode 100644
index 17114e7..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/HostEntityImpl.java
+++ /dev/null
@@ -1,215 +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;
-
-import java.lang.reflect.Method;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.fsm.NoTransitionException;
-
-public class HostEntityImpl implements HostEntity {
-
- private DataCenterResourceManager manager;
-
- private EngineHostVO hostVO;
-
- public HostEntityImpl(String uuid, DataCenterResourceManager manager) {
- this.manager = manager;
- hostVO = manager.loadHost(uuid);
- }
-
- @Override
- public boolean enable() {
- try {
- manager.changeState(this, Event.EnableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean disable() {
- try {
- manager.changeState(this, Event.DisableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean deactivate() {
- try {
- manager.changeState(this, Event.DeactivateRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean reactivate() {
- try {
- manager.changeState(this, Event.ActivatedRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public State getState() {
- return hostVO.getOrchestrationState();
- }
-
- @Override
- public void persist() {
- manager.saveHost(hostVO);
- }
-
- @Override
- public String getName() {
- return hostVO.getName();
- }
-
- @Override
- public String getUuid() {
- return hostVO.getUuid();
- }
-
- @Override
- public long getId() {
- return hostVO.getId();
- }
-
- @Override
- public String getCurrentState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getDesiredState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Date getCreatedTime() {
- return hostVO.getCreated();
- }
-
- @Override
- public Date getLastUpdatedTime() {
- return hostVO.getLastUpdated();
- }
-
- @Override
- public String getOwner() {
- // TODO Auto-generated method stub
- return hostVO.getOwner();
- }
-
-
- public void setDetails(Map<String,String> details) {
- hostVO.setDetails(details);
- }
-
- @Override
- public Map<String, String> getDetails() {
- return hostVO.getDetails();
- }
-
- @Override
- public void addDetail(String name, String value) {
- hostVO.setDetail(name, value);
- }
-
- @Override
- public void delDetail(String name, String value) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void updateDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public List<Method> getApplicableActions() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Long getTotalMemory() {
- return hostVO.getTotalMemory();
- }
-
- @Override
- public Integer getCpus() {
- return hostVO.getCpus();
- }
-
- @Override
- public Long getSpeed() {
- return hostVO.getSpeed();
- }
-
- @Override
- public Long getPodId() {
- return hostVO.getPodId();
- }
-
- @Override
- public long getDataCenterId() {
- return hostVO.getDataCenterId();
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return hostVO.getHypervisorType();
- }
-
- @Override
- public String getGuid() {
- return hostVO.getGuid();
- }
-
- @Override
- public Long getClusterId() {
- return hostVO.getClusterId();
- }
-
- public void setOwner(String owner) {
- hostVO.setOwner(owner);
- }
-
- public void setName(String name) {
- hostVO.setName(name);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java
deleted file mode 100755
index 758a997..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/PodEntityImpl.java
+++ /dev/null
@@ -1,211 +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;
-
-import java.lang.reflect.Method;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
-
-import com.cloud.org.Cluster;
-import com.cloud.org.Grouping.AllocationState;
-import com.cloud.utils.fsm.NoTransitionException;
-
-public class PodEntityImpl implements PodEntity {
-
-
- private DataCenterResourceManager manager;
-
- private EngineHostPodVO podVO;
-
- public PodEntityImpl(String uuid, DataCenterResourceManager manager) {
- this.manager = manager;
- podVO = manager.loadPod(uuid);
- }
-
- @Override
- public boolean enable() {
- try {
- manager.changeState(this, Event.EnableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean disable() {
- try {
- manager.changeState(this, Event.DisableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean deactivate() {
- try {
- manager.changeState(this, Event.DeactivateRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean reactivate() {
- try {
- manager.changeState(this, Event.ActivatedRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public State getState() {
- return podVO.getState();
- }
-
- @Override
- public String getUuid() {
- return podVO.getUuid();
- }
-
- @Override
- public long getId() {
- return podVO.getId();
- }
-
- @Override
- public String getCurrentState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getDesiredState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Date getCreatedTime() {
- return podVO.getCreated();
- }
-
- @Override
- public Date getLastUpdatedTime() {
- return podVO.getLastUpdated();
- }
-
- @Override
- public String getOwner() {
- return podVO.getOwner();
- }
-
-
- @Override
- public List<Method> getApplicableActions() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getCidrAddress() {
- return podVO.getCidrAddress();
- }
-
- @Override
- public int getCidrSize() {
- return podVO.getCidrSize();
- }
-
- @Override
- public String getGateway() {
- return podVO.getGateway();
- }
-
- @Override
- public long getDataCenterId() {
- return podVO.getDataCenterId();
- }
-
- @Override
- public String getName() {
- return podVO.getName();
- }
-
- @Override
- public AllocationState getAllocationState() {
- return podVO.getAllocationState();
- }
-
- @Override
- public boolean getExternalDhcp() {
- return podVO.getExternalDhcp();
- }
-
- @Override
- public List<Cluster> listClusters() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void persist() {
- manager.savePod(podVO);
-
- }
-
- @Override
- public Map<String, String> getDetails() {
- return null;
- }
-
- @Override
- public void addDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void delDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void updateDetail(String name, String value) {
-
- }
-
- public void setOwner(String owner) {
- podVO.setOwner(owner);
- }
-
- public void setName(String name) {
- podVO.setName(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java
deleted file mode 100644
index e254880..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntityImpl.java
+++ /dev/null
@@ -1,201 +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;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
-import com.cloud.utils.fsm.FiniteStateObject;
-import com.cloud.utils.fsm.NoTransitionException;
-
-
-@Path("/zone/{id}")
-public class ZoneEntityImpl implements ZoneEntity, FiniteStateObject<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event> {
-
-
- private DataCenterResourceManager manager;
-
- private EngineDataCenterVO dataCenterVO;
-
-
- public ZoneEntityImpl(String dataCenterId, DataCenterResourceManager manager) {
- this.manager = manager;
- this.dataCenterVO = this.manager.loadDataCenter(dataCenterId);
- }
-
- @Override
- @GET
- public String getUuid() {
- return dataCenterVO.getUuid();
- }
-
- @Override
- public long getId() {
- return dataCenterVO.getId();
- }
-
- @Override
- public boolean enable() {
- try {
- manager.changeState(this, Event.EnableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean disable() {
- try {
- manager.changeState(this, Event.DisableRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean deactivate() {
- try {
- manager.changeState(this, Event.DeactivateRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean reactivate() {
- try {
- manager.changeState(this, Event.ActivatedRequest);
- } catch (NoTransitionException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public String getCurrentState() {
- // TODO Auto-generated method stub
- return "state";
- }
-
- @Override
- public String getDesiredState() {
- // TODO Auto-generated method stub
- return "desired_state";
- }
-
- @Override
- public Date getCreatedTime() {
- return dataCenterVO.getCreated();
- }
-
- @Override
- public Date getLastUpdatedTime() {
- return dataCenterVO.getLastUpdated();
- }
-
- @Override
- public String getOwner() {
- return dataCenterVO.getOwner();
- }
-
-
- public void setOwner(String owner) {
- dataCenterVO.setOwner(owner);
- }
-
- @Override
- public Map<String, String> getDetails() {
- return dataCenterVO.getDetails();
- }
-
- public void setDetails(Map<String,String> details) {
- dataCenterVO.setDetails(details);
- }
-
-
- @Override
- public void addDetail(String name, String value) {
- dataCenterVO.setDetail(name, value);
- }
-
- @Override
- public void delDetail(String name, String value) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void updateDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public List<Method> getApplicableActions() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public State getState() {
- return dataCenterVO.getState();
- }
-
-
- @Override
- public List<PodEntity> listPods() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setState(State state) {
- //use FSM to set state.
- }
-
- @Override
- public void persist() {
- manager.saveDataCenter(dataCenterVO);
- }
-
- @Override
- public String getName() {
- return dataCenterVO.getName();
- }
-
- @Override
- public List<String> listPodIds() {
- List<String> podIds = new ArrayList<String>();
- podIds.add("pod-uuid-1");
- podIds.add("pod-uuid-2");
- return podIds;
- }
-
- public void setName(String name) {
- dataCenterVO.setName(name);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/ClusterDetailsVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/ClusterDetailsVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/ClusterDetailsVO.java
deleted file mode 100644
index d735c47..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/ClusterDetailsVO.java
+++ /dev/null
@@ -1,68 +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;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="cluster_details")
-public class ClusterDetailsVO {
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="cluster_id")
- private long clusterId;
-
- @Column(name="name")
- private String name;
-
- @Column(name="value")
- private String value;
-
- protected ClusterDetailsVO() {
- }
-
- public ClusterDetailsVO(long clusterId, String name, String value) {
- this.clusterId = clusterId;
- this.name = name;
- this.value = value;
- }
-
- public long getClusterId() {
- return clusterId;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public long getId() {
- return id;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/DcDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/DcDetailVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/DcDetailVO.java
deleted file mode 100644
index ef59118..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/DcDetailVO.java
+++ /dev/null
@@ -1,67 +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;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="data_center_details")
-public class DcDetailVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="dc_id")
- private long dcId;
-
- @Column(name="name")
- private String name;
-
- @Column(name="value")
- private String value;
-
- protected DcDetailVO() {
- }
-
- public DcDetailVO(long dcId, String name, String value) {
- this.dcId = dcId;
- this.name = name;
- this.value = value;
- }
-
- public long getDcId() {
- return dcId;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public long getId() {
- return id;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java
deleted file mode 100644
index 98b7a99..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineCluster.java
+++ /dev/null
@@ -1,23 +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;
-
-import com.cloud.org.Cluster;
-
-public interface EngineCluster extends Cluster {
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineClusterVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineClusterVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineClusterVO.java
deleted file mode 100644
index 0034419..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineClusterVO.java
+++ /dev/null
@@ -1,243 +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;
-
-import java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.org.Cluster;
-import com.cloud.org.Grouping;
-import com.cloud.org.Managed.ManagedState;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.StateMachine;
-
-@Entity
-@Table(name="cluster")
-public class EngineClusterVO implements EngineCluster, Identity {
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="name")
- String name;
-
- @Column(name="guid")
- String guid;
-
- @Column(name="data_center_id")
- long dataCenterId;
-
- @Column(name="pod_id")
- long podId;
-
- @Column(name="hypervisor_type")
- String hypervisorType;
-
- @Column(name="cluster_type")
- @Enumerated(value=EnumType.STRING)
- Cluster.ClusterType clusterType;
-
- @Column(name="allocation_state")
- @Enumerated(value=EnumType.STRING)
- AllocationState allocationState;
-
- @Column(name="managed_state")
- @Enumerated(value=EnumType.STRING)
- ManagedState managedState;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- @Column(name="uuid")
- String uuid;
-
- //orchestration
-
- @Column(name="owner")
- private String owner = null;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- protected Date created;
-
- @Column(name="lastUpdated", updatable=true)
- @Temporal(value=TemporalType.TIMESTAMP)
- protected Date lastUpdated;
-
- /**
- * 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="engine_state", updatable=true, nullable=false, length=32)
- protected State engineState = null;
-
-
- public EngineClusterVO() {
- clusterType = Cluster.ClusterType.CloudManaged;
- allocationState = Grouping.AllocationState.Enabled;
-
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- public EngineClusterVO(long dataCenterId, long podId, String name) {
- this.dataCenterId = dataCenterId;
- this.podId = podId;
- this.name = name;
- this.clusterType = Cluster.ClusterType.CloudManaged;
- this.allocationState = Grouping.AllocationState.Enabled;
- this.managedState = ManagedState.Managed;
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- @Override
- public long getPodId() {
- return podId;
- }
-
- @Override
- public Cluster.ClusterType getClusterType() {
- return clusterType;
- }
-
- public void setClusterType(Cluster.ClusterType clusterType) {
- this.clusterType = clusterType;
- }
-
- @Override
- public AllocationState getAllocationState() {
- return allocationState;
- }
-
- public void setAllocationState(AllocationState allocationState) {
- this.allocationState = allocationState;
- }
-
- @Override
- public ManagedState getManagedState() {
- return managedState;
- }
-
- public void setManagedState(ManagedState managedState) {
- this.managedState = managedState;
- }
-
- public EngineClusterVO(long clusterId) {
- this.id = clusterId;
- }
-
- @Override
- public int hashCode() {
- return NumbersUtil.hash(id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof EngineClusterVO)) {
- return false;
- }
- EngineClusterVO that = (EngineClusterVO)obj;
- return this.id == that.id;
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return HypervisorType.getType(hypervisorType);
- }
-
- public void setHypervisorType(String hy) {
- hypervisorType = hy;
- }
-
- public String getGuid() {
- return guid;
- }
-
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public State getState() {
- return engineState;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java
deleted file mode 100644
index 240dddf..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenter.java
+++ /dev/null
@@ -1,23 +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;
-
-import com.cloud.dc.DataCenter;
-
-public interface EngineDataCenter extends DataCenter {
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java
deleted file mode 100644
index cdf08cc..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java
+++ /dev/null
@@ -1,504 +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;
-
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-
-
-import com.cloud.network.Network.Provider;
-import com.cloud.org.Grouping;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.StateMachine;
-
-@Entity
-@Table(name="data_center")
-public class EngineDataCenterVO implements EngineDataCenter, Identity {
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="name")
- private String name = null;
-
- @Column(name="description")
- private String description = null;
-
- @Column(name="dns1")
- private String dns1 = null;
-
- @Column(name="dns2")
- private String dns2 = null;
-
- @Column(name="ip6Dns1")
- private String ip6Dns1 = null;
-
- @Column(name="ip6Dns2")
- private String ip6Dns2 = null;
-
- @Column(name="internal_dns1")
- private String internalDns1 = null;
-
- @Column(name="internal_dns2")
- private String internalDns2 = null;
-
- @Column(name="router_mac_address", updatable = false, nullable=false)
- private String routerMacAddress = "02:00:00:00:00:01";
-
- @Column(name="guest_network_cidr")
- private String guestNetworkCidr = null;
-
- @Column(name="domain_id")
- private Long domainId = null;
-
- @Column(name="domain")
- private String domain;
-
- @Column(name="networktype")
- @Enumerated(EnumType.STRING)
- NetworkType networkType;
-
- @Column(name="dns_provider")
- private String dnsProvider;
-
- @Column(name="dhcp_provider")
- private String dhcpProvider;
-
- @Column(name="gateway_provider")
- private String gatewayProvider;
-
- @Column(name="vpn_provider")
- private String vpnProvider;
-
- @Column(name="userdata_provider")
- private String userDataProvider;
-
- @Column(name="lb_provider")
- private String loadBalancerProvider;
-
- @Column(name="firewall_provider")
- private String firewallProvider;
-
- @Column(name="mac_address", nullable=false)
- @TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
- private long macAddress = 1;
-
- @Column(name="zone_token")
- private String zoneToken;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- // This is a delayed load value. If the value is null,
- // then this field has not been loaded yet.
- // Call the dao to load it.
- @Transient
- Map<String, String> details;
-
- @Column(name="allocation_state")
- @Enumerated(value=EnumType.STRING)
- AllocationState allocationState;
-
- @Column(name="uuid")
- private String uuid;
-
- @Column(name="is_security_group_enabled")
- boolean securityGroupEnabled;
-
- @Column(name="is_local_storage_enabled")
- boolean localStorageEnabled;
-
- //orchestration
- @Column(name="owner")
- private String owner = null;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- protected Date created;
-
- @Column(name="lastUpdated", updatable=true)
- @Temporal(value=TemporalType.TIMESTAMP)
- protected Date lastUpdated;
-
- /**
- * 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="engine_state", updatable=true, nullable=false, length=32)
- protected State engineState = null;
-
-
- @Override
- public String getDnsProvider() {
- return dnsProvider;
- }
-
- public void setDnsProvider(String dnsProvider) {
- this.dnsProvider = dnsProvider;
- }
-
- @Override
- public String getDhcpProvider() {
- return dhcpProvider;
- }
-
- public void setDhcpProvider(String dhcpProvider) {
- this.dhcpProvider = dhcpProvider;
- }
-
- @Override
- public String getGatewayProvider() {
- return gatewayProvider;
- }
-
- public void setGatewayProvider(String gatewayProvider) {
- this.gatewayProvider = gatewayProvider;
- }
-
- @Override
- public String getLoadBalancerProvider() {
- return loadBalancerProvider;
- }
-
- public void setLoadBalancerProvider(String loadBalancerProvider) {
- this.loadBalancerProvider = loadBalancerProvider;
- }
-
- @Override
- public String getFirewallProvider() {
- return firewallProvider;
- }
-
- public void setFirewallProvider(String firewallProvider) {
- this.firewallProvider = firewallProvider;
- }
-
- public EngineDataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
- this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
- this.id = id;
- this.allocationState = Grouping.AllocationState.Enabled;
- this.uuid = UUID.randomUUID().toString();
- }
-
- public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) {
- this.name = name;
- this.description = description;
- this.dns1 = dns1;
- this.dns2 = dns2;
- this.internalDns1 = dns3;
- this.internalDns2 = dns4;
- this.guestNetworkCidr = guestCidr;
- this.domain = domain;
- this.domainId = domainId;
- this.networkType = zoneType;
- this.allocationState = Grouping.AllocationState.Enabled;
- this.securityGroupEnabled = securityGroupEnabled;
- this.localStorageEnabled = localStorageEnabled;
-
- if (zoneType == NetworkType.Advanced) {
- loadBalancerProvider = Provider.VirtualRouter.getName();
- firewallProvider = Provider.VirtualRouter.getName();
- dhcpProvider = Provider.VirtualRouter.getName();
- dnsProvider = Provider.VirtualRouter.getName();
- gatewayProvider = Provider.VirtualRouter.getName();
- vpnProvider = Provider.VirtualRouter.getName();
- userDataProvider = Provider.VirtualRouter.getName();
- } else if (zoneType == NetworkType.Basic){
- dhcpProvider = Provider.VirtualRouter.getName();
- dnsProvider = Provider.VirtualRouter.getName();
- userDataProvider = Provider.VirtualRouter.getName();
- loadBalancerProvider = Provider.ElasticLoadBalancerVm.getName();
- }
-
- this.zoneToken = zoneToken;
- this.domain = domainSuffix;
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- @Override
- public String getVpnProvider() {
- return vpnProvider;
- }
-
- public void setVpnProvider(String vpnProvider) {
- this.vpnProvider = vpnProvider;
- }
-
- @Override
- public String getUserDataProvider() {
- return userDataProvider;
- }
-
- public void setUserDataProvider(String userDataProvider) {
- this.userDataProvider = userDataProvider;
- }
-
- @Override
- public String getGuestNetworkCidr()
- {
- return guestNetworkCidr;
- }
-
- public void setGuestNetworkCidr(String guestNetworkCidr)
- {
- this.guestNetworkCidr = guestNetworkCidr;
- }
-
- @Override
- public Long getDomainId() {
- return domainId;
- }
-
- public void setDomainId(Long domainId) {
- this.domainId = domainId;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public String getRouterMacAddress() {
- return routerMacAddress;
- }
-
- @Override
- public String getDns1() {
- return dns1;
- }
-
- @Override
- public String getDns2() {
- return dns2;
- }
-
- @Override
- public String getInternalDns1() {
- return internalDns1;
- }
-
- @Override
- public String getInternalDns2() {
- return internalDns2;
- }
-
- protected EngineDataCenterVO() {
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setDns1(String dns1) {
- this.dns1 = dns1;
- }
-
- public void setDns2(String dns2) {
- this.dns2 = dns2;
- }
-
- public void setInternalDns1(String dns3) {
- this.internalDns1 = dns3;
- }
-
- public void setInternalDns2(String dns4) {
- this.internalDns2 = dns4;
- }
-
- public void setRouterMacAddress(String routerMacAddress) {
- this.routerMacAddress = routerMacAddress;
- }
-
- @Override
- public String getDomain() {
- return domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public void setNetworkType(NetworkType zoneNetworkType) {
- this.networkType = zoneNetworkType;
- }
-
- @Override
- public NetworkType getNetworkType() {
- return networkType;
- }
-
- @Override
- public boolean isSecurityGroupEnabled() {
- return securityGroupEnabled;
- }
-
- public void setSecurityGroupEnabled(boolean enabled) {
- this.securityGroupEnabled = enabled;
- }
-
- @Override
- public boolean isLocalStorageEnabled() {
- return localStorageEnabled;
- }
-
- public void setLocalStorageEnabled(boolean enabled) {
- this.localStorageEnabled = enabled;
- }
-
- @Override
- public Map<String, String> getDetails() {
- return details;
- }
-
- @Override
- public void setDetails(Map<String, String> details2) {
- details = details2;
- }
-
- public String getDetail(String name) {
- assert (details != null) : "Did you forget to load the details?";
-
- return details != null ? details.get(name) : null;
- }
-
- public void setDetail(String name, String value) {
- assert (details != null) : "Did you forget to load the details?";
-
- details.put(name, value);
- }
-
- @Override
- public AllocationState getAllocationState() {
- return allocationState;
- }
-
- public void setAllocationState(AllocationState allocationState) {
- this.allocationState = allocationState;
- }
-
- @Override
- public int hashCode() {
- return NumbersUtil.hash(id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof EngineDataCenterVO)) {
- return false;
- }
- EngineDataCenterVO that = (EngineDataCenterVO)obj;
- return this.id == that.id;
- }
-
- @Override
- public String getZoneToken() {
- return zoneToken;
- }
-
- public void setZoneToken(String zoneToken) {
- this.zoneToken = zoneToken;
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public long getMacAddress() {
- return macAddress;
- }
-
- public void setMacAddress(long macAddress) {
- this.macAddress = macAddress;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public State getState() {
- return engineState;
- }
-
- @Override
- public String getIp6Dns1() {
- return ip6Dns1;
- }
-
- public void setIp6Dns1(String ip6Dns1) {
- this.ip6Dns1 = ip6Dns1;
- }
-
- @Override
- public String getIp6Dns2() {
- return ip6Dns2;
- }
-
- public void setIp6Dns2(String ip6Dns2) {
- this.ip6Dns2 = ip6Dns2;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java
deleted file mode 100644
index 127c445..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHost.java
+++ /dev/null
@@ -1,24 +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;
-
-import com.cloud.host.Host;
-
-public interface EngineHost extends Host {
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java
deleted file mode 100644
index 65b9db5..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java
+++ /dev/null
@@ -1,245 +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;
-
-import java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-
-import com.cloud.org.Grouping;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.StateMachine;
-
-@Entity
-@Table(name = "host_pod_ref")
-public class EngineHostPodVO implements EnginePod, Identity {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- long id;
-
- @Column(name = "name")
- private String name = null;
-
- @Column(name = "data_center_id")
- private long dataCenterId;
-
- @Column(name = "gateway")
- private String gateway;
-
- @Column(name = "cidr_address")
- private String cidrAddress;
-
- @Column(name = "cidr_size")
- private int cidrSize;
-
- @Column(name = "description")
- private String description;
-
- @Column(name="allocation_state")
- @Enumerated(value=EnumType.STRING)
- AllocationState allocationState;
-
- @Column(name = "external_dhcp")
- private Boolean externalDhcp;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- @Column(name = "uuid")
- private String uuid;
-
- //orchestration
- @Column(name="owner")
- private String owner = null;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- protected Date created;
-
- @Column(name="lastUpdated", updatable=true)
- @Temporal(value=TemporalType.TIMESTAMP)
- protected Date lastUpdated;
-
- /**
- * 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="engine_state", updatable=true, nullable=false, length=32)
- protected State engineState = null;
-
- public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
- this.name = name;
- this.dataCenterId = dcId;
- this.gateway = gateway;
- this.cidrAddress = cidrAddress;
- this.cidrSize = cidrSize;
- this.description = description;
- this.allocationState = Grouping.AllocationState.Enabled;
- this.externalDhcp = false;
- this.uuid = UUID.randomUUID().toString();
- this.engineState = State.Disabled;
- }
-
- /*
- * public HostPodVO(String name, long dcId) { this(null, name, dcId); }
- */
- protected EngineHostPodVO() {
- this.uuid = UUID.randomUUID().toString();
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- public void setDataCenterId(long dataCenterId) {
- this.dataCenterId = dataCenterId;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String getCidrAddress() {
- return cidrAddress;
- }
-
- public void setCidrAddress(String cidrAddress) {
- this.cidrAddress = cidrAddress;
- }
-
- @Override
- public int getCidrSize() {
- return cidrSize;
- }
-
- public void setCidrSize(int cidrSize) {
- this.cidrSize = cidrSize;
- }
-
- @Override
- public String getGateway() {
- return gateway;
- }
-
- public void setGateway(String gateway) {
- this.gateway = gateway;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @Override
- public AllocationState getAllocationState() {
- return allocationState;
- }
-
- public void setAllocationState(AllocationState allocationState) {
- this.allocationState = allocationState;
- }
-
- // Use for comparisons only.
- public EngineHostPodVO(Long id) {
- this.id = id;
- }
-
- @Override
- public int hashCode() {
- return NumbersUtil.hash(id);
- }
-
- @Override
- public boolean getExternalDhcp() {
- return externalDhcp;
- }
-
- public void setExternalDhcp(boolean use) {
- externalDhcp = use;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EngineHostPodVO) {
- return id == ((EngineHostPodVO)obj).id;
- } else {
- return false;
- }
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public State getState() {
- return engineState;
- }
-}
[2/7] Moved VOs into the schema
Posted by ah...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostVO.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostVO.java
new file mode 100644
index 0000000..a528e1f
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostVO.java
@@ -0,0 +1,778 @@
+// 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;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+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.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
+
+import com.cloud.host.Status;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.resource.ResourceState;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.StateMachine;
+
+@Entity
+@Table(name="host")
+@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
+@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
+public class EngineHostVO implements EngineHost, Identity {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="disconnected")
+ @Temporal(value=TemporalType.TIMESTAMP)
+ private Date disconnectedOn;
+
+ @Column(name="name", nullable=false)
+ private String name = null;
+
+ /**
+ * Note: There is no setter for status because it has to be set in the dao code.
+ */
+ @Column(name="status", nullable=false)
+ private Status status = null;
+
+ @Column(name="type", updatable = true, nullable=false)
+ @Enumerated(value=EnumType.STRING)
+ private Type type;
+
+ @Column(name="private_ip_address", nullable=false)
+ private String privateIpAddress;
+
+ @Column(name="private_mac_address", nullable=false)
+ private String privateMacAddress;
+
+ @Column(name="private_netmask", nullable=false)
+ private String privateNetmask;
+
+ @Column(name="public_netmask")
+ private String publicNetmask;
+
+ @Column(name="public_ip_address")
+ private String publicIpAddress;
+
+ @Column(name="public_mac_address")
+ private String publicMacAddress;
+
+ @Column(name="storage_ip_address")
+ private String storageIpAddress;
+
+ @Column(name="cluster_id")
+ private Long clusterId;
+
+ @Column(name="storage_netmask")
+ private String storageNetmask;
+
+ @Column(name="storage_mac_address")
+ private String storageMacAddress;
+
+ @Column(name="storage_ip_address_2")
+ private String storageIpAddressDeux;
+
+ @Column(name="storage_netmask_2")
+ private String storageNetmaskDeux;
+
+ @Column(name="storage_mac_address_2")
+ private String storageMacAddressDeux;
+
+ @Column(name="hypervisor_type", updatable = true, nullable=false)
+ @Enumerated(value=EnumType.STRING)
+ private HypervisorType hypervisorType;
+
+ @Column(name="proxy_port")
+ private Integer proxyPort;
+
+ @Column(name="resource")
+ private String resource;
+
+ @Column(name="fs_type")
+ private StoragePoolType fsType;
+
+ @Column(name="available")
+ private boolean available = true;
+
+ @Column(name="setup")
+ private boolean setup = false;
+
+ @Column(name="resource_state", nullable=false)
+ @Enumerated(value=EnumType.STRING)
+ private ResourceState resourceState;
+
+ @Column(name="hypervisor_version")
+ private String hypervisorVersion;
+
+ @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="uuid")
+ private String uuid;
+
+ // This is a delayed load value. If the value is null,
+ // then this field has not been loaded yet.
+ // Call host dao to load it.
+ @Transient
+ Map<String, String> details;
+
+ // This is a delayed load value. If the value is null,
+ // then this field has not been loaded yet.
+ // Call host dao to load it.
+ @Transient
+ List<String> hostTags;
+
+ @Override
+ public String getStorageIpAddressDeux() {
+ return storageIpAddressDeux;
+ }
+
+ public void setStorageIpAddressDeux(String deuxStorageIpAddress) {
+ this.storageIpAddressDeux = deuxStorageIpAddress;
+ }
+
+ @Override
+ public String getStorageNetmaskDeux() {
+ return storageNetmaskDeux;
+ }
+
+ @Override
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(Long clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public void setStorageNetmaskDeux(String deuxStorageNetmask) {
+ this.storageNetmaskDeux = deuxStorageNetmask;
+ }
+
+ @Override
+ public String getStorageMacAddressDeux() {
+ return storageMacAddressDeux;
+ }
+
+ public void setStorageMacAddressDeux(String duexStorageMacAddress) {
+ this.storageMacAddressDeux = duexStorageMacAddress;
+ }
+
+ @Override
+ public String getPrivateMacAddress() {
+ return privateMacAddress;
+ }
+
+ public void setPrivateMacAddress(String privateMacAddress) {
+ this.privateMacAddress = privateMacAddress;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Override
+ public String getPrivateNetmask() {
+ return privateNetmask;
+ }
+
+ public void setPrivateNetmask(String privateNetmask) {
+ this.privateNetmask = privateNetmask;
+ }
+
+ @Override
+ public String getPublicNetmask() {
+ return publicNetmask;
+ }
+
+ public void setPublicNetmask(String publicNetmask) {
+ this.publicNetmask = publicNetmask;
+ }
+
+ @Override
+ public String getPublicIpAddress() {
+ return publicIpAddress;
+ }
+
+ public void setPublicIpAddress(String publicIpAddress) {
+ this.publicIpAddress = publicIpAddress;
+ }
+
+ @Override
+ public String getPublicMacAddress() {
+ return publicMacAddress;
+ }
+
+ public void setPublicMacAddress(String publicMacAddress) {
+ this.publicMacAddress = publicMacAddress;
+ }
+
+ @Override
+ public String getStorageIpAddress() {
+ return storageIpAddress;
+ }
+
+ public void setStorageIpAddress(String storageIpAddress) {
+ this.storageIpAddress = storageIpAddress;
+ }
+
+ @Override
+ public String getStorageNetmask() {
+ return storageNetmask;
+ }
+
+ public void setStorageNetmask(String storageNetmask) {
+ this.storageNetmask = storageNetmask;
+ }
+
+ @Override
+ public String getStorageMacAddress() {
+ return storageMacAddress;
+ }
+
+ public boolean isSetup() {
+ return setup;
+ }
+
+ public void setSetup(boolean setup) {
+ this.setup = setup;
+ }
+
+ public void setStorageMacAddress(String storageMacAddress) {
+ this.storageMacAddress = storageMacAddress;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ public Map<String, String> getDetails() {
+ return details;
+ }
+
+ public String getDetail(String name) {
+ assert (details != null) : "Did you forget to load the details?";
+
+ return details != null ? details.get(name) : null;
+ }
+
+ 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;
+ }
+
+ public List<String> getHostTags() {
+ return hostTags;
+ }
+
+ public void setHostTags(List<String> hostTags) {
+ this.hostTags = hostTags;
+ }
+
+ @Column(name="data_center_id", nullable=false)
+ private long dataCenterId;
+
+ @Column(name="pod_id")
+ private Long podId;
+
+ @Column(name="cpus")
+ private Integer cpus;
+
+ @Column(name="url")
+ private String storageUrl;
+
+ @Column(name="speed")
+ private Long speed;
+
+ @Column(name="ram")
+ private long totalMemory;
+
+ @Column(name="parent", nullable=false)
+ private String parent;
+
+ @Column(name="guid", updatable=true, nullable=false)
+ private String guid;
+
+ @Column(name="capabilities")
+ private String caps;
+
+ @Column(name="total_size")
+ private Long totalSize;
+
+ @Column(name="last_ping")
+ private long lastPinged;
+
+ @Column(name="mgmt_server_id")
+ private Long managementServerId;
+
+ @Column(name="dom0_memory")
+ private long dom0MinMemory;
+
+ @Column(name="version")
+ private String version;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ //orchestration
+ @Column(name="owner")
+ private String owner = null;
+
+ @Column(name="lastUpdated", updatable=true)
+ @Temporal(value=TemporalType.TIMESTAMP)
+ protected Date lastUpdated;
+
+ /**
+ * 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="engine_state", updatable=true, nullable=false, length=32)
+ protected State engineState = null;
+
+
+ public EngineHostVO(String guid) {
+ this.guid = guid;
+ this.status = Status.Creating;
+ this.totalMemory = 0;
+ this.dom0MinMemory = 0;
+ this.resourceState = ResourceState.Creating;
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ protected EngineHostVO() {
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ public EngineHostVO(long id,
+ String name,
+ Type type,
+ String privateIpAddress,
+ String privateNetmask,
+ String privateMacAddress,
+ String publicIpAddress,
+ String publicNetmask,
+ String publicMacAddress,
+ String storageIpAddress,
+ String storageNetmask,
+ String storageMacAddress,
+ String deuxStorageIpAddress,
+ String duxStorageNetmask,
+ String deuxStorageMacAddress,
+ String guid,
+ Status status,
+ String version,
+ String iqn,
+ Date disconnectedOn,
+ long dcId,
+ Long podId,
+ long serverId,
+ long ping,
+ String parent,
+ long totalSize,
+ StoragePoolType fsType) {
+ this(id, name, type, privateIpAddress, privateNetmask, privateMacAddress, publicIpAddress, publicNetmask, publicMacAddress, storageIpAddress, storageNetmask, storageMacAddress, guid, status, version, iqn, disconnectedOn, dcId, podId, serverId, ping, null, null, null, 0, null);
+ this.parent = parent;
+ this.totalSize = totalSize;
+ this.fsType = fsType;
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ public EngineHostVO(long id,
+ String name,
+ Type type,
+ String privateIpAddress,
+ String privateNetmask,
+ String privateMacAddress,
+ String publicIpAddress,
+ String publicNetmask,
+ String publicMacAddress,
+ String storageIpAddress,
+ String storageNetmask,
+ String storageMacAddress,
+ String guid,
+ Status status,
+ String version,
+ String url,
+ Date disconnectedOn,
+ long dcId,
+ Long podId,
+ long serverId,
+ long ping,
+ Integer cpus,
+ Long speed,
+ Long totalMemory,
+ long dom0MinMemory,
+ String caps) {
+ this.id = id;
+ this.name = name;
+ this.status = status;
+ this.type = type;
+ this.privateIpAddress = privateIpAddress;
+ this.privateNetmask = privateNetmask;
+ this.privateMacAddress = privateMacAddress;
+ this.publicIpAddress = publicIpAddress;
+ this.publicNetmask = publicNetmask;
+ this.publicMacAddress = publicMacAddress;
+ this.storageIpAddress = storageIpAddress;
+ this.storageNetmask = storageNetmask;
+ this.storageMacAddress = storageMacAddress;
+ this.dataCenterId = dcId;
+ this.podId = podId;
+ this.cpus = cpus;
+ this.version = version;
+ this.speed = speed;
+ this.totalMemory = totalMemory != null ? totalMemory : 0;
+ this.guid = guid;
+ this.parent = null;
+ this.totalSize = null;
+ this.fsType = null;
+ this.managementServerId = serverId;
+ this.lastPinged = ping;
+ this.caps = caps;
+ this.disconnectedOn = disconnectedOn;
+ this.dom0MinMemory = dom0MinMemory;
+ this.storageUrl = url;
+ this.uuid = UUID.randomUUID().toString();
+ this.engineState = State.Disabled;
+ }
+
+ public void setPodId(Long podId) {
+
+ this.podId = podId;
+ }
+
+ public void setDataCenterId(long dcId) {
+ this.dataCenterId = dcId;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public void setStorageUrl(String url) {
+ this.storageUrl = url;
+ }
+
+ public void setDisconnectedOn(Date disconnectedOn) {
+ this.disconnectedOn = disconnectedOn;
+ }
+
+ public String getStorageUrl() {
+ return storageUrl;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setPrivateIpAddress(String ipAddress) {
+ this.privateIpAddress = ipAddress;
+ }
+
+ public void setCpus(Integer cpus) {
+ this.cpus = cpus;
+ }
+
+ public void setSpeed(Long speed) {
+ this.speed = speed;
+ }
+
+ public void setTotalMemory(long totalMemory) {
+ this.totalMemory = totalMemory;
+ }
+
+ public void setParent(String parent) {
+ this.parent = parent;
+ }
+
+ public void setCaps(String caps) {
+ this.caps = caps;
+ }
+
+ public void setTotalSize(Long totalSize) {
+ this.totalSize = totalSize;
+ }
+
+ public void setLastPinged(long lastPinged) {
+ this.lastPinged = lastPinged;
+ }
+
+ public void setManagementServerId(Long managementServerId) {
+ this.managementServerId = managementServerId;
+ }
+
+ @Override
+ public long getLastPinged() {
+ return lastPinged;
+ }
+
+ @Override
+ public String getParent() {
+ return parent;
+ }
+
+ @Override
+ public long getTotalSize() {
+ return totalSize;
+ }
+
+ @Override
+ public String getCapabilities() {
+ return caps;
+ }
+
+ @Override
+ public Date getCreated() {
+ return created;
+ }
+
+ @Override
+ public Date getRemoved() {
+ return removed;
+ }
+
+ @Override
+ public String getVersion() {
+ return version;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Status getStatus() {
+ return status;
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ @Override
+ public Long getPodId() {
+ return podId;
+ }
+
+ @Override
+ public Long getManagementServerId() {
+ return managementServerId;
+ }
+
+ @Override
+ public Date getDisconnectedOn() {
+ return disconnectedOn;
+ }
+
+ @Override
+ public String getPrivateIpAddress() {
+ return privateIpAddress;
+ }
+
+ @Override
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ @Override
+ public Integer getCpus() {
+ return cpus;
+ }
+
+ @Override
+ public Long getSpeed() {
+ return speed;
+ }
+
+ @Override
+ public Long getTotalMemory() {
+ return totalMemory;
+ }
+
+ @Override
+ public Integer getProxyPort() {
+ return proxyPort;
+ }
+
+ public void setProxyPort(Integer port) {
+ proxyPort = port;
+ }
+
+ public StoragePoolType getFsType() {
+ return fsType;
+ }
+
+ @Override
+ public Type getType() {
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ return NumbersUtil.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof EngineHostVO) {
+ return ((EngineHostVO)obj).getId() == this.getId();
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("Host[").append("-").append(id).append("-").append(type).append("]").toString();
+ }
+
+ public void setHypervisorType(HypervisorType hypervisorType) {
+ this.hypervisorType = hypervisorType;
+ }
+
+ @Override
+ public HypervisorType getHypervisorType() {
+ return hypervisorType;
+ }
+
+ public void setHypervisorVersion(String hypervisorVersion) {
+ this.hypervisorVersion = hypervisorVersion;
+ }
+
+ @Override
+ public String getHypervisorVersion() {
+ return hypervisorVersion;
+ }
+
+ @Override
+
+ // TODO, I tempoerary disable it as it breaks GenericSearchBuild when @Transient is applied
+ // @Transient
+ public Status getState() {
+ return status;
+ }
+
+ @Override
+ public ResourceState getResourceState() {
+ return resourceState;
+ }
+
+ public void setResourceState(ResourceState state) {
+ resourceState = state;
+ }
+
+ @Override
+ public boolean isInMaintenanceStates() {
+ return (getResourceState() == ResourceState.Maintenance || getResourceState() == ResourceState.ErrorInMaintenance
+ || getResourceState() == ResourceState.PrepareForMaintenance);
+ }
+
+ public long getUpdated() {
+ return updated;
+ }
+
+ public long incrUpdated() {
+ updated++;
+ return updated;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public State getOrchestrationState() {
+ return engineState;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EnginePod.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EnginePod.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EnginePod.java
new file mode 100644
index 0000000..59ade3e
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EnginePod.java
@@ -0,0 +1,23 @@
+// 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;
+
+import com.cloud.dc.Pod;
+
+public interface EnginePod extends Pod {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDao.java
new file mode 100644
index 0000000..bcfbfc4
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDao.java
@@ -0,0 +1,29 @@
+// 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.dao;
+
+import java.util.Map;
+
+import org.apache.cloudstack.engine.datacenter.entity.DcDetailVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface DcDetailsDao extends GenericDao<DcDetailVO, Long> {
+ Map<String, String> findDetails(long dcId);
+
+ void persist(long dcId, Map<String, String> details);
+
+ DcDetailVO findDetail(long dcId, String name);
+
+ void deleteDetails(long dcId);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDaoImpl.java
new file mode 100644
index 0000000..5b46e75
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/DcDetailsDaoImpl.java
@@ -0,0 +1,95 @@
+// 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.dao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+
+import org.apache.cloudstack.engine.datacenter.entity.DcDetailVO;
+
+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(value="EngineDcDetailsDao")
+@Local(value=DcDetailsDao.class)
+public class DcDetailsDaoImpl extends GenericDaoBase<DcDetailVO, Long> implements DcDetailsDao {
+ protected final SearchBuilder<DcDetailVO> DcSearch;
+ protected final SearchBuilder<DcDetailVO> DetailSearch;
+
+ protected DcDetailsDaoImpl() {
+ DcSearch = createSearchBuilder();
+ DcSearch.and("dcId", DcSearch.entity().getDcId(), SearchCriteria.Op.EQ);
+ DcSearch.done();
+
+ DetailSearch = createSearchBuilder();
+ DetailSearch.and("dcId", DetailSearch.entity().getDcId(), SearchCriteria.Op.EQ);
+ DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
+ DetailSearch.done();
+ }
+
+ @Override
+ public DcDetailVO findDetail(long dcId, String name) {
+ SearchCriteria<DcDetailVO> sc = DetailSearch.create();
+ sc.setParameters("dcId", dcId);
+ sc.setParameters("name", name);
+
+ return findOneIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public Map<String, String> findDetails(long dcId) {
+ SearchCriteria<DcDetailVO> sc = DcSearch.create();
+ sc.setParameters("dcId", dcId);
+
+ List<DcDetailVO> results = search(sc, null);
+ Map<String, String> details = new HashMap<String, String>(results.size());
+ for (DcDetailVO result : results) {
+ details.put(result.getName(), result.getValue());
+ }
+ return details;
+ }
+
+ @Override
+ public void deleteDetails(long dcId) {
+ SearchCriteria sc = DcSearch.create();
+ sc.setParameters("dcId", dcId);
+
+ List<DcDetailVO> results = search(sc, null);
+ for (DcDetailVO result : results) {
+ remove(result.getId());
+ }
+ }
+
+ @Override
+ public void persist(long dcId, Map<String, String> details) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ SearchCriteria<DcDetailVO> sc = DcSearch.create();
+ sc.setParameters("dcId", dcId);
+ expunge(sc);
+
+ for (Map.Entry<String, String> detail : details.entrySet()) {
+ DcDetailVO vo = new DcDetailVO(dcId, detail.getKey(), detail.getValue());
+ persist(vo);
+ }
+ txn.commit();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDao.java
new file mode 100644
index 0000000..945298d
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDao.java
@@ -0,0 +1,37 @@
+// 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.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineClusterVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
+
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface EngineClusterDao extends GenericDao<EngineClusterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
+ List<EngineClusterVO> listByPodId(long podId);
+ EngineClusterVO findBy(String name, long podId);
+ List<EngineClusterVO> listByHyTypeWithoutGuid(String hyType);
+ List<EngineClusterVO> listByZoneId(long zoneId);
+
+ List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
+ List<EngineClusterVO> listByDcHyType(long dcId, String hyType);
+ Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
+ List<Long> listDisabledClusters(long zoneId, Long podId);
+ List<Long> listClustersWithDisabledPods(long zoneId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
new file mode 100644
index 0000000..fb86e44
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
@@ -0,0 +1,288 @@
+// 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.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 java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineClusterVO;
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostPodVO;
+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.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.org.Grouping;
+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="EngineClusterDao")
+@Local(value=EngineClusterDao.class)
+public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> implements EngineClusterDao {
+ private static final Logger s_logger = Logger.getLogger(EngineClusterDaoImpl.class);
+
+ protected final SearchBuilder<EngineClusterVO> PodSearch;
+ protected final SearchBuilder<EngineClusterVO> HyTypeWithoutGuidSearch;
+ protected final SearchBuilder<EngineClusterVO> AvailHyperSearch;
+ protected final SearchBuilder<EngineClusterVO> ZoneSearch;
+ protected final SearchBuilder<EngineClusterVO> ZoneHyTypeSearch;
+ protected SearchBuilder<EngineClusterVO> StateChangeSearch;
+ protected SearchBuilder<EngineClusterVO> UUIDSearch;
+
+ private static final String GET_POD_CLUSTER_MAP_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( ";
+ private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
+
+ @Inject protected EngineHostPodDao _hostPodDao;
+
+ protected EngineClusterDaoImpl() {
+ super();
+
+ HyTypeWithoutGuidSearch = createSearchBuilder();
+ HyTypeWithoutGuidSearch.and("hypervisorType", HyTypeWithoutGuidSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
+ HyTypeWithoutGuidSearch.and("guid", HyTypeWithoutGuidSearch.entity().getGuid(), SearchCriteria.Op.NULL);
+ HyTypeWithoutGuidSearch.done();
+
+ ZoneHyTypeSearch = createSearchBuilder();
+ ZoneHyTypeSearch.and("hypervisorType", ZoneHyTypeSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
+ ZoneHyTypeSearch.and("dataCenterId", ZoneHyTypeSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ ZoneHyTypeSearch.done();
+
+ PodSearch = createSearchBuilder();
+ PodSearch.and("pod", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
+ PodSearch.and("name", PodSearch.entity().getName(), SearchCriteria.Op.EQ);
+ PodSearch.done();
+
+ ZoneSearch = createSearchBuilder();
+ ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ ZoneSearch.groupBy(ZoneSearch.entity().getHypervisorType());
+ ZoneSearch.done();
+
+ AvailHyperSearch = createSearchBuilder();
+ AvailHyperSearch.and("zoneId", AvailHyperSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ AvailHyperSearch.select(null, Func.DISTINCT, AvailHyperSearch.entity().getHypervisorType());
+ AvailHyperSearch.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<EngineClusterVO> listByZoneId(long zoneId) {
+ SearchCriteria<EngineClusterVO> sc = ZoneSearch.create();
+ sc.setParameters("dataCenterId", zoneId);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<EngineClusterVO> listByPodId(long podId) {
+ SearchCriteria<EngineClusterVO> sc = PodSearch.create();
+ sc.setParameters("pod", podId);
+
+ return listBy(sc);
+ }
+
+ @Override
+ public EngineClusterVO findBy(String name, long podId) {
+ SearchCriteria<EngineClusterVO> sc = PodSearch.create();
+ sc.setParameters("pod", podId);
+ sc.setParameters("name", name);
+
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<EngineClusterVO> listByHyTypeWithoutGuid(String hyType) {
+ SearchCriteria<EngineClusterVO> sc = HyTypeWithoutGuidSearch.create();
+ sc.setParameters("hypervisorType", hyType);
+
+ return listBy(sc);
+ }
+
+ @Override
+ public List<EngineClusterVO> listByDcHyType(long dcId, String hyType) {
+ SearchCriteria<EngineClusterVO> sc = ZoneHyTypeSearch.create();
+ sc.setParameters("dataCenterId", dcId);
+ sc.setParameters("hypervisorType", hyType);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
+ SearchCriteria<EngineClusterVO> sc = AvailHyperSearch.create();
+ if (zoneId != null) {
+ sc.setParameters("zoneId", zoneId);
+ }
+ List<EngineClusterVO> clusters = listBy(sc);
+ List<HypervisorType> hypers = new ArrayList<HypervisorType>(4);
+ for (EngineClusterVO cluster : clusters) {
+ hypers.add(cluster.getHypervisorType());
+ }
+
+ return hypers;
+ }
+
+ @Override
+ public Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds){
+ Transaction txn = Transaction.currentTxn();
+ PreparedStatement pstmt = null;
+ Map<Long, List<Long>> result = new HashMap<Long, List<Long>>();
+
+ try {
+ StringBuilder sql = new StringBuilder(GET_POD_CLUSTER_MAP_PREFIX);
+ if (clusterIds.size() > 0) {
+ for (Long clusterId : clusterIds) {
+ sql.append(clusterId).append(",");
+ }
+ sql.delete(sql.length()-1, sql.length());
+ sql.append(GET_POD_CLUSTER_MAP_SUFFIX);
+ }
+
+ pstmt = txn.prepareAutoCloseStatement(sql.toString());
+ ResultSet rs = pstmt.executeQuery();
+ while (rs.next()) {
+ Long podId = rs.getLong(1);
+ Long clusterIdInPod = rs.getLong(2);
+ if(result.containsKey(podId)){
+ List<Long> clusterList = result.get(podId);
+ clusterList.add(clusterIdInPod);
+ result.put(podId, clusterList);
+ }else{
+ List<Long> clusterList = new ArrayList<Long>();
+ clusterList.add(clusterIdInPod);
+ result.put(podId, clusterList);
+ }
+ }
+ return result;
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("DB Exception on: " + GET_POD_CLUSTER_MAP_PREFIX, e);
+ } catch (Throwable e) {
+ throw new CloudRuntimeException("Caught: " + GET_POD_CLUSTER_MAP_PREFIX, e);
+ }
+ }
+
+ @Override
+ public List<Long> listDisabledClusters(long zoneId, Long podId) {
+ GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
+ clusterIdSearch.selectField(clusterIdSearch.entity().getId());
+ clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
+ if(podId != null){
+ clusterIdSearch.and("podId", clusterIdSearch.entity().getPodId(), Op.EQ);
+ }
+ clusterIdSearch.and("allocationState", clusterIdSearch.entity().getAllocationState(), Op.EQ);
+ clusterIdSearch.done();
+
+
+ SearchCriteria<Long> sc = clusterIdSearch.create();
+ sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
+ if (podId != null) {
+ sc.addAnd("podId", SearchCriteria.Op.EQ, podId);
+ }
+ sc.addAnd("allocationState", SearchCriteria.Op.EQ, Grouping.AllocationState.Disabled);
+ return customSearch(sc, null);
+ }
+
+ @Override
+ public List<Long> listClustersWithDisabledPods(long zoneId) {
+
+ GenericSearchBuilder<EngineHostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
+ disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
+ disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
+ disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
+
+ GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
+ clusterIdSearch.selectField(clusterIdSearch.entity().getId());
+ clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
+ clusterIdSearch.done();
+
+
+ SearchCriteria<Long> sc = clusterIdSearch.create();
+ sc.setJoinParameters("disabledPodIdSearch", "dataCenterId", zoneId);
+ sc.setJoinParameters("disabledPodIdSearch", "allocationState", Grouping.AllocationState.Disabled);
+
+ return customSearch(sc, null);
+ }
+
+ @Override
+ public boolean remove(Long id) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ EngineClusterVO cluster = createForUpdate();
+ cluster.setName(null);
+ cluster.setGuid(null);
+
+ update(id, cluster);
+
+ boolean result = super.remove(id);
+ txn.commit();
+ return result;
+ }
+
+ @Override
+ public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
+
+ EngineClusterVO vo = findById(clusterEntity.getId());
+
+ Date oldUpdatedTime = vo.getLastUpdated();
+
+ SearchCriteria<EngineClusterVO> 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(vo, sc);
+
+ if (rows == 0 && s_logger.isDebugEnabled()) {
+ EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
+ if (dbCluster != null) {
+ StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
+ str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=")
+ .append(dbCluster.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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDao.java
new file mode 100644
index 0000000..5e99c88
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDao.java
@@ -0,0 +1,54 @@
+// 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.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineDataCenterVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
+
+
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+
+public interface EngineDataCenterDao extends GenericDao<EngineDataCenterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
+ EngineDataCenterVO findByName(String name);
+
+ /**
+ * @param id data center id
+ * @return a pair of mac address strings. The first one is private and second is public.
+ */
+ String[] getNextAvailableMacAddressPair(long id);
+ String[] getNextAvailableMacAddressPair(long id, long mask);
+ List<EngineDataCenterVO> findZonesByDomainId(Long domainId);
+
+ List<EngineDataCenterVO> listPublicZones(String keyword);
+
+ List<EngineDataCenterVO> findChildZones(Object[] ids, String keyword);
+
+ void loadDetails(EngineDataCenterVO zone);
+ void saveDetails(EngineDataCenterVO zone);
+
+ List<EngineDataCenterVO> listDisabledZones();
+ List<EngineDataCenterVO> listEnabledZones();
+ EngineDataCenterVO findByToken(String zoneToken);
+ EngineDataCenterVO findByTokenOrIdOrName(String tokenIdOrName);
+
+
+
+ List<EngineDataCenterVO> findZonesByDomainId(Long domainId, String keyword);
+
+ List<EngineDataCenterVO> findByKeyword(String keyword);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2fa36120/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDaoImpl.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDaoImpl.java
new file mode 100644
index 0000000..16f4d76
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineDataCenterDaoImpl.java
@@ -0,0 +1,327 @@
+// 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.dao;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import javax.persistence.TableGenerator;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineDataCenterVO;
+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.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.org.Grouping;
+import com.cloud.utils.NumbersUtil;
+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.SequenceFetcher;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.UpdateBuilder;
+import com.cloud.utils.net.NetUtils;
+
+/**
+ * @config
+ * {@table
+ * || Param Name | Description | Values | Default ||
+ * || mac.address.prefix | prefix to attach to all public and private mac addresses | number | 06 ||
+ * }
+ **/
+@Component(value="EngineDataCenterDao")
+@Local(value={EngineDataCenterDao.class})
+public class EngineDataCenterDaoImpl extends GenericDaoBase<EngineDataCenterVO, Long> implements EngineDataCenterDao {
+ private static final Logger s_logger = Logger.getLogger(EngineDataCenterDaoImpl.class);
+
+ protected SearchBuilder<EngineDataCenterVO> NameSearch;
+ protected SearchBuilder<EngineDataCenterVO> ListZonesByDomainIdSearch;
+ protected SearchBuilder<EngineDataCenterVO> PublicZonesSearch;
+ protected SearchBuilder<EngineDataCenterVO> ChildZonesSearch;
+ protected SearchBuilder<EngineDataCenterVO> DisabledZonesSearch;
+ protected SearchBuilder<EngineDataCenterVO> TokenSearch;
+ protected SearchBuilder<EngineDataCenterVO> StateChangeSearch;
+ protected SearchBuilder<EngineDataCenterVO> UUIDSearch;
+
+ protected long _prefix;
+ protected Random _rand = new Random(System.currentTimeMillis());
+ protected TableGenerator _tgMacAddress;
+
+ @Inject protected DcDetailsDao _detailsDao;
+
+
+ @Override
+ public EngineDataCenterVO findByName(String name) {
+ SearchCriteria<EngineDataCenterVO> sc = NameSearch.create();
+ sc.setParameters("name", name);
+ return findOneBy(sc);
+ }
+
+
+ @Override
+ public EngineDataCenterVO findByToken(String zoneToken){
+ SearchCriteria<EngineDataCenterVO> sc = TokenSearch.create();
+ sc.setParameters("zoneToken", zoneToken);
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<EngineDataCenterVO> findZonesByDomainId(Long domainId){
+ SearchCriteria<EngineDataCenterVO> sc = ListZonesByDomainIdSearch.create();
+ sc.setParameters("domainId", domainId);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<EngineDataCenterVO> findZonesByDomainId(Long domainId, String keyword){
+ SearchCriteria<EngineDataCenterVO> sc = ListZonesByDomainIdSearch.create();
+ sc.setParameters("domainId", domainId);
+ if (keyword != null) {
+ SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+ }
+ return listBy(sc);
+ }
+
+ @Override
+ public List<EngineDataCenterVO> findChildZones(Object[] ids, String keyword){
+ SearchCriteria<EngineDataCenterVO> sc = ChildZonesSearch.create();
+ sc.setParameters("domainid", ids);
+ if (keyword != null) {
+ SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+ }
+ return listBy(sc);
+ }
+
+ @Override
+ public List<EngineDataCenterVO> listPublicZones(String keyword){
+ SearchCriteria<EngineDataCenterVO> sc = PublicZonesSearch.create();
+ if (keyword != null) {
+ SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+ }
+ //sc.setParameters("domainId", domainId);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<EngineDataCenterVO> findByKeyword(String keyword){
+ SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
+ ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+ return listBy(ssc);
+ }
+
+
+ @Override
+ public String[] getNextAvailableMacAddressPair(long id) {
+ return getNextAvailableMacAddressPair(id, 0);
+ }
+
+ @Override
+ public String[] getNextAvailableMacAddressPair(long id, long mask) {
+ SequenceFetcher fetch = SequenceFetcher.getInstance();
+
+ long seq = fetch.getNextSequence(Long.class, _tgMacAddress, id);
+ seq = seq | _prefix | ((id & 0x7f) << 32);
+ seq |= mask;
+ seq |= ((_rand.nextInt(Short.MAX_VALUE) << 16) & 0x00000000ffff0000l);
+ String[] pair = new String[2];
+ pair[0] = NetUtils.long2Mac(seq);
+ pair[1] = NetUtils.long2Mac(seq | 0x1l << 39);
+ return pair;
+ }
+
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ if (!super.configure(name, params)) {
+ return false;
+ }
+
+ String value = (String)params.get("mac.address.prefix");
+ _prefix = (long)NumbersUtil.parseInt(value, 06) << 40;
+
+ return true;
+ }
+
+ protected EngineDataCenterDaoImpl() {
+ super();
+ NameSearch = createSearchBuilder();
+ NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
+ NameSearch.done();
+
+ ListZonesByDomainIdSearch = createSearchBuilder();
+ ListZonesByDomainIdSearch.and("domainId", ListZonesByDomainIdSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
+ ListZonesByDomainIdSearch.done();
+
+ PublicZonesSearch = createSearchBuilder();
+ PublicZonesSearch.and("domainId", PublicZonesSearch.entity().getDomainId(), SearchCriteria.Op.NULL);
+ PublicZonesSearch.done();
+
+ ChildZonesSearch = createSearchBuilder();
+ ChildZonesSearch.and("domainid", ChildZonesSearch.entity().getDomainId(), SearchCriteria.Op.IN);
+ ChildZonesSearch.done();
+
+ DisabledZonesSearch = createSearchBuilder();
+ DisabledZonesSearch.and("allocationState", DisabledZonesSearch.entity().getAllocationState(), SearchCriteria.Op.EQ);
+ DisabledZonesSearch.done();
+
+ TokenSearch = createSearchBuilder();
+ TokenSearch.and("zoneToken", TokenSearch.entity().getZoneToken(), SearchCriteria.Op.EQ);
+ TokenSearch.done();
+
+ StateChangeSearch = createSearchBuilder();
+ StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
+ StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
+ StateChangeSearch.done();
+
+ UUIDSearch = createSearchBuilder();
+ UUIDSearch.and("uuid", UUIDSearch.entity().getUuid(), SearchCriteria.Op.EQ);
+ UUIDSearch.done();
+
+
+ _tgMacAddress = _tgs.get("macAddress");
+ assert _tgMacAddress != null : "Couldn't get mac address table generator";
+ }
+
+ @Override @DB
+ public boolean update(Long zoneId, EngineDataCenterVO zone) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ boolean persisted = super.update(zoneId, zone);
+ if (!persisted) {
+ return persisted;
+ }
+ saveDetails(zone);
+ txn.commit();
+ return persisted;
+ }
+
+ @Override
+ public void loadDetails(EngineDataCenterVO zone) {
+ Map<String, String> details =_detailsDao.findDetails(zone.getId());
+ zone.setDetails(details);
+ }
+
+ @Override
+ public void saveDetails(EngineDataCenterVO zone) {
+ Map<String, String> details = zone.getDetails();
+ if (details == null) {
+ return;
+ }
+ _detailsDao.persist(zone.getId(), details);
+ }
+
+ @Override
+ public List<EngineDataCenterVO> listDisabledZones(){
+ SearchCriteria<EngineDataCenterVO> sc = DisabledZonesSearch.create();
+ sc.setParameters("allocationState", Grouping.AllocationState.Disabled);
+
+ List<EngineDataCenterVO> dcs = listBy(sc);
+
+ return dcs;
+ }
+
+ @Override
+ public List<EngineDataCenterVO> listEnabledZones(){
+ SearchCriteria<EngineDataCenterVO> sc = DisabledZonesSearch.create();
+ sc.setParameters("allocationState", Grouping.AllocationState.Enabled);
+
+ List<EngineDataCenterVO> dcs = listBy(sc);
+
+ return dcs;
+ }
+
+ @Override
+ public EngineDataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
+ EngineDataCenterVO result = findByToken(tokenOrIdOrName);
+ if (result == null) {
+ result = findByName(tokenOrIdOrName);
+ if (result == null) {
+ try {
+ Long dcId = Long.parseLong(tokenOrIdOrName);
+ return findById(dcId);
+ } catch (NumberFormatException nfe) {
+
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean remove(Long id) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ EngineDataCenterVO zone = createForUpdate();
+ zone.setName(null);
+
+ update(id, zone);
+
+ boolean result = super.remove(id);
+ txn.commit();
+ return result;
+ }
+
+
+ @Override
+ public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity zoneEntity, Object data) {
+
+ EngineDataCenterVO vo = findById(zoneEntity.getId());
+
+ Date oldUpdatedTime = vo.getLastUpdated();
+
+ SearchCriteria<EngineDataCenterVO> 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(vo, sc);
+
+ if (rows == 0 && s_logger.isDebugEnabled()) {
+ EngineDataCenterVO 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/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDao.java b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDao.java
new file mode 100644
index 0000000..c7ec8b9
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDao.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 org.apache.cloudstack.engine.datacenter.entity.dao;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.cloudstack.engine.datacenter.entity.EngineHostVO;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
+
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.host.Status;
+import com.cloud.info.RunningHostCountInfo;
+import com.cloud.resource.ResourceState;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+/**
+ * Data Access Object for server
+ *
+ */
+public interface EngineHostDao extends GenericDao<EngineHostVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
+ long countBy(long clusterId, ResourceState... states);
+
+ /**
+ * Mark all hosts associated with a certain management server
+ * as disconnected.
+ *
+ * @param msId management server id.
+ */
+ void markHostsAsDisconnected(long msId, long lastPing);
+
+ List<EngineHostVO> findLostHosts(long timeout);
+
+ List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId);
+
+ List<RunningHostCountInfo> getRunningHostCounts(Date cutTime);
+
+ long getNextSequence(long hostId);
+
+ void loadDetails(EngineHostVO host);
+
+ void saveDetails(EngineHostVO host);
+
+ void loadHostTags(EngineHostVO host);
+
+ List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
+
+ long countRoutingHostsByDataCenter(long dcId);
+
+ List<EngineHostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId);
+
+ boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
+
+ EngineHostVO findByGuid(String guid);
+
+ EngineHostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type);
+ List<EngineHostVO> findHypervisorHostInCluster(long clusterId);
+
+
+ /**
+ * @param type
+ * @param clusterId
+ * @param podId
+ * @param dcId
+ * @param haTag TODO
+ * @return
+ */
+ List<EngineHostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
+}