mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
More changes for deployVM flow.
This commit is contained in:
parent
94e8090bf3
commit
e6cd47ddc0
@ -154,7 +154,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeploymentPlanner planner = ComponentContext.getCompanent(plannerToUse);
|
DeploymentPlanner planner = ComponentContext.getComponent(plannerToUse);
|
||||||
DeployDestination dest = null;
|
DeployDestination dest = null;
|
||||||
|
|
||||||
if (planner.canHandle(vmProfile, plan, exclude)) {
|
if (planner.canHandle(vmProfile, plan, exclude)) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.org.Cluster.ClusterType;
|
import com.cloud.org.Cluster.ClusterType;
|
||||||
import com.cloud.org.Grouping.AllocationState;
|
import com.cloud.org.Grouping.AllocationState;
|
||||||
@ -36,7 +36,7 @@ public class ClusterEntityImpl implements ClusterEntity {
|
|||||||
|
|
||||||
private DataCenterResourceManager manager;
|
private DataCenterResourceManager manager;
|
||||||
|
|
||||||
private ClusterVO clusterVO;
|
private EngineClusterVO clusterVO;
|
||||||
|
|
||||||
|
|
||||||
public ClusterEntityImpl(String clusterId, DataCenterResourceManager manager) {
|
public ClusterEntityImpl(String clusterId, DataCenterResourceManager manager) {
|
||||||
|
|||||||
@ -18,10 +18,10 @@ 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.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
|
||||||
|
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
|
|
||||||
@ -29,22 +29,22 @@ import com.cloud.utils.fsm.NoTransitionException;
|
|||||||
|
|
||||||
public interface DataCenterResourceManager {
|
public interface DataCenterResourceManager {
|
||||||
|
|
||||||
DataCenterVO loadDataCenter(String dataCenterId);
|
EngineDataCenterVO loadDataCenter(String dataCenterId);
|
||||||
|
|
||||||
void saveDataCenter(DataCenterVO dc);
|
void saveDataCenter(EngineDataCenterVO dc);
|
||||||
|
|
||||||
void savePod(HostPodVO dc);
|
void savePod(EngineHostPodVO dc);
|
||||||
|
|
||||||
void saveCluster(ClusterVO cluster);
|
void saveCluster(EngineClusterVO cluster);
|
||||||
|
|
||||||
boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException;
|
boolean changeState(DataCenterResourceEntity entity, Event event) throws NoTransitionException;
|
||||||
|
|
||||||
HostPodVO loadPod(String uuid);
|
EngineHostPodVO loadPod(String uuid);
|
||||||
|
|
||||||
ClusterVO loadCluster(String uuid);
|
EngineClusterVO loadCluster(String uuid);
|
||||||
|
|
||||||
HostVO loadHost(String uuid);
|
EngineHostVO loadHost(String uuid);
|
||||||
|
|
||||||
void saveHost(HostVO hostVO);
|
void saveHost(EngineHostVO hostVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,14 +20,14 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
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.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.ClusterDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DataCenterDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostPodDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
@ -39,23 +39,23 @@ import com.cloud.utils.fsm.StateMachine2;
|
|||||||
public class DataCenterResourceManagerImpl implements DataCenterResourceManager {
|
public class DataCenterResourceManagerImpl implements DataCenterResourceManager {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DataCenterDao _dataCenterDao;
|
EngineDataCenterDao _dataCenterDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
HostPodDao _podDao;
|
EngineHostPodDao _podDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ClusterDao _clusterDao;
|
EngineClusterDao _clusterDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
HostDao _hostDao;
|
EngineHostDao _hostDao;
|
||||||
|
|
||||||
|
|
||||||
protected StateMachine2<State, Event, DataCenterResourceEntity> _stateMachine = DataCenterResourceEntity.State.s_fsm;
|
protected StateMachine2<State, Event, DataCenterResourceEntity> _stateMachine = DataCenterResourceEntity.State.s_fsm;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataCenterVO loadDataCenter(String dataCenterId) {
|
public EngineDataCenterVO loadDataCenter(String dataCenterId) {
|
||||||
DataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
|
EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
|
||||||
if(dataCenterVO == null){
|
if(dataCenterVO == null){
|
||||||
throw new InvalidParameterValueException("Zone does not exist");
|
throw new InvalidParameterValueException("Zone does not exist");
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDataCenter(DataCenterVO dc) {
|
public void saveDataCenter(EngineDataCenterVO dc) {
|
||||||
_dataCenterDao.persist(dc);
|
_dataCenterDao.persist(dc);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostPodVO loadPod(String uuid) {
|
public EngineHostPodVO loadPod(String uuid) {
|
||||||
HostPodVO pod = _podDao.findByUuid(uuid);
|
EngineHostPodVO pod = _podDao.findByUuid(uuid);
|
||||||
if(pod == null){
|
if(pod == null){
|
||||||
throw new InvalidParameterValueException("Pod does not exist");
|
throw new InvalidParameterValueException("Pod does not exist");
|
||||||
}
|
}
|
||||||
@ -94,8 +94,8 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterVO loadCluster(String uuid) {
|
public EngineClusterVO loadCluster(String uuid) {
|
||||||
ClusterVO cluster = _clusterDao.findByUuid(uuid);
|
EngineClusterVO cluster = _clusterDao.findByUuid(uuid);
|
||||||
if(cluster == null){
|
if(cluster == null){
|
||||||
throw new InvalidParameterValueException("Pod does not exist");
|
throw new InvalidParameterValueException("Pod does not exist");
|
||||||
}
|
}
|
||||||
@ -103,18 +103,18 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void savePod(HostPodVO pod) {
|
public void savePod(EngineHostPodVO pod) {
|
||||||
_podDao.persist(pod);
|
_podDao.persist(pod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveCluster(ClusterVO cluster) {
|
public void saveCluster(EngineClusterVO cluster) {
|
||||||
_clusterDao.persist(cluster);
|
_clusterDao.persist(cluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostVO loadHost(String uuid) {
|
public EngineHostVO loadHost(String uuid) {
|
||||||
HostVO host = _hostDao.findByUuid(uuid);
|
EngineHostVO host = _hostDao.findByUuid(uuid);
|
||||||
if(host == null){
|
if(host == null){
|
||||||
throw new InvalidParameterValueException("Host does not exist");
|
throw new InvalidParameterValueException("Host does not exist");
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveHost(HostVO hostVO) {
|
public void saveHost(EngineHostVO hostVO) {
|
||||||
_hostDao.persist(hostVO);
|
_hostDao.persist(hostVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
@ -31,7 +31,7 @@ public class HostEntityImpl implements HostEntity {
|
|||||||
|
|
||||||
private DataCenterResourceManager manager;
|
private DataCenterResourceManager manager;
|
||||||
|
|
||||||
private HostVO hostVO;
|
private EngineHostVO hostVO;
|
||||||
|
|
||||||
public HostEntityImpl(String uuid, DataCenterResourceManager manager) {
|
public HostEntityImpl(String uuid, DataCenterResourceManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
|
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
import com.cloud.org.Grouping.AllocationState;
|
import com.cloud.org.Grouping.AllocationState;
|
||||||
@ -35,7 +35,7 @@ public class PodEntityImpl implements PodEntity {
|
|||||||
|
|
||||||
private DataCenterResourceManager manager;
|
private DataCenterResourceManager manager;
|
||||||
|
|
||||||
private HostPodVO podVO;
|
private EngineHostPodVO podVO;
|
||||||
|
|
||||||
public PodEntityImpl(String uuid, DataCenterResourceManager manager) {
|
public PodEntityImpl(String uuid, DataCenterResourceManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import java.util.Map;
|
|||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
|
||||||
import com.cloud.utils.fsm.FiniteStateObject;
|
import com.cloud.utils.fsm.FiniteStateObject;
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class ZoneEntityImpl implements ZoneEntity, FiniteStateObject<DataCenterR
|
|||||||
|
|
||||||
private DataCenterResourceManager manager;
|
private DataCenterResourceManager manager;
|
||||||
|
|
||||||
private DataCenterVO dataCenterVO;
|
private EngineDataCenterVO dataCenterVO;
|
||||||
|
|
||||||
|
|
||||||
public ZoneEntityImpl(String dataCenterId, DataCenterResourceManager manager) {
|
public ZoneEntityImpl(String dataCenterId, DataCenterResourceManager manager) {
|
||||||
|
|||||||
@ -40,7 +40,7 @@ import com.cloud.utils.db.StateMachine;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cluster")
|
@Table(name="cluster")
|
||||||
public class ClusterVO implements Cluster, Identity {
|
public class EngineClusterVO implements Cluster, Identity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@ -99,19 +99,19 @@ public class ClusterVO implements Cluster, Identity {
|
|||||||
*/
|
*/
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
@StateMachine(state=State.class, event=Event.class)
|
@StateMachine(state=State.class, event=Event.class)
|
||||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
@Column(name="engine_state", updatable=true, nullable=false, length=32)
|
||||||
protected State state = null;
|
protected State engineState = null;
|
||||||
|
|
||||||
|
|
||||||
public ClusterVO() {
|
public EngineClusterVO() {
|
||||||
clusterType = Cluster.ClusterType.CloudManaged;
|
clusterType = Cluster.ClusterType.CloudManaged;
|
||||||
allocationState = Grouping.AllocationState.Enabled;
|
allocationState = Grouping.AllocationState.Enabled;
|
||||||
|
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClusterVO(long dataCenterId, long podId, String name) {
|
public EngineClusterVO(long dataCenterId, long podId, String name) {
|
||||||
this.dataCenterId = dataCenterId;
|
this.dataCenterId = dataCenterId;
|
||||||
this.podId = podId;
|
this.podId = podId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -119,7 +119,7 @@ public class ClusterVO implements Cluster, Identity {
|
|||||||
this.allocationState = Grouping.AllocationState.Enabled;
|
this.allocationState = Grouping.AllocationState.Enabled;
|
||||||
this.managedState = ManagedState.Managed;
|
this.managedState = ManagedState.Managed;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -169,7 +169,7 @@ public class ClusterVO implements Cluster, Identity {
|
|||||||
this.managedState = managedState;
|
this.managedState = managedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClusterVO(long clusterId) {
|
public EngineClusterVO(long clusterId) {
|
||||||
this.id = clusterId;
|
this.id = clusterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,10 +180,10 @@ public class ClusterVO implements Cluster, Identity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof ClusterVO)) {
|
if (!(obj instanceof EngineClusterVO)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ClusterVO that = (ClusterVO)obj;
|
EngineClusterVO that = (EngineClusterVO)obj;
|
||||||
return this.id == that.id;
|
return this.id == that.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +238,6 @@ public class ClusterVO implements Cluster, Identity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
return state;
|
return engineState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ import com.cloud.utils.db.StateMachine;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="data_center")
|
@Table(name="data_center")
|
||||||
public class DataCenterVO implements DataCenter, Identity {
|
public class EngineDataCenterVO implements DataCenter, Identity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@ -151,8 +151,8 @@ public class DataCenterVO implements DataCenter, Identity {
|
|||||||
*/
|
*/
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
@StateMachine(state=State.class, event=Event.class)
|
@StateMachine(state=State.class, event=Event.class)
|
||||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
@Column(name="engine_state", updatable=true, nullable=false, length=32)
|
||||||
protected State state = null;
|
protected State engineState = null;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -200,14 +200,14 @@ public class DataCenterVO implements DataCenter, Identity {
|
|||||||
this.firewallProvider = firewallProvider;
|
this.firewallProvider = firewallProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataCenterVO(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) {
|
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);
|
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.allocationState = Grouping.AllocationState.Enabled;
|
this.allocationState = Grouping.AllocationState.Enabled;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataCenterVO(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) {
|
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) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.dns1 = dns1;
|
this.dns1 = dns1;
|
||||||
@ -240,7 +240,7 @@ public class DataCenterVO implements DataCenter, Identity {
|
|||||||
this.zoneToken = zoneToken;
|
this.zoneToken = zoneToken;
|
||||||
this.domain = domainSuffix;
|
this.domain = domainSuffix;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -310,7 +310,7 @@ public class DataCenterVO implements DataCenter, Identity {
|
|||||||
return internalDns2;
|
return internalDns2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataCenterVO() {
|
protected EngineDataCenterVO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -421,10 +421,10 @@ public class DataCenterVO implements DataCenter, Identity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof DataCenterVO)) {
|
if (!(obj instanceof EngineDataCenterVO)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DataCenterVO that = (DataCenterVO)obj;
|
EngineDataCenterVO that = (EngineDataCenterVO)obj;
|
||||||
return this.id == that.id;
|
return this.id == that.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,6 +475,6 @@ public class DataCenterVO implements DataCenter, Identity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
return state;
|
return engineState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ import com.cloud.utils.db.StateMachine;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "host_pod_ref")
|
@Table(name = "host_pod_ref")
|
||||||
public class HostPodVO implements Pod, Identity {
|
public class EngineHostPodVO implements Pod, Identity {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
long id;
|
long id;
|
||||||
@ -92,10 +92,10 @@ public class HostPodVO implements Pod, Identity {
|
|||||||
*/
|
*/
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
@StateMachine(state=State.class, event=Event.class)
|
@StateMachine(state=State.class, event=Event.class)
|
||||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
@Column(name="engine_state", updatable=true, nullable=false, length=32)
|
||||||
protected State state = null;
|
protected State engineState = null;
|
||||||
|
|
||||||
public HostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
|
public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.dataCenterId = dcId;
|
this.dataCenterId = dcId;
|
||||||
this.gateway = gateway;
|
this.gateway = gateway;
|
||||||
@ -105,13 +105,13 @@ public class HostPodVO implements Pod, Identity {
|
|||||||
this.allocationState = Grouping.AllocationState.Enabled;
|
this.allocationState = Grouping.AllocationState.Enabled;
|
||||||
this.externalDhcp = false;
|
this.externalDhcp = false;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* public HostPodVO(String name, long dcId) { this(null, name, dcId); }
|
* public HostPodVO(String name, long dcId) { this(null, name, dcId); }
|
||||||
*/
|
*/
|
||||||
protected HostPodVO() {
|
protected EngineHostPodVO() {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ public class HostPodVO implements Pod, Identity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use for comparisons only.
|
// Use for comparisons only.
|
||||||
public HostPodVO(Long id) {
|
public EngineHostPodVO(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,8 +204,8 @@ public class HostPodVO implements Pod, Identity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof HostPodVO) {
|
if (obj instanceof EngineHostPodVO) {
|
||||||
return id == ((HostPodVO)obj).id;
|
return id == ((EngineHostPodVO)obj).id;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -241,6 +241,6 @@ public class HostPodVO implements Pod, Identity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
return state;
|
return engineState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ import com.cloud.utils.db.StateMachine;
|
|||||||
@Table(name="host")
|
@Table(name="host")
|
||||||
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
|
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
|
||||||
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
|
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
|
||||||
public class HostVO implements Host, Identity {
|
public class EngineHostVO implements Host, Identity {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@Column(name="id")
|
@Column(name="id")
|
||||||
@ -383,26 +383,26 @@ public class HostVO implements Host, Identity {
|
|||||||
*/
|
*/
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
@StateMachine(state=State.class, event=Event.class)
|
@StateMachine(state=State.class, event=Event.class)
|
||||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
@Column(name="engine_state", updatable=true, nullable=false, length=32)
|
||||||
protected State state = null;
|
protected State engineState = null;
|
||||||
|
|
||||||
|
|
||||||
public HostVO(String guid) {
|
public EngineHostVO(String guid) {
|
||||||
this.guid = guid;
|
this.guid = guid;
|
||||||
this.status = Status.Creating;
|
this.status = Status.Creating;
|
||||||
this.totalMemory = 0;
|
this.totalMemory = 0;
|
||||||
this.dom0MinMemory = 0;
|
this.dom0MinMemory = 0;
|
||||||
this.resourceState = ResourceState.Creating;
|
this.resourceState = ResourceState.Creating;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HostVO() {
|
protected EngineHostVO() {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostVO(long id,
|
public EngineHostVO(long id,
|
||||||
String name,
|
String name,
|
||||||
Type type,
|
Type type,
|
||||||
String privateIpAddress,
|
String privateIpAddress,
|
||||||
@ -434,10 +434,10 @@ public class HostVO implements Host, Identity {
|
|||||||
this.totalSize = totalSize;
|
this.totalSize = totalSize;
|
||||||
this.fsType = fsType;
|
this.fsType = fsType;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostVO(long id,
|
public EngineHostVO(long id,
|
||||||
String name,
|
String name,
|
||||||
Type type,
|
Type type,
|
||||||
String privateIpAddress,
|
String privateIpAddress,
|
||||||
@ -493,7 +493,7 @@ public class HostVO implements Host, Identity {
|
|||||||
this.dom0MinMemory = dom0MinMemory;
|
this.dom0MinMemory = dom0MinMemory;
|
||||||
this.storageUrl = url;
|
this.storageUrl = url;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = State.Disabled;
|
this.engineState = State.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPodId(Long podId) {
|
public void setPodId(Long podId) {
|
||||||
@ -689,8 +689,8 @@ public class HostVO implements Host, Identity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof HostVO) {
|
if (obj instanceof EngineHostVO) {
|
||||||
return ((HostVO)obj).getId() == this.getId();
|
return ((EngineHostVO)obj).getId() == this.getId();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -774,6 +774,6 @@ public class HostVO implements Host, Identity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public State getOrchestrationState() {
|
public State getOrchestrationState() {
|
||||||
return state;
|
return engineState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16,21 +16,21 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.utils.fsm.StateDao;
|
import com.cloud.utils.fsm.StateDao;
|
||||||
|
|
||||||
public interface ClusterDao extends GenericDao<ClusterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
public interface EngineClusterDao extends GenericDao<EngineClusterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
||||||
List<ClusterVO> listByPodId(long podId);
|
List<EngineClusterVO> listByPodId(long podId);
|
||||||
ClusterVO findBy(String name, long podId);
|
EngineClusterVO findBy(String name, long podId);
|
||||||
List<ClusterVO> listByHyTypeWithoutGuid(String hyType);
|
List<EngineClusterVO> listByHyTypeWithoutGuid(String hyType);
|
||||||
List<ClusterVO> listByZoneId(long zoneId);
|
List<EngineClusterVO> listByZoneId(long zoneId);
|
||||||
|
|
||||||
List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
|
List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
|
||||||
List<ClusterVO> listByDcHyType(long dcId, String hyType);
|
List<EngineClusterVO> listByDcHyType(long dcId, String hyType);
|
||||||
Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
|
Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
|
||||||
List<Long> listDisabledClusters(long zoneId, Long podId);
|
List<Long> listDisabledClusters(long zoneId, Long podId);
|
||||||
List<Long> listClustersWithDisabledPods(long zoneId);
|
List<Long> listClustersWithDisabledPods(long zoneId);
|
||||||
@ -27,8 +27,8 @@ import javax.inject.Inject;
|
|||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
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;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -46,24 +46,24 @@ import com.cloud.utils.db.UpdateBuilder;
|
|||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Component(value="EngineClusterDao")
|
@Component(value="EngineClusterDao")
|
||||||
@Local(value=ClusterDao.class)
|
@Local(value=EngineClusterDao.class)
|
||||||
public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements ClusterDao {
|
public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> implements EngineClusterDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(ClusterDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(EngineClusterDaoImpl.class);
|
||||||
|
|
||||||
protected final SearchBuilder<ClusterVO> PodSearch;
|
protected final SearchBuilder<EngineClusterVO> PodSearch;
|
||||||
protected final SearchBuilder<ClusterVO> HyTypeWithoutGuidSearch;
|
protected final SearchBuilder<EngineClusterVO> HyTypeWithoutGuidSearch;
|
||||||
protected final SearchBuilder<ClusterVO> AvailHyperSearch;
|
protected final SearchBuilder<EngineClusterVO> AvailHyperSearch;
|
||||||
protected final SearchBuilder<ClusterVO> ZoneSearch;
|
protected final SearchBuilder<EngineClusterVO> ZoneSearch;
|
||||||
protected final SearchBuilder<ClusterVO> ZoneHyTypeSearch;
|
protected final SearchBuilder<EngineClusterVO> ZoneHyTypeSearch;
|
||||||
protected SearchBuilder<ClusterVO> StateChangeSearch;
|
protected SearchBuilder<EngineClusterVO> StateChangeSearch;
|
||||||
protected SearchBuilder<ClusterVO> UUIDSearch;
|
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_PREFIX = "SELECT pod_id, id FROM cloud.cluster WHERE cluster.id IN( ";
|
||||||
private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
|
private static final String GET_POD_CLUSTER_MAP_SUFFIX = " )";
|
||||||
|
|
||||||
@Inject protected HostPodDao _hostPodDao;
|
@Inject protected EngineHostPodDao _hostPodDao;
|
||||||
|
|
||||||
protected ClusterDaoImpl() {
|
protected EngineClusterDaoImpl() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
HyTypeWithoutGuidSearch = createSearchBuilder();
|
HyTypeWithoutGuidSearch = createSearchBuilder();
|
||||||
@ -102,23 +102,23 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClusterVO> listByZoneId(long zoneId) {
|
public List<EngineClusterVO> listByZoneId(long zoneId) {
|
||||||
SearchCriteria<ClusterVO> sc = ZoneSearch.create();
|
SearchCriteria<EngineClusterVO> sc = ZoneSearch.create();
|
||||||
sc.setParameters("dataCenterId", zoneId);
|
sc.setParameters("dataCenterId", zoneId);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClusterVO> listByPodId(long podId) {
|
public List<EngineClusterVO> listByPodId(long podId) {
|
||||||
SearchCriteria<ClusterVO> sc = PodSearch.create();
|
SearchCriteria<EngineClusterVO> sc = PodSearch.create();
|
||||||
sc.setParameters("pod", podId);
|
sc.setParameters("pod", podId);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterVO findBy(String name, long podId) {
|
public EngineClusterVO findBy(String name, long podId) {
|
||||||
SearchCriteria<ClusterVO> sc = PodSearch.create();
|
SearchCriteria<EngineClusterVO> sc = PodSearch.create();
|
||||||
sc.setParameters("pod", podId);
|
sc.setParameters("pod", podId);
|
||||||
sc.setParameters("name", name);
|
sc.setParameters("name", name);
|
||||||
|
|
||||||
@ -126,16 +126,16 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClusterVO> listByHyTypeWithoutGuid(String hyType) {
|
public List<EngineClusterVO> listByHyTypeWithoutGuid(String hyType) {
|
||||||
SearchCriteria<ClusterVO> sc = HyTypeWithoutGuidSearch.create();
|
SearchCriteria<EngineClusterVO> sc = HyTypeWithoutGuidSearch.create();
|
||||||
sc.setParameters("hypervisorType", hyType);
|
sc.setParameters("hypervisorType", hyType);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClusterVO> listByDcHyType(long dcId, String hyType) {
|
public List<EngineClusterVO> listByDcHyType(long dcId, String hyType) {
|
||||||
SearchCriteria<ClusterVO> sc = ZoneHyTypeSearch.create();
|
SearchCriteria<EngineClusterVO> sc = ZoneHyTypeSearch.create();
|
||||||
sc.setParameters("dataCenterId", dcId);
|
sc.setParameters("dataCenterId", dcId);
|
||||||
sc.setParameters("hypervisorType", hyType);
|
sc.setParameters("hypervisorType", hyType);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
@ -143,13 +143,13 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
|
public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
|
||||||
SearchCriteria<ClusterVO> sc = AvailHyperSearch.create();
|
SearchCriteria<EngineClusterVO> sc = AvailHyperSearch.create();
|
||||||
if (zoneId != null) {
|
if (zoneId != null) {
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
}
|
}
|
||||||
List<ClusterVO> clusters = listBy(sc);
|
List<EngineClusterVO> clusters = listBy(sc);
|
||||||
List<HypervisorType> hypers = new ArrayList<HypervisorType>(4);
|
List<HypervisorType> hypers = new ArrayList<HypervisorType>(4);
|
||||||
for (ClusterVO cluster : clusters) {
|
for (EngineClusterVO cluster : clusters) {
|
||||||
hypers.add(cluster.getHypervisorType());
|
hypers.add(cluster.getHypervisorType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listDisabledClusters(long zoneId, Long podId) {
|
public List<Long> listDisabledClusters(long zoneId, Long podId) {
|
||||||
GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
||||||
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
||||||
clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
|
clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
if(podId != null){
|
if(podId != null){
|
||||||
@ -219,12 +219,12 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
@Override
|
@Override
|
||||||
public List<Long> listClustersWithDisabledPods(long zoneId) {
|
public List<Long> listClustersWithDisabledPods(long zoneId) {
|
||||||
|
|
||||||
GenericSearchBuilder<HostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
|
GenericSearchBuilder<EngineHostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
|
||||||
disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
|
disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
|
||||||
disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
|
disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
|
disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
|
||||||
|
|
||||||
GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
||||||
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
||||||
clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||||
clusterIdSearch.done();
|
clusterIdSearch.done();
|
||||||
@ -241,7 +241,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
public boolean remove(Long id) {
|
public boolean remove(Long id) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
ClusterVO cluster = createForUpdate();
|
EngineClusterVO cluster = createForUpdate();
|
||||||
cluster.setName(null);
|
cluster.setName(null);
|
||||||
cluster.setGuid(null);
|
cluster.setGuid(null);
|
||||||
|
|
||||||
@ -255,11 +255,11 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
|
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
|
||||||
|
|
||||||
ClusterVO vo = findById(clusterEntity.getId());
|
EngineClusterVO vo = findById(clusterEntity.getId());
|
||||||
|
|
||||||
Date oldUpdatedTime = vo.getLastUpdated();
|
Date oldUpdatedTime = vo.getLastUpdated();
|
||||||
|
|
||||||
SearchCriteria<ClusterVO> sc = StateChangeSearch.create();
|
SearchCriteria<EngineClusterVO> sc = StateChangeSearch.create();
|
||||||
sc.setParameters("id", vo.getId());
|
sc.setParameters("id", vo.getId());
|
||||||
sc.setParameters("state", currentState);
|
sc.setParameters("state", currentState);
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
int rows = update(vo, sc);
|
int rows = update(vo, sc);
|
||||||
|
|
||||||
if (rows == 0 && s_logger.isDebugEnabled()) {
|
if (rows == 0 && s_logger.isDebugEnabled()) {
|
||||||
ClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
|
EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
|
||||||
if (dbCluster != null) {
|
if (dbCluster != null) {
|
||||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
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=")
|
str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=")
|
||||||
@ -16,15 +16,15 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
|
||||||
|
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.utils.fsm.StateDao;
|
import com.cloud.utils.fsm.StateDao;
|
||||||
|
|
||||||
|
|
||||||
public interface DataCenterDao extends GenericDao<DataCenterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
public interface EngineDataCenterDao extends GenericDao<EngineDataCenterVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
||||||
DataCenterVO findByName(String name);
|
EngineDataCenterVO findByName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id data center id
|
* @param id data center id
|
||||||
@ -32,24 +32,24 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long>, StateDao<
|
|||||||
*/
|
*/
|
||||||
String[] getNextAvailableMacAddressPair(long id);
|
String[] getNextAvailableMacAddressPair(long id);
|
||||||
String[] getNextAvailableMacAddressPair(long id, long mask);
|
String[] getNextAvailableMacAddressPair(long id, long mask);
|
||||||
List<DataCenterVO> findZonesByDomainId(Long domainId);
|
List<EngineDataCenterVO> findZonesByDomainId(Long domainId);
|
||||||
|
|
||||||
List<DataCenterVO> listPublicZones(String keyword);
|
List<EngineDataCenterVO> listPublicZones(String keyword);
|
||||||
|
|
||||||
List<DataCenterVO> findChildZones(Object[] ids, String keyword);
|
List<EngineDataCenterVO> findChildZones(Object[] ids, String keyword);
|
||||||
|
|
||||||
void loadDetails(DataCenterVO zone);
|
void loadDetails(EngineDataCenterVO zone);
|
||||||
void saveDetails(DataCenterVO zone);
|
void saveDetails(EngineDataCenterVO zone);
|
||||||
|
|
||||||
List<DataCenterVO> listDisabledZones();
|
List<EngineDataCenterVO> listDisabledZones();
|
||||||
List<DataCenterVO> listEnabledZones();
|
List<EngineDataCenterVO> listEnabledZones();
|
||||||
DataCenterVO findByToken(String zoneToken);
|
EngineDataCenterVO findByToken(String zoneToken);
|
||||||
DataCenterVO findByTokenOrIdOrName(String tokenIdOrName);
|
EngineDataCenterVO findByTokenOrIdOrName(String tokenIdOrName);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<DataCenterVO> findZonesByDomainId(Long domainId, String keyword);
|
List<EngineDataCenterVO> findZonesByDomainId(Long domainId, String keyword);
|
||||||
|
|
||||||
List<DataCenterVO> findByKeyword(String keyword);
|
List<EngineDataCenterVO> findByKeyword(String keyword);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ import javax.persistence.TableGenerator;
|
|||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
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;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -48,18 +48,18 @@ import com.cloud.utils.net.NetUtils;
|
|||||||
* }
|
* }
|
||||||
**/
|
**/
|
||||||
@Component(value="EngineDataCenterDao")
|
@Component(value="EngineDataCenterDao")
|
||||||
@Local(value={DataCenterDao.class})
|
@Local(value={EngineDataCenterDao.class})
|
||||||
public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implements DataCenterDao {
|
public class EngineDataCenterDaoImpl extends GenericDaoBase<EngineDataCenterVO, Long> implements EngineDataCenterDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(DataCenterDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(EngineDataCenterDaoImpl.class);
|
||||||
|
|
||||||
protected SearchBuilder<DataCenterVO> NameSearch;
|
protected SearchBuilder<EngineDataCenterVO> NameSearch;
|
||||||
protected SearchBuilder<DataCenterVO> ListZonesByDomainIdSearch;
|
protected SearchBuilder<EngineDataCenterVO> ListZonesByDomainIdSearch;
|
||||||
protected SearchBuilder<DataCenterVO> PublicZonesSearch;
|
protected SearchBuilder<EngineDataCenterVO> PublicZonesSearch;
|
||||||
protected SearchBuilder<DataCenterVO> ChildZonesSearch;
|
protected SearchBuilder<EngineDataCenterVO> ChildZonesSearch;
|
||||||
protected SearchBuilder<DataCenterVO> DisabledZonesSearch;
|
protected SearchBuilder<EngineDataCenterVO> DisabledZonesSearch;
|
||||||
protected SearchBuilder<DataCenterVO> TokenSearch;
|
protected SearchBuilder<EngineDataCenterVO> TokenSearch;
|
||||||
protected SearchBuilder<DataCenterVO> StateChangeSearch;
|
protected SearchBuilder<EngineDataCenterVO> StateChangeSearch;
|
||||||
protected SearchBuilder<DataCenterVO> UUIDSearch;
|
protected SearchBuilder<EngineDataCenterVO> UUIDSearch;
|
||||||
|
|
||||||
protected long _prefix;
|
protected long _prefix;
|
||||||
protected Random _rand = new Random(System.currentTimeMillis());
|
protected Random _rand = new Random(System.currentTimeMillis());
|
||||||
@ -69,33 +69,33 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataCenterVO findByName(String name) {
|
public EngineDataCenterVO findByName(String name) {
|
||||||
SearchCriteria<DataCenterVO> sc = NameSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = NameSearch.create();
|
||||||
sc.setParameters("name", name);
|
sc.setParameters("name", name);
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataCenterVO findByToken(String zoneToken){
|
public EngineDataCenterVO findByToken(String zoneToken){
|
||||||
SearchCriteria<DataCenterVO> sc = TokenSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = TokenSearch.create();
|
||||||
sc.setParameters("zoneToken", zoneToken);
|
sc.setParameters("zoneToken", zoneToken);
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> findZonesByDomainId(Long domainId){
|
public List<EngineDataCenterVO> findZonesByDomainId(Long domainId){
|
||||||
SearchCriteria<DataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
||||||
sc.setParameters("domainId", domainId);
|
sc.setParameters("domainId", domainId);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> findZonesByDomainId(Long domainId, String keyword){
|
public List<EngineDataCenterVO> findZonesByDomainId(Long domainId, String keyword){
|
||||||
SearchCriteria<DataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
||||||
sc.setParameters("domainId", domainId);
|
sc.setParameters("domainId", domainId);
|
||||||
if (keyword != null) {
|
if (keyword != null) {
|
||||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
|
||||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||||
@ -104,11 +104,11 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> findChildZones(Object[] ids, String keyword){
|
public List<EngineDataCenterVO> findChildZones(Object[] ids, String keyword){
|
||||||
SearchCriteria<DataCenterVO> sc = ChildZonesSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = ChildZonesSearch.create();
|
||||||
sc.setParameters("domainid", ids);
|
sc.setParameters("domainid", ids);
|
||||||
if (keyword != null) {
|
if (keyword != null) {
|
||||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
|
||||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||||
@ -117,10 +117,10 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> listPublicZones(String keyword){
|
public List<EngineDataCenterVO> listPublicZones(String keyword){
|
||||||
SearchCriteria<DataCenterVO> sc = PublicZonesSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = PublicZonesSearch.create();
|
||||||
if (keyword != null) {
|
if (keyword != null) {
|
||||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
|
||||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||||
@ -130,8 +130,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> findByKeyword(String keyword){
|
public List<EngineDataCenterVO> findByKeyword(String keyword){
|
||||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
SearchCriteria<EngineDataCenterVO> ssc = createSearchCriteria();
|
||||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||||
return listBy(ssc);
|
return listBy(ssc);
|
||||||
@ -170,7 +170,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataCenterDaoImpl() {
|
protected EngineDataCenterDaoImpl() {
|
||||||
super();
|
super();
|
||||||
NameSearch = createSearchBuilder();
|
NameSearch = createSearchBuilder();
|
||||||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||||
@ -211,7 +211,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public boolean update(Long zoneId, DataCenterVO zone) {
|
public boolean update(Long zoneId, EngineDataCenterVO zone) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
boolean persisted = super.update(zoneId, zone);
|
boolean persisted = super.update(zoneId, zone);
|
||||||
@ -224,13 +224,13 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadDetails(DataCenterVO zone) {
|
public void loadDetails(EngineDataCenterVO zone) {
|
||||||
Map<String, String> details =_detailsDao.findDetails(zone.getId());
|
Map<String, String> details =_detailsDao.findDetails(zone.getId());
|
||||||
zone.setDetails(details);
|
zone.setDetails(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDetails(DataCenterVO zone) {
|
public void saveDetails(EngineDataCenterVO zone) {
|
||||||
Map<String, String> details = zone.getDetails();
|
Map<String, String> details = zone.getDetails();
|
||||||
if (details == null) {
|
if (details == null) {
|
||||||
return;
|
return;
|
||||||
@ -239,28 +239,28 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> listDisabledZones(){
|
public List<EngineDataCenterVO> listDisabledZones(){
|
||||||
SearchCriteria<DataCenterVO> sc = DisabledZonesSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = DisabledZonesSearch.create();
|
||||||
sc.setParameters("allocationState", Grouping.AllocationState.Disabled);
|
sc.setParameters("allocationState", Grouping.AllocationState.Disabled);
|
||||||
|
|
||||||
List<DataCenterVO> dcs = listBy(sc);
|
List<EngineDataCenterVO> dcs = listBy(sc);
|
||||||
|
|
||||||
return dcs;
|
return dcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataCenterVO> listEnabledZones(){
|
public List<EngineDataCenterVO> listEnabledZones(){
|
||||||
SearchCriteria<DataCenterVO> sc = DisabledZonesSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = DisabledZonesSearch.create();
|
||||||
sc.setParameters("allocationState", Grouping.AllocationState.Enabled);
|
sc.setParameters("allocationState", Grouping.AllocationState.Enabled);
|
||||||
|
|
||||||
List<DataCenterVO> dcs = listBy(sc);
|
List<EngineDataCenterVO> dcs = listBy(sc);
|
||||||
|
|
||||||
return dcs;
|
return dcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
|
public EngineDataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
|
||||||
DataCenterVO result = findByToken(tokenOrIdOrName);
|
EngineDataCenterVO result = findByToken(tokenOrIdOrName);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = findByName(tokenOrIdOrName);
|
result = findByName(tokenOrIdOrName);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -279,7 +279,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
public boolean remove(Long id) {
|
public boolean remove(Long id) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
DataCenterVO zone = createForUpdate();
|
EngineDataCenterVO zone = createForUpdate();
|
||||||
zone.setName(null);
|
zone.setName(null);
|
||||||
|
|
||||||
update(id, zone);
|
update(id, zone);
|
||||||
@ -293,11 +293,11 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity zoneEntity, Object data) {
|
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity zoneEntity, Object data) {
|
||||||
|
|
||||||
DataCenterVO vo = findById(zoneEntity.getId());
|
EngineDataCenterVO vo = findById(zoneEntity.getId());
|
||||||
|
|
||||||
Date oldUpdatedTime = vo.getLastUpdated();
|
Date oldUpdatedTime = vo.getLastUpdated();
|
||||||
|
|
||||||
SearchCriteria<DataCenterVO> sc = StateChangeSearch.create();
|
SearchCriteria<EngineDataCenterVO> sc = StateChangeSearch.create();
|
||||||
sc.setParameters("id", vo.getId());
|
sc.setParameters("id", vo.getId());
|
||||||
sc.setParameters("state", currentState);
|
sc.setParameters("state", currentState);
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||||||
int rows = update(vo, sc);
|
int rows = update(vo, sc);
|
||||||
|
|
||||||
if (rows == 0 && s_logger.isDebugEnabled()) {
|
if (rows == 0 && s_logger.isDebugEnabled()) {
|
||||||
DataCenterVO dbDC = findByIdIncludingRemoved(vo.getId());
|
EngineDataCenterVO dbDC = findByIdIncludingRemoved(vo.getId());
|
||||||
if (dbDC != null) {
|
if (dbDC != null) {
|
||||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
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=")
|
str.append(": DB Data={id=").append(dbDC.getId()).append("; state=").append(dbDC.getState()).append(";updatedTime=")
|
||||||
@ -20,7 +20,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
|
||||||
|
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.Host.Type;
|
import com.cloud.host.Host.Type;
|
||||||
@ -34,7 +34,7 @@ import com.cloud.utils.fsm.StateDao;
|
|||||||
* Data Access Object for server
|
* Data Access Object for server
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface HostDao extends GenericDao<HostVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
public interface EngineHostDao extends GenericDao<EngineHostVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
||||||
long countBy(long clusterId, ResourceState... states);
|
long countBy(long clusterId, ResourceState... states);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,32 +45,32 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<DataCenterRe
|
|||||||
*/
|
*/
|
||||||
void markHostsAsDisconnected(long msId, long lastPing);
|
void markHostsAsDisconnected(long msId, long lastPing);
|
||||||
|
|
||||||
List<HostVO> findLostHosts(long timeout);
|
List<EngineHostVO> findLostHosts(long timeout);
|
||||||
|
|
||||||
List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId);
|
List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId);
|
||||||
|
|
||||||
List<RunningHostCountInfo> getRunningHostCounts(Date cutTime);
|
List<RunningHostCountInfo> getRunningHostCounts(Date cutTime);
|
||||||
|
|
||||||
long getNextSequence(long hostId);
|
long getNextSequence(long hostId);
|
||||||
|
|
||||||
void loadDetails(HostVO host);
|
void loadDetails(EngineHostVO host);
|
||||||
|
|
||||||
void saveDetails(HostVO host);
|
void saveDetails(EngineHostVO host);
|
||||||
|
|
||||||
void loadHostTags(HostVO host);
|
void loadHostTags(EngineHostVO host);
|
||||||
|
|
||||||
List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
|
List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
|
||||||
|
|
||||||
long countRoutingHostsByDataCenter(long dcId);
|
long countRoutingHostsByDataCenter(long dcId);
|
||||||
|
|
||||||
List<HostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId);
|
List<EngineHostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId);
|
||||||
|
|
||||||
boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
|
boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
|
||||||
|
|
||||||
HostVO findByGuid(String guid);
|
EngineHostVO findByGuid(String guid);
|
||||||
|
|
||||||
HostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type);
|
EngineHostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type);
|
||||||
List<HostVO> findHypervisorHostInCluster(long clusterId);
|
List<EngineHostVO> findHypervisorHostInCluster(long clusterId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,5 +81,5 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<DataCenterRe
|
|||||||
* @param haTag TODO
|
* @param haTag TODO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
|
List<EngineHostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ import javax.persistence.TableGenerator;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
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;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -58,52 +58,52 @@ import com.cloud.utils.db.UpdateBuilder;
|
|||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Component(value="EngineHostDao")
|
@Component(value="EngineHostDao")
|
||||||
@Local(value = { HostDao.class })
|
@Local(value = { EngineHostDao.class })
|
||||||
@DB(txn = false)
|
@DB(txn = false)
|
||||||
@TableGenerator(name = "host_req_sq", table = "op_host", pkColumnName = "id", valueColumnName = "sequence", allocationSize = 1)
|
@TableGenerator(name = "host_req_sq", table = "op_host", pkColumnName = "id", valueColumnName = "sequence", allocationSize = 1)
|
||||||
public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao {
|
public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO, Long> implements EngineHostDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(HostDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(EngineHostDaoImpl.class);
|
||||||
private static final Logger status_logger = Logger.getLogger(Status.class);
|
private static final Logger status_logger = Logger.getLogger(Status.class);
|
||||||
private static final Logger state_logger = Logger.getLogger(ResourceState.class);
|
private static final Logger state_logger = Logger.getLogger(ResourceState.class);
|
||||||
|
|
||||||
protected final SearchBuilder<HostVO> TypePodDcStatusSearch;
|
protected final SearchBuilder<EngineHostVO> TypePodDcStatusSearch;
|
||||||
|
|
||||||
protected final SearchBuilder<HostVO> IdStatusSearch;
|
protected final SearchBuilder<EngineHostVO> IdStatusSearch;
|
||||||
protected final SearchBuilder<HostVO> TypeDcSearch;
|
protected final SearchBuilder<EngineHostVO> TypeDcSearch;
|
||||||
protected final SearchBuilder<HostVO> TypeDcStatusSearch;
|
protected final SearchBuilder<EngineHostVO> TypeDcStatusSearch;
|
||||||
protected final SearchBuilder<HostVO> TypeClusterStatusSearch;
|
protected final SearchBuilder<EngineHostVO> TypeClusterStatusSearch;
|
||||||
protected final SearchBuilder<HostVO> MsStatusSearch;
|
protected final SearchBuilder<EngineHostVO> MsStatusSearch;
|
||||||
protected final SearchBuilder<HostVO> DcPrivateIpAddressSearch;
|
protected final SearchBuilder<EngineHostVO> DcPrivateIpAddressSearch;
|
||||||
protected final SearchBuilder<HostVO> DcStorageIpAddressSearch;
|
protected final SearchBuilder<EngineHostVO> DcStorageIpAddressSearch;
|
||||||
|
|
||||||
protected final SearchBuilder<HostVO> GuidSearch;
|
protected final SearchBuilder<EngineHostVO> GuidSearch;
|
||||||
protected final SearchBuilder<HostVO> DcSearch;
|
protected final SearchBuilder<EngineHostVO> DcSearch;
|
||||||
protected final SearchBuilder<HostVO> PodSearch;
|
protected final SearchBuilder<EngineHostVO> PodSearch;
|
||||||
protected final SearchBuilder<HostVO> TypeSearch;
|
protected final SearchBuilder<EngineHostVO> TypeSearch;
|
||||||
protected final SearchBuilder<HostVO> StatusSearch;
|
protected final SearchBuilder<EngineHostVO> StatusSearch;
|
||||||
protected final SearchBuilder<HostVO> ResourceStateSearch;
|
protected final SearchBuilder<EngineHostVO> ResourceStateSearch;
|
||||||
protected final SearchBuilder<HostVO> NameLikeSearch;
|
protected final SearchBuilder<EngineHostVO> NameLikeSearch;
|
||||||
protected final SearchBuilder<HostVO> NameSearch;
|
protected final SearchBuilder<EngineHostVO> NameSearch;
|
||||||
protected final SearchBuilder<HostVO> SequenceSearch;
|
protected final SearchBuilder<EngineHostVO> SequenceSearch;
|
||||||
protected final SearchBuilder<HostVO> DirectlyConnectedSearch;
|
protected final SearchBuilder<EngineHostVO> DirectlyConnectedSearch;
|
||||||
protected final SearchBuilder<HostVO> UnmanagedDirectConnectSearch;
|
protected final SearchBuilder<EngineHostVO> UnmanagedDirectConnectSearch;
|
||||||
protected final SearchBuilder<HostVO> UnmanagedApplianceSearch;
|
protected final SearchBuilder<EngineHostVO> UnmanagedApplianceSearch;
|
||||||
protected final SearchBuilder<HostVO> MaintenanceCountSearch;
|
protected final SearchBuilder<EngineHostVO> MaintenanceCountSearch;
|
||||||
protected final SearchBuilder<HostVO> ClusterStatusSearch;
|
protected final SearchBuilder<EngineHostVO> ClusterStatusSearch;
|
||||||
protected final SearchBuilder<HostVO> TypeNameZoneSearch;
|
protected final SearchBuilder<EngineHostVO> TypeNameZoneSearch;
|
||||||
protected final SearchBuilder<HostVO> AvailHypevisorInZone;
|
protected final SearchBuilder<EngineHostVO> AvailHypevisorInZone;
|
||||||
|
|
||||||
protected final SearchBuilder<HostVO> DirectConnectSearch;
|
protected final SearchBuilder<EngineHostVO> DirectConnectSearch;
|
||||||
protected final SearchBuilder<HostVO> ManagedDirectConnectSearch;
|
protected final SearchBuilder<EngineHostVO> ManagedDirectConnectSearch;
|
||||||
protected final SearchBuilder<HostVO> ManagedRoutingServersSearch;
|
protected final SearchBuilder<EngineHostVO> ManagedRoutingServersSearch;
|
||||||
protected final SearchBuilder<HostVO> SecondaryStorageVMSearch;
|
protected final SearchBuilder<EngineHostVO> SecondaryStorageVMSearch;
|
||||||
protected SearchBuilder<HostVO> StateChangeSearch;
|
protected SearchBuilder<EngineHostVO> StateChangeSearch;
|
||||||
|
|
||||||
protected SearchBuilder<HostVO> UUIDSearch;
|
protected SearchBuilder<EngineHostVO> UUIDSearch;
|
||||||
|
|
||||||
protected final GenericSearchBuilder<HostVO, Long> HostsInStatusSearch;
|
protected final GenericSearchBuilder<EngineHostVO, Long> HostsInStatusSearch;
|
||||||
protected final GenericSearchBuilder<HostVO, Long> CountRoutingByDc;
|
protected final GenericSearchBuilder<EngineHostVO, Long> CountRoutingByDc;
|
||||||
protected final SearchBuilder<HostVO> RoutingSearch;
|
protected final SearchBuilder<EngineHostVO> RoutingSearch;
|
||||||
|
|
||||||
protected final Attribute _statusAttr;
|
protected final Attribute _statusAttr;
|
||||||
protected final Attribute _resourceStateAttr;
|
protected final Attribute _resourceStateAttr;
|
||||||
@ -112,10 +112,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Inject protected HostDetailsDao _detailsDao;
|
@Inject protected HostDetailsDao _detailsDao;
|
||||||
@Inject protected HostTagsDao _hostTagsDao;
|
@Inject protected HostTagsDao _hostTagsDao;
|
||||||
@Inject protected ClusterDao _clusterDao;
|
@Inject protected EngineClusterDao _clusterDao;
|
||||||
|
|
||||||
|
|
||||||
public HostDaoImpl() {
|
public EngineHostDaoImpl() {
|
||||||
|
|
||||||
MaintenanceCountSearch = createSearchBuilder();
|
MaintenanceCountSearch = createSearchBuilder();
|
||||||
MaintenanceCountSearch.and("cluster", MaintenanceCountSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
MaintenanceCountSearch.and("cluster", MaintenanceCountSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||||
@ -123,7 +123,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
MaintenanceCountSearch.done();
|
MaintenanceCountSearch.done();
|
||||||
|
|
||||||
TypePodDcStatusSearch = createSearchBuilder();
|
TypePodDcStatusSearch = createSearchBuilder();
|
||||||
HostVO entity = TypePodDcStatusSearch.entity();
|
EngineHostVO entity = TypePodDcStatusSearch.entity();
|
||||||
TypePodDcStatusSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
|
TypePodDcStatusSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
|
||||||
TypePodDcStatusSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
|
TypePodDcStatusSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
|
||||||
TypePodDcStatusSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
|
TypePodDcStatusSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
@ -317,33 +317,33 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countBy(long clusterId, ResourceState... states) {
|
public long countBy(long clusterId, ResourceState... states) {
|
||||||
SearchCriteria<HostVO> sc = MaintenanceCountSearch.create();
|
SearchCriteria<EngineHostVO> sc = MaintenanceCountSearch.create();
|
||||||
|
|
||||||
sc.setParameters("resourceState", (Object[]) states);
|
sc.setParameters("resourceState", (Object[]) states);
|
||||||
sc.setParameters("cluster", clusterId);
|
sc.setParameters("cluster", clusterId);
|
||||||
|
|
||||||
List<HostVO> hosts = listBy(sc);
|
List<EngineHostVO> hosts = listBy(sc);
|
||||||
return hosts.size();
|
return hosts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostVO findByGuid(String guid) {
|
public EngineHostVO findByGuid(String guid) {
|
||||||
SearchCriteria<HostVO> sc = GuidSearch.create("guid", guid);
|
SearchCriteria<EngineHostVO> sc = GuidSearch.create("guid", guid);
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
|
public List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
SearchCriteria<HostVO> sc = UnmanagedDirectConnectSearch.create();
|
SearchCriteria<EngineHostVO> sc = UnmanagedDirectConnectSearch.create();
|
||||||
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
||||||
//sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.Disabled);
|
//sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.Disabled);
|
||||||
sc.setJoinParameters("ClusterManagedSearch", "managed", Managed.ManagedState.Managed);
|
sc.setJoinParameters("ClusterManagedSearch", "managed", Managed.ManagedState.Managed);
|
||||||
List<HostVO> hosts = lockRows(sc, new Filter(HostVO.class, "clusterId", true, 0L, limit), true);
|
List<EngineHostVO> hosts = lockRows(sc, new Filter(EngineHostVO.class, "clusterId", true, 0L, limit), true);
|
||||||
|
|
||||||
for (HostVO host : hosts) {
|
for (EngineHostVO host : hosts) {
|
||||||
host.setManagementServerId(managementServerId);
|
host.setManagementServerId(managementServerId);
|
||||||
update(host.getId(), host);
|
update(host.getId(), host);
|
||||||
}
|
}
|
||||||
@ -354,16 +354,16 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public List<HostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId) {
|
public List<EngineHostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
|
||||||
txn.start();
|
txn.start();
|
||||||
SearchCriteria<HostVO> sc = UnmanagedApplianceSearch.create();
|
SearchCriteria<EngineHostVO> sc = UnmanagedApplianceSearch.create();
|
||||||
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
||||||
sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer, Type.PxeServer, Type.TrafficMonitor, Type.L2Networking);
|
sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer, Type.PxeServer, Type.TrafficMonitor, Type.L2Networking);
|
||||||
List<HostVO> hosts = lockRows(sc, null, true);
|
List<EngineHostVO> hosts = lockRows(sc, null, true);
|
||||||
|
|
||||||
for (HostVO host : hosts) {
|
for (EngineHostVO host : hosts) {
|
||||||
host.setManagementServerId(managementServerId);
|
host.setManagementServerId(managementServerId);
|
||||||
update(host.getId(), host);
|
update(host.getId(), host);
|
||||||
}
|
}
|
||||||
@ -375,10 +375,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markHostsAsDisconnected(long msId, long lastPing) {
|
public void markHostsAsDisconnected(long msId, long lastPing) {
|
||||||
SearchCriteria<HostVO> sc = MsStatusSearch.create();
|
SearchCriteria<EngineHostVO> sc = MsStatusSearch.create();
|
||||||
sc.setParameters("ms", msId);
|
sc.setParameters("ms", msId);
|
||||||
|
|
||||||
HostVO host = createForUpdate();
|
EngineHostVO host = createForUpdate();
|
||||||
host.setLastPinged(lastPing);
|
host.setLastPinged(lastPing);
|
||||||
host.setDisconnectedOn(new Date());
|
host.setDisconnectedOn(new Date());
|
||||||
UpdateBuilder ub = getUpdateBuilder(host);
|
UpdateBuilder ub = getUpdateBuilder(host);
|
||||||
@ -398,14 +398,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) {
|
public List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) {
|
||||||
|
|
||||||
SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder();
|
SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder();
|
||||||
HostTagVO tagEntity = hostTagSearch.entity();
|
HostTagVO tagEntity = hostTagSearch.entity();
|
||||||
hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ);
|
hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ);
|
||||||
|
|
||||||
SearchBuilder<HostVO> hostSearch = createSearchBuilder();
|
SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder();
|
||||||
HostVO entity = hostSearch.entity();
|
EngineHostVO entity = hostSearch.entity();
|
||||||
hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
|
hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
|
||||||
hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
|
hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
|
||||||
hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
|
hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
@ -414,7 +414,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ);
|
hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ);
|
||||||
hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER);
|
hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER);
|
||||||
|
|
||||||
SearchCriteria<HostVO> sc = hostSearch.create();
|
SearchCriteria<EngineHostVO> sc = hostSearch.create();
|
||||||
sc.setJoinParameters("hostTagSearch", "tag", hostTag);
|
sc.setJoinParameters("hostTagSearch", "tag", hostTag);
|
||||||
sc.setParameters("type", type.toString());
|
sc.setParameters("type", type.toString());
|
||||||
if (podId != null) {
|
if (podId != null) {
|
||||||
@ -432,7 +432,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag) {
|
public List<EngineHostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag) {
|
||||||
SearchBuilder<HostTagVO> hostTagSearch = null;
|
SearchBuilder<HostTagVO> hostTagSearch = null;
|
||||||
if (haTag != null && !haTag.isEmpty()) {
|
if (haTag != null && !haTag.isEmpty()) {
|
||||||
hostTagSearch = _hostTagsDao.createSearchBuilder();
|
hostTagSearch = _hostTagsDao.createSearchBuilder();
|
||||||
@ -441,7 +441,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
hostTagSearch.cp();
|
hostTagSearch.cp();
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchBuilder<HostVO> hostSearch = createSearchBuilder();
|
SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder();
|
||||||
|
|
||||||
hostSearch.and("type", hostSearch.entity().getType(), SearchCriteria.Op.EQ);
|
hostSearch.and("type", hostSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||||
hostSearch.and("clusterId", hostSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
hostSearch.and("clusterId", hostSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||||
@ -454,7 +454,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
hostSearch.join("hostTagSearch", hostTagSearch, hostSearch.entity().getId(), hostTagSearch.entity().getHostId(), JoinBuilder.JoinType.LEFTOUTER);
|
hostSearch.join("hostTagSearch", hostTagSearch, hostSearch.entity().getId(), hostTagSearch.entity().getHostId(), JoinBuilder.JoinType.LEFTOUTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchCriteria<HostVO> sc = hostSearch.create();
|
SearchCriteria<EngineHostVO> sc = hostSearch.create();
|
||||||
|
|
||||||
if (haTag != null && !haTag.isEmpty()) {
|
if (haTag != null && !haTag.isEmpty()) {
|
||||||
sc.setJoinParameters("hostTagSearch", "tag", haTag);
|
sc.setJoinParameters("hostTagSearch", "tag", haTag);
|
||||||
@ -480,23 +480,23 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadDetails(HostVO host) {
|
public void loadDetails(EngineHostVO host) {
|
||||||
Map<String, String> details = _detailsDao.findDetails(host.getId());
|
Map<String, String> details = _detailsDao.findDetails(host.getId());
|
||||||
host.setDetails(details);
|
host.setDetails(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadHostTags(HostVO host) {
|
public void loadHostTags(EngineHostVO host) {
|
||||||
List<String> hostTags = _hostTagsDao.gethostTags(host.getId());
|
List<String> hostTags = _hostTagsDao.gethostTags(host.getId());
|
||||||
host.setHostTags(hostTags);
|
host.setHostTags(hostTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> findLostHosts(long timeout) {
|
public List<EngineHostVO> findLostHosts(long timeout) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
List<HostVO> result = new ArrayList<HostVO>();
|
List<EngineHostVO> result = new ArrayList<EngineHostVO>();
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
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') ;" ;
|
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') ;" ;
|
||||||
@ -524,7 +524,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDetails(HostVO host) {
|
public void saveDetails(EngineHostVO host) {
|
||||||
Map<String, String> details = host.getDetails();
|
Map<String, String> details = host.getDetails();
|
||||||
if (details == null) {
|
if (details == null) {
|
||||||
return;
|
return;
|
||||||
@ -532,7 +532,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
_detailsDao.persist(host.getId(), details);
|
_detailsDao.persist(host.getId(), details);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void saveHostTags(HostVO host) {
|
protected void saveHostTags(EngineHostVO host) {
|
||||||
List<String> hostTags = host.getHostTags();
|
List<String> hostTags = host.getHostTags();
|
||||||
if (hostTags == null || (hostTags != null && hostTags.isEmpty())) {
|
if (hostTags == null || (hostTags != null && hostTags.isEmpty())) {
|
||||||
return;
|
return;
|
||||||
@ -542,13 +542,13 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public HostVO persist(HostVO host) {
|
public EngineHostVO persist(EngineHostVO host) {
|
||||||
final String InsertSequenceSql = "INSERT INTO op_host(id) VALUES(?)";
|
final String InsertSequenceSql = "INSERT INTO op_host(id) VALUES(?)";
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
HostVO dbHost = super.persist(host);
|
EngineHostVO dbHost = super.persist(host);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertSequenceSql);
|
PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertSequenceSql);
|
||||||
@ -570,7 +570,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public boolean update(Long hostId, HostVO host) {
|
public boolean update(Long hostId, EngineHostVO host) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
@ -646,10 +646,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateState(State currentState, DataCenterResourceEntity.State.Event event, State nextState, DataCenterResourceEntity hostEntity, Object data) {
|
public boolean updateState(State currentState, DataCenterResourceEntity.State.Event event, State nextState, DataCenterResourceEntity hostEntity, Object data) {
|
||||||
HostVO vo = findById(hostEntity.getId());
|
EngineHostVO vo = findById(hostEntity.getId());
|
||||||
Date oldUpdatedTime = vo.getLastUpdated();
|
Date oldUpdatedTime = vo.getLastUpdated();
|
||||||
|
|
||||||
SearchCriteria<HostVO> sc = StateChangeSearch.create();
|
SearchCriteria<EngineHostVO> sc = StateChangeSearch.create();
|
||||||
sc.setParameters("id", hostEntity.getId());
|
sc.setParameters("id", hostEntity.getId());
|
||||||
sc.setParameters("state", currentState);
|
sc.setParameters("state", currentState);
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
int rows = update(vo, sc);
|
int rows = update(vo, sc);
|
||||||
|
|
||||||
if (rows == 0 && s_logger.isDebugEnabled()) {
|
if (rows == 0 && s_logger.isDebugEnabled()) {
|
||||||
HostVO dbHost = findByIdIncludingRemoved(vo.getId());
|
EngineHostVO dbHost = findByIdIncludingRemoved(vo.getId());
|
||||||
if (dbHost != null) {
|
if (dbHost != null) {
|
||||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
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=")
|
str.append(": DB Data={id=").append(dbHost.getId()).append("; state=").append(dbHost.getState()).append(";updatedTime=")
|
||||||
@ -676,13 +676,13 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo) {
|
public boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo) {
|
||||||
HostVO host = (HostVO)vo;
|
EngineHostVO host = (EngineHostVO)vo;
|
||||||
SearchBuilder<HostVO> sb = createSearchBuilder();
|
SearchBuilder<EngineHostVO> sb = createSearchBuilder();
|
||||||
sb.and("resource_state", sb.entity().getResourceState(), SearchCriteria.Op.EQ);
|
sb.and("resource_state", sb.entity().getResourceState(), SearchCriteria.Op.EQ);
|
||||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
sb.done();
|
sb.done();
|
||||||
|
|
||||||
SearchCriteria<HostVO> sc = sb.create();
|
SearchCriteria<EngineHostVO> sc = sb.create();
|
||||||
|
|
||||||
sc.setParameters("resource_state", oldState);
|
sc.setParameters("resource_state", oldState);
|
||||||
sc.setParameters("id", host.getId());
|
sc.setParameters("id", host.getId());
|
||||||
@ -693,7 +693,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
assert result <= 1 : "How can this update " + result + " rows? ";
|
assert result <= 1 : "How can this update " + result + " rows? ";
|
||||||
|
|
||||||
if (state_logger.isDebugEnabled() && result == 0) {
|
if (state_logger.isDebugEnabled() && result == 0) {
|
||||||
HostVO ho = findById(host.getId());
|
EngineHostVO ho = findById(host.getId());
|
||||||
assert ho != null : "How how how? : " + host.getId();
|
assert ho != null : "How how how? : " + host.getId();
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder("Unable to update resource state: [");
|
StringBuilder str = new StringBuilder("Unable to update resource state: [");
|
||||||
@ -717,8 +717,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type) {
|
public EngineHostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type) {
|
||||||
SearchCriteria<HostVO> sc = TypeNameZoneSearch.create();
|
SearchCriteria<EngineHostVO> sc = TypeNameZoneSearch.create();
|
||||||
sc.setParameters("type", type);
|
sc.setParameters("type", type);
|
||||||
sc.setParameters("name", name);
|
sc.setParameters("name", name);
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
@ -726,8 +726,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> findHypervisorHostInCluster(long clusterId) {
|
public List<EngineHostVO> findHypervisorHostInCluster(long clusterId) {
|
||||||
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
|
SearchCriteria<EngineHostVO> sc = TypeClusterStatusSearch.create();
|
||||||
sc.setParameters("type", Host.Type.Routing);
|
sc.setParameters("type", Host.Type.Routing);
|
||||||
sc.setParameters("cluster", clusterId);
|
sc.setParameters("cluster", clusterId);
|
||||||
sc.setParameters("status", Status.Up);
|
sc.setParameters("status", Status.Up);
|
||||||
@ -737,16 +737,16 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> lockRows(
|
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> lockRows(
|
||||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
|
||||||
Filter filter, boolean exclusive) {
|
Filter filter, boolean exclusive) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO lockOneRandomRow(
|
public org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO lockOneRandomRow(
|
||||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
|
||||||
boolean exclusive) {
|
boolean exclusive) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
@ -754,32 +754,32 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> search(
|
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> search(
|
||||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
|
||||||
Filter filter) {
|
Filter filter) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> search(
|
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> search(
|
||||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
|
||||||
Filter filter, boolean enable_query_cache) {
|
Filter filter, boolean enable_query_cache) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> searchIncludingRemoved(
|
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> searchIncludingRemoved(
|
||||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO> sc,
|
||||||
Filter filter, Boolean lock, boolean cache) {
|
Filter filter, Boolean lock, boolean cache) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> searchIncludingRemoved(
|
public List<EngineHostVO> searchIncludingRemoved(
|
||||||
SearchCriteria<HostVO> sc,
|
SearchCriteria<EngineHostVO> sc,
|
||||||
Filter filter, Boolean lock, boolean cache,
|
Filter filter, Boolean lock, boolean cache,
|
||||||
boolean enable_query_cache) {
|
boolean enable_query_cache) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@ -789,19 +789,19 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int remove(
|
public int remove(
|
||||||
SearchCriteria<HostVO> sc) {
|
SearchCriteria<EngineHostVO> sc) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int expunge(SearchCriteria<HostVO> sc) {
|
public int expunge(SearchCriteria<EngineHostVO> sc) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostVO findOneBy(SearchCriteria<HostVO> sc) {
|
public EngineHostVO findOneBy(SearchCriteria<EngineHostVO> sc) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -16,16 +16,16 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.utils.fsm.StateDao;
|
import com.cloud.utils.fsm.StateDao;
|
||||||
|
|
||||||
public interface HostPodDao extends GenericDao<HostPodVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
public interface EngineHostPodDao extends GenericDao<EngineHostPodVO, Long>, StateDao<DataCenterResourceEntity.State, DataCenterResourceEntity.State.Event, DataCenterResourceEntity> {
|
||||||
public List<HostPodVO> listByDataCenterId(long id);
|
public List<EngineHostPodVO> listByDataCenterId(long id);
|
||||||
|
|
||||||
public HostPodVO findByName(String name, long dcId);
|
public EngineHostPodVO findByName(String name, long dcId);
|
||||||
|
|
||||||
public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip);
|
public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip);
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ import javax.ejb.Local;
|
|||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
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;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -40,16 +40,16 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
|
|
||||||
@Component(value="EngineHostPodDao")
|
@Component(value="EngineHostPodDao")
|
||||||
@Local(value={HostPodDao.class})
|
@Local(value={EngineHostPodDao.class})
|
||||||
public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements HostPodDao {
|
public class EngineHostPodDaoImpl extends GenericDaoBase<EngineHostPodVO, Long> implements EngineHostPodDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(HostPodDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(EngineHostPodDaoImpl.class);
|
||||||
|
|
||||||
protected SearchBuilder<HostPodVO> DataCenterAndNameSearch;
|
protected SearchBuilder<EngineHostPodVO> DataCenterAndNameSearch;
|
||||||
protected SearchBuilder<HostPodVO> DataCenterIdSearch;
|
protected SearchBuilder<EngineHostPodVO> DataCenterIdSearch;
|
||||||
protected SearchBuilder<HostPodVO> UUIDSearch;
|
protected SearchBuilder<EngineHostPodVO> UUIDSearch;
|
||||||
protected SearchBuilder<HostPodVO> StateChangeSearch;
|
protected SearchBuilder<EngineHostPodVO> StateChangeSearch;
|
||||||
|
|
||||||
protected HostPodDaoImpl() {
|
protected EngineHostPodDaoImpl() {
|
||||||
DataCenterAndNameSearch = createSearchBuilder();
|
DataCenterAndNameSearch = createSearchBuilder();
|
||||||
DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||||
@ -72,16 +72,16 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostPodVO> listByDataCenterId(long id) {
|
public List<EngineHostPodVO> listByDataCenterId(long id) {
|
||||||
SearchCriteria<HostPodVO> sc = DataCenterIdSearch.create();
|
SearchCriteria<EngineHostPodVO> sc = DataCenterIdSearch.create();
|
||||||
sc.setParameters("dcId", id);
|
sc.setParameters("dcId", id);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostPodVO findByName(String name, long dcId) {
|
public EngineHostPodVO findByName(String name, long dcId) {
|
||||||
SearchCriteria<HostPodVO> sc = DataCenterAndNameSearch.create();
|
SearchCriteria<EngineHostPodVO> sc = DataCenterAndNameSearch.create();
|
||||||
sc.setParameters("dc", dcId);
|
sc.setParameters("dc", dcId);
|
||||||
sc.setParameters("name", name);
|
sc.setParameters("name", name);
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
|||||||
public boolean remove(Long id) {
|
public boolean remove(Long id) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
HostPodVO pod = createForUpdate();
|
EngineHostPodVO pod = createForUpdate();
|
||||||
pod.setName(null);
|
pod.setName(null);
|
||||||
|
|
||||||
update(id, pod);
|
update(id, pod);
|
||||||
@ -133,7 +133,7 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listDisabledPods(long zoneId) {
|
public List<Long> listDisabledPods(long zoneId) {
|
||||||
GenericSearchBuilder<HostPodVO, Long> podIdSearch = createSearchBuilder(Long.class);
|
GenericSearchBuilder<EngineHostPodVO, Long> podIdSearch = createSearchBuilder(Long.class);
|
||||||
podIdSearch.selectField(podIdSearch.entity().getId());
|
podIdSearch.selectField(podIdSearch.entity().getId());
|
||||||
podIdSearch.and("dataCenterId", podIdSearch.entity().getDataCenterId(), Op.EQ);
|
podIdSearch.and("dataCenterId", podIdSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
podIdSearch.and("allocationState", podIdSearch.entity().getAllocationState(), Op.EQ);
|
podIdSearch.and("allocationState", podIdSearch.entity().getAllocationState(), Op.EQ);
|
||||||
@ -150,11 +150,11 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity podEntity, Object data) {
|
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity podEntity, Object data) {
|
||||||
|
|
||||||
HostPodVO vo = findById(podEntity.getId());
|
EngineHostPodVO vo = findById(podEntity.getId());
|
||||||
|
|
||||||
Date oldUpdatedTime = vo.getLastUpdated();
|
Date oldUpdatedTime = vo.getLastUpdated();
|
||||||
|
|
||||||
SearchCriteria<HostPodVO> sc = StateChangeSearch.create();
|
SearchCriteria<EngineHostPodVO> sc = StateChangeSearch.create();
|
||||||
sc.setParameters("id", vo.getId());
|
sc.setParameters("id", vo.getId());
|
||||||
sc.setParameters("state", currentState);
|
sc.setParameters("state", currentState);
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
|||||||
builder.set(vo, "state", nextState);
|
builder.set(vo, "state", nextState);
|
||||||
builder.set(vo, "lastUpdated", new Date());
|
builder.set(vo, "lastUpdated", new Date());
|
||||||
|
|
||||||
int rows = update((HostPodVO) vo, sc);
|
int rows = update((EngineHostPodVO) vo, sc);
|
||||||
|
|
||||||
if (rows == 0 && s_logger.isDebugEnabled()) {
|
if (rows == 0 && s_logger.isDebugEnabled()) {
|
||||||
HostPodVO dbDC = findByIdIncludingRemoved(vo.getId());
|
EngineHostPodVO dbDC = findByIdIncludingRemoved(vo.getId());
|
||||||
if (dbDC != null) {
|
if (dbDC != null) {
|
||||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
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=")
|
str.append(": DB Data={id=").append(dbDC.getId()).append("; state=").append(dbDC.getState()).append(";updatedTime=")
|
||||||
@ -17,10 +17,10 @@
|
|||||||
package org.apache.cloudstack.engine.provisioning.test;
|
package org.apache.cloudstack.engine.provisioning.test;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.ClusterDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DataCenterDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostPodDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
@ -30,22 +30,22 @@ import org.springframework.context.annotation.Bean;
|
|||||||
public class ChildTestConfiguration {
|
public class ChildTestConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataCenterDao dataCenterDao() {
|
public EngineDataCenterDao dataCenterDao() {
|
||||||
return Mockito.mock(DataCenterDao.class);
|
return Mockito.mock(EngineDataCenterDao.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public HostPodDao hostPodDao() {
|
public EngineHostPodDao hostPodDao() {
|
||||||
return Mockito.mock(HostPodDao.class);
|
return Mockito.mock(EngineHostPodDao.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ClusterDao clusterDao() {
|
public EngineClusterDao clusterDao() {
|
||||||
return Mockito.mock(ClusterDao.class);
|
return Mockito.mock(EngineClusterDao.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public HostDao hostDao() {
|
public EngineHostDao hostDao() {
|
||||||
return Mockito.mock(HostDao.class);
|
return Mockito.mock(EngineHostDao.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,10 +31,10 @@ import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEnti
|
|||||||
import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity;
|
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.PodEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.ClusterDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DataCenterDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDao;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostPodDao;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDao;
|
||||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -43,10 +43,10 @@ import org.mockito.Mockito;
|
|||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.ClusterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.DataCenterVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineDataCenterVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostPodVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostPodVO;
|
||||||
import org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO;
|
import org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
|
|
||||||
@ -60,35 +60,35 @@ public class ProvisioningTest extends TestCase {
|
|||||||
ProvisioningService service;
|
ProvisioningService service;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DataCenterDao dcDao;
|
EngineDataCenterDao dcDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
HostPodDao _podDao;
|
EngineHostPodDao _podDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ClusterDao _clusterDao;
|
EngineClusterDao _clusterDao;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
HostDao _hostDao;
|
EngineHostDao _hostDao;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
|
EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
|
||||||
null, null, NetworkType.Basic, null, null, true, true);
|
null, null, NetworkType.Basic, null, null, true, true);
|
||||||
Mockito.when(dcDao.findByUUID(Mockito.anyString())).thenReturn(dc);
|
Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc);
|
||||||
Mockito.when(dcDao.persist((DataCenterVO) Mockito.anyObject())).thenReturn(dc);
|
Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc);
|
||||||
|
|
||||||
HostPodVO pod = new HostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
|
EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
|
||||||
Mockito.when(_podDao.findByUUID(Mockito.anyString())).thenReturn(pod);
|
Mockito.when(_podDao.findByUuid(Mockito.anyString())).thenReturn(pod);
|
||||||
Mockito.when(_podDao.persist((HostPodVO) Mockito.anyObject())).thenReturn(pod);
|
Mockito.when(_podDao.persist((EngineHostPodVO) Mockito.anyObject())).thenReturn(pod);
|
||||||
|
|
||||||
ClusterVO cluster = new ClusterVO();
|
EngineClusterVO cluster = new EngineClusterVO();
|
||||||
Mockito.when(_clusterDao.findByUUID(Mockito.anyString())).thenReturn(cluster);
|
Mockito.when(_clusterDao.findByUuid(Mockito.anyString())).thenReturn(cluster);
|
||||||
Mockito.when(_clusterDao.persist((ClusterVO) Mockito.anyObject())).thenReturn(cluster);
|
Mockito.when(_clusterDao.persist((EngineClusterVO) Mockito.anyObject())).thenReturn(cluster);
|
||||||
|
|
||||||
HostVO host = new HostVO("68765876598");
|
EngineHostVO host = new EngineHostVO("68765876598");
|
||||||
Mockito.when(_hostDao.findByUUID(Mockito.anyString())).thenReturn(host);
|
Mockito.when(_hostDao.findByUuid(Mockito.anyString())).thenReturn(host);
|
||||||
Mockito.when(_hostDao.persist((HostVO) Mockito.anyObject())).thenReturn(host);
|
Mockito.when(_hostDao.persist((EngineHostVO) Mockito.anyObject())).thenReturn(host);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -354,7 +354,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserVmVO vm = new UserVmVO(id, instanceName, cmd.getDisplayName(), template.getId(), HypervisorType.BareMetal,
|
UserVmVO vm = new UserVmVO(id, instanceName, cmd.getDisplayName(), template.getId(), HypervisorType.BareMetal,
|
||||||
template.getGuestOSId(), offering.getOfferHA(), false, domainId, owner.getId(), offering.getId(), userData, hostName);
|
template.getGuestOSId(), offering.getOfferHA(), false, domainId, owner.getId(), offering.getId(), userData, hostName, null);
|
||||||
|
|
||||||
if (sshPublicKey != null) {
|
if (sshPublicKey != null) {
|
||||||
vm.setDetail("SSH.PublicKey", sshPublicKey);
|
vm.setDetail("SSH.PublicKey", sshPublicKey);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class UserVmDaoImplTest extends TestCase {
|
|||||||
|
|
||||||
dao.expunge(1000l);
|
dao.expunge(1000l);
|
||||||
|
|
||||||
UserVmVO vo = new UserVmVO(1000l, "instancename", "displayname", 1, HypervisorType.XenServer, 1, true, true, 1, 1, 1, "userdata", "name");
|
UserVmVO vo = new UserVmVO(1000l, "instancename", "displayname", 1, HypervisorType.XenServer, 1, true, true, 1, 1, 1, "userdata", "name", null);
|
||||||
dao.persist(vo);
|
dao.persist(vo);
|
||||||
|
|
||||||
vo = dao.findById(1000l);
|
vo = dao.findById(1000l);
|
||||||
|
|||||||
@ -23,6 +23,27 @@ alter table template_spool_ref add state varchar(255);
|
|||||||
alter table template_spool_ref add update_count bigint unsigned;
|
alter table template_spool_ref add update_count bigint unsigned;
|
||||||
alter table volumes add disk_type varchar(255);
|
alter table volumes add disk_type varchar(255);
|
||||||
alter table volumes drop foreign key `fk_volumes__account_id`;
|
alter table volumes drop foreign key `fk_volumes__account_id`;
|
||||||
|
alter table vm_instance add column disk_offering_id bigint unsigned;
|
||||||
|
alter table data_center add column owner varchar(255);
|
||||||
|
alter table data_center add column created datetime COMMENT 'date created';
|
||||||
|
alter table data_center add column lastUpdated datetime COMMENT 'last updated';
|
||||||
|
alter table data_center add column engine_state varchar(32) NOT NULL COMMENT 'the engine state of the zone';
|
||||||
|
alter table host_pod_ref add column owner varchar(255);
|
||||||
|
alter table host_pod_ref add column created datetime COMMENT 'date created';
|
||||||
|
alter table host_pod_ref add column lastUpdated datetime COMMENT 'last updated';
|
||||||
|
alter table host_pod_ref add column engine_state varchar(32) NOT NULL COMMENT 'the engine state of the zone';
|
||||||
|
alter table host add column owner varchar(255);
|
||||||
|
alter table host add column lastUpdated datetime COMMENT 'last updated';
|
||||||
|
alter table host add column engine_state varchar(32) NOT NULL COMMENT 'the engine state of the zone';
|
||||||
|
|
||||||
|
|
||||||
|
alter table cluster add column owner varchar(255);
|
||||||
|
alter table cluster add column created datetime COMMENT 'date created';
|
||||||
|
alter table cluster add column lastUpdated datetime COMMENT 'last updated';
|
||||||
|
alter table cluster add column engine_state varchar(32) NOT NULL COMMENT 'the engine state of the zone';
|
||||||
|
|
||||||
|
alter table data_center add column removed datetime COMMENT 'date removed';
|
||||||
|
|
||||||
CREATE TABLE `cloud`.`data_store_provider` (
|
CREATE TABLE `cloud`.`data_store_provider` (
|
||||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
|
`name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user