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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations