Search in sources :

Example 1 with CheckSshAnswer

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);
}
Also used : CheckSshAnswer(com.cloud.legacymodel.communication.answer.CheckSshAnswer) VirtualRoutingResource(com.cloud.common.virtualnetwork.VirtualRoutingResource)

Example 2 with CheckSshAnswer

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);
}
Also used : CheckSshAnswer(com.cloud.legacymodel.communication.answer.CheckSshAnswer) Connection(com.xensource.xenapi.Connection)

Example 3 with CheckSshAnswer

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;
}
Also used : CheckSshAnswer(com.cloud.legacymodel.communication.answer.CheckSshAnswer) SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) IPAddressVO(com.cloud.network.dao.IPAddressVO) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) OperationTimedoutException(com.cloud.legacymodel.exceptions.OperationTimedoutException) URISyntaxException(java.net.URISyntaxException) InsufficientCapacityException(com.cloud.legacymodel.exceptions.InsufficientCapacityException) ConfigurationException(javax.naming.ConfigurationException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) UnableDeleteHostException(com.cloud.legacymodel.exceptions.UnableDeleteHostException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

Example 4 with CheckSshAnswer

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;
}
Also used : CheckSshAnswer(com.cloud.legacymodel.communication.answer.CheckSshAnswer) IPAddressVO(com.cloud.network.dao.IPAddressVO) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) OperationTimedoutException(com.cloud.legacymodel.exceptions.OperationTimedoutException) InsufficientCapacityException(com.cloud.legacymodel.exceptions.InsufficientCapacityException) ConfigurationException(javax.naming.ConfigurationException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) UnableDeleteHostException(com.cloud.legacymodel.exceptions.UnableDeleteHostException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

Aggregations

CheckSshAnswer (com.cloud.legacymodel.communication.answer.CheckSshAnswer)4 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)2 ConcurrentOperationException (com.cloud.legacymodel.exceptions.ConcurrentOperationException)2 InsufficientCapacityException (com.cloud.legacymodel.exceptions.InsufficientCapacityException)2 OperationTimedoutException (com.cloud.legacymodel.exceptions.OperationTimedoutException)2 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)2 UnableDeleteHostException (com.cloud.legacymodel.exceptions.UnableDeleteHostException)2 IPAddressVO (com.cloud.network.dao.IPAddressVO)2 ConfigurationException (javax.naming.ConfigurationException)2 VirtualRoutingResource (com.cloud.common.virtualnetwork.VirtualRoutingResource)1 ConsoleProxyVO (com.cloud.vm.ConsoleProxyVO)1 SecondaryStorageVmVO (com.cloud.vm.SecondaryStorageVmVO)1 Connection (com.xensource.xenapi.Connection)1 URISyntaxException (java.net.URISyntaxException)1