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.Remove, Status.Removed);
|
||||
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.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Down, Event.Remove, Status.Removed);
|
||||
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.AgentConnected, Status.Connecting);
|
||||
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
|
||||
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);
|
||||
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.RebalanceCompleted, Status.Connecting);
|
||||
}
|
||||
|
||||
@ -1193,75 +1193,85 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected boolean loadDirectlyConnectedHost(HostVO host, boolean forRebalance) {
|
||||
String resourceName = host.getResource();
|
||||
boolean initialized = false;
|
||||
ServerResource resource = null;
|
||||
try {
|
||||
Class<?> clazz = Class.forName(resourceName);
|
||||
Constructor constructor = clazz.getConstructor();
|
||||
resource = (ServerResource) constructor.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.warn("Unable to find class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (InstantiationException e) {
|
||||
s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalAccessException e) {
|
||||
s_logger.warn("Illegal access " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (SecurityException e) {
|
||||
s_logger.warn("Security error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (NoSuchMethodException e) {
|
||||
s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
|
||||
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);
|
||||
params.putAll(host.getDetails());
|
||||
|
||||
params.put("guid", host.getGuid());
|
||||
params.put("zone", Long.toString(host.getDataCenterId()));
|
||||
if (host.getPodId() != null) {
|
||||
params.put("pod", Long.toString(host.getPodId()));
|
||||
}
|
||||
if (host.getClusterId() != null) {
|
||||
params.put("cluster", Long.toString(host.getClusterId()));
|
||||
String guid = null;
|
||||
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
||||
if (cluster.getGuid() == null) {
|
||||
guid = host.getDetail("pool");
|
||||
} else {
|
||||
guid = cluster.getGuid();
|
||||
}
|
||||
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"));
|
||||
|
||||
try {
|
||||
resource.configure(host.getName(), params);
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
s_logger.warn("Unable to configure resource due to ", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!resource.start()) {
|
||||
s_logger.warn("Unable to start the resource");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
String resourceName = host.getResource();
|
||||
try {
|
||||
Class<?> clazz = Class.forName(resourceName);
|
||||
Constructor constructor = clazz.getConstructor();
|
||||
resource = (ServerResource) constructor.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.warn("Unable to find class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (InstantiationException e) {
|
||||
s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalAccessException e) {
|
||||
s_logger.warn("Illegal access " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (SecurityException e) {
|
||||
s_logger.warn("Security error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (NoSuchMethodException e) {
|
||||
s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
|
||||
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);
|
||||
params.putAll(host.getDetails());
|
||||
|
||||
params.put("guid", host.getGuid());
|
||||
params.put("zone", Long.toString(host.getDataCenterId()));
|
||||
if (host.getPodId() != null) {
|
||||
params.put("pod", Long.toString(host.getPodId()));
|
||||
}
|
||||
if (host.getClusterId() != null) {
|
||||
params.put("cluster", Long.toString(host.getClusterId()));
|
||||
String guid = null;
|
||||
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
|
||||
if (cluster.getGuid() == null) {
|
||||
guid = host.getDetail("pool");
|
||||
} else {
|
||||
guid = cluster.getGuid();
|
||||
}
|
||||
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"));
|
||||
|
||||
try {
|
||||
resource.configure(host.getName(), params);
|
||||
} catch (ConfigurationException e) {
|
||||
s_logger.warn("Unable to configure resource due to ", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!resource.start()) {
|
||||
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) {
|
||||
AgentAttache attache = simulateStart(host.getId(), resource, host.getDetails(), false, null, null, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user