Search in sources :

Example 1 with ReadyAnswer

use of com.cloud.agent.api.ReadyAnswer in project cloudstack by apache.

the class CitrixReadyCommandWrapper method execute.

@Override
public Answer execute(final ReadyCommand command, final CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();
    final Long dcId = command.getDataCenterId();
    // Ignore the result of the callHostPlugin. Even if unmounting the
    // snapshots dir fails, let Ready command
    // succeed.
    citrixResourceBase.umountSnapshotDir(conn, dcId);
    citrixResourceBase.setupLinkLocalNetwork(conn);
    // try to destroy CD-ROM device for all system VMs on this host
    try {
        final Host host = Host.getByUuid(conn, citrixResourceBase.getHost().getUuid());
        final Set<VM> vms = host.getResidentVMs(conn);
        for (final VM vm : vms) {
            citrixResourceBase.destroyPatchVbd(conn, vm.getNameLabel(conn));
        }
    } catch (final Exception e) {
    }
    try {
        final boolean result = citrixResourceBase.cleanupHaltedVms(conn);
        if (!result) {
            return new ReadyAnswer(command, "Unable to cleanup halted vms");
        }
    } catch (final XenAPIException e) {
        s_logger.warn("Unable to cleanup halted vms", e);
        return new ReadyAnswer(command, "Unable to cleanup halted vms");
    } catch (final XmlRpcException e) {
        s_logger.warn("Unable to cleanup halted vms", e);
        return new ReadyAnswer(command, "Unable to cleanup halted vms");
    }
    return new ReadyAnswer(command);
}
Also used : VM(com.xensource.xenapi.VM) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) Host(com.xensource.xenapi.Host) XmlRpcException(org.apache.xmlrpc.XmlRpcException) XenAPIException(com.xensource.xenapi.Types.XenAPIException) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 2 with ReadyAnswer

use of com.cloud.agent.api.ReadyAnswer in project cloudstack by apache.

the class VmwareResource method execute.

protected Answer execute(ReadyCommand cmd) {
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Executing resource ReadyCommand: " + _gson.toJson(cmd));
    }
    try {
        VmwareContext context = getServiceContext();
        VmwareHypervisorHost hyperHost = getHyperHost(context);
        if (hyperHost.isHyperHostConnected()) {
            return new ReadyAnswer(cmd);
        } else {
            return new ReadyAnswer(cmd, "Host is not in connect state");
        }
    } catch (Exception e) {
        s_logger.error("Unexpected exception: ", e);
        return new ReadyAnswer(cmd, VmwareHelper.getExceptionMessage(e));
    }
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Example 3 with ReadyAnswer

use of com.cloud.agent.api.ReadyAnswer in project cloudstack by apache.

the class Ovm3HypervisorSupport method execute.

/* Check if the host is in ready state for CS */
public ReadyAnswer execute(ReadyCommand cmd) {
    try {
        Linux host = new Linux(c);
        Pool pool = new Pool(c);
        /* only interesting when doing cluster */
        if (!host.getIsMaster() && config.getAgentInOvm3Cluster()) {
            if (pool.getPoolMasterVip().equalsIgnoreCase(c.getIp())) {
                /* check pool state here */
                return new ReadyAnswer(cmd);
            } else {
                LOGGER.debug("Master IP changes to " + pool.getPoolMasterVip() + ", it should be " + c.getIp());
                return new ReadyAnswer(cmd, "I am not the master server");
            }
        } else if (host.getIsMaster()) {
            LOGGER.debug("Master, not clustered " + config.getAgentHostname());
            return new ReadyAnswer(cmd);
        } else {
            LOGGER.debug("No master, not clustered " + config.getAgentHostname());
            return new ReadyAnswer(cmd);
        }
    } catch (CloudRuntimeException | Ovm3ResourceException e) {
        LOGGER.debug("XML RPC Exception" + e.getMessage(), e);
        throw new CloudRuntimeException("XML RPC Exception" + e.getMessage(), e);
    }
}
Also used : Linux(com.cloud.hypervisor.ovm3.objects.Linux) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) Pool(com.cloud.hypervisor.ovm3.objects.Pool) ReadyAnswer(com.cloud.agent.api.ReadyAnswer)

Aggregations

ReadyAnswer (com.cloud.agent.api.ReadyAnswer)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 Linux (com.cloud.hypervisor.ovm3.objects.Linux)1 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)1 Pool (com.cloud.hypervisor.ovm3.objects.Pool)1 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)1 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)1 Connection (com.xensource.xenapi.Connection)1 Host (com.xensource.xenapi.Host)1 XenAPIException (com.xensource.xenapi.Types.XenAPIException)1 VM (com.xensource.xenapi.VM)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ConnectException (java.net.ConnectException)1 RemoteException (java.rmi.RemoteException)1 ConfigurationException (javax.naming.ConfigurationException)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1