use of com.cloud.legacymodel.communication.answer.CheckSshAnswer in project cosmic by MissionCriticalCloud.
the class LibvirtCheckSshCommandWrapper method execute.
@Override
public Answer execute(final CheckSshCommand command, final LibvirtComputingResource libvirtComputingResource) {
final String vmName = command.getName();
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
}
final VirtualRoutingResource virtRouterResource = libvirtComputingResource.getVirtRouterResource();
if (!virtRouterResource.connect(privateIp, cmdPort)) {
return new CheckSshAnswer(command, "Can not ping System vm " + vmName + " because of a connection failure");
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Ping command port succeeded for vm " + vmName);
}
return new CheckSshAnswer(command);
}
use of com.cloud.legacymodel.communication.answer.CheckSshAnswer in project cosmic by MissionCriticalCloud.
the class CitrixCheckSshCommandWrapper method execute.
@Override
public Answer execute(final CheckSshCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final String vmName = command.getName();
final String privateIp = command.getIp();
final int cmdPort = command.getPort();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
}
try {
final String result = citrixResourceBase.connect(conn, command.getName(), privateIp, cmdPort);
if (result != null) {
return new CheckSshAnswer(command, "Can not ping System vm " + vmName + "due to:" + result);
}
// Do not destroy the disk here! It will stio the patching process. Please, don't!
// destroyPatchVbd(conn, vmName);
} catch (final Exception e) {
return new CheckSshAnswer(command, e);
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Ping command port succeeded for vm " + vmName);
}
return new CheckSshAnswer(command);
}
use of com.cloud.legacymodel.communication.answer.CheckSshAnswer in project cosmic by MissionCriticalCloud.
the class SecondaryStorageManagerImpl method finalizeStart.
@Override
public boolean finalizeStart(final VirtualMachineProfile profile, final long hostId, final Commands cmds, final ReservationContext context) {
final CheckSshAnswer answer = (CheckSshAnswer) cmds.getAnswer("checkSsh");
if (!answer.getResult()) {
logger.warn("Unable to ssh to the VM: " + answer.getDetails());
return false;
}
try {
// get system ip and create static nat rule for the vm in case of basic networking with EIP/ELB
this._rulesMgr.getSystemIpAndEnableStaticNatForVm(profile.getVirtualMachine(), false);
final IPAddressVO ipaddr = this._ipAddressDao.findByAssociatedVmId(profile.getVirtualMachine().getId());
if (ipaddr != null && ipaddr.getSystem()) {
final SecondaryStorageVmVO secVm = this._secStorageVmDao.findById(profile.getId());
// override SSVM guest IP with EIP, so that download url's with be prepared with EIP
secVm.setPublicIpAddress(ipaddr.getAddress().addr());
this._secStorageVmDao.update(secVm.getId(), secVm);
}
} catch (final Exception e) {
logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", e);
return false;
}
return true;
}
use of com.cloud.legacymodel.communication.answer.CheckSshAnswer in project cosmic by MissionCriticalCloud.
the class ConsoleProxyManagerImpl method finalizeStart.
@Override
public boolean finalizeStart(final VirtualMachineProfile profile, final long hostId, final Commands cmds, final ReservationContext context) {
final CheckSshAnswer answer = (CheckSshAnswer) cmds.getAnswer("checkSsh");
if (answer == null || !answer.getResult()) {
if (answer != null) {
logger.warn("Unable to ssh to the VM: " + answer.getDetails());
} else {
logger.warn("Unable to ssh to the VM: null answer");
}
return false;
}
try {
// get system ip and create static nat rule for the vm in case of basic networking with EIP/ELB
this._rulesMgr.getSystemIpAndEnableStaticNatForVm(profile.getVirtualMachine(), false);
final IPAddressVO ipaddr = this._ipAddressDao.findByAssociatedVmId(profile.getVirtualMachine().getId());
if (ipaddr != null && ipaddr.getSystem()) {
final ConsoleProxyVO consoleVm = this._consoleProxyDao.findById(profile.getId());
// override CPVM guest IP with EIP, so that console url's will be prepared with EIP
consoleVm.setPublicIpAddress(ipaddr.getAddress().addr());
this._consoleProxyDao.update(consoleVm.getId(), consoleVm);
}
} catch (final Exception ex) {
logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex);
return false;
}
return true;
}
Aggregations