Search in sources :

Example 6 with HostSystemConnectionState

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());
    }
}
Also used : Task(com.vmware.vim25.mo.Task) HostSystemConnectionState(com.vmware.vim25.HostSystemConnectionState) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException)

Example 7 with HostSystemConnectionState

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());
    }
}
Also used : HostSystemConnectionState(com.vmware.vim25.HostSystemConnectionState)

Example 8 with HostSystemConnectionState

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;
}
Also used : HostRuntimeInfo(com.vmware.vim25.HostRuntimeInfo) HostSystemConnectionState(com.vmware.vim25.HostSystemConnectionState)

Aggregations

HostSystemConnectionState (com.vmware.vim25.HostSystemConnectionState)8 HostRuntimeInfo (com.vmware.vim25.HostRuntimeInfo)3 HostSystem (com.vmware.vim25.mo.HostSystem)2 ExecutionException (com.emc.sa.engine.ExecutionException)1 GetBlockResource (com.emc.sa.service.vipr.block.tasks.GetBlockResource)1 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)1 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)1 GetHost (com.emc.sa.service.vipr.tasks.GetHost)1 VMwareSupport (com.emc.sa.service.vmware.VMwareSupport)1 GetVcenter (com.emc.sa.service.vmware.tasks.GetVcenter)1 GetVcenterDataCenter (com.emc.sa.service.vmware.tasks.GetVcenterDataCenter)1 Host (com.emc.storageos.db.client.model.Host)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 Vcenter (com.emc.storageos.db.client.model.Vcenter)1 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)1 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)1 HostRestRep (com.emc.storageos.model.host.HostRestRep)1 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)1 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)1 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)1