use of com.vmware.vim25.HostSystemConnectionState in project coprhd-controller by CoprHD.
the class VcenterApiClient method reconnectHost.
private void reconnectHost(HostSystem hostSystem) throws VcenterSystemException {
try {
String hostname = hostSystem.getName();
HostSystemConnectionState hostSystemConnectionState = hostSystem.getRuntime().getConnectionState();
if (hostSystemConnectionState == HostSystemConnectionState.disconnected || hostSystemConnectionState == HostSystemConnectionState.notResponding) {
Integer operationTimeout = Integer.parseInt(propertyInfo.getProperty("vcenter_operation_timeout"));
_log.info("Host " + hostname + " is in a " + hostSystemConnectionState + "state - Attempt to reconnect");
// might need to provide conn info, no arg should use
Task reconnectHostTask = hostSystem.reconnectHost_Task(null);
// 'defaults' guessing means what it was registered originally
// with
// wait
VcenterTaskMonitor.TaskStatus taskStatus = (new VcenterTaskMonitor(operationTimeout)).monitor(reconnectHostTask);
// configured
// timeout
_log.info("After running reconnect task for host " + hostname + " the task result is " + taskStatus + " and host is in connection state " + hostSystem.getRuntime().getConnectionState());
}
} catch (Exception e) {
_log.error("reconnectHost exception " + e);
throw new VcenterSystemException(e.getLocalizedMessage());
}
}
use of com.vmware.vim25.HostSystemConnectionState in project coprhd-controller by CoprHD.
the class FindCluster method checkConnectionState.
private void checkConnectionState(HostSystem host) {
// Check the connection state of this host
HostSystemConnectionState connectionState = VMwareUtils.getConnectionState(host);
logInfo("find.cluster.host.state", host.getName(), connectionState);
if (connectionState == null) {
throw stateException("FindCluster.illegalState.noHostState", host.getName(), datacenterName);
} else if (connectionState == HostSystemConnectionState.notResponding) {
throw stateException("FindCluster.illegalState.notResponding", host.getName());
} else if (connectionState == HostSystemConnectionState.disconnected) {
throw stateException("FindCluster.illegalState.notConnected", host.getName());
}
}
use of com.vmware.vim25.HostSystemConnectionState in project coprhd-controller by CoprHD.
the class VMwareSupport method isHostConnected.
/**
* Returns true if the host is in a connected state
*
* @param host the host to check
* @return true if host is connected, otherwise returns false
*/
public static boolean isHostConnected(HostSystem host) {
HostRuntimeInfo runtime = (host != null) ? host.getRuntime() : null;
HostSystemConnectionState connectionState = (runtime != null) ? runtime.getConnectionState() : null;
return connectionState == HostSystemConnectionState.connected;
}
Aggregations