Search in sources :

Example 1 with ResourceState

use of com.cloud.resource.ResourceState in project cosmic by MissionCriticalCloud.

the class CheckOnHostCommandTest method testGetResourceState.

@Test
public void testGetResourceState() {
    final ResourceState r = host.getResourceState();
    assertTrue(r == ResourceState.Enabled);
}
Also used : ResourceState(com.cloud.resource.ResourceState) Test(org.junit.Test)

Example 2 with ResourceState

use of com.cloud.resource.ResourceState in project cosmic by MissionCriticalCloud.

the class AgentManagerImpl method agentStatusTransitTo.

@Override
public boolean agentStatusTransitTo(final HostVO host, final Status.Event e, final long msId) {
    try {
        _agentStatusLock.lock();
        if (status_logger.isDebugEnabled()) {
            final ResourceState state = host.getResourceState();
            final StringBuilder msg = new StringBuilder("Transition:");
            msg.append("[Resource state = ").append(state);
            msg.append(", Agent event = ").append(e.toString());
            msg.append(", Host id = ").append(host.getId()).append(", name = " + host.getName()).append("]");
            status_logger.debug(msg.toString());
        }
        host.setManagementServerId(msId);
        try {
            return _statusStateMachine.transitTo(host, e, host.getId(), _hostDao);
        } catch (final NoTransitionException e1) {
            status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + ", mangement server id is " + msId);
            throw new CloudRuntimeException("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId + "," + e1.getMessage());
        }
    } finally {
        _agentStatusLock.unlock();
    }
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) ResourceState(com.cloud.resource.ResourceState)

Example 3 with ResourceState

use of com.cloud.resource.ResourceState in project cloudstack by apache.

the class AgentManagerImpl method agentStatusTransitTo.

@Override
public boolean agentStatusTransitTo(final HostVO host, final Status.Event e, final long msId) {
    try {
        _agentStatusLock.lock();
        if (s_logger.isDebugEnabled()) {
            final ResourceState state = host.getResourceState();
            final StringBuilder msg = new StringBuilder("Transition:");
            msg.append("[Resource state = ").append(state);
            msg.append(", Agent event = ").append(e.toString());
            msg.append(", Host id = ").append(host.getId()).append(", name = " + host.getName()).append("]");
            s_logger.debug(msg);
        }
        host.setManagementServerId(msId);
        try {
            return _statusStateMachine.transitTo(host, e, host.getId(), _hostDao);
        } catch (final NoTransitionException e1) {
            s_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + ", mangement server id is " + msId);
            throw new CloudRuntimeException("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId + "," + e1.getMessage());
        }
    } finally {
        _agentStatusLock.unlock();
    }
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) ResourceState(com.cloud.resource.ResourceState)

Example 4 with ResourceState

use of com.cloud.resource.ResourceState in project cloudstack by apache.

the class CheckOnHostCommandTest method testGetResourceState.

@Test
public void testGetResourceState() {
    ResourceState r = host.getResourceState();
    assertTrue(r == ResourceState.Enabled);
}
Also used : ResourceState(com.cloud.resource.ResourceState) Test(org.junit.Test)

Aggregations

ResourceState (com.cloud.resource.ResourceState)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)2 Test (org.junit.Test)2