Search in sources :

Example 1 with ModifySshKeysCommand

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();
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) ModifySshKeysCommand(com.cloud.legacymodel.communication.command.ModifySshKeysCommand) LibvirtUtilitiesHelper(com.cloud.agent.resource.kvm.wrapper.LibvirtUtilitiesHelper) Test(org.junit.Test)

Example 2 with ModifySshKeysCommand

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());
}
Also used : RebootAnswer(com.cloud.legacymodel.communication.answer.RebootAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CreateAnswer(com.cloud.legacymodel.communication.answer.CreateAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) ModifySshKeysCommand(com.cloud.legacymodel.communication.command.ModifySshKeysCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with ModifySshKeysCommand

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());
                }
            }
        }
    }
}
Also used : StartupCommand(com.cloud.legacymodel.communication.command.startup.StartupCommand) AgentUnavailableException(com.cloud.legacymodel.exceptions.AgentUnavailableException) ModifySshKeysCommand(com.cloud.legacymodel.communication.command.ModifySshKeysCommand) Commands(com.cloud.agent.manager.Commands) StartupRoutingCommand(com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)

Aggregations

ModifySshKeysCommand (com.cloud.legacymodel.communication.command.ModifySshKeysCommand)3 Answer (com.cloud.legacymodel.communication.answer.Answer)2 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)2 Test (org.junit.Test)2 Commands (com.cloud.agent.manager.Commands)1 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)1 LibvirtUtilitiesHelper (com.cloud.agent.resource.kvm.wrapper.LibvirtUtilitiesHelper)1 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)1 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)1 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)1 StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)1 StartupRoutingCommand (com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)1 AgentUnavailableException (com.cloud.legacymodel.exceptions.AgentUnavailableException)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1