mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11304: restore host status after initialization failure
This commit is contained in:
parent
c683fda236
commit
4d3d47f01c
@ -180,15 +180,18 @@ public enum Status {
|
|||||||
s_fsm.addTransition(Status.Disconnected, Event.WaitedTooLong, Status.Alert);
|
s_fsm.addTransition(Status.Disconnected, Event.WaitedTooLong, Status.Alert);
|
||||||
s_fsm.addTransition(Status.Disconnected, Event.Remove, Status.Removed);
|
s_fsm.addTransition(Status.Disconnected, Event.Remove, Status.Removed);
|
||||||
s_fsm.addTransition(Status.Disconnected, Event.HypervisorVersionChanged, Status.Disconnected);
|
s_fsm.addTransition(Status.Disconnected, Event.HypervisorVersionChanged, Status.Disconnected);
|
||||||
|
s_fsm.addTransition(Status.Disconnected, Event.AgentDisconnected, Status.Disconnected);
|
||||||
s_fsm.addTransition(Status.Down, Event.MaintenanceRequested, Status.PrepareForMaintenance);
|
s_fsm.addTransition(Status.Down, Event.MaintenanceRequested, Status.PrepareForMaintenance);
|
||||||
s_fsm.addTransition(Status.Down, Event.AgentConnected, Status.Connecting);
|
s_fsm.addTransition(Status.Down, Event.AgentConnected, Status.Connecting);
|
||||||
s_fsm.addTransition(Status.Down, Event.Remove, Status.Removed);
|
s_fsm.addTransition(Status.Down, Event.Remove, Status.Removed);
|
||||||
s_fsm.addTransition(Status.Down, Event.ManagementServerDown, Status.Down);
|
s_fsm.addTransition(Status.Down, Event.ManagementServerDown, Status.Down);
|
||||||
|
s_fsm.addTransition(Status.Down, Event.AgentDisconnected, Status.Down);
|
||||||
s_fsm.addTransition(Status.Alert, Event.MaintenanceRequested, Status.PrepareForMaintenance);
|
s_fsm.addTransition(Status.Alert, Event.MaintenanceRequested, Status.PrepareForMaintenance);
|
||||||
s_fsm.addTransition(Status.Alert, Event.AgentConnected, Status.Connecting);
|
s_fsm.addTransition(Status.Alert, Event.AgentConnected, Status.Connecting);
|
||||||
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
||||||
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
||||||
s_fsm.addTransition(Status.Alert, Event.ManagementServerDown, Status.Alert);
|
s_fsm.addTransition(Status.Alert, Event.ManagementServerDown, Status.Alert);
|
||||||
|
s_fsm.addTransition(Status.Alert, Event.AgentDisconnected, Status.Alert);
|
||||||
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceFailed, Status.Disconnected);
|
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceFailed, Status.Disconnected);
|
||||||
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceCompleted, Status.Connecting);
|
s_fsm.addTransition(Status.Rebalancing, Event.RebalanceCompleted, Status.Connecting);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1193,75 +1193,85 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected boolean loadDirectlyConnectedHost(HostVO host, boolean forRebalance) {
|
protected boolean loadDirectlyConnectedHost(HostVO host, boolean forRebalance) {
|
||||||
String resourceName = host.getResource();
|
boolean initialized = false;
|
||||||
ServerResource resource = null;
|
ServerResource resource = null;
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName(resourceName);
|
String resourceName = host.getResource();
|
||||||
Constructor constructor = clazz.getConstructor();
|
try {
|
||||||
resource = (ServerResource) constructor.newInstance();
|
Class<?> clazz = Class.forName(resourceName);
|
||||||
} catch (ClassNotFoundException e) {
|
Constructor constructor = clazz.getConstructor();
|
||||||
s_logger.warn("Unable to find class " + host.getResource(), e);
|
resource = (ServerResource) constructor.newInstance();
|
||||||
return false;
|
} catch (ClassNotFoundException e) {
|
||||||
} catch (InstantiationException e) {
|
s_logger.warn("Unable to find class " + host.getResource(), e);
|
||||||
s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
|
return false;
|
||||||
return false;
|
} catch (InstantiationException e) {
|
||||||
} catch (IllegalAccessException e) {
|
s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
|
||||||
s_logger.warn("Illegal access " + host.getResource(), e);
|
return false;
|
||||||
return false;
|
} catch (IllegalAccessException e) {
|
||||||
} catch (SecurityException e) {
|
s_logger.warn("Illegal access " + host.getResource(), e);
|
||||||
s_logger.warn("Security error on " + host.getResource(), e);
|
return false;
|
||||||
return false;
|
} catch (SecurityException e) {
|
||||||
} catch (NoSuchMethodException e) {
|
s_logger.warn("Security error on " + host.getResource(), e);
|
||||||
s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
|
return false;
|
||||||
return false;
|
} catch (NoSuchMethodException e) {
|
||||||
} catch (IllegalArgumentException e) {
|
s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
|
||||||
s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
|
return false;
|
||||||
return false;
|
} catch (IllegalArgumentException e) {
|
||||||
} catch (InvocationTargetException e) {
|
s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
|
||||||
s_logger.warn("InvocationTargetException error on " + host.getResource(), e);
|
return false;
|
||||||
return false;
|
} catch (InvocationTargetException e) {
|
||||||
}
|
s_logger.warn("InvocationTargetException error on " + host.getResource(), e);
|
||||||
|
return false;
|
||||||
_hostDao.loadDetails(host);
|
}
|
||||||
|
|
||||||
HashMap<String, Object> params = new HashMap<String, Object>(host.getDetails().size() + 5);
|
_hostDao.loadDetails(host);
|
||||||
params.putAll(host.getDetails());
|
|
||||||
|
HashMap<String, Object> params = new HashMap<String, Object>(host.getDetails().size() + 5);
|
||||||
params.put("guid", host.getGuid());
|
params.putAll(host.getDetails());
|
||||||
params.put("zone", Long.toString(host.getDataCenterId()));
|
|
||||||
if (host.getPodId() != null) {
|
params.put("guid", host.getGuid());
|
||||||
params.put("pod", Long.toString(host.getPodId()));
|
params.put("zone", Long.toString(host.getDataCenterId()));
|
||||||
}
|
if (host.getPodId() != null) {
|
||||||
if (host.getClusterId() != null) {
|
params.put("pod", Long.toString(host.getPodId()));
|
||||||
params.put("cluster", Long.toString(host.getClusterId()));
|
}
|
||||||
String guid = null;
|
if (host.getClusterId() != null) {
|
||||||
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
params.put("cluster", Long.toString(host.getClusterId()));
|
||||||
if (cluster.getGuid() == null) {
|
String guid = null;
|
||||||
guid = host.getDetail("pool");
|
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
||||||
} else {
|
if (cluster.getGuid() == null) {
|
||||||
guid = cluster.getGuid();
|
guid = host.getDetail("pool");
|
||||||
}
|
} else {
|
||||||
if (guid != null && !guid.isEmpty()) {
|
guid = cluster.getGuid();
|
||||||
params.put("pool", guid);
|
}
|
||||||
}
|
if (guid != null && !guid.isEmpty()) {
|
||||||
}
|
params.put("pool", guid);
|
||||||
|
}
|
||||||
params.put("ipaddress", host.getPrivateIpAddress());
|
}
|
||||||
params.put("secondary.storage.vm", "false");
|
|
||||||
params.put("max.template.iso.size", _configDao.getValue("max.template.iso.size"));
|
params.put("ipaddress", host.getPrivateIpAddress());
|
||||||
|
params.put("secondary.storage.vm", "false");
|
||||||
try {
|
params.put("max.template.iso.size", _configDao.getValue("max.template.iso.size"));
|
||||||
resource.configure(host.getName(), params);
|
|
||||||
} catch (ConfigurationException e) {
|
try {
|
||||||
e.printStackTrace();
|
resource.configure(host.getName(), params);
|
||||||
s_logger.warn("Unable to configure resource due to ", e);
|
} catch (ConfigurationException e) {
|
||||||
return false;
|
s_logger.warn("Unable to configure resource due to ", e);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if (!resource.start()) {
|
|
||||||
s_logger.warn("Unable to start the resource");
|
if (!resource.start()) {
|
||||||
return false;
|
s_logger.warn("Unable to start the resource");
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
} finally {
|
||||||
|
if(!initialized) {
|
||||||
|
if (host != null) {
|
||||||
|
_hostDao.updateStatus(host, Event.AgentDisconnected, _nodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (forRebalance) {
|
if (forRebalance) {
|
||||||
AgentAttache attache = simulateStart(host.getId(), resource, host.getDetails(), false, null, null, true);
|
AgentAttache attache = simulateStart(host.getId(), resource, host.getDetails(), false, null, null, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user