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