Search in sources :

Example 11 with CopyCommand

use of com.cloud.legacymodel.communication.command.CopyCommand in project cosmic by MissionCriticalCloud.

the class XenServerGuru method getCommandHostDelegation.

@Override
public Pair<Boolean, Long> getCommandHostDelegation(final long hostId, final Command cmd) {
    LOGGER.debug("getCommandHostDelegation: " + cmd.getClass());
    if (cmd instanceof StorageSubSystemCommand) {
        final StorageSubSystemCommand c = (StorageSubSystemCommand) cmd;
        c.setExecuteInSequence(true);
    }
    if (cmd instanceof CopyCommand) {
        final CopyCommand cpyCommand = (CopyCommand) cmd;
        final DataTO srcData = cpyCommand.getSrcTO();
        final DataTO destData = cpyCommand.getDestTO();
        if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) {
            final DataStoreTO srcStore = srcData.getDataStore();
            final DataStoreTO destStore = destData.getDataStore();
            if (srcStore instanceof NfsTO && destStore instanceof NfsTO) {
                HostVO host = hostDao.findById(hostId);
                final EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId()));
                host = hostDao.findById(ep.getId());
                hostDao.loadDetails(host);
                final String hypervisorVersion = host.getHypervisorVersion();
                final String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix);
                if (hypervisorVersion != null && !hypervisorVersion.equalsIgnoreCase("6.1.0")) {
                    if (!(hypervisorVersion.equalsIgnoreCase("6.2.0") && !(snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)))) {
                        return new Pair<>(Boolean.TRUE, new Long(ep.getId()));
                    }
                }
            }
        }
    }
    return new Pair<>(Boolean.FALSE, new Long(hostId));
}
Also used : ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) DataStoreTO(com.cloud.legacymodel.to.DataStoreTO) StorageSubSystemCommand(com.cloud.legacymodel.communication.command.StorageSubSystemCommand) DataTO(com.cloud.legacymodel.to.DataTO) CopyCommand(com.cloud.legacymodel.communication.command.CopyCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) NfsTO(com.cloud.legacymodel.to.NfsTO) HostVO(com.cloud.host.HostVO) Pair(com.cloud.legacymodel.utils.Pair)

Aggregations

CopyCommand (com.cloud.legacymodel.communication.command.CopyCommand)11 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)8 Answer (com.cloud.legacymodel.communication.answer.Answer)7 MigrateVolumeAnswer (com.cloud.legacymodel.communication.answer.MigrateVolumeAnswer)6 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)6 RemoteHostEndPoint (com.cloud.storage.RemoteHostEndPoint)6 DataObject (com.cloud.engine.subsystem.api.storage.DataObject)5 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)5 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)4 ClusterScope (com.cloud.engine.subsystem.api.storage.ClusterScope)3 CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)3 HostScope (com.cloud.engine.subsystem.api.storage.HostScope)3 Scope (com.cloud.engine.subsystem.api.storage.Scope)3 SnapshotInfo (com.cloud.engine.subsystem.api.storage.SnapshotInfo)3 HostVO (com.cloud.host.HostVO)3 CopyCmdAnswer (com.cloud.legacymodel.communication.answer.CopyCmdAnswer)3 StorageSubSystemCommand (com.cloud.legacymodel.communication.command.StorageSubSystemCommand)2 DataStoreTO (com.cloud.legacymodel.to.DataStoreTO)2 DataTO (com.cloud.legacymodel.to.DataTO)2 NfsTO (com.cloud.legacymodel.to.NfsTO)2