Search in sources :

Example 1 with ReadyAnswer

use of com.cloud.legacymodel.communication.answer.ReadyAnswer in project cosmic by MissionCriticalCloud.

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.legacymodel.communication.answer.ReadyAnswer) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Aggregations

ReadyAnswer (com.cloud.legacymodel.communication.answer.ReadyAnswer)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 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1