use of com.cloud.legacymodel.communication.command.ModifySshKeysCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testModifySshKeysCommand.
@Test
public void testModifySshKeysCommand() {
final ModifySshKeysCommand command = new ModifySshKeysCommand("", "");
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
when(libvirtUtilitiesHelper.retrieveSshKeysPath()).thenReturn("/path/keys");
when(libvirtUtilitiesHelper.retrieveSshPubKeyPath()).thenReturn("/path/pub/keys");
when(libvirtUtilitiesHelper.retrieveSshPrvKeyPath()).thenReturn("/path/pvt/keys");
when(this.libvirtComputingResource.getScriptsTimeout()).thenReturn(0);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getScriptsTimeout();
}
use of com.cloud.legacymodel.communication.command.ModifySshKeysCommand in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testModifySshKeysCommand.
@Test
public void testModifySshKeysCommand() {
final ModifySshKeysCommand sshKeysCommand = new ModifySshKeysCommand("", "");
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(sshKeysCommand, this.citrixResourceBase);
assertTrue(answer.getResult());
}
use of com.cloud.legacymodel.communication.command.ModifySshKeysCommand in project cosmic by MissionCriticalCloud.
the class SshKeysDistriMonitor method processConnect.
@Override
public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) {
for (final StartupCommand startupCommand : startupCommands) {
if (startupCommand instanceof StartupRoutingCommand) {
if (((StartupRoutingCommand) startupCommand).getHypervisorType() == HypervisorType.KVM || ((StartupRoutingCommand) startupCommand).getHypervisorType() == HypervisorType.XenServer) {
/*TODO: Get the private/public keys here*/
final String pubKey = _configDao.getValue("ssh.publickey");
final String prvKey = _configDao.getValue("ssh.privatekey");
try {
final ModifySshKeysCommand cmds = new ModifySshKeysCommand(pubKey, prvKey);
final Commands c = new Commands(cmds);
_agentMgr.send(host.getId(), c, this);
} catch (final AgentUnavailableException e) {
s_logger.debug("Failed to send keys to agent: " + host.getId());
}
}
}
}
}
Aggregations