mirror of https://github.com/apache/cloudstack.git
Propagate fixes from 2.2.4
This commit is contained in:
parent
2d52813ff2
commit
0ee7e7678a
|
|
@ -153,7 +153,8 @@ public class HostVO implements Host {
|
|||
this.storageIpAddressDeux = deuxStorageIpAddress;
|
||||
}
|
||||
|
||||
public String getStorageNetmaskDeux() {
|
||||
@Override
|
||||
public String getStorageNetmaskDeux() {
|
||||
return storageNetmaskDeux;
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +171,8 @@ public class HostVO implements Host {
|
|||
this.storageNetmaskDeux = deuxStorageNetmask;
|
||||
}
|
||||
|
||||
public String getStorageMacAddressDeux() {
|
||||
@Override
|
||||
public String getStorageMacAddressDeux() {
|
||||
return storageMacAddressDeux;
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +180,8 @@ public class HostVO implements Host {
|
|||
this.storageMacAddressDeux = duexStorageMacAddress;
|
||||
}
|
||||
|
||||
public String getPrivateMacAddress() {
|
||||
@Override
|
||||
public String getPrivateMacAddress() {
|
||||
return privateMacAddress;
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +197,7 @@ public class HostVO implements Host {
|
|||
this.available = available;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrivateNetmask() {
|
||||
return privateNetmask;
|
||||
}
|
||||
|
|
@ -202,6 +206,7 @@ public class HostVO implements Host {
|
|||
this.privateNetmask = privateNetmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicNetmask() {
|
||||
return publicNetmask;
|
||||
}
|
||||
|
|
@ -210,6 +215,7 @@ public class HostVO implements Host {
|
|||
this.publicNetmask = publicNetmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicIpAddress() {
|
||||
return publicIpAddress;
|
||||
}
|
||||
|
|
@ -218,6 +224,7 @@ public class HostVO implements Host {
|
|||
this.publicIpAddress = publicIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicMacAddress() {
|
||||
return publicMacAddress;
|
||||
}
|
||||
|
|
@ -235,6 +242,7 @@ public class HostVO implements Host {
|
|||
this.storageIpAddress = storageIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageNetmask() {
|
||||
return storageNetmask;
|
||||
}
|
||||
|
|
@ -243,6 +251,7 @@ public class HostVO implements Host {
|
|||
this.storageNetmask = storageNetmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageMacAddress() {
|
||||
return storageMacAddress;
|
||||
}
|
||||
|
|
@ -648,7 +657,7 @@ public class HostVO implements Host {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder(type.toString()).append("-").append(id).append("-").append(name).toString();
|
||||
return new StringBuilder("Host[").append("-").append(id).append("-").append(type).append("]").toString();
|
||||
}
|
||||
|
||||
public void setHypervisorType(HypervisorType hypervisorType) {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ import javax.naming.ConfigurationException;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.StartupCommandProcessor;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.StartupCommandProcessor;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
import com.cloud.agent.api.AgentControlCommand;
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -481,7 +481,11 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
|
||||
public AgentAttache findAttache(long hostId) {
|
||||
return _agents.get(hostId);
|
||||
AgentAttache attache = null;
|
||||
synchronized (_agents) {
|
||||
attache = _agents.get(hostId);
|
||||
}
|
||||
return attache;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -587,8 +591,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
String username = cmd.getUsername();
|
||||
String password = cmd.getPassword();
|
||||
|
||||
if(url != null)
|
||||
url = URLDecoder.decode(url);
|
||||
if(url != null) {
|
||||
url = URLDecoder.decode(url);
|
||||
}
|
||||
|
||||
URI uri = null;
|
||||
|
||||
|
|
@ -716,7 +721,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
break;
|
||||
}
|
||||
|
||||
AgentAttache attache = simulateStart(resource, entry.getValue(), true, null, null);
|
||||
AgentAttache attache = simulateStart(null, resource, entry.getValue(), true, null, null);
|
||||
if (attache != null) {
|
||||
hosts.add(_hostDao.findById(attache.getId()));
|
||||
}
|
||||
|
|
@ -950,7 +955,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
return null;
|
||||
}
|
||||
AgentAttache attache = simulateStart(resource, entry.getValue(), true, hostTags, allocationState);
|
||||
AgentAttache attache = simulateStart(null, resource, entry.getValue(), true, hostTags, allocationState);
|
||||
if (attache != null) {
|
||||
hosts.add(_hostDao.findById(attache.getId()));
|
||||
}
|
||||
|
|
@ -1694,11 +1699,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Deregistering link for " + hostId + " with state " + nextState);
|
||||
}
|
||||
|
||||
_hostDao.disconnect(host, event, _nodeId);
|
||||
|
||||
removeAgent(attache, nextState);
|
||||
|
||||
_hostDao.disconnect(host, event, _nodeId);
|
||||
|
||||
host = _hostDao.findById(host.getId());
|
||||
if (host.getStatus() == Status.Alert || host.getStatus() == Status.Down) {
|
||||
_haMgr.scheduleRestartForVmsOnHost(host, investigate);
|
||||
|
|
@ -1873,11 +1876,19 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
_executor.execute(new SimulateStartTask(host.getId(), resource, host.getDetails(), null));
|
||||
}
|
||||
|
||||
protected AgentAttache simulateStart(ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags, String allocationState) throws IllegalArgumentException {
|
||||
protected AgentAttache simulateStart(Long id, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags, String allocationState) throws IllegalArgumentException {
|
||||
StartupCommand[] cmds = resource.initialize();
|
||||
if (cmds == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
HostVO host = _hostDao.findById(id);
|
||||
if (!_hostDao.directConnect(host, _nodeId)) {
|
||||
s_logger.info("Someone else is loading " + host);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
AgentAttache attache = null;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -2386,7 +2397,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
}
|
||||
|
||||
AgentAttache attache = simulateStart(resource, hostDetails, true, null, null);
|
||||
AgentAttache attache = simulateStart(null, resource, hostDetails, true, null, null);
|
||||
return _hostDao.findById(attache.getId());
|
||||
}
|
||||
|
||||
|
|
@ -2559,8 +2570,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
link.attach(attache);
|
||||
AgentAttache old = null;
|
||||
synchronized (_agents) {
|
||||
old = _agents.get(id);
|
||||
_agents.put(id, attache);
|
||||
old = _agents.put(id, attache);
|
||||
}
|
||||
if (old != null) {
|
||||
old.disconnect(Status.Removed);
|
||||
|
|
@ -2577,8 +2587,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
|| server.getStatus() == Status.PrepareForMaintenance, this);
|
||||
AgentAttache old = null;
|
||||
synchronized (_agents) {
|
||||
old = _agents.get(id);
|
||||
_agents.put(id, attache);
|
||||
old = _agents.put(id, attache);
|
||||
}
|
||||
if (old != null) {
|
||||
old.disconnect(Status.Removed);
|
||||
|
|
@ -2959,23 +2968,17 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
AgentAttache at = null;
|
||||
try {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Simulating start for resource " + resource.getName() + " id " + id);
|
||||
}
|
||||
simulateStart(resource, details, false, null, null);
|
||||
simulateStart(id, resource, details, false, null, null);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to simulate start on resource " + id + " name " + resource.getName(), e);
|
||||
} finally {
|
||||
if (actionDelegate != null) {
|
||||
actionDelegate.action(new Long(id));
|
||||
}
|
||||
if (at == null) {
|
||||
HostVO host = _hostDao.findById(id);
|
||||
host.setManagementServerId(null);
|
||||
_hostDao.update(id, host);
|
||||
}
|
||||
StackMaid.current().exitCleanup();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,16 +125,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hosts != null && hosts.size() > 0) {
|
||||
for (HostVO host : hosts) {
|
||||
AgentAttache agentattache = findAttache(host.getId());
|
||||
if (agentattache != null) {
|
||||
// already loaded, skip
|
||||
if (agentattache.forForward()) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Host " + host.getName() + " is detected down, but we have a forward attache running, disconnect this one before launching the host");
|
||||
}
|
||||
}
|
||||
if(hosts != null && hosts.size() > 0) {
|
||||
for(HostVO host: hosts) {
|
||||
AgentAttache agentattache = findAttache(host.getId());
|
||||
if(agentattache != null) {
|
||||
// already loaded, skip
|
||||
if(agentattache.forForward()) {
|
||||
if(s_logger.isInfoEnabled()) {
|
||||
s_logger.info(host + " is detected down, but we have a forward attache running, disconnect this one before launching the host");
|
||||
}
|
||||
removeAgent(agentattache, Status.Disconnected);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -166,4 +166,6 @@ public interface HostDao extends GenericDao<HostVO, Long> {
|
|||
long countRoutingHostsByDataCenter(long dcId);
|
||||
|
||||
List<HostVO> listSecondaryStorageHosts(long dataCenterId);
|
||||
|
||||
boolean directConnect(HostVO host, long msId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
protected final SearchBuilder<HostVO> ConsoleProxyHostSearch;
|
||||
protected final SearchBuilder<HostVO> AvailHypevisorInZone;
|
||||
|
||||
protected final SearchBuilder<HostVO> DirectConnectSearch;
|
||||
|
||||
protected final GenericSearchBuilder<HostVO, Long> HostsInStatusSearch;
|
||||
protected final GenericSearchBuilder<HostVO, Long> CountRoutingByDc;
|
||||
|
||||
|
|
@ -204,7 +206,6 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
UnmanagedDirectConnectSearch.and("resource", UnmanagedDirectConnectSearch.entity().getResource(), SearchCriteria.Op.NNULL);
|
||||
UnmanagedDirectConnectSearch.and("server", UnmanagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
||||
UnmanagedDirectConnectSearch.and("lastPinged", UnmanagedDirectConnectSearch.entity().getLastPinged(), SearchCriteria.Op.LTEQ);
|
||||
|
||||
/*
|
||||
UnmanagedDirectConnectSearch.op(SearchCriteria.Op.OR, "managementServerId", UnmanagedDirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
|
||||
UnmanagedDirectConnectSearch.and("lastPinged", UnmanagedDirectConnectSearch.entity().getLastPinged(), SearchCriteria.Op.LTEQ);
|
||||
|
|
@ -213,6 +214,12 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
*/
|
||||
UnmanagedDirectConnectSearch.done();
|
||||
|
||||
DirectConnectSearch = createSearchBuilder();
|
||||
DirectConnectSearch.and("server", DirectConnectSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
||||
DirectConnectSearch.and("resource", DirectConnectSearch.entity().getResource(), SearchCriteria.Op.NNULL);
|
||||
DirectConnectSearch.and("id", DirectConnectSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
DirectConnectSearch.done();
|
||||
|
||||
UnmanagedExternalNetworkApplianceSearch = createSearchBuilder();
|
||||
UnmanagedExternalNetworkApplianceSearch.and("resource", UnmanagedExternalNetworkApplianceSearch.entity().getResource(), SearchCriteria.Op.NNULL);
|
||||
UnmanagedExternalNetworkApplianceSearch.and("server", UnmanagedExternalNetworkApplianceSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
||||
|
|
@ -433,7 +440,20 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
public void loadHostTags(HostVO host){
|
||||
List<String> hostTags = _hostTagsDao.gethostTags(host.getId());
|
||||
host.setHostTags(hostTags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean directConnect(HostVO host, long msId) {
|
||||
SearchCriteria<HostVO> sc = DirectConnectSearch.create();
|
||||
sc.setParameters("id", host.getId());
|
||||
|
||||
host.setManagementServerId(msId);
|
||||
host.setLastPinged(System.currentTimeMillis() >> 10);
|
||||
UpdateBuilder ub = getUpdateBuilder(host);
|
||||
ub.set(host, _statusAttr, Status.Connecting);
|
||||
|
||||
return update(host, sc) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStatus(HostVO host, Event event, long msId) {
|
||||
|
|
@ -539,8 +559,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
public List<HostVO> findLostHosts(long timeout) {
|
||||
SearchCriteria<HostVO> sc = LastPingedSearch.create();
|
||||
sc.setParameters("ping", timeout);
|
||||
sc.setParameters("state", Status.Up.toString(), Status.Updating.toString(),
|
||||
Status.Disconnected.toString(), Status.Down.toString());
|
||||
sc.setParameters("state", Status.Up, Status.Updating, Status.Disconnected, Status.Down, Status.Connecting);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue