use of com.cloud.legacymodel.communication.command.CheckSshCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testCheckSshCommand.
@Test
public void testCheckSshCommand() {
final String instanceName = "Test";
final String ip = "127.0.0.1";
final int port = 22;
final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port);
final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(true);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
verify(virtRouterResource, times(1)).connect(privateIp, cmdPort);
}
use of com.cloud.legacymodel.communication.command.CheckSshCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testCheckSshCommandFailure.
@Test
public void testCheckSshCommandFailure() {
final String instanceName = "Test";
final String ip = "127.0.0.1";
final int port = 22;
final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port);
final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(false);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
verify(virtRouterResource, times(1)).connect(privateIp, cmdPort);
}
use of com.cloud.legacymodel.communication.command.CheckSshCommand in project cosmic by MissionCriticalCloud.
the class SecondaryStorageManagerImpl method finalizeCommandsOnStart.
@Override
public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachineProfile profile) {
NicProfile managementNic = null;
NicProfile controlNic = null;
for (final NicProfile nic : profile.getNics()) {
if (nic.getTrafficType() == TrafficType.Management) {
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control && nic.getIPv4Address() != null) {
controlNic = nic;
}
}
if (controlNic == null) {
if (managementNic == null) {
logger.error("Management network doesn't exist for the secondaryStorageVm " + profile.getVirtualMachine());
return false;
}
controlNic = managementNic;
}
final CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIPv4Address(), 3922);
cmds.addCommand("checkSsh", check);
return true;
}
use of com.cloud.legacymodel.communication.command.CheckSshCommand in project cosmic by MissionCriticalCloud.
the class VirtualNetworkApplianceManagerImpl method finalizeSshAndVersionAndNetworkUsageOnStart.
protected void finalizeSshAndVersionAndNetworkUsageOnStart(final Commands cmds, final VirtualMachineProfile profile, final DomainRouterVO router, final NicProfile controlNic) {
final DomainRouterVO vr = _routerDao.findById(profile.getId());
cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIPv4Address(), 3922));
// Update router template/scripts version
final GetDomRVersionCommand command = new GetDomRVersionCommand();
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlNic.getIPv4Address());
command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
cmds.addCommand("getDomRVersion", command);
// Network usage command to create iptables rules
final boolean forVpc = vr.getVpcId() != null;
if (!forVpc) {
cmds.addCommand("networkUsage", new NetworkUsageCommand(controlNic.getIPv4Address(), router.getHostName(), "create", forVpc));
}
}
use of com.cloud.legacymodel.communication.command.CheckSshCommand in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testCheckSshCommand.
@Test
public void testCheckSshCommand() {
final CheckSshCommand sshCommand = new CheckSshCommand("Test", "127.0.0.1", 22);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(sshCommand, this.citrixResourceBase);
verify(this.citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
Aggregations