Search in sources :

Example 1 with StorageSubSystemCommand

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

the class KVMGuru method getCommandHostDelegation.

@Override
public Pair<Boolean, Long> getCommandHostDelegation(final long hostId, final Command cmd) {
    if (cmd instanceof StorageSubSystemCommand) {
        final StorageSubSystemCommand c = (StorageSubSystemCommand) cmd;
        c.setExecuteInSequence(false);
    }
    if (cmd instanceof CopyCommand) {
        final CopyCommand c = (CopyCommand) cmd;
        final DataTO srcData = c.getSrcTO();
        boolean inSeq = true;
        if (c.getSrcTO().getObjectType() == DataObjectType.SNAPSHOT || c.getDestTO().getObjectType() == DataObjectType.SNAPSHOT) {
            inSeq = false;
        } else if (c.getDestTO().getDataStore().getRole() == DataStoreRole.Image || c.getDestTO().getDataStore().getRole() == DataStoreRole.ImageCache) {
            inSeq = false;
        }
        c.setExecuteInSequence(inSeq);
        if (srcData.getHypervisorType() == HypervisorType.KVM) {
            return new Pair<>(true, new Long(hostId));
        }
    }
    return new Pair<>(false, new Long(hostId));
}
Also used : StorageSubSystemCommand(com.cloud.legacymodel.communication.command.StorageSubSystemCommand) DataTO(com.cloud.legacymodel.to.DataTO) CopyCommand(com.cloud.legacymodel.communication.command.CopyCommand) Pair(com.cloud.legacymodel.utils.Pair)

Example 2 with StorageSubSystemCommand

use of com.cloud.legacymodel.communication.command.StorageSubSystemCommand 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)2 StorageSubSystemCommand (com.cloud.legacymodel.communication.command.StorageSubSystemCommand)2 DataTO (com.cloud.legacymodel.to.DataTO)2 Pair (com.cloud.legacymodel.utils.Pair)2 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)1 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)1 HostVO (com.cloud.host.HostVO)1 DataStoreTO (com.cloud.legacymodel.to.DataStoreTO)1 NfsTO (com.cloud.legacymodel.to.NfsTO)1