Search in sources :

Example 11 with RebootCommand

use of com.cloud.agent.api.RebootCommand in project cosmic by MissionCriticalCloud.

the class LibvirtRebootRouterCommandWrapper method execute.

@Override
public Answer execute(final RebootRouterCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    final RebootCommand rebootCommand = new RebootCommand(command.getVmName(), true);
    final Answer answer = wrapper.execute(rebootCommand, libvirtComputingResource);
    final VirtualRoutingResource virtualRouterResource = libvirtComputingResource.getVirtRouterResource();
    if (virtualRouterResource.connect(command.getPrivateIpAddress())) {
        libvirtComputingResource.networkUsage(command.getPrivateIpAddress(), "create", null);
        return answer;
    } else {
        return new Answer(command, false, "Failed to connect to virtual router " + command.getVmName());
    }
}
Also used : Answer(com.cloud.agent.api.Answer) RebootCommand(com.cloud.agent.api.RebootCommand) VirtualRoutingResource(com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource)

Example 12 with RebootCommand

use of com.cloud.agent.api.RebootCommand in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testRebootCommand.

@Test
public void testRebootCommand() {
    final RebootCommand rebootCommand = new RebootCommand("Test", true);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(rebootCommand, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) Answer(com.cloud.agent.api.Answer) AttachAnswer(com.cloud.storage.command.AttachAnswer) RebootCommand(com.cloud.agent.api.RebootCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with RebootCommand

use of com.cloud.agent.api.RebootCommand in project cosmic by MissionCriticalCloud.

the class CitrixRebootRouterCommandWrapper method execute.

@Override
public Answer execute(final RebootRouterCommand command, final CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    final RebootCommand rebootCommand = new RebootCommand(command.getVmName(), true);
    final Answer answer = wrapper.execute(rebootCommand, citrixResourceBase);
    if (answer.getResult()) {
        final String cnct = citrixResourceBase.connect(conn, command.getVmName(), command.getPrivateIpAddress());
        citrixResourceBase.networkUsage(conn, command.getPrivateIpAddress(), "create", null);
        if (cnct == null) {
            return answer;
        } else {
            return new Answer(command, false, cnct);
        }
    }
    return answer;
}
Also used : Answer(com.cloud.agent.api.Answer) RebootCommand(com.cloud.agent.api.RebootCommand) Connection(com.xensource.xenapi.Connection)

Example 14 with RebootCommand

use of com.cloud.agent.api.RebootCommand in project cosmic by MissionCriticalCloud.

the class SecondaryStorageManagerImpl method rebootSecStorageVm.

@Override
public boolean rebootSecStorageVm(final long secStorageVmId) {
    final SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
    if (secStorageVm == null || secStorageVm.getState() == State.Destroyed) {
        return false;
    }
    if (secStorageVm.getState() == Running && secStorageVm.getHostId() != null) {
        final RebootCommand cmd = new RebootCommand(secStorageVm.getInstanceName(), _itMgr.getExecuteInSequence(secStorageVm.getHypervisorType()));
        final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd);
        if (answer != null && answer.getResult()) {
            logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName());
            SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this, new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_REBOOTED, secStorageVm.getDataCenterId(), secStorageVm.getId(), secStorageVm, null));
            return true;
        } else {
            final String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName();
            logger.debug(msg);
            return false;
        }
    } else {
        return startSecStorageVm(secStorageVmId) != null;
    }
}
Also used : SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) Answer(com.cloud.agent.api.Answer) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) RebootCommand(com.cloud.agent.api.RebootCommand)

Example 15 with RebootCommand

use of com.cloud.agent.api.RebootCommand in project cosmic by MissionCriticalCloud.

the class ConsoleProxyManagerImpl method rebootProxy.

@Override
public boolean rebootProxy(final long proxyVmId) {
    final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
    if (proxy == null || proxy.getState() == State.Destroyed) {
        return false;
    }
    if (proxy.getState() == State.Running && proxy.getHostId() != null) {
        final RebootCommand cmd = new RebootCommand(proxy.getInstanceName(), _itMgr.getExecuteInSequence(proxy.getHypervisorType()));
        final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd);
        if (answer != null && answer.getResult()) {
            logger.debug("Successfully reboot console proxy " + proxy.getHostName());
            SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this, new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterId(), proxy.getId(), proxy, null));
            return true;
        } else {
            logger.debug("failed to reboot console proxy : " + proxy.getHostName());
            return false;
        }
    } else {
        return startProxy(proxyVmId, false) != null;
    }
}
Also used : ConsoleProxyLoadAnswer(com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) Answer(com.cloud.agent.api.Answer) RebootCommand(com.cloud.agent.api.RebootCommand) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO)

Aggregations

Answer (com.cloud.agent.api.Answer)26 RebootCommand (com.cloud.agent.api.RebootCommand)26 Test (org.junit.Test)10 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)8 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)8 LibvirtUtilitiesHelper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper)8 LibvirtException (org.libvirt.LibvirtException)8 RebootAnswer (com.cloud.agent.api.RebootAnswer)7 CheckSshAnswer (com.cloud.agent.api.check.CheckSshAnswer)7 Connect (org.libvirt.Connect)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)5 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)5 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)4 StartAnswer (com.cloud.agent.api.StartAnswer)4 StopAnswer (com.cloud.agent.api.StopAnswer)4 UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)4 AttachAnswer (com.cloud.storage.command.AttachAnswer)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)3