Search in sources :

Example 46 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class ElasticLoadBalancerManagerImplTest method testFinalizeStartWhenCmdsAnswerIsNotNullButAnswerResultIsFalse.

@Test
public void testFinalizeStartWhenCmdsAnswerIsNotNullButAnswerResultIsFalse() throws Exception {
    CheckSshAnswer answerMock = mock(CheckSshAnswer.class);
    when(answerMock.getResult()).thenReturn(false);
    VirtualMachineProfile profileMock = mock(VirtualMachineProfile.class);
    long hostId = 1L;
    Commands cmds = mock(Commands.class);
    when(cmds.getAnswer("checkSsh")).thenReturn(answerMock);
    ReservationContext context = mock(ReservationContext.class);
    boolean expected = false;
    boolean actual = elasticLoadBalancerManagerImpl.finalizeStart(profileMock, hostId, cmds, context);
    assertEquals(expected, actual);
}
Also used : CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) ReservationContext(com.cloud.vm.ReservationContext) Test(org.junit.Test)

Example 47 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class ElasticLoadBalancerManagerImplTest method testFinalizeStartWhenCmdsAnswerIsNotNullAndAnswerResultIsTrue.

@Test
public void testFinalizeStartWhenCmdsAnswerIsNotNullAndAnswerResultIsTrue() throws Exception {
    CheckSshAnswer answerMock = mock(CheckSshAnswer.class);
    when(answerMock.getResult()).thenReturn(true);
    VirtualMachineProfile profileMock = mock(VirtualMachineProfile.class);
    long hostId = 1L;
    Commands cmds = mock(Commands.class);
    when(cmds.getAnswer("checkSsh")).thenReturn(answerMock);
    ReservationContext context = mock(ReservationContext.class);
    boolean expected = true;
    boolean actual = elasticLoadBalancerManagerImpl.finalizeStart(profileMock, hostId, cmds, context);
    assertEquals(expected, actual);
}
Also used : CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) Commands(com.cloud.agent.manager.Commands) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) ReservationContext(com.cloud.vm.ReservationContext) Test(org.junit.Test)

Example 48 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final LoadBalancingRules loadbalancing) throws ResourceUnavailableException {
    final Network network = loadbalancing.getNetwork();
    final DomainRouterVO router = (DomainRouterVO) loadbalancing.getRouter();
    final List<LoadBalancingRule> rules = loadbalancing.getRules();
    final Commands cmds = new Commands(Command.OnError.Continue);
    _commandSetupHelper.createApplyLoadBalancingRulesCommands(rules, router, cmds, network.getId());
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : LoadBalancingRule(com.cloud.network.lb.LoadBalancingRule) Network(com.cloud.network.Network) Commands(com.cloud.agent.manager.Commands) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 49 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final SshKeyToRouterRules sshkey) throws ResourceUnavailableException {
    final VirtualRouter router = sshkey.getRouter();
    final VirtualMachineProfile profile = sshkey.getProfile();
    final String sshKeystr = sshkey.getSshPublicKey();
    final UserVmVO userVM = sshkey.getUserVM();
    final Commands commands = new Commands(Command.OnError.Stop);
    final NicVO nicVo = sshkey.getNicVo();
    final VMTemplateVO template = sshkey.getTemplate();
    if (template != null && template.getEnablePassword()) {
        _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
    }
    _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, sshKeystr, commands);
    return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) Commands(com.cloud.agent.manager.Commands) VMTemplateVO(com.cloud.storage.VMTemplateVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) NicVO(com.cloud.vm.NicVO) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 50 with Commands

use of com.cloud.agent.manager.Commands in project cloudstack by apache.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final StaticRoutesRules staticRoutesRules) throws ResourceUnavailableException {
    final VirtualRouter router = staticRoutesRules.getRouter();
    final List<StaticRouteProfile> staticRoutes = staticRoutesRules.getStaticRoutes();
    final Commands cmds = new Commands(Command.OnError.Continue);
    _commandSetupHelper.createStaticRouteCommands(staticRoutes, router, cmds);
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : StaticRouteProfile(com.cloud.network.vpc.StaticRouteProfile) Commands(com.cloud.agent.manager.Commands) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

Commands (com.cloud.agent.manager.Commands)64 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)22 VirtualRouter (com.cloud.network.router.VirtualRouter)19 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)17 Answer (com.cloud.agent.api.Answer)16 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)13 Network (com.cloud.network.Network)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)11 NicVO (com.cloud.vm.NicVO)10 UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)9 ArrayList (java.util.ArrayList)9 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)8 UserVmVO (com.cloud.vm.UserVmVO)8 DataCenter (com.cloud.dc.DataCenter)7 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)7 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)7 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)6 RestoreVMSnapshotAnswer (com.cloud.agent.api.RestoreVMSnapshotAnswer)6 StartAnswer (com.cloud.agent.api.StartAnswer)6 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)6